Go to Post ...remember RAID 0 is a trap. - Sperkowsky [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 03-02-2006, 17:45
nukem nukem is offline
Registered User
#1676
 
Join Date: Jan 2005
Location: Hillsdale, NJ
Posts: 43
nukem is on a distinguished road
Gear Tooth Sensor

So for a couple of days ive been researching how to get the gear tooth sensor to work and I have seen many different posts on it but none really explain how to get it working with the 2006 code. I know that I need to use interrupts but how do I do that on the 2006 code? It seems that it was implemented by default on the 2005 code why was it not on the 2006? If anyone knows when the gear tooth sensor or at least the interrupt code will be ready on kevin.org that would be a great help to.

Thanks
  #2   Spotlight this post!  
Unread 03-02-2006, 17:59
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Gear Tooth Sensor

The services supplied by Mr. Watson are on a voluntary basis. You have all of the information you need to implement your own interrupts.

If you wait for someone else to do it for you, you may have to wait a long time...

JMHO

Mike
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #3   Spotlight this post!  
Unread 03-02-2006, 19:24
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Gear Tooth Sensor

That and it is ready, his encoder code works with the gear tooth sensors with minor modification, found easily by searching:
http://www.chiefdelphi.com/forums/sh...5&postcount=16

Be sure to thank Kevin, and it's never a bad idea to do it yourself anyway, I'd rather know how to do something so if Kevin decides he doesn't like us anymore, I'm not stuck.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #4   Spotlight this post!  
Unread 04-02-2006, 01:58
b_mallerd b_mallerd is offline
Programmer
FRC #1346 (Trobotics)
Team Role: Programmer
 
Join Date: Dec 2005
Rookie Year: 2005
Location: Vancouver
Posts: 35
b_mallerd is on a distinguished road
Send a message via MSN to b_mallerd
Re: Gear Tooth Sensor

I really recommend interrupts for dummies...I know this will be enforcing a bad habit so DON'T ASK FOR HELP BEFORE YOU TRY TO LEARN IT YOURSELF.

Ok. say you plug your gts into your digital io port 1...that corresponds to interrupt number 2. Now to use the interrupt you must first enable it, then set the interrupt flag to 0, then set the configuration so it interrupts on a rising edge or a falling edge. I wrapped all of it into a function so here it is!

void initialize_interrupt2(void)
{
INTCON3bits.INT2IP = 0; //set interrupt 2 to low priority
INTCON2bits.INTEDG2 = 1; //edge select 1 = rising edge 0 = falling edge
INTCON3bits.INT2IF = 0; //clear interrupt flag
INTCON3bits.INT2IE = 1; //enable interrupts
}

There you go...that enables the interrupt...now you find a line in your user_routines_fast.c file and look for the line with

if(INTCON3bits.INT2IE && INTCON3bits.INT2IF)
{
INTCON3bits.INT2IF=0;
}

and you change it so that it calls your handler

e.g

if(INTCON3bits.INT2IE && INTCON3bits.INT2IF)
{
INTCON3bits.INT2IF=0;
interrupt_2_handler();
}

Once that is finished you need to write a handler, the thing that is executed everysingle time the interrupt happens (when a gear passes the sensor)

e.g

interrupt_2_handler(void)
{
gear_count++;
}

and you can use gear count wherever you like as long as you declare the gear_count as a global variable (outside of any functions).

Good Luck (you probably don't need any with this guide =D but everyone wants that lady's attention

PS. reminding you not to be lazy...researching and doing this yourself is a valuble lesson...i guess i'm being selfish in keeping all the merits of digging through text files for myself.
__________________
  #5   Spotlight this post!  
Unread 04-02-2006, 02:16
dtengineering's Avatar
dtengineering dtengineering is offline
Teaching Teachers to Teach Tech
AKA: Jason Brett
no team (British Columbia FRC teams)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Vancouver, BC
Posts: 1,829
dtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond repute
Re: Gear Tooth Sensor

Interesting, I'll have to have the programmer's look at the Kevin's new code release.

We had worked out two solutions... one was to use a custom filter circuit to filter out the shorter pulse, then use two sensors, one forward and one backward on each gear. The other was to program a PIC 16f627 or similar other "little" PIC to serve as a dedicated gear tooth sensor monitor.

Of course, we haven't got around to implementing these, and with the deadline coming, Kevin's help is once again most appreciated.

Jason
  #6   Spotlight this post!  
Unread 04-02-2006, 09:28
Gdeaver Gdeaver is offline
Registered User
FRC #1640
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 2001
Location: West Chester, Pa.
Posts: 1,363
Gdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond reputeGdeaver has a reputation beyond repute
Re: Gear Tooth Sensor

We're taking the easy way out and not worrying about direction info. We are mounting VEX encoders on the KOP transmission output shaft and use the EASY-C function. Our capabilities are very limited. Worked well on the VEX bot.
  #7   Spotlight this post!  
Unread 04-02-2006, 11:23
nukem nukem is offline
Registered User
#1676
 
Join Date: Jan 2005
Location: Hillsdale, NJ
Posts: 43
nukem is on a distinguished road
Re: Gear Tooth Sensor

Well I did search around but no matter what I did the code I wrote would not work. I had code implemented very similar to b_mallerd and infact I just tried the code he showed and still nothing happens. I put the interupts initialization in User_Initialization() and uncommented the code for interrupts in InterruptHandlerLow(). I told it just to print out On whenever it sees the gear tooth(Im moving it by hand) but nothing prints on the screen. It seems nothing ever triggers the interrupt code(yes it is plugged in on Digial In 1). I thought I was doing something wrong but I guess not. Why isnt anything I do make the gear tooth sensor trigger?
  #8   Spotlight this post!  
Unread 04-02-2006, 11:30
nukem nukem is offline
Registered User
#1676
 
Join Date: Jan 2005
Location: Hillsdale, NJ
Posts: 43
nukem is on a distinguished road
Re: Gear Tooth Sensor

I just did a search for INTCON3bits.INT2IF and it was only found in the if statement seeing if it was trigged and when I set it to 0. Where/how do I put code to make it trigger?
  #9   Spotlight this post!  
Unread 04-02-2006, 20:17
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
Re: Gear Tooth Sensor

Quote:
Originally Posted by nukem
I just did a search for INTCON3bits.INT2IF and it was only found in the if statement seeing if it was trigged and when I set it to 0. Where/how do I put code to make it trigger?
As you can see from page 125 of this document, the flag is set in hardware and must be reset (cleared) in software.

Quote:
Interrupt flag bits are set when an interrupt condition occurs, regardless of the state of its corresponding enable bit or the global interrupt enable bit. User software should ensure the appropriate interrupt flag bits are clear prior to enabling an interrupt. This feature allows for software polling.
Does this answer your question?
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...

Last edited by Mike Betts : 05-02-2006 at 02:19.
  #10   Spotlight this post!  
Unread 04-02-2006, 20:21
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: Gear Tooth Sensor

Interrupts aren't supposed to be triggered by code. They are triggered by events such as signals changing on the input pins or timers overflowing.
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 Talha Electrical 1 23-01-2006 21:29
gear tooth sensor connecting problem nirty Electrical 2 23-01-2006 12:17
Gear Tooth Sensor AMIRAM Electrical 2 22-01-2006 04:09
Gear tooth sensor vs. Optical Encoders Avarik Programming 7 17-01-2006 10:18
LabView Gear Tooth Sensor Code SkiRacer LabView and Data Acquisition 2 17-01-2006 03:53


All times are GMT -5. The time now is 01:33.

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