![]() |
Finding RPMs with encoder
I am trying to set up an encoder to tell me the RPM of a shooter, the encoder is a US digital s4t - 120 - 250 encoder and 4x decoding. I see the multiple ways to get information from an encoder (getRate(), getPeriod(), get()) but what should I use to find RPMs with this encoder. Also, I don't know what to set as my setDistanceperpulse(), is it asking for how far the motor will move per pulse and if so by what unit of measurement is it asking?
|
Re: Finding RPMs with encoder
Quote:
120 is the Counts Per Revolution (CPR). That's the resolution of the encoder per 360 degrees of rotation. So it will provide 120 counts/pulses/ticks per 360 degrees... or one count per every 3 degrees. I'm not sure what language you're using, but I'm only familiar with the LabVIEW libraries. The getRate() function will provide you with a counts / second value while getPeriod() will return the inverse, seconds / count. I imagine get() returns the total counts since the encoder count value was reset. The setDistancePerPulse() function should take in either degrees or radians equal to 3 degrees. Finally, 250 is rather boring to this control mentor. It's just the shaft size, 250 mils or 1/4" shaft diameter. |
Re: Finding RPMs with encoder
Quote:
|
Re: Finding RPMs with encoder
Quote:
Thank you for replying. |
Re: Finding RPMs with encoder
CPR is cycles per revolution. One cycle has a rising edge and a falling edge on each channel. The number of "counts" per rev depends on the way you decode it. Counting rising and falling edges on both channels will give you 480 counts per rev Counting rising and falling edges on one channel only will give you 240 counts per rev Counting only rising - or falling - edges on one channel only will give you 120 counts per rev |
Re: Finding RPMs with encoder
Quote:
|
Re: Finding RPMs with encoder
Quote:
Quote:
|
Re: Finding RPMs with encoder
Quote:
Quote:
Quote:
Quote:
Quote:
Also, if possible, would you be able to provide a brief generalization of what each decoding type is used for? |
Re: Finding RPMs with encoder
Quote:
And did you consider using bang-bang instead of PID? This is the perfect application for it. And there's no tuning required. A 250 CPR encoder spinning at 3000 RPM is easily decoded by the roboRIO at 4X or 2X or 1X. It samples for edges much faster than the cRIO did, which removes many of the considerations which came into play in the cRIO days with high-RPM high-CPR encoder use. But, there are still some things you need to know to be successful. I will expound on that and answer the rest of your questions in a few minutes. EDIT: Oh, and what is the period of your control loop (e.g. 20ms, 10ms, etc). |
Re: Finding RPMs with encoder
Quote:
Quote:
|
Re: Finding RPMs with encoder
What is the period of your control loop (e.g. 20ms, 10ms, etc)? |
Re: Finding RPMs with encoder
Quote:
|
Re: Finding RPMs with encoder
Quote:
OK, doing the calculations for 1X decoding: rpm=3000; CPR=250; X=1; secondsPerControlLoop=0.020; 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. |
Re: Finding RPMs with encoder
alright, thanks for the help. I don't have means for testing anything right now but all of this was very helpful.
|
Re: Finding RPMs with encoder
Quote:
|
Re: Finding RPMs with encoder
Quote:
Could I talk you into posting a trace of your wheel speed vs time? Others can maybe learn from it. Thanks. |
Re: Finding RPMs with encoder
Quote:
I managed to get the encoder to show me values in RPM as well as allow inputs to be in RPMs, my big issue was not getting values I wanted as well as not knowing what stood for what in the code. so my result was this... Code:
RPM = 5000.0;Code:
RPM = 5000.0;That might have been lengthy and possibly unimportant for those who might look to this for learning about the RPM calculations but the 'setDistancePerPulse' was a big trouble of mine when trying to find what to put in there and is important to the code. 3 would not be the distance per pulse if this was not 1x decoding. Code:
pidShooter.setSetpoint(((RPM/60)*360)/3);now for what the encoder tells you. getRate() in also in counts per second so it's the exact opposite. the rate in counts per second multiplied by 3 to turn it into degrees, then divide by 360 to turn it into RPS(revolutions per second), and finally multiply by 60 to get RPMs. This might have been a bad explanation or included too much rambling and not enough detail, especially with be just putting in the exact code, if that is the case I'm sorry I'm not much of a teacher, so if you want me to include more specific details let me know and I will say what I did, how I did it, and what value everything (related to this thread) intakes and outtakes. |
| All times are GMT -5. The time now is 21:58. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi