View Single Post
  #5   Spotlight this post!  
Unread 25-03-2009, 23:11
gwytheyrn gwytheyrn is offline
Registered User
AKA: David
FRC #0461 (West Side Boiler Invasion)
Team Role: Programmer
 
Join Date: Dec 2007
Rookie Year: 2004
Location: Indiana
Posts: 44
gwytheyrn is infamous around these parts
Send a message via AIM to gwytheyrn
Re: PID on a one directional Shooter

Okay, so here's what I did.
1. I made my own encoder rate counter using a timed 30ms loop and a feedback node to find the rate/30ms. This was done because the rate function in the get encoder vi put out too large a number and was pretty unstable (could range 40%).
2. Scale above rate to 0->1. 1 is max speed.
3. Using a customized PID controller (Using only the I term...maybe a little P), I can now control the wheel rate. Unfortunately, I had to set the I term a little high to prevent stalling, so there is a suboptimal amount of oscillation and overshoot, but it doesn't take that long to settle, so it's okay. I have the I term reset whenever the target speed is 0. My loop runs every 30ms, but I can't remember my gains right now. (make sure you limit your I term and stuff...Another note, the PID controller in LV has a really strange way of doing I and D...doesn't use kI and kD, it uses like ti td...)

Using this method, you don't have to know a "nominal" PWM value because it finds it for you. I suggest not going with a pure P, since it'll slow down the closer it gets to the setpoint until settles between the initial and set points. I may/may not be able to get around to posting an example, so if you want it, just ask. (We use LV, so if you're looking for C++, I can't provide an example, but the theory remains the same).

Last edited by gwytheyrn : 26-03-2009 at 00:09. Reason: add extra note