Differences between 1.8 and .9

301 views
Skip to first unread message

Bill Clark

unread,
Jan 30, 2019, 8:24:34 PM1/30/19
to Smart Stepper
Any advantage, from an accuracy standpoint point, in using a .9 deg motor? Application is a high precision micro mill.

misfittech

unread,
Jan 31, 2019, 7:11:14 AM1/31/19
to Smart Stepper
I find that their is little advantage.  I find that the smart steppers after calibration will have around +/- 0.1 degrees are better repeatability.  This seems to be about as good as I have been able to get units and does not matter if it is 0.9 or 1.8 degree motors. 

Generally speaking if you want best precision build this into the gearing of the machine.  That is gear the machine down such that your errors (backlash, and such) is twice your step accuracy . This will give you best speed and accuracy for your machine.  

Note for the maximum speed use 24V supply for motors, verses 12V supply it makes a huge difference. 

Trampas

Bill Clark

unread,
Feb 2, 2019, 4:45:42 PM2/2/19
to Smart Stepper
Thanks for the feedback. That resolution would work well with my application (mini mill/Duet ccontroller) as I'm targeting +-.0025mm. +- .1 degrees would theoretically give almost twice that with a 6mm lead ball screw. How does your drive effect the torque curve of the motor compared to how it would be if operated like a conventional stepper? The low side of the feedrate range the machine will have the motor turning about 20-40 rpm.. Seems pullout torque curves shown for many NEMA 17 steppers show peak torque above 100 rpm. I could go to a 2mm lead ball screw to get the low side feedrate up around 100-150rpm but the controller may limit the high side feedrate in its ability to produce a fast enough step rate. 

misfittech

unread,
Feb 2, 2019, 5:25:31 PM2/2/19
to Smart Stepper
A couple of things to do to maximize the torque are:

1. Run off a 24V power supply - the higher the voltage power supply the more torque you will get. 
2. Set the motor current on the smart stepper to maximum (well beyond the motor maximum). 

For #1 the torque is dependent on the rate of change of the current, having higher voltage allows the current to change faster and you get more torque and speed as a result. 

For #2 the motor current limit is the maximum continuous current for the motor. The limit on the smart stepper is the peak current limit. What the smart stepper does is drive at the peak current until the error drops, then it drops the current. Hence the continuous current rarely if ever reaches the peak current. 

As far as the pitch on the ball screw it is best to set the pitch based on the accuracy you want.  I would design it such that 1 full step of the stepper motor was less than my accuracy requirement. This gives you the maximum torque and accuracy.  That is the torque is maximum when taking full steps.   The only reason not to do this is speed, the more you gear down the motor the lower the top speed of the machine.  For CNC machines top speed is rarely a concern, that is I find I have to slow machines down based on the spindle speed and torque more than the movement speed and torque.   For example on one of my mills I can not mill more than 0.1mm depth as the spindle does not have the power to cut faster than that  in aluminium. If I do try to go deeper I end up slowing the feed rate such that the bits are taking such small bytes of the material they start getting hot.  If I slow the spindle down it looses torque and can not cut.  Hence the whole machine design needs to be matched for torque and speed.  

With that said at the end of the day it is better to machine parts slow and perfect than to be fast and have errors.  
So if you are worried about the torque of the NEMA 17, then go with a NEMA 23 or 34. There is little reason to be under powered (up to point you exceed current on AC power plug).  That is even if you could buy a 3 Ton dump truck with a 4 cylinder engine, why would you?   

My experience building a mill is that trying to machine aluminum with a less than 1HP is frustrating at best.  That is it can do it very slowly, so I have been looking for a used Haas machine with tool changer and coolant.   
  

Bill Clark

