Stepper Driver

oracacle

Senior Member
AS some of you know i have been working on a little project involving a stepper motor. I have made a bit of theortical progress but life is stopping me buy stuff for thing like the motor and ahaing a custom threaded bar cut.

but back to the theory and design, i have been looking at micro step controllers using something like the TB6560 or TH6064 when at work and with a little inspiration from stpperworld and idea hit me like a freight train.

why not have the wave patern pre-programmed into a picaxe. then i realised my analogue electronic isnt so hot

circuit so far

Driver 0.1 by f2268d215cc925918731918f4efa0289, on Flickr

now as you can there is no comparitor (should go on the red wires, one for each phase of the motor), this is the problem as it will be needed to stop putting too much voltage into the picaxe if you use a higher voltage motor, or you will loose resolution fro lower voltage. any ideas on the best type of circuit i should use, i know it will most likely by op-amp with some hysterisis but it will need to keep within 0-5v and follow the voltage arc from the phase of the motor

Code:
#picaxe 28x2

symbol L0		= b0
symbol U0 		= b1
symbol L1		= b2
symbol U1		= b3
symbol PhaseA	= b5
symbol PhaseB	= b6
symbol PhAlook	= b7
symbol PhBlook	= b8
symbol PhAval	= b9
symbol PhBval	= b10

symbol clk		= pinc.0
symbol direct	= pinc.1

intit:
	setint %00000001, %00000001		'set interupt
	'now set sine wave lookup value
	let phalook = 0
	let phblook = phalook + 6
	
main:
	'now get voltage value from ech phase
	readadc 0, phaseA
	readadc 1, phaseB
	'now check if phase A is within tolerence
	if phaseA < L0 or phasea > U0 then
		if Phasea < L0 then
			'switch on phase a
		else
			'swithc of phase
		end if
	end if
	
	'now check if phase B is within tolerence
	if phaseB < L0 or phaseb > U0 then
		if PhaseB < L0 then
			'switch on phase a
		else
			'swithc of phase
		end if
	end if		
	goto main

interrupt:
	pause 5000
	
#rem

step	|%	  |Voltage	|ADC value	|ADC
----------------------------------------
0	|100.00%|	5	|256		|256
1	| 98.10%|	4.905	|251.136	|251
2	| 92.40%|	4.62	|236.544	|237
3	| 83.10%|	4.155	|212.736	|213
4	| 70.10%|	3.505	|179.456	|179
5	| 55.50%|	2.775	|142.08	|142
6	| 38.20%|	1.91	|97.792	|98
7	| 19.50%|	0.975	|49.92	|50
8	| 0.00% |	0	|0	0
Figures Obtained from stepperworld.com

#endrem
	'check direction
	if direct = 0 then
		inc phalook
		inc phalook
	else
		dec phalook
		dec phblook
	end if
	
	'over/underflow protection needed
	
	'lookup sine wave values
	lookup phalook, (256,251,237,213,179,142,98,50),phaval
	let L0 = phaval - 10
	let U0 = phaval + 10
	
	lookup phblook, (256,251,237,213,179,142,98,50),phbval
	let L1 = phbval - 10
	let U1 = phbval + 10

	'coil change and reducing votlage needed.

	setint %00000001, %00000001
	return
it a very rough start any ideas or testing or error i have made feel free to say something. the biggest thing is, will it work, and if so how well

http://www.stepperworld.com/Tutorials/pgMicrostepping.htm
 

rossko57

Senior Member
I would seriously reconsider driving H-bridges directly from Picaxe. Self-destruction is total and immediate from just one slight programming or timing error. Dedicated H-bridge driver chips are protected from accidently turning on both paths at once.

The current sense resistors are usually selected as very low value for efficiency; you're not likely to accidentally put overvolts into the Picaxe from there (a low resistance to ground). More likely is a need to amplify the very small voltage present.

Last we heard your leadscrew/stepper combination gave a theoretical 0.0036mm per step ... what are you hoping to gain here?
 

nick12ab

Senior Member
There's no base resistors and the PNP transistors will be on all the time if the voltage used for the motors is greater than the PICAXE power supply voltage. Actually, won't all the transistors turn on anyway because of the direct connection between the bases of the NPN and PNP transistors?
 

