Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Magnetic Sensor (http://www.chiefdelphi.com/forums/showthread.php?t=114435)

Kevin Sevcik 28-02-2013 17:18

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.

tomy 28-02-2013 17:58

Re: Magnetic Sensor
 
i changed :

Code:

m_counter->writeTimerConfig_AverageSize(6, &localStatus);
to:

Code:

m_counter->writeTimerConfig_AverageSize(1, &localStatus);
and im getting a consistant rpm with that function i had in there. every once and a while ill get a blip of 30k rpm or something should the set max period fix that?

Edit: consistent rpm of 247 rpm when i do

Code:

talon.Set(.1);

Kevin Sevcik 28-02-2013 18:10

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.

tomy 28-02-2013 18:14

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?

Kevin Sevcik 28-02-2013 18:20

Re: Magnetic Sensor
 
Quote:

Originally Posted by tomy (Post 1241709)
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?

Take a look at the RPMCounter class I uploaded. In the GetRPM function I'm comparing the period with a constant value I set in the .h file. The idea is that if the period is less than some value, you ignore it and return the previous value.

tomy 28-02-2013 18:30

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;
for the proper calculation of the rpm shouldnt it be something like:

Code:

prevResult = ( ((1 / period) / 6) * 60)
or at least thats the function im using to calculate the rpm


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