unread,
Feb 6, 2019, 8:50:05 PM2/6/19
to Smart Stepper
I always prefer higher voltage so 24v was the plan. 
If I use your guidelines (1 full step= better than required resolution) I still cant quite get to my target of +-.0002" (.005mm) with a 2mm lead screw. and 1.8deg motor. With a .9deg motor I could. This is almost as good as the resolution of my Haas VMC with servos.Once the Smart Steppers are back in stock I want to give one a try on my test rig. With a 6mm lead screw driven by a .9deg nema 17 motor and a Duet in 1/16 ms im getting about +- .0002" .(005mm) resolution with no load and a following error of about .0008" (.02mm) with 10lbs of load. This setup provides up tp 50lbs of force at the nut. Predicted machining forces are 7 lbs to drive an 1/8" endmill, full slot @ 1/8" ADC through CP2 titanium.

Michael Anton

unread,
Feb 7, 2019, 2:50:36 AM2/7/19
to Smart Stepper
So, working backwards, you have 6mm/rev on your test rig, with an error of 0.02mm under load, so this is equivalent to 300 steps/revolution, which is lower than the full step resolution of your 0.9 degree/step motor at 400 steps/rev.  I'd say the microstepping is doing nothing for your resolution in this case, though it probably runs much smoother.

misfittech

unread,
Feb 7, 2019, 10:32:52 AM2/7/19
to Smart Stepper
The Smart Steppers will improve accuracy/resolution with microstepping.  However the issue becomes a question of torque to understand this lets assume we have a motor which is rated at 1A per phase.  Also assume the torque is a direct linear relationship to the current going into motor.  

Now with both phase on at 1.0A the vector sum of the currents is 1.414A, see below.

Capture.JPG


Now if only phase A is on and phase B is off you have 1A of total current into the motor and the torque therefore is less.  If we could put 1.414A into phase A then would have the same torque, but if we limit to 1A per phase we end up with our torque curve is square shown above.  We could limit the torque to be circle inside the square such that our maximum current at 45 degrees would be 0.707A per phase for vector total of 1A. 


So as you can see even if you have improved accuracy from smart stepper the torque during microstepping is lower.  However we have a few more tricks we can employee... 


The maximum motor current of 1A is normally the maximum continuous current you can apply to the motor.  That is the motors have windings of wire to generate the magnetic field, these field windings fail when they get too hot (either hot enough to melt insulation, or hot enough to burn wire into).  So if you apply  more than 1A to a cold motor it will start heating up, then after some time it would get so hot it melts windings or insulation.  This does not happen instantly.  That is the heat has to build up before failure.   What if you put 1.4A into motor for a short period of time?  If the time is short then most likely the motor will not fail as it does not have time to create enough heat to melt.  Of course at some amperage level it will heat up so quick it will melt the windings  almost instantly.  


One thing I am working on with the smart steppers is to have a peak current limit (per phase) and then an average current limit per phase.  The average would be averaged over some time period say 100ms. The idea is that you can exceed the motor's continuous current limit for some brief period of time, but the average current must be below the continuous current limit of the motor.   


For applications like 3D printers this would allow faster moves, and more instantaneous torque, and hence over all better performance. However for CNC milling machines where you need continuous torque to drive the tool into the material it will not be of an advantage as the current needs to be high continuously. 


Since you need high torque on CNC mills my recommendation is to design CNC mills with motors having large torque (NEMA 23 or 34) and not use the small NEMA 17.  The reasoning is that if you need more torque you can get buy a bigger motor in the NEMA 23 or 34 form factor without making new mounting brackets. 


Once you have the bigger motor I still recommend trying to match the full steps to the accuracy, especially if you are not concerned about speed.  Not because the smart steppers are not accurate at micro stepping but because you will have the maximum torque and the most flexibility.  That is it is better to add the smart steppers and get better accuracy than required than it is to be on the edge of what you need. 


For 3D printers they often count on the microstepping for accuracy as they also want high velocity moves.  The speed is such a concern the accuracy has to be made up by microstepping.  Even here however the main advantage of the smart stepper is to prevent missing steps, as that the 3D printers are so cost sensitive designs their accuracy is limited by other factors (back lash, belts, etc).   While one saved 24 hour print on a 3D printer from missing steps can easily pay for the smart steppers.  The missed steps in 3D printers often come from such things a plastic blob on the print, or dirt on the linear rails.  These things are often not predictable and thus having closed loop to deal with them makes sense. 


