Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Tachometer Interrupt Help (http://www.chiefdelphi.com/forums/showthread.php?t=103848)

itsZN 26-02-2012 12:18

Tachometer Interrupt Help
 
Our team currently has a tachometer attached to one of our wheels. We were using it to find the Rpm of the wheel, but the method we were using was very inaccurate, sometimes by up to 260 rpm difference. We decided that the best way to fix this was to cause an interrupt in the code every time the counter for the tachometer pulsed. That way we could measure more accurately. How exactly would we have to set that up so it runs a segment of code whenever the tach pulses?
Thanks for any help!

-Team 1277

Joe Ross 26-02-2012 13:41

Re: Tachometer Interrupt Help
 
There are interrupts, but my guess is that isn't the best way to solve your problem. It would be better to take advantage of some of the features in the FPGA.

Can you describe your tachometer, what it outputs, and what your code is right now?

itsZN 26-02-2012 15:26

Re: Tachometer Interrupt Help
 
Currently, we have a counter hooked up to record the number of pulses from the tachometer, which is triggered by a bolt on the axial of the wheel. Currently, the code takes the finds the average rpm of a half second, based on the number of new ticks on the counter. This doesn't work, because if we get only one tick, it reads 120 rpm, which is a big range for error.

After looking through the wpilibj api again, I found that there was counter.getPeriod(); Which would fix the whole problem most likely. If it does we won't need to use the interrupt.

Thanks Anyway :D

ProgrammerMatt 28-02-2012 11:46

Re: Tachometer Interrupt Help
 
It may be better to use a quaduture encoder thats what we use and use the .getRate(); command

twiggzee 02-03-2012 19:47

Re: Tachometer Interrupt Help
 
Quote:

Originally Posted by itsZN (Post 1135183)
Currently, we have a counter hooked up to record the number of pulses from the tachometer, which is triggered by a bolt on the axial of the wheel. Currently, the code takes the finds the average rpm of a half second, based on the number of new ticks on the counter. This doesn't work, because if we get only one tick, it reads 120 rpm, which is a big range for error.

After looking through the wpilibj api again, I found that there was counter.getPeriod(); Which would fix the whole problem most likely. If it does we won't need to use the interrupt.

Thanks Anyway :D


have you had any luck with the getPeriod method in the counter class? i've tried it but it doesn't seem to work. it starts out with a value of infinity and never changes when i run it....

loafdog 07-03-2012 12:50

Re: Tachometer Interrupt Help
 
twiggzee, have you tried different speeds when running your device/tach? We found that until our shooter reached a certain speed getPeriod returned infinity. We also used setMaxPeriod to adjust the period so that we could measure shooter revolutions at the lowest speed we would ever use.
I didn't see a way to find out what the original max period value was, either by calling a function or looking at wpilib src code.

-Maciej

twiggzee 17-03-2012 18:38

Re: Tachometer Interrupt Help
 
Quote:

Originally Posted by loafdog (Post 1140643)
twiggzee, have you tried different speeds when running your device/tach? We found that until our shooter reached a certain speed getPeriod returned infinity. We also used setMaxPeriod to adjust the period so that we could measure shooter revolutions at the lowest speed we would ever use.
I didn't see a way to find out what the original max period value was, either by calling a function or looking at wpilib src code.

-Maciej


that was it. tried it again, turns out that the getPeriod method only consistently gives a reading when our wheel is spinning more than 1200 rpm. anything below that we get either an "infinity" reading or an occasional reading when approaching 1200 rpm. thanks!

Ether 17-03-2012 19:02

Re: Tachometer Interrupt Help
 
Quote:

Originally Posted by twiggzee (Post 1145325)
that was it. tried it again, turns out that the getPeriod method only consistently gives a reading when our wheel is spinning more than 1200 rpm. anything below that we get either an "infinity" reading or an occasional reading when approaching 1200 rpm. thanks!

Maybe Java has a "SetMaxPeriod" like C++ does:

Quote:

/**
* Set the maximum period where the device is still considered "moving".
* Sets the maximum period where the device is considered moving. This value is used to determine
* the "stopped" state of the counter using the GetStopped method.
* @param maxPeriod The maximum period where the counted device is considered moving in
* seconds.
*/
void Counter::SetMaxPeriod(double maxPeriod)


All times are GMT -5. The time now is 09:48.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi