![]() |
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 triggerTypeAlso how could I make it so it had a very small sampling time like .1 of a second? |
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).
|
Quote:
The AS5030 is not a quaderature encoder. It won't work with the encoder class. |
Re: RPM calculator
Quote:
|
Re: RPM calculator
Quote:
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. |
Re: RPM calculator
Thanks for your replies, but I was just wondering if anyone had any ideas for the RPM issue?
thanks Dimitir |
Re: RPM calculator
Quote:
Or you could use a sensor more suited to your purpose. |
Re: RPM calculator
The encoder class works with both i belive..
if so Code:
Encoder myencoder = new Encoder(#); |
Re: RPM calculator
Quote:
|
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? |
Re: RPM calculator
Quote:
https://decibel.ni.com/content/thread/11955 |
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 |
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 |
Re: RPM calculator
Quote:
this is straight out of the encoder class Code:
* Get the current rate of the encoder. |
Re: RPM calculator
Quote:
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. |
Re: RPM calculator
To calculate the delta time in Java do you use System.currentTimeMillis() before or after getting latest count or is there a better timestamp that is associated with the time the encoder count value was actually taken?
|
Re: RPM calculator
Quote:
I suppose you could put the code to grab the encoder count and the system timer in a critical section to prevent getting swapped out between the two operations. |
Re: RPM calculator
I meant to ask if System.currentTimeMillis() is the best time source -or- is there some other timeStamp to use?
|
Re: RPM calculator
Quote:
Code:
/** |
Re: RPM calculator
Excellent! In the WPILib I just found:
Timer.java /** * Return the system clock time in seconds. Return the time from the * FPGA hardware clock in seconds since the FPGA started. * * @return Robot running time in seconds. */ public static double getFPGATimestamp() { return Utility.getFPGATime() / 1000000.0; } Utility.java /** * Read the microsecond timer from the FPGA. * * @return The current time in microseconds according to the FPGA. */ public static long getFPGATime() { return tGlobal.readLocalTime(); } Thanks! |
Re: RPM calculator
I generally use System.nanoTime() for anything in Java. It's overkill, but I've never found a reason NOT to use it.
You could measure the dT that it takes to get the latest count and see how negligible it is. (or isn't) |
| All times are GMT -5. The time now is 21:01. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi