Discussion:
[Machinekit] Stepper motor configuration
euerka
2016-09-21 14:45:50 UTC
Permalink
Dear all,
Recently i am trying to use CRAMPS.ini(without cape just BBB) to drive step
motor.
My Motor model is:
Moon's stepping motor
Type 17HA6403-09N

Driver is A4988

P8-13 and P8-14 are used as stepdir and step.

First of all, I adjust the limit current to 0.43A according to motor data
sheet.
Then i set scale to -1600 in the configure file

[AXIS_0]
#
# Step timing is 40 us steplen + 40 us stepspace
# That gives 80 us step period = 12.5 KHz step freq
#
# Bah, even software stepping can handle that, hm2 doesnt buy you much
with
# such slow steppers.
#
# Scale is 200 steps/rev * 5 revs/inch = 1000 steps/inch
#
# This gives a maxvel of 12.5/1 = 12.5 ips
#
TYPE = LINEAR
MAX_VELOCITY = 200.0
MAX_ACCELERATION = 3000.0
# Set Stepgen max 20% higher than the axis
STEPGEN_MAX_VEL = 240.0
STEPGEN_MAX_ACC = 3600.0
BACKLASH = 0.000
SCALE = -1600
MIN_LIMIT = -1.0
MAX_LIMIT = 220.0
FERROR = 1.0
MIN_FERROR = 0.25
HOME = 0.000
HOME_OFFSET = 0.00
HOME_IGNORE_LIMITS = YES
HOME_USE_INDEX = NO
HOME_SEQUENCE = 0
# Set to zero if you don't have physical home/limit switches
# Set to the desired homing and latch velocity if you have switches
# See: https://github.com/machinekit/machinekit-docs
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
# these are in nanoseconds
DIRSETUP = 200
DIRHOLD = 200
STEPLEN = 1000
STEPSPACE = 1000
As motor specification shows 0.9 deg per step, 400 step/rev * 4 rev/mm=1600
step/mm
my target is 1600 steps per mm.
Then I tested G01X1.f40., it looks rotate 4 round.
If i tested G00X1.F40., Motor freezed and make noise. Speed too fast???
Or when i run a G program, sometimes it just freeze and make noise.

Then I tested NC program from nc_files such as butterfly.ngc, it will
accelerate then decelerate, when speed nearly goes to zero, motor start to
shaking, and make noise.

I have almost zero experience about tuning stepper motor, so may i know how
to configure stepper motor and make it work smooth with machinekit?

Thanks very much!

-chengxi
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+***@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.
Charles Steinkuehler
2016-09-21 15:03:37 UTC
Permalink
MAX_VELOCITY = 200.0
MAX_ACCELERATION = 3000.0
# Set Stepgen max 20% higher than the axis
STEPGEN_MAX_VEL = 240.0
STEPGEN_MAX_ACC = 3600.0
<snip>
# these are in nanoseconds
DIRSETUP = 200
DIRHOLD = 200
STEPLEN = 1000
STEPSPACE = 1000
As motor specification shows 0.9 deg per step, 400 step/rev * 4 rev/mm=1600 step/mm
my target is 1600 steps per mm.
Then I tested G01X1.f40., it looks rotate 4 round.
If i tested G00X1.F40., Motor freezed and make noise. Speed too fast???
Almost certainly. With a scale of 1600, and a maximum velocity of
200, your maximum step pulse rate would be 320,000 KHz, and with your
acceleration of 3000 mm/s/s, you'll get there pretty quick. The
default PRU settings result in a maximum pulse speed of about 50 KHz,
so you need to either reduce the maximum allowed velocity or decrease
the PRU cycle time (or both).

