Bench top setup for demonstrating PID

We’re building a bench top demo setup for experimenting with PID control. We’d use the Smart Dashboard to show internal state like the gain values, setpoint, and the PWM input value to the motor controller.

I’m looking for mechanical ideas on how to load a small motor with different levels of resistance in a safe way.

Does anyone have an example that they’re willing to share?

what is the output you will be measuring? and how will you measure it? speed or position?

Inverted pendulums are pretty cool.

*If you are trying to control position, you could drive a speed-reduction gearbox connected to an arm with weights on the end. Physically limit the arm travel so no-one gets hurt.

If you are trying to control speed, you could:

a) drive a speed-increasing gearbox connected to a fan (make sure the fan has a shield to protect errant fingers and contain blade failures)


b) drive a speed-reduction gearbox connected to the shaft of a second motor, and short the second motor’s leads.

Wear safety glasses.

Speed control is the goal. The fan idea is a good one. Right now we’re using a CIM motor with a gear reduction and wheel attached, but I’m looking to go to a smaller BaneBots motor once I work out how to connect the US Digital encoder up to it.

I’m outputting the encoder values and current Jaguar value to the Smart Dashboard to monitor things.

We’re starting with velocity control, using the Robodox guide as the template:

Our current setup is a CIM motor / CIMPle Box combo with the US Digital E4P encoder that came in the 2011 KOP. I’d like to replace the motor with something lower in power to make it a bit safer. Thoughts?

You might try having one DC motor drive another one. Permanent magnet DC motors act as generators when driven like this, though you may need to add some gearing depending on what target RPM you want to control. If you vary the electrical load on the generator it will translate into a varying mechanical load on the motor. Add a few switches and some lamps and you should have a simple variable load simulator. Depending on your application you may want to add some type of flywheel to add rotational inertia as well.

I would love to see a picture when you get it all done

A ‘pure’ PID controller can act as a velocity controller if both of the inputs (setpoint and process variable) are velocity. In this case, D will be unused, I will act as P, and P will act as D. The issues come when the PID class has additional logic to handle the I term, such as resetting the integral when the error zero-crosses, capping the integral, etc. - I’ve heard the Jaguars reset I under some conditions, although I’ve never verified this.

Every time I have worked with a speed controller, attempting to adapt a position controller has always failed to meet the design requirements, and I design a better controller to handle it (usually incorporating some application-specific limiting of the integral term). Adding a Feed Forward term also helped with response time and oscillation.

Basically, what I’m saying is, don’t be afraid to write your own PID math and not use the per-existing class.

Here are some other options:

The Robodox paper proposes implementing a PIDSource subclass (RPMSource) that wraps an RPM value, which is the wired to the WPILib PIDController. On each turn of the Execute() crank in our command, we take the elapsed time and change in encoder count to calculate an RPM value, which is fed into the RPMSource instance.

apalard – it does look like we’re not too far from doing all of the calculations ourselves, so we will probably give that a try if the build-in controller fails us. One item that hasn’t been obvious is how far back in time to accumulate errors.

We’re just finished building ours. We used a Victor + Globe motor with a VEX encoder ( as feedback.

Still haven’t figured out a great way to provide consistent, measurable resistance yet. But the globe is so slow we can at least test the PID loop by using our fingers to resist the position.