oracacle

Senior Member
there is loads of stuff missing from the circuit, pull down resistors and all sorts along with a non-inverting amp of some decription.

i did say in my post that it i a very rough start. as for the H-bridges, they may well end up being a driver chip (like the l293d) i put that transistor circuit in for a minuite as i am still not sure how i am going to go about turning off each oft he phases, wither by turning of the output or by having another transistor between power and each h-bridge.

rossoko57, yes the sense resistors have to match the current required for the motor, and have to be of a a non-inductance construction. as for what i will gain from micro stepping, things like more even torque output from the motor, greater effiency and seeing as i am having to have a custom screw made i may be at the mercy of the maker to keep costs down a bit, they may not go for the planed 1.5mm pitch so will have to gain accuracy from the electroic side of things. also the motor is due to be changed for something with a little more torque when i get paid in a couple of weeks

on another note a friend has helped with calculating percentages for greater number of steps if needed. i will try and post the spread sheet later.

any good places where to start learning op-amp circuits?
 

rossko57

Senior Member
Principles are sound. Don't expect "extra efficiency" from this - total motor current i.e. power consumption is the same as simple bang-bang drive. Smoother, more steps, more torque yes. Driving a leadscrew I doubt any noticeable "smoothness" is there to be had but I'll bet it'll reduce noise a lot.

You can divide the function into two:
Producing the "target" current values for the two phases - yep that looks like a job for Picaxe, stepping through a table of values and outputting on DACs
The comparators, comparing motor current with target and chopping the drive. While the Picaxe can contain the two comparators, I'd consider speed of response. The stepper guru suggests expecting 20kHz operation here, something like that should be achievable. Certainly worth experimenting.
In fact if the "DAC" table is internal to the same Picaxe you can do the comparing in software and just use plain ol ADC to monitor motor current.

I'll maintain that building umm "experiment proof" H-bridges is a very specialist skill, and to survive development and be reliable in the field you should be choosing dedicated chips or modules - obviously choice depends on as yet unselected motor.
 

oracacle

Senior Member
if you have a qucik read of the program i posted i do plan to use 2 ADC inputs (one for each coil).

a friend of mine who used to design quided torpedos and satalitets has given some material to read through which cover a bunch of analogue electronics.

heres the sinusidel tables in pdf (forum wont except .xlsx). 64 step from rise maybe a bit of a tall order ecen with adc10. however 32 on rise maybe possible. it is more likely that i will use 16 on rise and 16 on fall giving 32 steps overall.
i dont have any resinators atm so may end up experimenting at 16mhz and look at going faster later on.

at the minuite i do not plan on building an h-bridge. however alot of the motors that site in a NEMA 17 chassi run at around 2.8v and 1.7amp (rep rap 3d printer motors)

also heres and exploded image of the design i am hoping to create when finances allow


Exploded by f2268d215cc925918731918f4efa0289, on Flickr
 

Attachments

oracacle

Senior Member
I have done a bit more work to the circuit design.

C1, C2 = 100nf
C3 = 470uF
C4 = 470uF
R1, R2 = 1.6 ohms - not inductive, maybe carbon film
R3, R5 = 3700 ohms
R4, R6 = 4700 Ohms


driver 0.2 by f2268d215cc925918731918f4efa0289, on Flickr

would it be a good idea to add some resistors to the signal lines, i am very tempted to add some 1ks as you would for using transistors. The circuit has been design with a 2.8v, 1.68 amp motor, however i need some ideas about the diodes, the data sheet indicate fast 2A type - not really sure where to look for these. is there anything you would chnage add or remove? if not i will put some thought into the programme.
 

rossko57

Senior Member
You'll need to re-investigate how to use the sense output of L298, how to connect the sense resistor. View it in two stages; first add sense resistor to motor drive to generate current-related voltage, then think about amplifying the voltage (if needed at all)

I presume you won't really be using 741 op amps, a bit old hat apart from not working off a 5V supply.

1.6ohms is a bit big for sense resistor, you could use smaller ones in the interests of efficiency and less heating, as you'll be using the opamp to boost the smaller voltage. Or use one that size and dispense with amplifying.
 

