Go to Post If the pattern holds, it's a bizarro year. - GeeTwo [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 30-01-2008, 23:34
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Multiple Interrupts

Hi, I was thinking of having and interrupt for the rising and falling edges from the geartooth sensors on each of two wheels as well as have a timer interrupt for each of three SONAR sensors. How do you program different interrupt handlers so that each one responds to a different interrupt from each device?

Thanks,
Windell
#2477
  #2   Spotlight this post!  
Unread 30-01-2008, 23:50
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,721
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: Multiple Interrupts

You only have one interrupt handler for your entire program. To handle multiple interrupts, you put a large amount of if-else statements in your interrupt handler to check for which particular interrupt you're handling at the moment, then you do whatever you need to inside that particular if-else statement.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #3   Spotlight this post!  
Unread 31-01-2008, 00:00
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Multiple Interrupts

Ahh I see what you mean. Are there any examples that you can show me?

Thanks,
Windell
  #4   Spotlight this post!  
Unread 31-01-2008, 00:29
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: Multiple Interrupts

Kevin Watson's encoder software is a good example of multiple interrupt sources being handled.

http://www.kevin.org/frc/frc_encoder.zip

Many of his other utilities, such as the adc and pwm replacements, are also useful examples.
  #5   Spotlight this post!  
Unread 31-01-2008, 13:49
JohnC's Avatar
JohnC JohnC is offline
my other name is nigel
FRC #0360 (360 Revolution)
Team Role: Programmer
 
Join Date: Mar 2005
Rookie Year: 2005
Location: user_routines.c
Posts: 100
JohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the roughJohnC is a jewel in the rough
Send a message via AIM to JohnC
Re: Multiple Interrupts

I just had a bad idea. If you want interrupts on the rising AND falling edges...
Code:
void Int_1_ISR(void)
{
	INTCON2bits.INTEDG2 = !INTCON2bits.INTEDG2;
}
Mmm, does anyone smell the processor cooking?
__________________
What place are we at? ... TODAI!
  #6   Spotlight this post!  
Unread 31-01-2008, 16:41
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: Multiple Interrupts

Kevin would definitely be the one to ask, but i think that might work, if you also disabled the interrupt, then made the INTEDG2 change, and then reenabled it.

Alternatively, if you want rising and falling edges, just use the PORTB ones (Int3-6).
  #7   Spotlight this post!  
Unread 31-01-2008, 16:52
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Multiple Interrupts

Quote:
Originally Posted by JohnC View Post
I just had a bad idea. If you want interrupts on the rising AND falling edges...
Code:
void Int_1_ISR(void)
{
    INTCON2bits.INTEDG2 = !INTCON2bits.INTEDG2;
}
Mmm, does anyone smell the processor cooking?
I did this for the 2004 IR beacon receiver and it works just fine (and no smoke or flames <grin>).

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #8   Spotlight this post!  
Unread 31-01-2008, 22:00
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Multiple Interrupts

I have been trying to get Interrupts 2 and 3 working that would be on pins 1 and 2 of the Digital Inputs. I have the code and I seem to get in an infinite loop on the left gear tooth sensor. . . The interrupt keeps going and makes both the right and left gear boxes go full 254 forward.

Right GTS doesn't work at all. (yes we have tested the GTS after we fixed the resistors problem and it works fine)

Can someone see where I messed up??? Copied the code from Kevin Watson's Encoder Code.
Attached Files
File Type: txt team171a.txt (3.0 KB, 54 views)
File Type: txt team171b.txt (1.1 KB, 38 views)
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
  #9   Spotlight this post!  
Unread 01-02-2008, 00:37
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Multiple Interrupts

Quote:
Originally Posted by Gamer930 View Post
I have been trying to get Interrupts 2 and 3 working that would be on pins 1 and 2 of the Digital Inputs. I have the code and I seem to get in an infinite loop on the left gear tooth sensor. . . The interrupt keeps going and makes both the right and left gear boxes go full 254 forward.

Right GTS doesn't work at all. (yes we have tested the GTS after we fixed the resistors problem and it works fine)

Can someone see where I messed up??? Copied the code from Kevin Watson's Encoder Code.
I can't really make out what's going on, but I did see that you were calling printf() in your interrupt service routine, which can cause problems. A much better quick-and-dirty way to signal the outside world is to just send a single character using Write_Serial_Port_One(), which executes much faster. It's as simple as this:

Write_Serial_Port_One('*');

Fix this one problem and let us know if it works.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #10   Spotlight this post!  
Unread 01-02-2008, 01:59
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Multiple Interrupts

Quote:
Originally Posted by Kevin Watson View Post
I can't really make out what's going on, but I did see that you were calling printf() in your interrupt service routine, which can cause problems. A much better quick-and-dirty way to signal the outside world is to just send a single character using Write_Serial_Port_One(), which executes much faster. It's as simple as this:

Write_Serial_Port_One('*');

Fix this one problem and let us know if it works.

-Kevin
I originally had no printf's and was having the problem. Then added them in to see additionally what could have been causing problems.
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
  #11   Spotlight this post!  
Unread 01-02-2008, 03:08
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Multiple Interrupts

Quote:
Originally Posted by Gamer930 View Post
yes we have tested the GTS after we fixed the resistors problem and it works fine
I was unaware of a resistor problem. What is the problem that you speak of?
  #12   Spotlight this post!  
Unread 01-02-2008, 13:47
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Multiple Interrupts

Quote:
Originally Posted by windell747 View Post
I was unaware of a resistor problem. What is the problem that you speak of?
Team Update #6 explains it. There are a bunch of discussion here on ChiefDelphi about it also. . . Pretty much they switched R3 and R4 on one of the Gear Tooth Sensors
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
  #13   Spotlight this post!  
Unread 02-02-2008, 19:03
Gamer930's Avatar
Gamer930 Gamer930 is offline
Team 930 and 171 Alumni
AKA: Justin
no team
Team Role: Alumni
 
Join Date: Mar 2002
Rookie Year: 2002
Location: New Berlin, WI
Posts: 388
Gamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to beholdGamer930 is a splendid one to behold
Re: Multiple Interrupts

I changed all the Longs to Ints
Took out the printf in the interrupt function.

And everything started to work!!!. . . With making those few changes the above code works for Digital Input 1 and Digital Input 2 Gear Tooth Sensors.

It really made me excited today when programming the robot to go *** (A calculated value) gear teeth (8 ft) forward it actually did.
__________________
2010 to Present, Scorekeeper/Field Power Volunteer for FRC/FTC/FLL
2005 - 2010, Team 171 College Mentor
2002 - 2005, Team 930 Student
  #14   Spotlight this post!  
Unread 03-02-2008, 03:52
windell747 windell747 is offline
Registered User
FRC #2477
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2001
Location: Hawaii
Posts: 158
windell747 will become famous soon enoughwindell747 will become famous soon enough
Re: Multiple Interrupts

whoa! Congrats! I'll be sure to remember that when I get around to the closed loop feedback.
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
Hosting multiple sites in multiple VMs EHaskins Website Design/Showcase 6 22-12-2007 01:09
Interrupts JSonntag Programming 1 14-01-2006 12:43
timers/interrupts Anton Programming 1 17-02-2005 08:42
Interrupts CyberWolf_22 Control System 3 12-01-2004 21:46


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

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