|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
RPM calculator
I have the AS5030 rotary encoders and I was trying to find a way to calculate the RPM of our shooter motors with it. Does any one have any idea how to do so? I tried the counter class but I am having trouble selecting the
Code:
AnalogTriggerOutput.Type triggerType Also how could I make it so it had a very small sampling time like .1 of a second? |
|
#2
|
||||
|
||||
|
Re: RPM calculator
Try just using the Encoder class. That should have everything you need. Just make sure you use setDistancePerPulse() with the right units and you can get the speed (this class gives speeds in units per second, not minute, but you can always scale it).
|
|
#3
|
||||||
|
||||||
|
Quote:
The AS5030 is not a quaderature encoder. It won't work with the encoder class. |
|
#4
|
||||
|
||||
|
Re: RPM calculator
And what would you suggest then? That was not helpful.
|
|
#5
|
||||
|
||||
|
Re: RPM calculator
Well, it helped him avoid wasting time going down a rabbit hole.
A bit of advice, if you are open to it: as a newcomer you might want to be a bit more respectful, especially with people like Joe who have helped countless people over the past 10 years. |
|
#6
|
|||
|
|||
|
Re: RPM calculator
Thanks for your replies, but I was just wondering if anyone had any ideas for the RPM issue?
thanks Dimitir |
|
#7
|
||||
|
||||
|
Re: RPM calculator
Quote:
Or you could use a sensor more suited to your purpose. |
|
#8
|
|||
|
|||
|
Re: RPM calculator
The encoder class works with both i belive..
if so Code:
Encoder myencoder = new Encoder(#); myencoder.getRate(); |
|
#9
|
||||
|
||||
|
Re: RPM calculator
No, I think Joe is right. The Encoder class is for quadrature encoders which use two signals, and this encoder the OP is trying to use only has one signal and if I'm not mistaken produces a different type of signal (the way it counts rotation is different). It's unfortunate that there's no built-in FRC class for those encoders though.
|
|
#10
|
||||
|
||||
|
Re: RPM calculator
According to the operation manual for the AS5030 adapter board, if you open the P1 solder bridge you can access cos&sin quadrature signals at JP3 pins 1&3. Not sure if the WPILib Encoder class will work with those waveforms without some signal conditioning. Has anyone tried and succeeded? Last edited by Ether : 28-02-2012 at 17:05. Reason: corrected pinout |
|
#11
|
||||
|
||||
|
Re: RPM calculator
Quote:
https://decibel.ni.com/content/thread/11955 |
|
#12
|
|||
|
|||
|
Re: RPM calculator
Does it output analog or digital? if its digital try using the Counter class, if its analog then use something like
Code:
int count
if(encoder.getVoltage() >"voltage when ticked") {
count = count + 1; // or count ++;
|
|
#13
|
||||
|
||||
|
Re: RPM calculator
Get rate is not ideal.
We store a last time variable. Take counter.getdistance / (current time - last time) Then reset the counter. You will get a much stabler speed this way |
|
#14
|
|||
|
|||
|
Re: RPM calculator
Quote:
this is straight out of the encoder class Code:
* Get the current rate of the encoder.
* Units are distance per second as scaled by the value from setDistancePerPulse().
|
|
#15
|
||||
|
||||
|
Re: RPM calculator
GetRate() computes the rate based on the elapsed time of a single encoder pulse (the most recent one).
This is manifestly not the same as the computing the rate using delta counts since the last sample and dividing by the elapsed time since the last sample, for sample periods on the order of 20ms and encoder pulse periods associated with shooter wheel speeds. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|