oracacle

Senior Member
i have re-read the data sheet for the L988, one circuit example they have states a use of a 0.5ohm sense resitor, it also states that the senese out put is -1 to 2.3v, it however does not state how this relates to anything (ie coil voltage). so even we presume on a non-inverting amp circuit 0 to 2.3v i will decrease the adc range.

as for the op amps, nothing has been set in stone, i have had very little experience with op-amps - do you have any suggestions on what to use?

oh and i spotted my mistake with the sense resistors, and have altered the diagram, they should go to ground with the op-amp between the l298 and resisitor
 

oracacle

Senior Member
heres the updated circuit, though i may be able to go to a 20x2 instead and have thought about adding some i2c function into the mix.


Driver 0.3.1 by f2268d215cc925918731918f4efa0289, on Flickr

Code:
#picaxe 20x2
setfreq m16

symbol L0		= b0
symbol U0 		= b1
symbol L1		= b2
symbol U1		= b3
symbol PhaseA	= b5
symbol PhaseB	= b6
symbol PhAlook	= b7
symbol PhBlook	= b8
symbol PhAval	= b9
symbol PhBval	= b10
symbol phases	= b11
symbol coil		= b12

symbol clk		= pinc.5
symbol direct	= pinc.6
symbol rst		= pinc.7

symbol stepno	= b13
symbol stepstore	= 0
symbol cosine	= b14

symbol enableA	= b.4
symbol enableb	= b.6

let dirsc = %00000000
let dirsb = %01011111
let adcsetup = %0000001100000000
i2cslave %11110000, i2cfast16, i2cbyte

init:
	setint %00100000, %00100000
	let stepno = 0
	get stepstore, stepno
	lookup stepno, (6,12,24),cosine
	let phalook = 0
	let phblook = phalook + cosine
	lookup coil,(%00001010,%00001001,%00000101,%00000110),phases
	gosub interrupt
	
	
main:
	'now get voltage value from ech phase
	readadc 9, phaseA
	readadc 8, phaseB
	'now check if phase A is within tolerence
	if phaseA < L0 or phasea > U0 then
		if Phasea < L0 then
			'switch on phase a
			high enablea
		else
			'swithc of phase
			low enablea
		end if
	end if
	
	'now check if phase B is within tolerence
	if phaseB < L1 or phaseb > U1 then
		if PhaseB < L1 then
			'switch on phase a
			high enableb
		else
			'swithc of phase
			low enableb
		end if
	end if		
	goto main

interrupt:
#rem

step	|%	  |Voltage	|ADC value	|ADC
----------------------------------------
0	|100.00%|	5	|256		|256
1	| 98.10%|	4.905	|251.136	|251
2	| 92.40%|	4.62	|236.544	|237
3	| 83.10%|	4.155	|212.736	|213
4	| 70.10%|	3.505	|179.456	|179
5	| 55.50%|	2.775	|142.08	|142
6	| 38.20%|	1.91	|97.792	|98
7	| 19.50%|	0.975	|49.92	|50
8	| 0.00% |	0	|0		|0
Figures Obtained from stepperworld.com

#endrem
	'check reset
	'reset must be held high before clock is pulled high
	if rst = 1 then goto init

	'check direction
	if direct = 0 then
		inc phalook
		inc phblook
		'check for overflow
		if phalook > 15 then
			let phalook = 0
		end if
		if phblook > 15 then
			let phblook = 0
		end if
	else
		dec phalook
		dec phblook
		'check for overflow
		if phalook > 15 then
			let phalook = 15
		end if
		if phblook > 15 then
			let phblook = 15
		end if
	end if
	
	'lookup sine wave values
	on stepno gosub eight, sixteen, thirtytwo

	'coil change and reducing votlage needed.
	if phaval = 0 or phbval = 0 then
		inc coil
		let coil = coil & %00000011 			&#8216;mask lower two bits of b1
		lookup coil,(%00001010,%00001001,%00000101,%00000110),phases
		
		end if
	let pinsb = phases
	
	setint %00100000, %00100000
	'if clock is held high return to the main program will not occour until release
	return
	