On CNC mills most people start adding the smart steppers when they are trying to get every drop of performance out of the machines.  That is they are pushing machine to limits where they can miss steps because they do not have the torque needed for the speed they are running. My personal experience is that  when this starts happening even the smart steppers will be just a temporary band aid. That is maybe it can recover if the mill hits a hard spot briefly, but if the motor is already at full torque there is little the smart steppers can do to get more power from motor to  try and correct error.  Here again it is better to design with bigger motors so you have excessive torque, this way the smart steppers can increase the torque to deal with the errors.  The other advantages of the smart stepper is lower motor heat and smoother movements, which can be significant advantage as well. 



As far as improving accuracy in microstepping using the smart steppers, imagine that the one coil of your motor is 1% difference in inductance or resistance. Then what happens is when both coils are on at 1A one will actually get more power than the other. In the diagram about the vector would not be at 45 degrees but would have some error.  With the smart stepper it measures the actual shaft position and will change the currents until the angle is correct. 


The difference in the motor coils does happen, in early firmware we calibrated with both phases powered up, but since the current was different our motor angle was off. Now the smart steppers calibrate with only one phase on to ensure that the motor shaft is at the correct angle. That is one phase on it is always on the X or Y axis above regardless of minor changes in the phase currents.  


 

Trampas




 




Bill Clark

unread,
Feb 17, 2019, 1:34:58 PM2/17/19
to Smart Stepper
Thank you for the detailed and informative response, as always. Any updates on when the next batch will arrive?

Radek J

unread,
Jul 22, 2020, 6:15:16 AM7/22/20
to Smart Stepper
I think in microstepping is essentially a Sinusoidal Commutation. https://www.pmdcorp.com/resources/type/articles/get/field-oriented-control-foc-a-deep-dive-article

I imagine it would be possible to add Field Weakening feature (using Park Transform) to help with high speed?  

dzid...@gmail.com

unread,
Jul 22, 2020, 9:57:36 AM7/22/20
to Smart Stepper
"...as the frequency of motor rotation increases, so does the challenge of maintaining the desired current. This is because the current loop is affected by the rotation frequency. Lag in the current loop, insignificant at low rotation speeds, generates increasing amounts of D (unwanted) torque at higher rotation speeds, resulting in a reduction of available torque.
"
That should be compensated by phase advancement someone proposed. 

