Electrical – Bi-directional PID control

pid controller

I am currently a Mechanical engineering student and I am trying to create a device that will balance two weights by moving the fulcrum between them. The whole thing looks like a see-saw with a motor and gyroscope attached, mostly because that's exactly what it is.
Diagram

The problem I am having is getting the motor to move the board to place its center of mass above the motor in order to balance the load. The motor has a large gear on it that meshes with a linear gear across the bottom of the board. I am using an arduino mega to control a Spark motor controller using PWM. My first idea was to simply measure the angle from the gyro(between -4 and 4 degrees) and activate the motor whenever it did not read 0 degrees(level). This threw the board off of the motor. Later I decided that a PID loop would be a better solution. I wanted to have something like this video shows. https://www.youtube.com/watch?v=fusr9eTceEo
The problem is that as far as I know, PID only works in one direction. A gas pedal in a car is a good example because the PID loop can only give more or less gas and cannot hit the brake pedal. In my case I need two PID loops in order to control the position both left and right. Currently I am running the two loops side by side using the Arduino library with the angle as the input and the motor power as the output. I take the difference between the outputs and the resulting positive or negative value goes to the motor. I really don't think this is the right way to do this as I still cannot even balance the board itself. What do I need to do in order get the right motion?

Best Answer

Chris is correct and PID commonly operate to give positive and negative outputs - even your car cruise control example is out of data, modern radar controlled cruise controls can indeed operate the brakes as well as the throttle. A more general example is called a servo. Small scale ones are used for models.

Here is another example of an Arduino using a PID loop to balance a beam in a different way:

Beam balancing example