eight:
#rem

step	|%	  |Voltage	|ADC value	|ADC
----------------------------------------
0	|100.00%|	5	|256		|256
1	| 98.10%|	4.905	|251.136	|251
2	| 92.40%|	4.62	|236.544	|237
3	| 83.10%|	4.155	|212.736	|213
4	| 70.10%|	3.505	|179.456	|179
5	| 55.50%|	2.775	|142.08	|142
6	| 38.20%|	1.91	|97.792	|98
7	| 19.50%|	0.975	|49.92	|50
8	| 0.00% |	0	|0		|0
Figures Obtained from stepperworld.com

Step	Max Step	sine angle	Percentage	Voltage	ADC	ADC 10
0	8		0		0.00%	0	0		0
1	8		11.25		19.51%	0.97545161	50	200
2	8		22.5		38.27%	1.913417162	98	391
3	8		33.75		55.56%	2.777851165	142	568
4	8		45		70.71%	3.535533906	180	723
5	8		56.25		83.15%	4.157348062	212	851
6	8		67.5		92.39%	4.619397663	236	945
7	8		78.75		98.08%	4.903926402	250	1003
8	8		90		100.00%	5		255	1023


#endrem

	lookup phalook, (255,251,237,213,179,142,98,50,0,50,98,142,179,213,237,251,255),phaval
			   '( 0 , 1 , 2 , 3 , 4 , 5 , 6, 7,8, 9,10, 11, 12, 13, 14. 15, 16)
	let L0 = phaval - 10
	let U0 = phaval + 10
	
	lookup phblook, (255,251,237,213,179,142,98,50,0,50,98,142,179,213,237,251,255),phbval
			   '( 0 , 1 , 2 , 3 , 4 , 5 , 6, 7,8, 9,10, 11, 12, 13, 14. 15, 16)
	let L1 = phbval - 10
	let U1 = phbval + 10
	return
	
sixteen:
#rem
Step	Max Step	sine angle	Percentage	Voltage	ADC	ADC 10
0	16		0		0.00%		0		0	0
1	16		5.625		9.80%		0.490085702	25	100
2	16		11.25		19.51%	0.97545161	50	200
3	16		16.875	29.03%	1.451423386	74	297
4	16		22.5		38.27%	1.913417162	98	391
5	16		28.125	47.14%	2.356983684	120	482
6	16		33.75		55.56%	2.777851165	142	568
7	16		39.375	63.44%	3.171966421	162	649
8	16		45		70.71%	3.535533906	180	723
9	16		50.625	77.30%	3.865052267	197	791
10	16		56.25		83.15%	4.157348062	212	851
11	16		61.875	88.19%	4.409606322	225	902
12	16		67.5		92.39%	4.619397663	236	945
13	16		73.125	95.69%	4.784701679	244	979
14	16		78.75		98.08%	4.903926402	250	1003
15	16		84.375	99.52%	4.975923633	254	1018
16	16		90		100.00%	5		255	1023
#endrem

	lookup phalook, (255,254,250,244,236,225,212,197,180,162,142,120,98,74,50,25,0 ,25,50,74,98,120,142,162,180,197,212,225,236,244,250,254,255),phaval
			   '( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ,10,11,12,13,14,15,16,17,18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
	let L0 = phaval - 5
	let U0 = phaval + 5
	
	lookup phblook, (255,254,250,244,236,225,212,197,180,162,142,120,98,74,50,25,0 ,25,50,74,98,120,142,162,180,197,212,225,236,244,250,254,255),phbval
			   '( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ,10,11,12,13,14,15,16,17,18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
	let L1 = phbval - 5
	let U1 = phbval + 5
	return
	
