Electrical – FPGA: need a stepper motor controller with smooth acceleration

fpgastepper motor

I want to connect a stepper motor to my Cyclone V FPGA via a STEP/DIR-interfaced driver.
But I don't want to simply give N pulses with F frequency. I want to set its max acceleration and deceleration. But it's a bit too sophisticated for me.

Cannot you advice me a suitable ready-made stepper controller module with smooth acceleration?

P.S. I also have an option to use AccelStepper library with Arduino Due, but it won't give me the full speed.

Best Answer

Write the whole thing yourself, gives more control.

Stop thinking frequency, and start thinking motor phase. What is the angle of the motor, and what do you want the angle to be shortly?

Change in angle is frequency.

Change in frequency is acceleration.

Have a register that represents the motor phase. The top few bits of this will map onto the stepper motor drive wires. The potentially many LSBs of this register allow you to implement low speeds, that is a tiny fraction of a turn per time step.

Have a register that represents the motor frequency. Every time step, limit it to max speed, and increment the phase register with this value.

Have a register that represents the motor acceleration. Every time step, limit it to max acceleration, and increment the frequency register with this value.

These three register values can be tested against your wanted target position/speed/acceleration, and modified every time step as required, by closing a control loop. Using all three gives you a leg-up for implementing a PID type response.

To smoothly accelerate to your maximum speed - set the desired position to be infinite.

To smoothly move from one position to another as fast as possible - set the new motor phase as the target. It will accelerate as fast as possible to max speed. In order to have it decelerating down into your target position without overshoot, you need to tune your PID loop appropriately.