Previous Question

Hello, In continuation of my question above, I have another question. I have managed to control the speed of the treadmill using a PID and StevO mentioned to me how the scaling from process variable(speed) to control signal (pwm) is done.

Now, I want to control the position of the robot at a fixed position on the treadmill. I want to use the first approach shown in picture below. Note that the labeling is for a quadcopter. I want to use the same approach but the labeling is different in my case. For me the input to Stabilize PID is desired robot positon on treadmill and actual robot position on treadmill.

The Rate PID is up and working. I want to use the Stabilize PID to make the robot hold a fixed position on the treadmill. I can measure the position of the robot using a distance sensor and find the error = desired distance - actual distance.

My problem is that the error is in terms of distance(meters) but the control signal needs to be speed that would be fed to the speed control. The speed controller would do its job.

To sum up, my question is that for the Stabilitze PID block, by using a process variable which is position (meters), how can I get a control signal that would be speed?, what kind of scaling should be done here?

Thank you.


1 Answer 1


Consider using calculus or rather derivatives.

You have stumbled upon the relationship between velocity and position. This can be extended to include acceleration. Simply put, velocity is the derivative of position. And taking the derivative of position gives acceleration. Instead of writing an equation and actually taking the derivative, computers simply takes samples and divide the samples by time. A good example might be an electronic bicycle speedometer.

For your project, you can get velocity by dividing the change in the distance sensors position value by an arbitrary but consistent time interval. Then correcting the robot's velocity relative to the treadmill.

  • $\begingroup$ Ok, so I take the sensor values from the distance sensor and divide by a fixed time, say the sampling time. This would give me the velocity of the robot on the treadmill or how fast is the robot moving away from the distance sensor. This velocity would be fed to the speed controller as a set point for the treadmill and the treadmill moves with the same velocity as the robot. Am I correct in understanding your suggestion ? I can only correct the velocity of the treadmill and not the robot. Robot should move with a fixed velocity. $\endgroup$ Commented Sep 27, 2017 at 6:30
  • 1
    $\begingroup$ Oh, I had it backwards. Ok, yes - but don't literally divide the position by time. Take a position measurement, then, at a fixed time later, take another and find the difference. The change in the position is your velocity with respect to the treadmill. Then add (or subtract) this (depending on how you are doing your math) to the value you use to control the speed of your treadmill. Be wary of under (adjustments are too fast or large causing osculations) or over (adjustments are too delayed or small causing the robot to fall off) dampened scenarios. $\endgroup$
    – st2000
    Commented Sep 27, 2017 at 14:18

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.