What sort of drive system are you using to get 4 rev/mm? That's
pretty low even for a ball screw with a belt reduction.
Or when i run a G program, sometimes it just freeze and make noise.
Then I tested NC program from nc_files such as butterfly.ngc, it will accelerate
then decelerate, when speed nearly goes to zero, motor start to shaking, and
make noise.
I'm not sure why this is happening, it shouldn't be caused by the fast
step pulse rate issue above. Sometimes this happens if you have
problems with your stepper motor wiring (the pairs are hooked up wrong
or one of the pairs has faulty wiring).
--
Charles Steinkuehler
***@steinkuehler.net
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+***@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.
Bas de Bruijn
2016-09-21 18:57:16 UTC
Permalink
Post by Charles Steinkuehler
As motor specification shows 0.9 deg per step, 400 step/rev * 4 rev/mm=1600 step/mm
Post by euerka
my target is 1600 steps per mm.
Then I tested G01X1.f40., it looks rotate 4 round.
If i tested G00X1.F40., Motor freezed and make noise. Speed too fast???
Almost certainly. With a scale of 1600, and a maximum velocity of
200, your maximum step pulse rate would be 320,000 KHz, and with your
acceleration of 3000 mm/s/s, you'll get there pretty quick. The
default PRU settings result in a maximum pulse speed of about 50 KHz,
so you need to either reduce the maximum allowed velocity or decrease
the PRU cycle time (or both).
What sort of drive system are you using to get 4 rev/mm? That's
pretty low even for a ball screw with a belt reduction.
could it be that instead of 4 rev/mm you have a reduction of 4 mm/rev ?
that would mean 100 full steps/mm and might make more sense.
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+***@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.
euerka
2016-09-22 14:46:05 UTC
Permalink
Dear Charles,Schooner, Bas de Bruijin,

Due to time lag and working, sorry for late reply.

could it be that instead of 4 rev/mm you have a reduction of 4 mm/rev ?
Post by Bas de Bruijn
that would mean 100 full steps/mm and might make more sense.
First of all, I make mistake that is should be 4 rev/mm. So I change scale
to 100.

As Charles comment:
"Almost certainly. With a scale of 1600, and a maximum velocity of
200, your maximum step pulse rate would be 320,000 KHz, and with your
acceleration of 3000 mm/s/s, you'll get there pretty quick. The
default PRU settings result in a maximum pulse speed of about 50 KHz,
so you need to either reduce the maximum allowed velocity or decrease
the PRU cycle time (or both). "

May I guess in this comment 320,000 KHz should be 320KHZ, is it?
If PRU maximum pulse speed is 50KHZ, the max speed is 500? Because scale
100* 500=50KHZ.

I am not very sure about Schooner said "Try increasing dirhold / dirlen to
1us and steplen / stepspace to 5us
If that cures it, try reducing the figures towards the chip specs until you
hit problems"

Anyhow I tried to change ini file, i am not sure. But it seems no affect.
# these are in nanoseconds
DIRSETUP = 1000
DIRHOLD = 1000
STEPLEN = 5000
STEPSPACE = 5000


About speed, yes, i shift one decimal left as follow:

TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 300.0
# Set Stepgen max 20% higher than the axis
STEPGEN_MAX_VEL = 24.0
STEPGEN_MAX_ACC = 360.0
Post by Bas de Bruijn
SCALE = -100
It works much better than before, but motor still stall when execute G00.
Speed still too high? where to set G00 speed? 20.0 is only stand for feed
speed?
Then when motor change rotate direction, speed decrease to zero, around
Zero motor start move step by step, make vibration and noise. It seems it
doesn't work well at low speed.

It will be much clear if i can post video here.

Thanks for anymore tuning methods!

