Step control of stepper motors

Status
Not open for further replies.

MadJak

New member
I have a project were I'm feeding a stream of rotation data to the Teensie via a serial connection from a PC. That data is arriving at random speed but is generally delivered around 80 - 100 Hz. I then need to take that data and feed it live to several large stepper motors.

So far to do this I'm setting a target rotation for each motor directly from the incoming stream of serial data as well as keeping track of the current rotation for each motor, and when the rotation value is offset by more than a step, I fire off a single step in the required direction and increment the current rotation value. This works really well however the Teensie is so fast it will complete several loops on this logic too quickly then do nothing until the next packet arrives. I think this causes a lot of vibrations in the motor.

Are there libraries out there that would help smooth out the steps or is this stuff I need to program myself. I figure I could predict the average packet arrival time by averaging it over time, then spread the steps out over the predicted time interval to the next value. So say I get a difference of rotation of 2 degrees. I know the next packet will arrive in approx 10ms so I time my 20 steps 0.1ms apart instead of all at once. If a new rotation value arrives early and I haven't completed all the steps then it will retarget the next rotation and time it out based from the current achieved position. Alternatively I could go into calculating acceleration / velocities and smooth the steps based on trajectories etc.

I've done very little coding so I'm not really sure on the best way to do this stuff. Also controlling stepper motors smoothly is going to be important for my project.

Any advice?
 
You should be using a library that handles speed-ramping (acceleration) for steppers - this is essential to smooth operation
of a stepper. The classic library is AccelStepper but there's the TeensyStep library specifically optimized to the Teensy's.

Another approach would be to low-pass filter the incoming position values with a digital filter at a rate fast enough for the
highest step-rate needed.
 
You should be using a library that handles speed-ramping (acceleration) for steppers - this is essential to smooth operation
of a stepper. The classic library is AccelStepper but there's the TeensyStep library specifically optimized to the Teensy's.

Another approach would be to low-pass filter the incoming position values with a digital filter at a rate fast enough for the
highest step-rate needed.

One of the key considerations is that I need as little lag between the incoming data stream and actual achieved position so filtering it difficult. With TeensyStep I could probably calculate the required steps and the speed based on an estimated time till next data packet arrives and let it do all the work. I'll have a look. thanks
 
Status
Not open for further replies.
Back
Top