![]() |
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?
|
Re: Magnetic Sensor
What kind of magnetic sensor is this? How many counts are you getting per revolution of your shooter wheel?
|
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 |
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.
|
Re: Magnetic Sensor
1 Attachment(s)
I can get a reading off of it by using the counter class and counter.Get();
|
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. |
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 |
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; |
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. |
Re: Magnetic Sensor
Quote:
|
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. |
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? |
Re: Magnetic Sensor
Quote:
|
Re: Magnetic Sensor
Quote:
|
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 |
Re: Magnetic Sensor
2 Attachment(s)
Inf would be because you're getting 0 for the period. Try setting the MaxPeriod to something reasonable. gts.SetMaxPeriod(0.25) or so. The counter class clears out the buffer if it doesn't see a pulse in within MaxPeriod seconds, and I don't know what the default is. Past that, I made my own class that did a little filtering of values so I'd ignore values I knew were bad. I've attached the files, you can try using it. You'd just need to modify "prevResult = 60.0 / period;" to read "prevResult = 10.0 / period;" And you'd want to reduce periodThreshold in the .h file to something like 1e-3 just so it doesn't limit the max RPM to something less that what you can actually output. It's set up so you can use it as a PIDSource for a PIDController.
|
Re: Magnetic Sensor
i changed :
Code:
m_counter->writeTimerConfig_AverageSize(6, &localStatus);Code:
m_counter->writeTimerConfig_AverageSize(1, &localStatus);Edit: consistent rpm of 247 rpm when i do Code:
talon.Set(.1); |
Re: Magnetic Sensor
Does it looks like your wheel is turning at 247 RPM? That's about 4 revs per second. Max period wouldn't help with the 30k blip. That's why I added a minimum period check in my RPMCounter class to ignore any period values that were obviously too small. Max period will help if your feedback is going from some number like 100 straight to zero. or flashing between 0 and 100. That's the counter thinking the wheel hast stopped and sending a 0 for period, then sending a good value when it sees the next pulse. Less likely to happen on your setup since you have 6 screw heads.
The 30k problem might be your screwheads. The GTS might be picking up the small gap in the screwhead for the flathead screwdriver. Using a hex-head fastener or something without the gap in the middle would probably work better. |
Re: Magnetic Sensor
ok sweet the only problem im having now is the random blips of high rmp you said that in your rpm counter class you used a function to ignore small rpm can i do that to ignore the high ones as well?
|
Re: Magnetic Sensor
Quote:
|
Re: Magnetic Sensor
Ahhh thank you for your help. Two more quick question why would i need to change the "periodThreshold in the .h file to something like 1e-3". Also in the .cpp you have
Code:
prevResult = 60.0 / period;Code:
prevResult = ( ((1 / period) / 6) * 60) |
| All times are GMT -5. The time now is 14:24. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi