Velocity control with the Synaptron Micro

I spent a couple of days adding velocity control to our Synaptron Micro motion controller.  I should probably be more clear.  The product already has the ability to use the velocity measurement from a quadrature encoder as a feedback source.  Meaning you can operate a motor at a PID controlled velocity.  What you couldn’t do was operate as a position controller with a velocity limit applied to the movement.  Okay you could already do that too, but the methods were a little “complicated”.  The desire for a less complicated velocity control method  came about when working on the articulated robot wheel.   Laziness, the mother of invention.

For those not familiar with the Synaptron Micro the product is configured by modifying internal register settings.  For some applications, such as analog control of position, you only need to configure the device once.  For other modes such as serial control of position it is assumed you have a controller that is continuously in contact with the Synaptron Micro motion controller.

The video above shows the results of the velocity control that was added, while the remainder of this blog entry covers other methods of controlling motor speed during movement.  Here are the four ways you can now control a motor’s velocity while moving to a position…

A)  Velocity for feedback – Using the velocity measurement as the feedback source you can program the PID algorithm, and send motor speed commands.  While the motor is moving a master controller can read the position and and make adjustments to the motor speed.  You can even change the feedback source when the motor is near its desired end position, and convert the controller to a straight position controller.  The downside?  Your controller has to be monitoring the Synaptron Micro during its movement, and communication timing could create problems.  Using pseudo code it might look something like this…

Write PID settings
Write desired motor velocity to ControlInput registers
Loop:
Read Position
    If Position =  desired endpoint
exit Loop
else
goto Loop
Write 0 to ControlInput stopping motor

B)  Limit the motor drive signal – Using the encoder’s position measurement as feedback you can command the motor to be moved from point A to point B.  By adjusting the maximum PWM motor drive signal (NegativePWMLimit and PositivePWMLimit registers) you can reduce the motor speed.  For example if you set the PWM limits to 50% then the motor will move at roughly half speed.  The downside?  If the PID position algorithm needs 100% duty cycle to force the motor into position you will have limited it to some lower value.  You could also monitor the motor position and adjust the PWM limits up or down, but again your controller needs to be monitoring things during a movement.  Using pseudo code it might look something like this…

Write PID settings
Write PWM Limits
Write desired motor position to ControlInput registers
Loop:
Read Position
  If Position = to endpoint
exit Loop
else
goto Loop
Write new PWM limits if needed

C) Send your position controls in a loop – If you can control the time between serial commands you can create a velocity controlled movement by sending your position commands from a loop.   However, the resolution available would be limited by the update rate of your serial commands.  For long movements and medium velocities this method works pretty well.  The downside?  There is some built-in latency in the Synaptron Micro’s communication routines, so tight control of your loop is not possible.  In desktop computers interrupts and other background processing can create delays that are quite long in the world of microcontrollers and could make velocity control very loose.  Using pseudo code it might look something like this…

Write PID settings
Establish Start Position (current position)
Establish End Position (desired end point)
Establish Position Change
Loop:
Delay some period of time
Start Position = Start Position + Position Change
Write Start Position to ControlInput registers
If Start Position = End Position
exit Loop
else
goto Loop
Read Position

D)  **New Method** Velocity limits – The mechanism I used to add velocity was basically to incorporate method C into the controller.  Since the timing loop is pretty accurate we can improve the low resolution control.  Now we allow the user to enable velocity limits by setting an associated bit in the Function register (Function.F_VelocityLimit to be exact), and writing a value to the VelocityLimit register (index 53).  Whenever the ControlInput register value is changed (this happens when a new position is written to it)  the Synaptron Micro logs the current position as the start position and the new ControlInput value as the end position. With every PID loop the start position is increased by the VelocityLimit until the result is within the end position +/- VelocityLimit.   Using pseudo code it might look something like this…

Write PID settings
Write VelocityLimit register
Set Function.F_VelocityLimit bit
Write ControlInput registers

Speak Your Mind

*