PID controlled ball balancing beam

First of all, thank you for spending some time helping me out.

I would like to make something akin to this.

I know I want to use Arduino to do this. I have some experience coding and plenty of teachers to go running to for help but I’d like to make sure I’m buying the right equipment.
All I believe I need (please correct me if I’m mistaken) is:

  • Arduino
  • Servo motor
  • Some sort of motion sensor

If that is all that I would need, where can I buy it? Many thanks!

Arduino

Good idea.

Servo motor

To move what?

Some sort of motion sensor

To detect the motion of what?

If that is all that I would need, where can I buy it?

Lots of places sell Arduinos and servos and sensors. Whether they will ship to your country, or not, and whether you want to wait, or not, will have a HUGE impact on that answer.

PaulS:
Good idea.
To move what?
To detect the motion of what?
Lots of places sell Arduinos and servos and sensors. Whether they will ship to your country, or not, and whether you want to wait, or not, will have a HUGE impact on that answer.

I was thinking of putting the motor in the middle of a wooden beam. This would mean I just need one motor and I can tilt the beam to a specified angle with relative ease. I need something that is very precise. By adjusting the tilt angle I can vary the force acting on a single ball that is somewhere on the beam.

I was hoping to use the detector to be able to tell where the ball is every time I go through the PID loop.

I need something that is very precise.

That leaves out your typical low cost hobby servo. While they are relatively fast, they are not very accurate.

I was hoping to use the detector to be able to tell where the ball is every time I go through the PID loop.

How? A ping sensor could measure the distance from one end, but not very accurately OR very fast.

A typical motion sensor would be attached to the ball, so sense when it moved. That seems unlikely to be practical.

PaulS:
That leaves out your typical low cost hobby servo. While they are relatively fast, they are not very accurate.
How? A ping sensor could measure the distance from one end, but not very accurately OR very fast.

A typical motion sensor would be attached to the ball, so sense when it moved. That seems unlikely to be practical.

What would you recommend?

I didn't see sensors attached to the ball. I'm not sure whether they could provide useful position information, when the ball is rolling (turning). The ball position seems to be the key point of that device, from which the movement speed and acceleration can be determined. I guess that it's controlled by a state regulator, not by a simple PID regulator.

The device at the left (open) end of the beam may be an US distance sensor, but the author prefers to keep such details secret. Other projects mention an IR sensor.

DrDiettrich:
I didn't see sensors attached to the ball. I'm not sure whether they could provide useful position information, when the ball is rolling (turning). The ball position seems to be the key point of that device, from which the movement speed and acceleration can be determined. I guess that it's controlled by a state regulator, not by a simple PID regulator.

The device at the left (open) end of the beam may be an US distance sensor, but the author prefers to keep such details secret. Other projects mention an IR sensor.

Thank you, the main purpose of this is to help impress admissions tutors for engineering courses in the UK.
I just want to know that the stuff I'm buying will allow me to build something which allows me to play with a PID controller I have coded myself.

Find out whether your motion or position sensor satisfies your needs. Even the most sensitive sensor cannot help to extend the limitations of the regulator.

I have done the exact same thing before. Just the regulator design though, not the hardware.

The regulator design is quite forgiving. I think the root locus without a compensator actually barely hit LHP in my case, so I was able to design a P-regulator; it was just a bit lazy.

You will probably need a P or PD regulator. The I made some mess when I tried to implement it. Also encountred problems with the deadzones.

If you are designing the regulator in a proper way, you will want to include dynamics of the motor into the differential equations describing the system. You can assume that di/dt=0, since current changes so quickly, it... stays the same? Ummm I don't remember the reason why I did that, but it was a good idea. :smiley:

The easiest and most reliable way (and the way the machine I worked on used) is to implement the position sensing with a pair of resistive wires. the metal ball rides on those wires and shorts them out; you measure the resistance and calculate position from it. Extremely fast and pretty reliable.

thegoodhen:
I have done the exact same thing before. Just the regulator design though, not the hardware.

The regulator design is quite forgiving. I think the root locus without a compensator actually barely hit LHP in my case, so I was able to design a P-regulator; it was just a bit lazy.

You will probably need a P or PD regulator. The I made some mess when I tried to implement it. Also encountred problems with the deadzones.

If you are designing the regulator in a proper way, you will want to include dynamics of the motor into the differential equations describing the system. You can assume that di/dt=0, since current changes so quickly, it... stays the same? Ummm I don't remember the reason why I did that, but it was a good idea. :smiley:

The easiest and most reliable way (and the way the machine I worked on used) is to implement the position sensing with a pair of resistive wires. the metal ball rides on those wires and shorts them out; you measure the resistance and calculate position from it. Extremely fast and pretty reliable.

I had the same idea with the wires but worried that as they heated resistance would increase and my calculations would be unreliable. Are you saying you didn't experience this issue?

Don't use too much power for the wires and only power them when
you are actually measuring.
You don't need to make them glow.
You do need a little settle time for the sample hold of the arduino.
Dwight

notyourcup0tea:
I had the same idea with the wires but worried that as they heated resistance would increase and my calculations would be unreliable. Are you saying you didn't experience this issue?

O-o

As dwight thinker said, you don't need to make them glow. :smiley: The temperature coefficient will be a few hundreds or thousands ppm; (around 0.0004 for nichrome alloy); the position error introduced over the working range of say +-10 degrees K will be couple of millimeters at most (more like sub 1mm tho); in fact, it will be so low that you will lose more accuracy in the AD converter...
Plus the error is going to drift really slowly. Unless you apply a blowtorch to the thing, this has no chance to affect your control loop. Plus even if, over time, your total resistance doubled or tripled, it would just affect the target position setting, but a good PID regulator with a proper D settings would handle it just fine.