Go to Post A Red Ryder 200-shot carbine Range model air rifle!!! - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-01-2008, 22:28
Tim Skloss's Avatar
Tim Skloss Tim Skloss is offline
Dr. Skloss
FRC #0930
Team Role: Parent
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Waukesha, WI, USA
Posts: 73
Tim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the rough
A Better Gear Tooth sensor

Get a couple of Honeywell 1GT101DC sensors from DigiKey ($25 each). These give you a pulse every time a tooth comes by the tip of the sensor. Sprocket teeth work well too.

The sensors in the KOP only give you rate information and therefore make distance measuring nearly impossible. Besides, they are hard to use.

The Honeywell sensors can operate up to 10,000 teeth per second which is plenty fast for our needs. We used our RC to clock the speed of a Dremel tool at 30,000 rpm (2 pulses per revolution = 1000 Hz).

In the RC we used interrupts 2 and 3 (on RC DIO pins 1 and 2). Every time the gear tooth stimulates a low-to-high transition on the signal pin, an interrupt is thrown. From this we can count teeth over time (be sure to use an interrupt driven timer, like the one in the IFI whitepapers) to calculate rates or just count teeth for distance measurement in a drivetrain. Works on sprockets too--that's were we generally place it.

I verified that 1000 interrupts per second (the Dremel experiment) slowed the "fast" execution loop of my RC by about 30%; sounds bad but that was still running over 14 thousand loops per second!!! The "slow" loop was not affected in the least by this many interrupts. Of course you MUST keep your interrupt servicing routine as short as possible. As such we simply increment an unsigned int as a counter:

void InterruptHandlerLow ()
{
unsigned char int_byte;
if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) /* The INT2 pin is RB2/DIG I/O 1. */
{
INTCON3bits.INT2IF = 0;
pulse1Count++;
}
else if (INTCON3bits.INT3IF && INTCON3bits.INT3IE) /* The INT3 pin is RB3/DIG I/O 2. */
{
INTCON3bits.INT3IF = 0;
pulse2Count++;
}
}

BE SURE TO DISABLE INTERRUPTS when resetting the counters outside of the ISR or else you can random bad things happen. As such:
INTCONbits.GIEL = 0; /* Disable Low Priority Interrupts */
pulse2Count = 0;
INTCONbits.GIEL = 1; /* Enable Low Priority Interrupts */

To connect the sensor, simply wire the sensor's ground, power and signal pins accordingly to a DIO input. I found that a 5K pull-up resistor on the output pin of the sensor makes a very clean square wave when running at high tooth speeds. You could also wire power to 12VDC, but it works fine for us drawing power from the DIO bank.

Initialization code for INT2 and INT3:
/* Initialize INT2 for pulse counting. INT2 is rc_dig_in01 */
INTCON3bits.INT2IE = 1; //enable INT2
INTCON3bits.INT2IP = 0; //set INT2 to low priority
INTCON2bits.INTEDG2 = 1; //rising edge

/* Initialize INT3 for pulse counting INT3 is rc_dig_in02*/
INTCON3bits.INT3IE = 1; //enable INT3
INTCON2bits.INT3IP = 0; //set INT3 to low priority
INTCON2bits.INTEDG3 = 1; //rising edge

INTCONbits.GIEL = 1; /* Enable Global Low Priority Interrupts */

Again, I high recommend implementing the interrupt-driven timer as described in the IFIrobotics.com whitepapers page. We use a 1 second tick to printf out the status of our code for debugging. We increment counters every execution of the fast and slow loops in normal and auton modes, and then printf the counts every second (and resetting them too) as a sort of speedometer which is very useful for watching the impact a high number of interrupts would have on the code.

Good luck!
__________________
---------------
FIRST Mentor and Team Leader
C.O.R.E 2062 a NASA, GE Volunteers and Rockwell Automation FRC Team
  #2   Spotlight this post!  
Unread 09-01-2008, 23:12
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: A Better Gear Tooth sensor

Quote:
Originally Posted by Tim Skloss View Post
Get a couple of Honeywell 1GT101DC sensors from DigiKey ($25 each). These give you a pulse every time a tooth comes by the tip of the sensor. Sprocket teeth work well too.

The sensors in the KOP only give you rate information and therefore make distance measuring nearly impossible. Besides, they are hard to use.
According to the 2008 Sensor Manual, the KOP gear tooth sensors give a pulse every time a tooth comes by. Where are you finding information saying they only give rate information? And what do you mean by "hard to use"? We used the ones in the 2006 kit with substantially the same software you suggest for the Honeywell parts.
  #3   Spotlight this post!  
Unread 09-01-2008, 23:44
Tim Skloss's Avatar
Tim Skloss Tim Skloss is offline
Dr. Skloss
FRC #0930
Team Role: Parent
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Waukesha, WI, USA
Posts: 73
Tim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the rough
Re: A Better Gear Tooth sensor

