Go to Post The robots are the attracting force, the common interest that brings us all together - sanddrag [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
  #1   Spotlight this post!  
Unread 27-02-2013, 14:41
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: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
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?
Reply With Quote
  #2   Spotlight this post!  
Unread 27-02-2013, 14:45
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,708
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

What kind of magnetic sensor is this? How many counts are you getting per revolution of your shooter wheel?
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #3   Spotlight this post!  
Unread 27-02-2013, 14:48
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: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
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
Reply With Quote
  #4   Spotlight this post!  
Unread 27-02-2013, 15:49
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,708
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

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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #5   Spotlight this post!  
Unread 27-02-2013, 16:00
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: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Magnetic Sensor

I can get a reading off of it by using the counter class and counter.Get();
Attached Thumbnails
Click image for larger version

Name:	DSC00178.JPG
Views:	30
Size:	148.8 KB
ID:	14206  
Reply With Quote
  #6   Spotlight this post!  
Unread 27-02-2013, 19:36
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,708
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
I can get a reading off of it by using the counter class and counter.Get();
You seem to be in a sort of no-man's land here with that setup. You should be getting 6 counts per revolution like that. That's not enough counts per second to do any reasonable speed control. On the other hand, it's probably too many counts per second to use 60/counter.GetPeriod() to give you an RPM to control. You can try this method, but I don't think it'll be super stable for your current sensor setup.

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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #7   Spotlight this post!  
Unread 27-02-2013, 20:40
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Magnetic Sensor

Quote:
Originally Posted by Kevin Sevcik View Post
You seem to be in a sort of no-man's land here with that setup. You should be getting 6 counts per revolution like that. That's not enough counts per second to do any reasonable speed control. On the other hand, it's probably too many counts per second to use 60/counter.GetPeriod() to give you an RPM to control. You can try this method, but I don't think it'll be super stable for your current sensor setup.
...
The whole idea here is that you only want one pulse per revolution of the wheel.
Kevin,

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.
Reply With Quote
  #8   Spotlight this post!  
Unread 27-02-2013, 21:37
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: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
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)
I might have missed a ( somewhere
Reply With Quote
  #9   Spotlight this post!  
Unread 27-02-2013, 21:39
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,708
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 Ether View Post
Kevin,

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
I thought there was something like that, was just leery to suggest it because the period between each of the 6 pulses would likely be a bit different. Though I suppose it works out with a buffer of 6, as it'd have a full revolution of pulses, so physical variance between the pulses should cancel out.

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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #10   Spotlight this post!  
Unread 27-02-2013, 21:45
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Magnetic Sensor

Quote:
Originally Posted by Kevin Sevcik View Post
the period between each of the 6 pulses would likely be a bit different. Though I suppose it works out with a buffer of 6, as it'd have a full revolution of pulses, so physical variance between the pulses should cancel out.
Exactly.


Reply With Quote
  #11   Spotlight this post!  
Unread 27-02-2013, 21:48
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,708
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
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)
I might have missed a ( somewhere
The idea there is correct, our concern is that your screwheads aren't perfectly spaced and there's 6 of them. That means you're going to have a noisy signal. 6 screws means pulses are 1/6th as long, means at 5000 RPM, your period is 2ms. Ether will probably come in with the exact formula for how much inherent noise you'll see in a 2ms period, but it's definitively more than with the 12ms pulse. Add in the fact that each screw head is going to trigger the pulse at a different time, and you could end up with pretty noisy feedback that won't be fun to control.

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.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
Reply With Quote
  #12   Spotlight this post!  
Unread 27-02-2013, 21:57
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: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
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.
Reply With Quote
  #13   Spotlight this post!  
Unread 27-02-2013, 23:05
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,098
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Magnetic Sensor

Quote:
Originally Posted by tomy View Post
so now my function would be

(1/gts.GetPeriod)/60 which would give me my rpm right?
Your question was answered in a previous post.


Reply With Quote
  #14   Spotlight this post!  
Unread 27-02-2013, 23:48
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: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
Re: Magnetic Sensor

Quote:
Originally Posted by Ether View Post
Your question was answered in a previous post.


ahh kk ty
Reply With Quote
  #15   Spotlight this post!  
Unread 28-02-2013, 16:55
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: 495
tomy has a spectacular aura abouttomy has a spectacular aura about
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);
Then in my code I have this:

Code:
float rpm
Counter gts;
.
.
.
rpm = (((1/gts.GetPeriod()) / 6) *60);
to find the rpm and when i print out the rpm i get strange results. most of the prints say inf the others say something like 23334.053 for rpm. What is going on with that?
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 03:34.

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