-chengxi
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+***@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.
Charles Steinkuehler
2016-09-22 15:55:58 UTC
Permalink
Post by euerka
May I guess in this comment 320,000 KHz should be 320KHZ, is it?
Yes, sorry. The speed required by your configuration was 320 KHz or
320,000 Hz. My goof on the extra zeros.
Post by euerka
If PRU maximum pulse speed is 50KHZ, the max speed is 500? Because scale 100*
500=50KHZ.
Yes, but that's the STEPGEN_MAX_VEL, you should back off that a bit
for MAX_VEL.
Post by euerka
I am not very sure about Schooner said "Try increasing dirhold / dirlen to 1us
and steplen / stepspace to 5us
If that cures it, try reducing the figures towards the chip specs until you hit
problems"
Anyhow I tried to change ini file, i am not sure. But it seems no affect.
# these are in nanoseconds
DIRSETUP = 1000
DIRHOLD = 1000
STEPLEN = 5000
STEPSPACE = 5000
Those values mostly matter for FPGA based stepgen logic, or if your
PRU cycle time is very fast. The minimum time for any of these values
is one PRU task cycle, which is typically 10 uS, or 10,000 nS, so you
probably won't see any difference by making small changes to these values.
Post by euerka
TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 300.0
# Set Stepgen max 20% higher than the axis
STEPGEN_MAX_VEL = 24.0
STEPGEN_MAX_ACC = 360.0
SCALE = -100
It works much better than before, but motor still stall when execute G00. Speed
still too high? where to set G00 speed? 20.0 is only stand for feed speed?
Then when motor change rotate direction, speed decrease to zero, around Zero
motor start move step by step, make vibration and noise. It seems it doesn't
work well at low speed.
MAX_VELOCITY sets the G0 speed. 20.0 should be a very reasonable
value, I run with MAX_VEL=200.0 on a system with SCALE=110.0

If your stepper is not moving well at low speed, double-check all your
wiring, the driver, and the motor itself. Normally, stepper motors
work best at low speed and start having problems (loosing torque and
missing steps) at higher speeds. A stepper motor _will_, however,
move with only one coil energized, but it will have problems with low
and high speeds.
--
Charles Steinkuehler
***@steinkuehler.net
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+***@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.
euerka
2016-10-08 10:18:19 UTC
Permalink
Dear all,

Thanks to Charles. My stepper motors have been worked stably with A4988
driver.
I try to summarize as follow:

Firstly driver output current have to be adjusted according to stepper
motor specification.
Secondly Scale have to be set properly, for example, for 400 pulse /rev,
screw lead is 4mm/rev, scale is 100.
Thirdly, speed and acceleration have to set reasonable.
Finally, due to vibration, i use micro stepping function, now i set 1/16,
which means scale have to change to 1600.

That is what I can understanding now, maybe there are other issues will
occur in future test.

Best regards!
-chengxi
Post by Charles Steinkuehler
Post by euerka
May I guess in this comment 320,000 KHz should be 320KHZ, is it?
Yes, sorry. The speed required by your configuration was 320 KHz or
320,000 Hz. My goof on the extra zeros.
Post by euerka
If PRU maximum pulse speed is 50KHZ, the max speed is 500? Because scale
100*
Post by euerka
500=50KHZ.
Yes, but that's the STEPGEN_MAX_VEL, you should back off that a bit
for MAX_VEL.
Post by euerka
I am not very sure about Schooner said "Try increasing dirhold / dirlen
to 1us
Post by euerka
and steplen / stepspace to 5us
If that cures it, try reducing the figures towards the chip specs until
you hit
Post by euerka
problems"
Anyhow I tried to change ini file, i am not sure. But it seems no
affect.
Post by euerka
# these are in nanoseconds
DIRSETUP = 1000
DIRHOLD = 1000
STEPLEN = 5000
STEPSPACE = 5000
Those values mostly matter for FPGA based stepgen logic, or if your
PRU cycle time is very fast. The minimum time for any of these values
is one PRU task cycle, which is typically 10 uS, or 10,000 nS, so you
probably won't see any difference by making small changes to these values.
Post by euerka
TYPE = LINEAR
MAX_VELOCITY = 20.0
MAX_ACCELERATION = 300.0
# Set Stepgen max 20% higher than the axis
STEPGEN_MAX_VEL = 24.0
STEPGEN_MAX_ACC = 360.0
SCALE = -100
It works much better than before, but motor still stall when execute
G00. Speed
Post by euerka
still too high? where to set G00 speed? 20.0 is only stand for feed
speed?
Post by euerka
Then when motor change rotate direction, speed decrease to zero, around
Zero
Post by euerka
motor start move step by step, make vibration and noise. It seems it
doesn't
Post by euerka
work well at low speed.
MAX_VELOCITY sets the G0 speed. 20.0 should be a very reasonable
value, I run with MAX_VEL=200.0 on a system with SCALE=110.0
If your stepper is not moving well at low speed, double-check all your
wiring, the driver, and the motor itself. Normally, stepper motors
work best at low speed and start having problems (loosing torque and
missing steps) at higher speeds. A stepper motor _will_, however,
move with only one coil energized, but it will have problems with low
and high speeds.
--
Charles Steinkuehler
--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+***@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.
s***@btinternet.com
2016-09-21 15:18:40 UTC
Permalink
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 21/09/16 15:45, euerka wrote:<br>
</div>
<blockquote
cite="mid:8886244f-6e50-4d58-ae8c-***@googlegroups.com"
type="cite">
<div dir="ltr">Dear all,<br>
Recently i am trying to use CRAMPS.ini(without cape just BBB) to
drive step motor.<br>
My Motor model is:<br>
    Moon's stepping motor<br>
    Type 17HA6403-09N<br>