thirtytwo:
#rem
Step	Max Step	sine angle	Percentage	Voltage	ADC	ADC 10
0	32		0		0.00%		0		0	0
1	32		2.8125	4.91%		0.245338372	13	50
2	32		5.625		9.80%		0.490085702	25	100
3	32		8.4375	14.67%	0.733652372	37	150
4	32		11.25		19.51%	0.97545161	50	200
5	32		14.0625	24.30%	1.2149009	62	249
6	32		16.875	29.03%	1.451423386	74	297
7	32		19.6875	33.69%	1.684449267	86	345
8	32		22.5		38.27%	1.913417162	98	391
9	32		25.3125	42.76%	2.137775467	109	437
10	32		28.125	47.14%	2.356983684	120	482
11	32		30.9375	51.41%	2.570513721	131	526
12	32		33.75		55.56%	2.777851165	142	568
13	32		36.5625	59.57%	2.978496522	152	609
14	32		39.375	63.44%	3.171966421	162	649
15	32		42.1875	67.16%	3.357794774	171	687
16	32		45		70.71%	3.535533906	180	723
17	32		47.8125	74.10%	3.704755627	189	758
18	32		50.625	77.30%	3.865052267	197	791
19	32		53.4375	80.32%	4.016037657	205	822
20	32		56.25		83.15%	4.157348062	212	851
21	32		59.0625	85.77%	4.28864305	219	877
22	32		61.875	88.19%	4.409606322	225	902
23	32		64.6875	90.40%	4.519946466	231	925
24	32		67.5		92.39%	4.619397663	236	945
25	32		70.3125	94.15%	4.707720326	240	963
26	32		73.125	95.69%	4.784701679	244	979
27	32		75.9375	97.00%	4.850156266	247	992
28	32		78.75		98.08%	4.903926402	250	1003
29	32		81.5625	98.92%	4.94588255	252	1012
30	32		84.375	99.52%	4.975923633	254	1018
31	32		87.1875	99.88%	4.993977281	255	1022
32	32		90		100.00%	5		255	1023
#endrem

	lookup phalook, (255,255,254,252,250,247,244,240,236,231,225,219,212,205,197,189,180,171,162,152,142,131,120,109,98,86,74,62,50,37,25,13,0,13,25,37,50,62,74,86,98,109,120,131,142,152,162,171,180,189,197,205,212,219,225,231,236,240,244,247,250,252,254,255,255),phaval
	let L0 = phaval - 1
	let U0 = phaval + 1
	
	lookup phblook, (255,255,254,252,250,247,244,240,236,231,225,219,212,205,197,189,180,171,162,152,142,131,120,109,98,86,74,62,50,37,25,13,0,13,25,37,50,62,74,86,98,109,120,131,142,152,162,171,180,189,197,205,212,219,225,231,236,240,244,247,250,252,254,255,255),phbval
			   '( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ,10,11,12,13,14,15,16,17,18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
	let L1 = phbval - 1
	let U1 = phbval + 1
	return
there is still some development ot do, may look at going to 10bit adc, and making it so that the master can setup a full custom stepping cycle, or auto move a number of stepes
 
Last edited:

rossko57

Senior Member
it also states that the senese out put is -1 to 2.3v
It's not an output as such, those are maximum ratings i.e. you should not allow the voltage at that pin to go outside the range of -1 to 2.3V. That is to say, it is not advising what you can expect to see the L298 producing for you - its warning you not to do things to the L298 that it won't like.

it however does not state how this relates to anything (ie coil voltage).
Ohms law.

There may be misunderstanding here. The current flowing through the H-switch and motor is lead to ground via the "sense" pin. You can just earth that pin and all will work nicely.
If, instead, you connect that "sense" pin to ground via a low value resistor, the motor current flowing through it generates a voltage according to Ohm's Law.
Let's say you use a 1.5ohm resistor and motor current is 1 Amp - the 'sense' voltage will be 1.5V. Not "produced" by the L298, but developed across the resistor.

If the motor current were 2A the voltage would be 3V ... here you are breaching the L298 safe rating and at risk of smoking it. You'd choose a smaller resistor.

If you can choose a resistor that develops a voltage, at the currents you are interested in, that is directly readable by the Pic's ADC then you won't need any amplification. Something like covering the range 0 to 1.5V would probably do for the purpose here.

If you're desperate for efficiency (limited batteries perhaps) then you'd want to have as low-value resistor as possible, to save wasting energy. That'll generate a tiny current-related voltage - so you'd probably need to amplify that to process it.
 

oracacle

