![]() |
Continuous Feedback Sensor on CANTalon
Does anyone know if the CANTalon PID supports continuous feedback like the PIDController does?
|
Re: Continuous Feedback Sensor on CANTalon
Hey Tim
Actually the sensor feedback is continuous by default. AnalogEncoder is continuous (over and under wraps are tracked so 3.3V=>0V equates to sensor pos 1023=>1024). Same is true for PulseWidth sensors and the CTRE Magnetic Encoder. AnalogPot is not continuous (meant to be used with analog sources that cannot wrap). |
Re: Continuous Feedback Sensor on CANTalon
Quote:
|
Re: Continuous Feedback Sensor on CANTalon
1 Attachment(s)
Quote:
The basic idea is if you want to move forward, use the appropriate multiple of your target position in the positive direction. If you want to move reverse, use the appropriate multiple in the negative direction. If you want to servo using the shortest distance, calculate how far the target is moving forward, and moving backwards, pick the shortest one, and use that as the final set point. Attached is an excel sheet demonstrating a few examples of how to do this. |
Re: Continuous Feedback Sensor on CANTalon
Quote:
Let P be your present angle sensor reading (converted to degrees) Let T be your desired angle position (in degrees) the angle between them (let's call it ERR) is found by the equation: ERR = (T-P) - 360*floor(0.5+(T-P)/360); the above returns a value for ERR between -180 and +180 degrees, the shortest angle path to the target. So it tells you which direction to rotate as well as how much to rotate. So compute your setpoint: SetPoint = P + ERR |
Re: Continuous Feedback Sensor on CANTalon
Or in native units do this: Code:
Code:
P=200.000000 T=1000.000000 SetPoint=-24.000000(Because 0 is equivalent to 1024, just as 0 is equivalent to 360 degrees). |
Re: Continuous Feedback Sensor on CANTalon
If your compiler supports the REMAINDER function "x REM y" per IEC 60559 as specified on Page 235 Section 7.12.10.2 of ISO/IEC 9899:TC3 (which java does I believe), then the following single line of code should work: Code:
SetPoint = P + Math.IEEEremainder(T-P,360.0);Code:
SetPoint = P + Math.IEEEremainder(T-P,1024.0); |
| All times are GMT -5. The time now is 23:08. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi