1
$\begingroup$

Can a PID with variable setpoint work?

I have already done tests, but these are not conclusive. On the other hand I am not certain of this algorithm.

Background

This project involves improving the tracking speed of a telescope.

An Arduino card (UNO32) that I program gives the instructions in "Pulse and Dir" mode to a driver. This driver controls a two-phase step motor (200 steps) in micro step mode (128 micro steps per step). This stepper motor rotates a worm screw against a wheel that has 360 teeth. And finally, this wheel rotates the axis of the telescope to make one revolution per day.

To reduce the speed error caused by imprecision of the wheel and screw, a high precision encoder (1800 000 PPR) is placed at the end of the axis of rotation of the telescope. My goal is to work in closed loop with the stepper motor and the encoder feedback.

I need your advice for the PID algorithm. Here is my idea but I am not sure that this is valid:

1) SP (Setpoint) : the desired position of the encoder. The encoder is in 4x reading mode.

At time t, this gives : SP(t)= ( t sec) * (4* 1800000 PPR)/(86164 sec/day)

I can convert into micro-step :

(360 turns_motor)(200 steps)(128 micro-steps) = 4*1800 000 encoder pulses

2) PV : the process variable. This is the measured position of the encoder.

3) E : the error , E= SP-PV

4) Command : I act on the frequency of the pulses to vary the speed of the motor according to this error

$\endgroup$
1
  • $\begingroup$ Welcome to Robotics Marc Storme. Thanks for your first question, you did a good job of explaining what you wanted and what you tried, but could you edit your question to add details of the results of your tests, i.e. what you saw & what you expected to see. You might also find the Robotics question checklist to b a useful reference for writing good questions. $\endgroup$
    – Mark Booth
    Jan 24, 2017 at 14:06

1 Answer 1

2
$\begingroup$

As a general answer:

Yes, PID controller use variable setpoints, in fact, this is what makes them usefull, that you can always change the setpoint of your system (regardless of this varis slowly or fast, stepwise or not).

The general algorithm you have specified is also correct, however you have to make sure that the variable typse you use can handle that large numbers.

SP(t)= ( t sec) * (4* 1800000 PPR)/(86164 sec/day) seems like a really large number if all terms are implemented as variables and are not simplified apriori (at implementation or maybe by the compiler?).

I would recommend giving the setpoint as a float in degrees and converting the encoder readings to degrees when calculating PV. This is just for conveniece.

Acting on the frequency of the pulses is also good idea in general.

In your specific case: Please keep in mind that in theory you have approx 5 motor microsteps per encoder tick. (200*128*360 = 9 216 000 microsteps and 1 800 000 tocks). This means that you have to have a PID controller that can do very fine adjustments. This should be something doable if overshot of the controller is not a problem. Problems arrise on the practical side.

Microsteps are not very exact. It depends very much on the quality of the motor, usually a half step is correct, hover anything below half of step is not necesarily evenly distribuited between the steps. Ideally you would get 360/(128*200) degrees of rotation for each microstep, however in reality, you might be very far from this. You might have far smaller microsteps and far larger microsteps (but their summ would give you a full step). If the far larger means 5x larger than you cannot position to the given end sensor tick. For motors which are not of high quality, 5x or larger microsteps in my opinion can happen. but I am not a stepper motor expert, you should test the length of your microsteps to make sure.

If you want to hit exactly all ticks with precision it might be a problem. If you want to be only in a certain range, you could add a deadband to your PID and so you can avoid any ocilations caused by not being able to exactly hit one encoder tick.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.