Go to Post Thank you NASA (except for Dave, his tormenting hints make us even) - Mike Schroeder [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 21-02-2004, 18:51
Kevin Karan's Avatar
Kevin Karan Kevin Karan is offline
Linux Guy
AKA: maxdamage
None #0174 (Arctic Warriors)
Team Role: Alumni
 
Join Date: Jan 2003
Location: Liverpool, NY
Posts: 141
Kevin Karan will become famous soon enoughKevin Karan will become famous soon enough
Send a message via AIM to Kevin Karan
Need interupts help, and another question...

Im having a problem getting the interupts working on the FRC. My sensor group has been working all the work period on seperate codes for the trackers, line sensors and encoders using the edubot. This week I ported everything for use on the FRC, but Im having a big problem getting the interupts to work. First, I just used the initialization routines that I made for the edubot, and worked on the edubot, in the FRC code but it didnt work. I tried putting the code out of kevin(.org)'s interupts example (they were almost identical) and still nothing. I tried using the code in first's timers guide but that was also identical. Im having this problems on timers 1,2 and interupts 1-6. Ive tried dissableing all interupts exept for one, but no luck. This is the code im using (as an example) to initialize the interupts for the drive encoders:
Code:
void Initialize_Encoders(void)  
{
	// init interupt 1
	TRISBbits.TRISB2 = 1;		//make input
	INTCON3bits.INT2IP = 0;		//low priority
	INTCON2bits.INTEDG2 = 1;	//rising-edge
	INTCON3bits.INT2IE = 1;		//enable
	
	// init interupt 2
	TRISBbits.TRISB3 = 1;		//make an input
	INTCON2bits.INT3IP = 0;		//low priority
	INTCON2bits.INTEDG3 = 1;	//rising-edge
	INTCON3bits.INT3IE = 1;		//enable
}
This is the code im using to initialize my 1khz timer:
Code:
void Initialize_Timer_2(void)  
{
	TMR2 = 0;				// 8-bit
	PR2	= 249;				// period register
	T2CONbits.T2OUTPS0 = 1;	// 1:10 postscaler
	T2CONbits.T2OUTPS1 = 0;	
	T2CONbits.T2OUTPS2 = 0;	
	T2CONbits.T2OUTPS3 = 1;

	T2CONbits.T2CKPS0 = 1;	// 1/4 prescaler
	T2CONbits.T2CKPS1 = 0;	

	PIE1bits.TMR2IE = 1;	// enable pr2

	IPR1bits.TMR2IP = 0;	// low priority

	T2CONbits.TMR2ON = 1;	// enable
}
I am using kevin(.org)'s interupt hander low (actualy im pretty much using his user_routines_fast.c) which is pretty much identical to FIRST's. The tracker interupt init is FIRST's.
Im calling the inits from User_Initialization like im supposed to.

My other question is if we can exclude some parts of firsts code, like the printf library since they take up a large chunk of the program flash memory and I want to use that space for other stuff.
Thanks,
Kevin Karan
Team 174 Arctic Warriors Programmer
__________________
It isnt ALWAYS the programmers falt!
2004: Buckeye team website award
2002: Rutgers semi-finalists
2001: National semi-finalists
2001: Rutgers semi-finalists
1998: Manchester Rookie All-Star Award
  #2   Spotlight this post!  
Unread 21-02-2004, 20:17
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Need interupts help, and another question...

As for the first part, ask Kevin.

As for the second part, I think that printf is the only one you can exclude, but only if you aren't using printf() anywhere. And this year's mem is huge, so if you filled it already, tell us!
  #3   Spotlight this post!  
Unread 21-02-2004, 20:26
Kevin Karan's Avatar
Kevin Karan Kevin Karan is offline
Linux Guy
AKA: maxdamage
None #0174 (Arctic Warriors)
Team Role: Alumni
 
Join Date: Jan 2003
Location: Liverpool, NY
Posts: 141
Kevin Karan will become famous soon enoughKevin Karan will become famous soon enough
Send a message via AIM to Kevin Karan
Re: Need interupts help, and another question...

Quote:
Originally Posted by Astronouth7303
As for the first part, ask Kevin.

As for the second part, I think that printf is the only one you can exclude, but only if you aren't using printf() anywhere. And this year's mem is huge, so if you filled it already, tell us!
er... where do I ask him, or may he see this post?
And I did fill it up , Its a mix of a heavily modified tracker, a math library, and my drive system that (hopefully) makes accurate speed/power ajustments relitive to the maximum speed of the bot as seen with the encoders. Thanks!
__________________
It isnt ALWAYS the programmers falt!
2004: Buckeye team website award
2002: Rutgers semi-finalists
2001: National semi-finalists
2001: Rutgers semi-finalists
1998: Manchester Rookie All-Star Award
  #4   Spotlight this post!  
Unread 21-02-2004, 21:23
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: Need interupts help, and another question...

Quote:
Originally Posted by Kevin Karan
er... where do I ask him, or may he see this post?
PM him, or wait till he sees this.

Quote:
Originally Posted by Kevin Karan
And I did fill it up , Its a mix of a heavily modified tracker, a math library, and my drive system that (hopefully) makes accurate speed/power ajustments relitive to the maximum speed of the bot as seen with the encoders. Thanks!
My eyes hurt from that dinner-plate type action. One word: OPTIMIZE. I hear it's huge. I see why you asked about printf. At this point, do conditional compilation of the debug stuff. But unfortunately, most of IFI's stuff stays. Good Luck! (your gonna need it.)

Last edited by Astronouth7303 : 21-02-2004 at 21:25.
  #5   Spotlight this post!  
Unread 21-02-2004, 22:06
Rickertsen2 Rickertsen2 is offline
Umm Errr...
None #1139 (Chamblee Gear Grinders)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: ATL
Posts: 1,421
Rickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant futureRickertsen2 has a brilliant future
Send a message via AIM to Rickertsen2 Send a message via Yahoo to Rickertsen2
Re: Need interupts help, and another question...

Quote:
Originally Posted by Kevin Karan
My other question is if we can exclude some parts of firsts code, like the printf library since they take up a large chunk of the program flash memory and I want to use that space for other stuff.
Thanks,
Kevin Karan
Team 174 Arctic Warriors Programmer
Yea. You can scrap alot more than jsut the printf lib. The first thing we did was gut the default code. I don't remember the exact amount of memory e saved, but we were able to shave off over about 20% of the code. Besides, printf, two other good places that have a lot of room for a diet are userroutines.c and ifi_utilities.c. It is also a good idea to turn on certian compilar optimizations. You would be surprised how much those can save you in some cases. If you don't understand the memory allocation, then it would be a good idea to read up on that, because it will allow you to write better code. The compiler manual is the best resource for that, although i think it kinda sucks.
__________________
1139 Alumni

Last edited by Rickertsen2 : 21-02-2004 at 22:09.
  #6   Spotlight this post!  
Unread 22-02-2004, 03:22
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: Need interupts help, and another question...

Quote:
Originally Posted by Kevin Karan
Im having a problem getting the interupts working on the FRC.
The one thing that comes to mind is to make sure that you also set all interrupt inputs as an INPUT (e.g., digital_io_01 = INPUT) while in User_Initialization(). Other than that, can you be more specific when you say they "don't work". If you're really stuck, send me the code and I'll have a look.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #7   Spotlight this post!  
Unread 22-02-2004, 10:27
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
Re: Need interupts help, and another question...

If you're having problems with interrupts, Daniel Katanski of team 240 wrote an amazingly helpful whitepaper on the topic - I recommend you read the whole thing, as not only it explains in details how to use interrupts and timers, but it also gives some neat programming tricks here and there. I just began using interrupts the other day (after sitting down for a day with that whitepaper and pouring through each line of the default code), so I think other people on this board are going to be more helpful than me in terms of debugging. However, I do want to include this part from the whitepaper:

Quote:
When initializing a digital input interrupt there are 5 things that must be done, they are:
1. Set the port to be an input (as shown in the code above).
2. Set the interrupt on the pin to be a low priority interrupt.
3. Set the edge select (rising from 1 to 0, or falling 0 to 1, remember bit values versus voltages).
4. Clear the interrupt flag.
5. Enable interrupts.
I printed out a copy of that and taped it to the computer monitor. During my debugging stage, I kept on referring back to there to see what I was forgetting - as a beginer, I found that probably the most important part of the entire whitepaper. I would also add "Make sure you call ALL of the necessary initialization functions," but you said you already are doing that.

Although it'll take quite a bit of work to incorporate into your code if you built something off the default IFI code, something that you might also wish to check out is Kevin's heavily annotated interrupt and timer template code. Kevin - you did a great job with your comments on that one - they helped me a lot.
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies

Last edited by DanL : 22-02-2004 at 10:31.
  #8   Spotlight this post!  
Unread 22-02-2004, 11:20
Kevin Karan's Avatar
Kevin Karan Kevin Karan is offline
Linux Guy
AKA: maxdamage
None #0174 (Arctic Warriors)
Team Role: Alumni
 
Join Date: Jan 2003
Location: Liverpool, NY
Posts: 141
Kevin Karan will become famous soon enoughKevin Karan will become famous soon enough
Send a message via AIM to Kevin Karan
Re: Need interupts help, and another question...

thanks everyone, esp SuperDanman and Kevin Watson. I dont have time on the frc again untill tomarrow, so Im going to have to wait to test this untill then, but what I did was strip some of the excess calories from Kevin Watson's interupt template (most of the printf library and some of the leftover first functions in user_routines) then put everything into that. Let you know how it goes.
Thanks for pointing out that whitepaper SuperDanman, helped alot.
__________________
It isnt ALWAYS the programmers falt!
2004: Buckeye team website award
2002: Rutgers semi-finalists
2001: National semi-finalists
2001: Rutgers semi-finalists
1998: Manchester Rookie All-Star Award

Last edited by Kevin Karan : 22-02-2004 at 11:33.
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 13:55.

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