Go to Post Robot gets bored during practice, wanted to listen to some podcasts. - Tom Bottiglieri [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 25-01-2008, 22:54
Nuggets08 Nuggets08 is offline
Registered User
FRC #1737 (Project X Robotics)
Team Role: Programmer
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Excelsior Springs, MO
Posts: 11
Nuggets08 is on a distinguished road
This darn Gear Tooth Sensor

Alright, my team has been around for 3 years this year. I have been head programmer all three years. Now basically, our programming has been relatively simple in the past years. I have gotten a feel for how the PIC works, and the code's architecture, but there is something I have never touched: Interrupts.
Looking into Chief Delphi, looking for answers, I found things saying that you need to use interrupts to get the input from the Gear Tooth Sensor. This is a lot more programming than I anticipated at first for this thing. I was hoping for a simple check on rc_dig_in01, but that doesn't work. I found this out by trying it, and then looking on here to see why.

Alright, I'm rambling. Onto my question:
How can I use interrupts to tell when the GTS pulses? I don't care what direction it is spinning, I am combining the GTS and the gyro, to get a heading of the robot. I am just merely finding the distance traveled by one wheel, and then doing the same on the other wheel.
Thank you!
--Adam
__________________
-Nuggets
Project X Robotics
Team 1737
Excelsior Springs, MO
Attending: KC-Metro Regional
Project Manager, Lead Programmer
  #2   Spotlight this post!  
Unread 25-01-2008, 23:41
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: This darn Gear Tooth Sensor

All you really have to do is enable the interrupt on port 1, make sure your sensor is plugged into digital I/O 1, and add 1 to a counter in the interrupt handler in "User_Routines_Fast.c"

Although to access it a quick function to disable the interrupt and return the variable's should also be used and the variable should be volatile type.

If you understood that thats good

I will edit this post with a link to a good white paper that gives an in-depth description of the interrupts. They are actually fairly easy

Here it is: http://www.chiefdelphi.com/media/papers/1483
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
  #3   Spotlight this post!  
Unread 25-01-2008, 23:43
Jake M Jake M is offline
void* Jake;
FRC #1178 (DURT)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Missouri
Posts: 118
Jake M has a spectacular aura aboutJake M has a spectacular aura about
Re: This darn Gear Tooth Sensor

The core of the interrupts, in IFI's default code is the InterruptHandlerLow() routine, which can be found in user_routines_fast.c. IFI's set things up so that when an interrupt is triggered, that function is automatically called. Within it, IFI setup a skeleton of if statements to demonstrate how to check which interrupt was triggered and how to handle it.

If you can't quite understand their skeleton (which I don't expect you to, don't worry) pull up the PIC Controller Manual (Kevin.org has it) and do a search for all the variables used in the function (such as INTCON3bits.INT2IF). They're actually software registers and the manual describes what they all do and how to use them. They might also be in the manual for the IFI Default Code, but I'm not sure.

Basically, each of the if statements corresponds to a different interrupt. Inside the statement you can either put a small section of your own code to process the interrupt (increment a counter of how many times it has triggered, perhaps), or you can call a separate function to do the same thing.

I believe you also need to enable the interrupt from User_Initialization() in user_routines.c. Look for something about interrupts in there.

Keep your progress posted here.
__________________
Code:
void function(void)
 {
  function();
 }

Last edited by Jake M : 25-01-2008 at 23:49.
  #4   Spotlight this post!  
Unread 26-01-2008, 10:22
tseres's Avatar
tseres tseres is offline
obsessed with FIRST...
FRC #1565 (Think Tank Tech)
Team Role: Leadership
 
Join Date: Apr 2007
Rookie Year: 2007
Location: Cambridge, ON
Posts: 305
tseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of lighttseres is a glorious beacon of light
Re: This darn Gear Tooth Sensor

look up kevin's encoder code ( kevin.org/frc ) and a modified copy should work with the GTS
__________________


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 marco_alchemy Electrical 7 06-02-2008 09:54
Gear Tooth Sensor Zoom Programming 46 22-01-2008 08:05
Gear Tooth Sensor Nathan Programming 4 12-01-2008 15:09
Gear Tooth Sensor? Raikon Kit & Additional Hardware 3 09-02-2007 16:40
Gear Tooth Sensor AMIRAM Electrical 2 22-01-2006 04:09


All times are GMT -5. The time now is 19:14.

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