View Single Post
  #1   Spotlight this post!  
Unread 04-02-2016, 16:23
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,101
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Finding RPMs with encoder

Quote:
Originally Posted by Sparx030 View Post
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.



Last edited by Ether : 04-02-2016 at 21:45. Reason: typo
Reply With Quote