View Single Post
  #10   Spotlight this post!  
Unread 15-01-2013, 08:57
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,532
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Keep the engine speed

Quote:
Originally Posted by DjScribbles View Post
Last year, we used a "Bang Bang" controller, which Mr. Ether helped us implement (though he got the idea from another member here, IIRC) for controlling our shooter wheel.

My C++ (similar enough to Java to help) source code from last year lives here:
https://github.com/TeamExcel/Project.../Robot2012.cpp
Lines 1063 and 1346 are most interesting for you.

The basic proposition is that a PID controller is overkill, or the wrong tool for the job; when you power the wheel, the RPM will increase, when you don't power the wheel, the RPM will decrease. Since you have direct control over what you want to change (speed of the wheel), you simply apply power when the wheel isn't going fast enough, and remove power once it is going fast enough; it won't continue going faster when you remove power, so you don't have to reduce power as you approach the setpoint (one of the features of a PID), and once you pass your setpoint removing power is the best way to reduce your speed (rather than applying power in the negative direction).

Our output to the motor uses a voltage ramp to prevent any big snap on/off actions (ie if the motor is off, quickly ramp up the voltage toward 100%, rather than jumping there instantly), other than that, it's "On" when too slow, and "Off" when too fast.

Make sure you are not in "brake" mode on your motor controller (a jumper on the Jaguar controls this).
A bang-bang controller tends to be limited in situations where your rotational inertia is not high. The result is an unstable speed that oscillates approximately just above your set point.

If you are using pneumatic wheels or something else with a reasonably high moment of inertia (I haven't done calculations to determine the cross over) then bang-bang is fine. Otherwise, you will probably want to look at PID. Or you can combine the two using a conditional to switch from bang-bang to PID when you are within a certain range of your setpoint.