<br>
    Driver is A4988<br>
</div>
</blockquote>
<br>
The stepper timings you are using are the theoretical ones for the
chip from the spec sheet, but take no account of any other<br>
source of delays such as opto isolators etc<br>
<br>
Try increasing dirhold / dirlen to 1us and steplen / stepspace to
5us<br>
If that cures it, try reducing the figures towards the chip specs
until you hit problems<br>
<br>
<blockquote
cite="mid:8886244f-6e50-4d58-ae8c-***@googlegroups.com"
type="cite">
<div dir="ltr"> <br>
<blockquote style="margin: 0px 0px 0px 0.8ex; border-left: 1px
solid rgb(204, 204, 204); padding-left: 1ex;"
class="gmail_quote"><br>
    TYPE =              LINEAR<br>
    MAX_VELOCITY =       200.0<br>
    MAX_ACCELERATION =   3000.0<br>
    # Set Stepgen max 20% higher than the axis<br>
    STEPGEN_MAX_VEL =    240.0<br>
    STEPGEN_MAX_ACC =    3600.0<br>
</blockquote>
</div>
</blockquote>
<br>
The second issue and potential hiccup are your speeds,<br>
if an axis ever moved far enough to build towards the maximums, I
would expect it to stall.<br>
<br>
Are you really expecting your Nema 17 (?) stepper to be able to
accelerate at 3.6 metres per second per second?<br>
Or to move an axis 14.4 metres per minute?<br>
<br>
Try calculating how many step pulses that would take and whether you
can generate them<br>
<br>
I would move the decimal point one place left for all velocity and
acceleration figures and scale up only if <br>
you can show spare capacity in step generation<br>
<br>
<blockquote
cite="mid:8886244f-6e50-4d58-ae8c-***@googlegroups.com"
type="cite">
<div dir="ltr"><br>
</div>
-- <br>
website: <a moz-do-not-send="true"
href="http://www.machinekit.io">http://www.machinekit.io</a>
blog: <a moz-do-not-send="true" href="http://blog.machinekit.io">http://blog.machinekit.io</a>
github: <a moz-do-not-send="true"
href="https://github.com/machinekit">https://github.com/machinekit</a><br>
--- <br>
You received this message because you are subscribed to the Google
Groups "Machinekit" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a moz-do-not-send="true"
href="mailto:machinekit+***@googlegroups.com">machinekit+***@googlegroups.com</a>.<br>
Visit this group at <a moz-do-not-send="true"
href="https://groups.google.com/group/machinekit">https://groups.google.com/group/machinekit</a>.<br>
For more options, visit <a moz-do-not-send="true"
href="https://groups.google.com/d/optout">https://groups.google.com/d/optout</a>.<br>
</blockquote>
<br>
</body>
</html>

<p></p>

-- <br />
website: <a href="http://www.machinekit.io">http://www.machinekit.io</a> blog: <a href="http://blog.machinekit.io">http://blog.machinekit.io</a> github: <a href="https://github.com/machinekit">https://github.com/machinekit</a><br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;Machinekit&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:machinekit+***@googlegroups.com">machinekit+***@googlegroups.com</a>.<br />
Visit this group at <a href="https://groups.google.com/group/machinekit">https://groups.google.com/group/machinekit</a>.<br />
For more options, visit <a href="https://groups.google.com/d/optout">https://groups.google.com/d/optout</a>.<br />
Loading...