stepmotor problem

klaasje

Member
Hi all,

I must drive a stepmotor to variabel positions (p and pr) but when i tested the motor i see he loses steps because he is going in stoll. When i have the time at 20ms like now it its working but very slow.
And when a make the time to 1ms it loses a lot of steps. Motor is a nema 17 whit a A4988 driver (https://www.hobbyelectronica.nl/product/a4988-3d-printer/) motor is not connected to mechanical parts.
I think there must be a better way to make code for it, but i am not getting further with it.
Any ideas?

Thanks

# picaxe40x2

symbol D7 = d.4 'direction***left turn high / right turn low
symbol S7 = d.5 'step
symbol E7 = d.6 'enable***disable high / enable low
symbol P = b10 'total number of pulses
symbol pr = b11 'total number of pulses reduced
symbol time = b17 'time delay
symbol temp1 = b13 'temp value 1


setfreq m8
time = 20

p=250
pr=100

do
high D7
do
high S7
pause time
low S7
pause time
inc temp1
loop while temp1 < p
low D7


wait 1

do
high S7
pause time
low S7
pause time
dec temp1
loop while temp1 < pr


loop
 

hippy

Technical Support
Staff member
Is it losing steps because of stalling or is it the software, in the handling of 'temp1' and the LOOP WHILE conditions ?

You perhaps need to have a "temp1=0" before each of the two stepping loops.
 
that's always the problem when you do not previously engaged in this subject.
a stepping motor can not start immediately from 0 to 100
you need a start-up ramp
to get more torque you usually have to use small steps like 1/4 1/8 or less
The higher the voltage the more power is possible, using 12V or 24V with chopper mode is usual
just connect cable and power on, it does not work simply always :)
 

klaasje

Member
Is it losing steps because of stalling or is it the software, in the handling of 'temp1' and the LOOP WHILE conditions ?

You perhaps need to have a "temp1=0" before each of the two stepping loops.
I have tried that but it didn't work. You can see that the motor is not running smoothly and falters.
 

klaasje

Member
Thanks for the answer. He does not have to make that muts speed. I am going to try the smaller steps. I am using 12V on the system. Its a mobile system whit 12V battery.
Do you have a example for ramping up and down the motor?
 

Technical

Technical Support
Staff member
ramping up/down the time simply means increaseing/decreasing the time between steps - so in your original program slowly decrease the value of b17/time rather than use a fixed value.
 
Top