Quote:
Originally Posted by Alan Anderson View Post
According to the 2008 Sensor Manual, the KOP gear tooth sensors give a pulse every time a tooth comes by. Where are you finding information saying they only give rate information? And what do you mean by "hard to use"? We used the ones in the 2006 kit with substantially the same software you suggest for the Honeywell parts.
Well, it says the output is a "PWM" signal with a period of 45 us. When I read that I imagine a train of pulses that flows regardless of gear motion. Add to that description the statement of "duty cycle varies from 41-61 percent" and you have a good description of a classic PWM rate-type signal.

Now that I have read the Allegro data sheet I find that you are correct and the sensor manual to be misleading. The sensor manual should say: "Each time a gear tooth passes the sensor a 45 (nominal) microsecond pulse will be transmitted on the S output with no indication of the direction of rotation." Saying it is a PWM signal, when it isn't (no width modulation) only leads to confusion. The variation in pulse width comes from the distance between the sensor and the gear, according to the data sheet.

Thanks for pointing that out. We will try them this year on the gearboxes and save the Honeywell sensors for other sensing jobs. The Honeywell sensors are easier to mount and extremely durable, that much is for sure. Plus you only need 3 wires.
__________________
---------------
FIRST Mentor and Team Leader
C.O.R.E 2062 a NASA, GE Volunteers and Rockwell Automation FRC Team
  #4   Spotlight this post!  
Unread 10-01-2008, 00:01
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: A Better Gear Tooth sensor

Quote:
Originally Posted by Tim Skloss View Post
The Honeywell sensors are easier to mount...
Easier to mount than what? The KOP gearbox has a perfect spot for placing the KOP gear tooth sensor, complete with mounting holes.
  #5   Spotlight this post!  
Unread 10-01-2008, 08:51
Tim Skloss's Avatar
Tim Skloss Tim Skloss is offline
Dr. Skloss
FRC #0930
Team Role: Parent
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Waukesha, WI, USA
Posts: 73
Tim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the rough
Re: A Better Gear Tooth sensor

Quote:
Originally Posted by Alan Anderson View Post
Easier to mount than what? The KOP gearbox has a perfect spot for placing the KOP gear tooth sensor, complete with mounting holes.
The FIRST GTS boards are designed to mount in the gearboxes. The features are provided (although the fasteners are not!). That is where we will use them.

But what about everywhere else on the robot? Placing the fragile board anywhere on the robot other than the inside the protective confines of the gearbox would be inviting disaster. Building protection would be required, but we only have so much time and resources.

The Honeywell sensors are cheap, very reliable, have a very clean signal, easy to use and are nearly bullet-proof.
__________________
---------------
FIRST Mentor and Team Leader
C.O.R.E 2062 a NASA, GE Volunteers and Rockwell Automation FRC Team
  #6   Spotlight this post!  
Unread 19-01-2008, 20:05
Tim Skloss's Avatar
Tim Skloss Tim Skloss is offline
Dr. Skloss
FRC #0930
Team Role: Parent
 
Join Date: Jan 2002
Rookie Year: 2000
Location: Waukesha, WI, USA
Posts: 73
Tim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the roughTim Skloss is a jewel in the rough
Re: A Better Gear Tooth sensor

We installed the sensors in the Andy Mark gearboxes today.

You can read about it here.
__________________
---------------
FIRST Mentor and Team Leader
C.O.R.E 2062 a NASA, GE Volunteers and Rockwell Automation FRC Team
  #7   Spotlight this post!  
Unread 19-01-2008, 20:20
Los Frijoles's Avatar
Los Frijoles Los Frijoles is offline
Stormin' Mormon
AKA: Kevin Cuzner
FRC #2062 (C.O.R.E.)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Waukesha, WI
Posts: 27
Los Frijoles has a spectacular aura aboutLos Frijoles has a spectacular aura about
Send a message via AIM to Los Frijoles
Re: A Better Gear Tooth sensor

Dr. Skloss, I see you be posting our techniques and tips...yay

These sensors are much more reliable than the included sensors from what I have seen. These are completely sealed (no accidental shorts from small pieces of metal that so often find their way into robots) and do not require a 12V line to operate.
__________________
Community Of Robotic Engineers 2062





Blender totally pwns 3DS Max...

My life is here and here.

Cuznersoft Hardware and Software Development
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gear Tooth Sensor Zoom Programming 46 22-01-2008 08:05
Gear Tooth Sensor? Raikon Kit & Additional Hardware 3 09-02-2007 16:40
Gear Tooth Sensor nukem Programming 9 04-02-2006 20:21
Gear Tooth Sensor Talha Electrical 1 23-01-2006 21:29
Gear Tooth Sensor AMIRAM Electrical 2 22-01-2006 04:09


All times are GMT -5. The time now is 23:16.

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