|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Magnetic Sensor
Im working on a magnetic sensor for our shooter this year. We can get a reading off of it using the counter class. The problem is that it keeps counting. Is there a way to set some kind of interupt so it reset every second so we can get a type of rpm?
|
|
#2
|
|||||
|
|||||
|
Re: Magnetic Sensor
What kind of magnetic sensor is this? How many counts are you getting per revolution of your shooter wheel?
|
|
#3
|
|||
|
|||
|
Re: Magnetic Sensor
i believe it was this one im not 100% sure because i dont have the packaging its with the our other robotics stuff right now.
http://www.digikey.com/product-detai...8-2-ND/2626345 |
|
#4
|
|||||
|
|||||
|
Re: Magnetic Sensor
Hrm. Are you using that to sense a magnet on a wheel, or teeth on a gear? I'm trying to figure out how many counts per revolution of your wheel you're expecting to get. If you're only expecting 1 count/pulse per revolution of your wheel, there's a better way to determine your wheel speed.
|
|
#5
|
|||
|
|||
|
Re: Magnetic Sensor
I can get a reading off of it by using the counter class and counter.Get();
|
|
#6
|
|||||
|
|||||
|
Re: Magnetic Sensor
Quote:
What I'd recommend is changing your sensor to this: http://www.digikey.com/product-detai...330-ND/2075330 Then gluing a small magnet to your wheel with the south pole facing that hall switch. That will work similarly to your current setup, except you'll only get one pulse per revolution, which will make the 60/counter.GetPeriod() RPM value much more stable. Your other option may be to change out 5 of those screws with flat head screws and countersink the holes so that the you only have one screwhead that will trigger your gear tooth sensor. Or, if that aluminum hub has a setscrew in it, you might re-orient your sensor to pick up the setscrew as it comes around. Or add a setscrew just for this sensing purpose. The whole idea here is that you only want one pulse per revolution of the wheel. |
|
#7
|
||||
|
||||
|
Re: Magnetic Sensor
Quote:
If he's getting good counts with that sensor, all he has to do is change the getPeriod() FPGA sample averaging ring buffer from the default value of "1" to "6". For Java and C++, this requires making a small change to the WPILib code. http://www.chiefdelphi.com/forums/sh...7&postcount=24 Last edited by Ether : 27-02-2013 at 21:28. |
|
#8
|
|||
|
|||
|
Re: Magnetic Sensor
So im still confused how will that help me? im getting current counts and its counting right i checked it. for the rpm im planing on doing something like:
Code:
Counter gts; float rpm . . . rpm = ( ((1/gts.GetPeriod())/6)*60) |
|
#9
|
|||||
|
|||||
|
Re: Magnetic Sensor
Quote:
tomy, You other other option is doing as Ether suggests and changing the averaging ring buffer for the counter, then using 10/counter.GetPeriod() as your feedback RPMs. |
|
#10
|
||||
|
||||
|
Re: Magnetic Sensor
Quote:
|
|
#11
|
|||||
|
|||||
|
Re: Magnetic Sensor
Quote:
You can fix that by making the edit to WPILib that Ether suggested. That will create a buffer of the last 6 period measurements and output the average of those. That means you'll get an average over all 6 of your unevenly spaced screws, which will even things out and greatly reduce the noise in your feedback. |
|
#12
|
|||
|
|||
|
Re: Magnetic Sensor
So where is this file that i have to change?
EDIT: found it so now my function would be (1/gts.GetPeriod)/60 which would give me my rpm right? Last edited by tomy : 27-02-2013 at 22:06. |
|
#13
|
||||
|
||||
|
Re: Magnetic Sensor
Quote:
|
|
#14
|
|||
|
|||
|
Re: Magnetic Sensor
|
|
#15
|
|||
|
|||
|
Re: Magnetic Sensor
Well i changed that values from a 1 to a 6 so it looked likes:
Code:
m_counter->writeTimerConfig_AverageSize(6, &localStatus); Code:
float rpm Counter gts; . . . rpm = (((1/gts.GetPeriod()) / 6) *60); |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|