An Electronic Lead Screw controller using a Teensy 4.1

Got the display running concurrently with everything. Tested with an encoder simulator running in a separate Teensy and ran it up to 100 KHz and it didn't lose counts, so that is good. At 200 KHz it lost counts, but my Omron rotary encoder that I have is only specified to 100 KHz. Now I need to work on the UI. I have made some sketches of screens with some notes on each screen. Sort of a storyboard as to what happens when you perform an action. Once I get them in a pretty form I'll post them.
 
Sounds great. How do you know when it is loosing counts? If it lost one occasionally at 100 khz would that be clear?
 
Inline there's an error check in my callback. If abs(delta)>=1, I print it out. For testing, I print the count value. The Encoder Simulator test program emits N steps, so I check for N steps on my platform. Except for the case that I noted, there's been a one to one relationship. Later, I will have to additionally check the closed loop stepper controller, that it's ok. (No alarm).
 
Anyone play around with a gui / screen designer software? I found some open source code for this. Edit: It is called GUIsliceBuilder.

It allows you to design the display using graphics functions. The UI for this tool is awkward, but it does allow you to see what will be on the screen. It supports the ili9341 and creates Arduino code. The code it creates is not that readable, but it is a start. For me, it exposes me to some widgets that I wasn't familiar with on these little displays, like sliders and radio buttons.
 
Last edited:
Just been playing with how fast I can drive this NEMA 11 motor with my driver. I can get 14085 microsteps/second. That is a microstep once per 71us. Faster than this, the motor makes noises and doesn't move.
I'm sure you're aware of this, but the stall speed will decrease as the motor experiences increased load. I wouldn't want to go above maybe 40% of that unloaded stall speed.

1652791781429.png

Also, again something you probably know, but the motor only produces a fraction of the rated torque when it is in a microstepping detent. At higher loads, the motor will cog to the nearest half or full step and you'll lose the added resolution of microstepping.
 
I'm sure you're aware of this, but the stall speed will decrease as the motor experiences increased load. I wouldn't want to go above maybe 40% of that unloaded stall speed.

View attachment 407209

Also, again something you probably know, but the motor only produces a fraction of the rated torque when it is in a microstepping detent. At higher loads, the motor will cog to the nearest half or full step and you'll lose the added resolution of microstepping.
Thanks for pointing this out. Yes, I figured that motors would lose torque vs speed, but this sort of chart is still an important reminder. I'm pretty glad that I haven't bought the real motor yet. There's lots to digest. Many motors come with really scanty information, which makes it hard to make a choice.

Is there a rule of thumb for torque loss due to microstepping? To make my math work out right, I used 8 microsteps for most threads and 4 microsteps for the really coarse threads.
 
So here is my understanding of stepper motor torque.

Let's use a hypothetical stepper motor with static holding torque "T".

There are quite a few speed related effects I'll gloss over here (low speed sinusoidal phase current losses, mid-band resonance, cornering frequency when the controller switches from current drive to voltage drive, etc.). Basically a modern digital stepper drive does a LOT to improve the motor performance.

So microstepping is a function of the controller to generate synthetic magnetic poles to increase the resolution of the motor. Since these are not true magnetic poles, you have a very rapid loss in torque when the rotor is positioned between two true magnetic poles.

1652794348352.png

1652794355439.png

In the image above, you can see that a half step position only produces 70% of the torque that would be generated at a full step position. Lets imagine you're configured to be in 8x microstepping. In this case let's look at the 8 positions between two true magnetic poles (0, 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, 1). The corresponding torques at those positions would be 1.000*T, 0.195*T, 0.383*T, 0.195*T, 0.707*T, 0.195*T, 0.383*T, 0.195*T, 1.000*T. Notice that at no position between the full steps do you get more than 70% torque.

So what happens if you're loading the motor to 0.500*T? Well the motor shaft will deflect to the nearest position where it can develop more than 0.500*T. So the increased resolution benefits of microstepping quickly diminish once you are applying load. At this load, your effective microstepping is only 2x

Microstepping can still help to reduce resonance, which is a place where torque is lost in full stepping motors.



 
Another fun one is understand the relationship between motor inductance, supply voltage, and the maximum usable motor speed.

The motor phase inductance is a fixed value based on how the motor is wound (yes, it varies with temperature, but let's keep this simple enough). As you shop around, you might see NEMA 23 motors ranging from 100oz-in to 450+oz-in. Most people buy the higher torque ones, because why not? What you're missing is that these motors have a much higher phase inductance which means they will lose that torque much more rapidly at higher speeds than a motor with lower inductance.

Inductance resists a change in current. If you want to change current through an inductor faster, you need a higher drive voltage. As the motor speed increases, the switching speed of the coils must necessarily increase to keep up with the desired rotor speed. This means that the current must rise in the windings fast enough to generate useful magnetization. But at some point the winding inductance blocks these rapid changes in current through the phases and the motor can produce no useful torque and the motor stalls. It actually gets a bit worse since the motor is producing back EMF from the generator action of its rotation and this opposes the drive voltage, reducing the current even more through the phases.

The only way to counter this is to increase the drive voltage. This allows the inductors to change currents more rapidly, and gives more headroom for the back EMF to eat away at. There is a limit on how high this voltage can go, usually limited by the motor drive power electronics, but this is why increasing the supply voltage lets you run the motors faster, but gives no increased low speed torque.

Winding current vs. Time at varying supply voltages
1652795157217.png
Example speed/torque plot at varying supply voltages.

1652795223124.png
 
Inline there's an error check in my callback. If abs(delta)>=1, I print it out. For testing, I print the count value. The Encoder Simulator test program emits N steps, so I check for N steps on my platform. Except for the case that I noted, there's been a one to one relationship. Later, I will have to additionally check the closed loop stepper controller, that it's ok. (No alarm).

I think you mentioned that the decoder is now software rather than hardware, so I wonder how it deals with errors internally. The end to end verification is good of course, so it sounds like things are doing well, but in operation this particular verification won't be available. Software decoders can recognize certain types of errors. Also, since this system will normally be moving in one direction any motion in the opposite direction might be an error. Noise in the encoder signal will potentially generate errors, and this will depend on the EMI from the lathe's motor controllers, etc, so it may change under spindle load and with different RPM in actual use.

Note that the closed loop steppers tend to have a rather large default error band that is painful to adjust (special tuning software, hard to get working, may be in foreign language and/or poorly documented terminology, etc), and if set too small may cause excess tripping (when they alarm they generally quit moving and require resetting). Also closed loop steppers may not have the same microstep torque response as a standard stepper.
 
Note that the closed loop steppers tend to have a rather large default error band that is painful to adjust (special tuning software, hard to get working, may be in foreign language and/or poorly documented terminology, etc), and if set too small may cause excess tripping (when they alarm they generally quit moving and require resetting). Also closed loop steppers may not have the same microstep torque response as a standard stepper.
Yes, the infamous tuning software. This is the mythical RJ45 connector on the side of some stepper motor controllers. Think playing with this will be a long term effort. I wouldn't want to rely on it at all to get started. More concerned about having enough torque to do the job, with my microstepping.

Got to go do more homework. Just don't want to spend $100's on motors, etc. and find out I can't thread on the lathe, after I made all the modifications. Then again, the Clough42 implementation with 8 microsteps, does seem to work, with whatever his motor choice was. As I recall it was a 3Nm motor. Think I will use a 4Nm motor and up the power supply voltage, to buy back some of the lost torque. Nonetheless, a bit more thought is required.
 
Back
Top