
11-02-2013, 20:54
|
 |
The Only Programmer
 FRC #3337 (Panthrobotics)
Team Role: Programmer
|
|
Join Date: Jan 2013
Rookie Year: 2012
Location: Baton Rouge
Posts: 37
|
|
|
Re: Photosensor as encoder for bang bang.
Quote:
Originally Posted by billbo911
When I first saw the code I was surprised at how familiar it looked, then I realized, I posted it last year.
Mark, would replacing the "Reset Counter" with a feedback loop and subtracting the previous count from the current count be a more stable option?
Both the IIR filter and the slew rate limiter were placed in this code as ways to compensate for other issues.
The slew rate limiter really is only needed when using a Jaguar. The current limiting circuit in the Jag can trip if the start up current is too high. If using a Talon or Victor, this entire block of code can be bypassed or completely removed.
Honestly, the IIR filter shouldn't be used. It introduces lag into the control. I put it in there as a way to smooth out the RPM signal. I believe the main reason the signal was noisy was due to the use of a "wait" loop instead of a timed loop in the original version. In addition, we were using "Get Rate" in the original version. "Get Rate" is an instantaneous measurement that is inherently noisy. This version uses a count divided by time to determine RPM, which is a much cleaner approach. This filter can be bypassed by setting the filter strength to "0", or just deleting that section of code.
The "360" is the number of ticks per revolution of the encoder it was designed to be used with. If the encoder is just a couple of lines on a wheel and an optical sensor, the this value needs to reflect the number of lines.
Bang-Bang is a simple control system. A comparison of the current RPM to the desired RPM. If the current is at or above the desired value, then turn off the motor. If it is below, turn the motor on at full power. Anything else in the loop just clutters the process.
|
Question can you tell me or show me a code which uses a photosensor with a bang bang when it only has one tick per revolution
__________________
Think Outside The Frame
|