Sunday, December 6, 2009

Mark I Control

Time to look at the control. An ideal PID control is defined as



where u is the control signal, e is the control error (reference minus actual), and kp ki and kd are the proportional, integral, and derivative gains. For this project, the control signal will be the velocity requested from the motors, and the error will be the angle of tilt from the accelerometer.

The terms in the equation above can be thought of as accounting for the present, past, and future error of the system to be controlled. A simple proportional gain can be applied to the current error to get close to a reasonable control signal at the current time. An integral component can be added to help account for any deviation of the process value from the reference value over time. I plan to attempt adding both of the components to my controller. The derivative term, which predicts the future error, will probably generate too much noise and will be difficult to tweak. I do not intend to implement this, but will consider it if time allows.

Starting small, the first control I'm trying to work with is a simple P control. Assuming that the error from the accelerometer's orientation on the platform is negligible (r == 0), this is as reasonably respectable way to control this system.



To implement this, I created a program using the LEGO Mindstorms NXT 2.0 software with the accelerometer sensor block add-on. Coming from a strong software background, this seemed unnecessarily convoluted. Where are my variables? Where's my mathematics? All I wanted to do was type out some variables and leave it at that! But like anything else, doing an activity for the first time will always be the hardest time through. I stumbled through creating the following program.



The above program applies some gain to the tilt angle coming from the x-axis of the accelerometer and inputs it to the velocity of the motors. The direction of the motors is set with a separate connection and is based off the sign of the x-axis angle.

Using experimentation, I was unable to find an acceptable value for the proportional gain kp using the program to keep the platform upright. There are many reasons why this might not work, but the biggest contributor at the moment is most likely my inexperience with the LEGO software.

I need to spend more time experimenting with the LEGO software before I can call this one way or another.

No comments: