Go to Post I wake up at noon on Christmas Eve, and find tweets announcing a game hint. Looks like I won't be seeing much of my family today... - Karibou [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 12-12-2003, 21:56
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
EDU Interrupt and Timer Template Code

To get the creative juices going for the coming build season, I've written some template code that will make the job of using interrupts and timers on the EDU controller much easier. It's somewhere around 800 lines of heavily annotated code that can be used alone or dropped into your own code. I've also re-written user_routines_fast.c to allow the use of all external and timer related interrupts. I'm also working on what I think are some cool demos using this code. If you have an idea on how to improve the code, find a bug or do something cool with it, leave a note here or e-mail me. Anyway, the zipped archive is located here. Have fun.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #2   Spotlight this post!  
Unread 13-12-2003, 19:37
CyberWolf_22's Avatar
CyberWolf_22 CyberWolf_22 is offline
Programming and Electrical Mentor
AKA: Allen Gregory
FRC #2587 (Afrobots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Houston, Texas
Posts: 227
CyberWolf_22 is just really niceCyberWolf_22 is just really niceCyberWolf_22 is just really niceCyberWolf_22 is just really nice
Re: EDU Interrupt and Timer Template Code

Thank you this code is very helpful.
__________________
  #3   Spotlight this post!  
Unread 14-12-2003, 16:28
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: EDU Interrupt and Timer Template Code

No problem. I'm glad you found it helpful.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #4   Spotlight this post!  
Unread 15-12-2003, 13:01
Larry Barello Larry Barello is offline
http://www.barello.net
#0492 (Titan Robotics Club)
Team Role: Mentor
 
Join Date: Jan 2002
Location: Bellevue, WA
Posts: 85
Larry Barello has a spectacular aura aboutLarry Barello has a spectacular aura about
Re: EDU Interrupt and Timer Template Code

I wrote a small quadrature encoder interface using RB4-7 (ifi interrupt 3-6) and ran across a problem that doesnt appear to be addressed in your code: If you call a subroutine from an interrupt handler, you need to save additional stuff. You can find this in the C compiler in section 2.9 (something) or on the quick reference card. You need to replace

#pragma interrupt InterruptHandlerLow

with

#pragma interruptlow InterruptHandlerLow save=section(".tmpdata")

For more info, see below:

http://www.chiefdelphi.com/forums/sh...91&postcount=4
  #5   Spotlight this post!  
Unread 15-12-2003, 13:15
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: EDU Interrupt and Timer Template Code

Hi Larry,

Thanks, I've had a few exchanges with folks about this via e-mail already and will make some changes to the code and do some testing this evening. It's strange in that I haven't had any problems with a couple of other applications that I've written lately. One, a motor controller, receives many hundreds of interrupts a second from an encoder, yet I've never had a problem (actually, while doing some testing, I found that I could handle a peak interrupt rate of just over 5,000 interrupts/sec and still see no wierdness).

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #6   Spotlight this post!  
Unread 15-12-2003, 13:24
Larry Barello Larry Barello is offline
http://www.barello.net
#0492 (Titan Robotics Club)
Team Role: Mentor
 
Join Date: Jan 2002
Location: Bellevue, WA
Posts: 85
Larry Barello has a spectacular aura aboutLarry Barello has a spectacular aura about
Re: EDU Interrupt and Timer Template Code

Quote:
Originally Posted by Kevin Watson
Hi Larry,

Thanks, I've had a few exchanges with folks about this via e-mail already and will make some changes to the code and do some testing this evening. It's strange in that I haven't had any problems with a couple of other applications that I've written lately. One, a motor controller, receives many hundreds of interrupts a second from an encoder, yet I've never had a problem (actually, while doing some testing, I found that I could handle a peak interrupt rate of just over 5,000 interrupts/sec and still see no wierdness).

-Kevin
I admit I was being a bit agressive: I have a 1000 count wheel on a servo motor as my test. I estimated around 1200-1800 RPM which gives 80-120K interrupts a second.

Even with the fix, that interrupt rate crashes the EDU system. It seems that 10-20k/sec is about as fast as it can go. Which is good since a 2 segment wheel on the back of a Boch motor generates about 5k/sec at full speed.
  #7   Spotlight this post!  
Unread 16-12-2003, 09:47
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,559
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: EDU Interrupt and Timer Template Code

Quote:
Originally Posted by Larry Barello
I admit I was being a bit agressive: I have a 1000 count wheel on a servo motor as my test. I estimated around 1200-1800 RPM which gives 80-120K interrupts a second.

Even with the fix, that interrupt rate crashes the EDU system. It seems that 10-20k/sec is about as fast as it can go. Which is good since a 2 segment wheel on the back of a Boch motor generates about 5k/sec at full speed.
100k interrupts a second is extremely fast for a 40mhz processor. That's only 400 cycles between interrupts. Considering the time to save registers, as well as the fact that IFI has higher priority interupts, I can easily see why you had problems.
  #8   Spotlight this post!  
Unread 17-12-2003, 15:08
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: EDU Interrupt and Timer Template Code

I've updated the template code to better handle low-priority interrupts.
It can be found here: http://kevin.org/frc.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #9   Spotlight this post!  
Unread 22-12-2003, 14:11
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: EDU Interrupt and Timer Template Code

"The Lucas" found a bug in my code related to timers 3/4 (thanks, Dude), so if you're using the interrupt and timer code that I posted, you might want to download the updated version from here: http://kevin.org/frc.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
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


All times are GMT -5. The time now is 09:35.

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