Go to Post Sometimes it is worth it to stop and read what you've written before posting. - [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 28-02-2013, 17:18
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,729
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Magnetic Sensor

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.
Attached Files
File Type: h RPMCounter.h (1.0 KB, 3 views)
File Type: cpp RPMCounter.cpp (2.0 KB, 3 views)
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #17   Spotlight this post!  
Unread 28-02-2013, 17:58
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 503
tomy has a spectacular aura abouttomy has a spectacular aura about
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);
Reply With Quote
  #18   Spotlight this post!  
Unread 28-02-2013, 18:10
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,729
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #19   Spotlight this post!  
Unread 28-02-2013, 18:14
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 503
tomy has a spectacular aura abouttomy has a spectacular aura about
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?
Reply With Quote
  #20   Spotlight this post!  
Unread 28-02-2013, 18:20
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,729
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Magnetic Sensor

Quote:
Originally Posted by tomy View Post
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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #21   Spotlight this post!  
Unread 28-02-2013, 18:30
tomy tomy is offline
Registered User
FRC #3038 (I.C.E. Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Stacy, Minnesota
Posts: 503
tomy has a spectacular aura abouttomy has a spectacular aura about
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
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:38.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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