Additionally  I am trying to apply concepts from 3 phase motor control into 2 phase stepper. Actually I think it is pretty simple. 
First of all, since this hardware relies on A4954 to individually control phase current on chip, so precise close loop torque adjustment part (based on both phases current feedback) goes away. 
Since it's two phase only, the Clarke and inverse Clarke go away.  
The only thing that's left is Inverse Park Transform. Now, I realized that's really simple. Misfit implements special case of the transform for D=0 (which results in no field weakening and no MTPA. 
By making d term non-zero, the transform extends to:
co = cos(theta);
si = sin(theta); 
X = co*D - si*Q; 
Y = si*D + co*Q;
the FW and MTPA can be implemented (additionally to phase advancement)
But since is open-loop, I and D will be only set according to our best guess, but in reality I think they may drift away, for example at high speed. 
Still, in theory, these features should be doable

misfittech

unread,
Jul 22, 2020, 10:41:02 AM7/22/20
to Smart Stepper
Yes that is correct. 

So you start getting into problems when time is added to the equations. 

So you know the position of the motor shaft Theta. Since the position changes over time we have the motor shaft angle as Theta(t).  The A4954 provides an estimate of this position, Theta'(t).  Specifically. 

Theta'(t)=Theta(t-t_error) + noise

That is at any time (t) the measurement from the A4954 is actually the position of the motor shaft in the past, due to delay in reading position.   This can be estimated as. 
  Theta'(t)=Theta(t) -T_error(rpm) + noise  

That is the t_error is assumed to be a constant time error due to delay in reading the A4954. As such the angle error that this delay introduces, T_error, is a function of the current motor speed.  

Now we have a second issue that is once we measure Theta'(t) we have to do the feedback control calculations which take some time to do, call it t_calc.  So we end up with an estimate motor shaft angle for what current we need to drive as:

Theta(t)=Theta'(t)  +  T_error(rpm)   -  noise +T_calc(rpm) 

Again we assume t_calc is constant time and so the angle error is a function of RPM, hence  T_calc(rpm) 

We can then assume since A4954 dealy and the t_calc are constants we get one term, T_e(rpm)

Theta(t)=Theta'(t) + T_e(rpm)  + noise 

So if  T_e(rpm) is a full step angle then we run into a problem where the motor rather than moving forward stops.  Worse still it as we approach the limit all is good, but once we hit this point the motor tries to stop, but the next measurement the motor has not move (assuming it stops) and then the A4954 measurement reflects this and now that the instantaneous RPM has dropped we are no longer at that threshold and the motor moves forward.  This then creates a shuttering effect in the motor. 

So we can try and predict the  T_e(rpm) that is the motor shaft angle error based on RPM, also known as the predicted phase angle error that the rpm causes and compensate our shaft angle prediction.  However our RPM estimate is based on our estimate of Theta, so we can have issues with noise. 

This helps alot with speed but care needs to be taken to make sure it does not introduce errors at low RPM and when you are changing RPM. This is especially a problem when the measurement angle noise dominates. 

Additionally there is another factor in the equation which is how fast you can change the magnetic field on the motor.  So if you think about full steps where coils have the following states (-1, 1) which represents full on in reverse or fully on forward current. Then the reality is that turning the coil on takes time to reach full magnetic saturation current. So you can never move faster than you can turn the magnetic field on and off. More precisely since it takes time to turn field on as you go faster you can never reach full field strength before you need to reverse field strength. As such your motor's torque has to drop as you reach this limit.  However if you increase the voltage on driving the current this speed and torque limit increases too. 

So right now the processing speed of the control loop is 6000 times a second, if we assume our T_e(rpm) is zero and we can change magnetic field instantly, then our maximum rotation speed is one full step per control loop cycle. So for a 200 step per rotation motor that would 6000 steps/sec / 200 steps/rotation =30 rotations per second = 1800 rotations per min.  Since in most applications we do not achieve this limit we are either bound by the delay in angle measurement or delay in increasing magnetic flux in motor.   So if we increase voltage and we get higher motor speed this would indicate we are dominated by how fast we can change the magnetic flux.  If we increase voltage and maximum speed does not change it is not a flux problem. 

My experience is that the maximum motor speed limits are:
1. How fast you can step the step pin - if you are 16x micro stepping and running at 500RPM you are pulsing step pin at ~26khz for a 200 step per rotation motor
2. Motor voltage 
3. delay in shaft position and calculation delays

For the step pin problem try issuing command through the command line to move the motor, if it is much faster than your controller is moving the motor your problem is step pin or controller.  If you increase voltage and motor moves faster then increase voltage if both of those are not enough then lets work on phase advancement, but note it is a cost of current and so you might need bigger motors to get more speed. 

Trampas

Radek J

unread,
Jul 22, 2020, 7:02:07 PM7/22/20
to Smart Stepper
Thanks for the practical insights!

Just to clarify for others to know, I think you meant AS5047D which gives us theta.


I think that for phase advancement circular reference, you mentioned, can be (partially?) solved with a little bit of model based approach. Basically you can predict speed based on your command. That will solve "unexpected" deceleration problem when full step is commanded. (Kalman filter with a modelled observed could work really nice here.)

The only unknown would be load. Now depending on application, the load may change instantly or smoothly. If the later, the resulting speed change will be slow, so no problem. If former, for example hitting a wall, then the calculation will be incorrect for a moment, like you said. But given that we have a wall in front of us, I think it would be acceptable to "loose few steps" trying to push the wall.
If it was someone was trying to detect end stops of their 3d printer that way, they should do it at low speed.


Regarding the maximum speed. I think one could also find out if there is more speed potential to be unlocked by just driving the motor (from UART) in complete open loop until it looses steps. This way the encoder latency wouldn't slow us down.
That is if the program loop is limiting factor before the magnetic field switching as you pointed out.

I guess only then field weakening could be worth considering. Because in theory it should allow for faster rotation than full step driving. But this sort of thing would probably require DMA to still write proper sine wave to PWM, otherwise the cpu probably wouldn't be fast enough. So it's probably out of the scope of Arduino library.

dzid...@gmail.com

unread,
Jul 23, 2020, 1:34:01 AM7/23/20
to Smart Stepper
I am confused as to whether A4954 actually controls current to target. Is the V_Ref modulated as mentioned here
And do we have actual current measurements? I think the schematics is outdated as ISENSE_FET_A on A3 input is not connected to anything. With the current readings, we can do a proper FOC current loop.


For a second I thought we are dealing here with the even simpler control scheme that is voltage control. I am still not 100% sure.  High precision vector manipulation I was thinking before would be even less possible with voltage control. 
(For the readers, here is a description of voltage control from Trinamic and current control for comparison). 
Drawbacks of voltage control are torque accuracy (linearity at any speed) and efficiency but at least there is less chopping hissing. But also we would rely on the (slower) position feedback loop to control torque). 