Senior Member
r = v/i, so we know we want 2.8v and 1.7 amps, the value of the resistor to obtain those values is 1.64ohms. however is the sense resitor isnt putting out that voltage i presume using a 1.3ohm (2.3/1.7) resistor will have to do. i will need to to produce somewhere between 2.5 and 2.8v for the coils, seeing as the voltage at the sense resistor will directly relate to this. constant currunt is more important here though, so even with a drop to 2.3v, ohm law still says we need to be using something large than 0.5ohm resistor

the problem with reading the sense directly is i will only be able to use the first 2 thirds (If that) of the adc which may affect thing like resolution.
 
Last edited:

rossko57

Senior Member
r = v/i, so we know we want 2.8v and 1.7 amps,
Don't confuse motor supply voltage with the voltage developed across the current sensing resistor.
You're designing a current chopper, it will _make_ the motor current 1.7A whether using a supply of 5, 12 , 20V etc.

You don't want to develop too much voltage across the sense resistor, as (a) its subtracted from supply volts to the motor and reduces efficiency and (b) the L298 won't like it

the problem with reading the sense directly is i will only be able to use the first 2 thirds (If that) of the adc which may affect thing like resolution.
I thought you only wanted 16 steps - you only have to distinguish between 0% to 100% current in sixteen steps, that only takes 4 bits so it doesn't matter if you're only using the lower part of the full ADC range. In real life you'd get away with just using part of the ADC range.
 

oracacle

Senior Member
you are going to have to explain what you mean a little more clearly.

i cant develop more than 2.3v across the sense resistor - Vsense acording to the ST data sheet is min -1v and a max 2v (or on another page 2.3). this i presume stays the same even with ramping up the supply voltage to an absolute max of 50v.
if we presume 0.5ohms at 2.3v (at v-sense) the l298 will need to supply 4.6amps to the coils - way beyond its absolute max of 3amp nonrepetitive, 2.5 repetitive (80% duty cycle) and 2 for dc operation

the idea is develop current, that what inductors prefer, this is also why i wont be using an inductive type resistor for the sense resistor as it will compund that power lose through heat with another inductive source.

please have a look at the last piece of code i have posted, there is the possibilty to have upto 32 step rising and 32 steps falling. 64 for both was a bit tight for variation.
 

Attachments

rossko57

Senior Member
you are going to have to explain what you mean a little more clearly.
...
if we presume 0.5ohms at 2.3v (at v-sense) the l298 will need to supply 4.6amps to the coils - way beyond its absolute max of 3amp nonrepetitive, 2.5 repetitive (80%
duty cycle) and 2 for dc operation
Yes, that'd be silly. Why would you choose to make 2.3V anyway, that's the level at which you might destroy the L298 as they warn you?

Okay, so you want 32 different current levels. The stepper guru is happy with 8 or 16. bear in mind these are subdivisions of whatever the "standard" step rotation is for your selected motor.

Volts-per-increment for Picaxe ADC10 is about 5mV.
So in theory, to get a range of 0 - 31 you'd only need a maximum input signal of 0.16V

In reality you'd want better resolution because your steps are actually non-linear, so say four ADC units per desired current level.
An input signal of max 0.64V would give you ADC readings of 0 to 128
You've chosen a motor where the "100%" current level is 1.7A
Ohms law says use a sense resistor of 0.376 ohm to get the desired sense voltage of 0.64

That's a hard to find resistor, so using a more standard 0R47 instead -
"100% current" would then be represented by 0.8V
Power dissapation in the resistor would be 1.35W, so a metal oxide 2W type should do.
0.8V is safely below the L298 permitted max by a good margin
ADC wil give numbers in the range 0 to 160, to be divided up into your 32 levels approximately sinusoidally.
 

oracacle

Senior Member
you havent explained much, while am able to to the maths you havent explained why you are desiring the 0.64v. you haven't explained where this figure came from (i can only imagine power caluclions and i dont have my reminder to hand to check it). this is why am so confused why you have come to the conclusion you have.

you have to bare in mind i am dyslexic and thing that seem completely obvious to you aren't to me, i have to keep a refrence of things like ohm law to hand. i wont go to tell you how many time i have to read each post before it starts to make sense. to put it simply, i am bit on the thick side and even though i am often able to understand how a circuit works i am often not able to to understnad why it worsk and what is needed to make it work - mechanical stuff is easy, but what is life without a challenge
 

