|
Re: PID algorithm using Arduino
For just P, it's not bad at all.
If you have the equations, then you know this:
Output = Kp * (Target Value - Process Value). What this does is findes the error (TV - PV), then applies a gain Kp to make the motor actually do something, or to calm it down some.
So with the Arduino, I'm assuming you're using a pre-made motor controller, such as a Victor or Jaguar, but since I don't see a team number, I might also assume you're using a different brand. Even so, the likelihood of it taking a PWM value is still high.
In the Arduino library, there's examples on how to run a servo. Most motor controllers that I have ever seen emulate a servo. There's actually an example on how to use a knob (read potentiometer) to control a servo. All you need to do is add in the feedback to the system using that equation above and you'll have yourself a simple P controller.
The I & D parts aren't hard to add either. The hardest part that you'll have is tuning it correctly. Seeing that you're driving a motor for steering, it will be extremely important to have a highly responsive system that does not overshoot or oscillate, as you can lose control.
Oh, by the way. Cool project! I always wanted to do something like that, but never had the time or money to do it in high school, and now I'm more broke than ever being in college. Maybe it can be a fun project for my wife and I do to once we're all finished and have our degrees in Electrical Engineering and Computer Engineering.
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian
Previous mentor and student from Team Fusion, FRC 364
|