misfittech

unread,
Jul 23, 2020, 7:17:02 AM7/23/20
to Smart Stepper
I did mean the AS5047D, sorry about that. 

So the A4954 does control the current to the motor.  Specifically it uses a current sense resistor and comparator to do this.  The SAMD21 provides an analog voltage (using PWM) which is used as input to the comparator to set the current limit. 

We do not get actual current measurements from the A4954, instead we are trying to set the current limit.  the ISENSE_FET_A is most likely in the code not schematics and was code I was doing for a 10A driver where I actually sensed the current.  So let me explain a bit about the the current control in the stepper to clear up a few more things. 

Capture.PNG

Capture.PNG

Above is the block diagram for the A4954 as you see at the bottom there is the VREF and current sense resistor going to the comparator.  What the A4954 does is turn on power to the motor then it waits a "blanking time" of 2-4us before it starts checking the comparator for over current.  Once it detects over current it enters what it calls "mixed decay" operation.  Specifically once it detects we reach the current desired it will reverse the H-bridge driver for some 'fast decay' time. After that it will short both wires of the motor coil to ground for the 'slow decay' time.  Theses times are both fixed at 12.5us each and can not be changed.  After this time it turns the coil back on and repeats the process. 


There are a few problems here, specifically if you use a small motor and large voltage it is possible to exceed the desired current level in the blanking time. You can also reverse all your current in the fast decay time.  Usually this is not a problem but it is possible.   Additionally the coils on the motor and current sense resistors are not perfect, so you will not always get the current you wanted into the coils. For example one coil could get higher lower current for the same VREF set point.  These problems however get taken care of in the control loop, that is by knowing the motor position we correct for any position errors, so if the current was off motor would move to bad position in micro stepping but then control loop would correct. 


Also as the load on the motor changes the inductance of the coils changes too, which will change the current ramp and ramp down times. The reality is that knowing the precise current also does not help as the current to magnetic flux in the motor will be different for each coil, hence in the end it all gets taken care of by measuring what we really want, that is the positional accuracy. 

dzid...@gmail.com

unread,
Jul 24, 2020, 2:20:35 AM7/24/20
to Smart Stepper
Thank you for the excellent explanation.
Reply all
Reply to author
Forward
0 new messages