rossko57

Senior Member
Okeydoke, there's lots going on and you need to break it into stages. (I nearly typed "steps" which would just add more confusion!)
Which part would you like to know more about?

I'm guessing the part you are missing is about Vsense?
Vsense is _not_ a signal from the L298 chip.
The L298 will run quite happily with the sense pin connected to ground, i.e. no Vsense at all, ever.
The sense pin is provided for your convenience, should you want to measure motor current.
If you want to implement current control, and it seems you do, then you need to add some kind of sense resistor to the L298 circuit.

Vsense is developed across the sense resistor that _you_ choose.
The Vsense you could expect from any given resistor is calculated, using Ohms law, from the expected motor current. Note that neither of those things involve the L298.

In theory, you can have whatever Vsense you like by choosing a different sense resistor.

In reality, the makers of the L298 say you musn't allow Vsense to go above 2.3V or the chip might blow up - so that is one constraint on your choices.

You don't want/need to go mad and use a large value sense resistor, that is wasting energy as heat, so you'd want to find the smallest resistor value you can get away with. Another constraint.

Whatever device you choose to monitor the Vsense will add more constraints - if we use a Picaxe to monitor Vsense directly, we need a certain minimum level just to detect it at all (around 5mV probably).

If we want the Picaxe ADC10 to give us a big enough number to divide up into 32, we'd need at least 5mV x 32 Vsense.

It'd be better to have a number bigger than than 32 to divide up into your 32 levels, so if we had say 4 Picaxe ADC steps for each of your 32 levels, the maximum Vsense would be 4 x 32 x 5mV

To find/make an exact resistor to fit the bill is difficult. But all you have to do is use the next highest readily available value, and re-do the Ohms law maths to find the maximum Vsense that will develop.
Make sure that won't blow up the L298.
Work out how many Picaxe ADC counts that is at 5mV per count. Then you have a number to be divided into your 32 current levels. I don't know the maths to do that to get a sinusoidal result, but you have someone who can.

If you're struggling with this ... can i suggest something simpler? Just make an ordinary stepper motor driver with no partial steps or fancy current control.
 

oracacle

Senior Member
right that makes laot more sense now that you know were you got the 0.64v from.

so if i check i have this correct, if we wanted so 10 adc10 level for each step on 32 step drive we would look for 1.6v at vsense and thus use a 0.94 ohm resistor. so we could presume 1ohm being the closest then there would be 1.7v at v-sense (i will work out adc max later wheni am on my main rig).

thanks for the help, i will do some more circuits later, one with an amped (i will be doing more research on what op-amp will be best if i decide to go this route) signals and one without, progress may be a bit slower now as i have finnished my time off for a couple of months.
 

rossko57

Senior Member
so if i check i have this correct, if we wanted so 10 adc10 level for each step on 32 step drive we would look for 1.6v at vsense and thus use a 0.94 ohm resistor.
10 ADC units X approx 5mV per unit X 32 desired levels = 1600mV yup :)

But you'd be making a rod for your own back there. 1 ohm resistor passing 1.7A (100% motor current) wastes 3W of power. Your two sense resistors between them will always be wasting this much.

You wouldn't really need 10 ADC units per level. If you reduced your Vsense so that it had just five ADC units per level, you'd waste half as much power.

It is true that you can minimise power wastage by using a tiny value of sense resistor, and amplifying the resulting tiny Vsense into something the Picae can read. It's more complication, of course. I was suggesting a possible simplification by choosing parts so that the opamps aren't needed.

Frankly I do think you should prototype with just a simple stepper drive and see if your mechanism/motor is up to scratch. You can always upgrade the controller to the fancy part-steps etc. later on.
 

oracacle

Senior Member
everything will be prototyped and tesed in stages. providng all of the machanics operate within planned perameters then there should be no issue.

this may not end up in the project at all, if i can track down a non-chinese th6065 then i may plump for that. i am trying to keep my options open to allow the project to proceed without "ideal" parts
 
Top