Quote:
Originally Posted by Sparx030
20ms
|
OK, doing the calculations for 1X decoding:
rpm=3000; CPR=250; X=1; secondsPerControlLoop=0.020;
edgesPerControlLoop: rpm * (1/60) * (X*CPR) * secondsPerControlLoop = 250
So 250 edges fly by every 20ms, which should be plenty enough to get a nice accurate and clean speed signal at 1X decoding. I recommend setting the FPGA sample size to something greater than the default value of "1"... say maybe 64.
If you like your code to be super efficient you can compute the edge period time once outside your control loop:
secondsPerEdge: float((1/rpm) * 60 * 1/(X*CPR)) = 80e-6
... and use that as the setpoint in your PID to compare to the getPeriod() process variable which returns the edge period in seconds.
When using PID to control shooter wheel speed there are some additional considerations to be aware of in order to be successful. Things like do you want to apply dynamic braking or reverse motor commands when wheel speed exceeds setpoint. I will leave it to shooter-wheel-PID gurus to fill in the details and recommendations.
You may be able to get better speed regulation at 10ms.