Go to Post As it stands your design defies physics (and breaks 1 of Karthik's 2 Golden Rules). - JesseK [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
  #16   Spotlight this post!  
Unread 11-03-2004, 18:36
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: quick question: TIMERS

Yes, it does have timers (4), but I couldn't figure out how to use them, and didn't feel the need to try much. If someone knows how, those would also work.
__________________

  #17   Spotlight this post!  
Unread 11-03-2004, 23:14
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: quick question: TIMERS

Quote:
Originally Posted by Texan
Yes, it does have timers (4), but I couldn't figure out how to use them, and didn't feel the need to try much. If someone knows how, those would also work.
Have a look at the two clock programs that I wrote and posted here. Comments within the code will show you where to place your own test code. If you run into problems, just leave a note here and we'll help you out.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #18   Spotlight this post!  
Unread 12-03-2004, 07:35
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: quick question: TIMERS

I have had problems with interupts.c and timers. I use Timer 2 (and/or 1) to increment a variable and if that variable overflows, it increments another one. The problem is that I can't ever seem to get either to change. Help?
  #19   Spotlight this post!  
Unread 12-03-2004, 10:00
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,825
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: quick question: TIMERS

Quote:
Originally Posted by Astronouth7303
I have had problems with interupts.c and timers. I use Timer 2 (and/or 1) to increment a variable and if that variable overflows, it increments another one. The problem is that I can't ever seem to get either to change. Help?
Sounds like the timers haven't been enabled in your initialization code.

Here's a sample initialization of Timer 4 to cause a 4ms interrupt.
Code:
OpenTimer4(TIMER_INT_ON &
	  T4_PS_1_16 &
	  T4_POST_1_10);
WriteTimer4(6); /* Preload timer to overflow after 4ms */
Here's the corrsponding user_routines_fast.c interrupt code.
Code:
unsigned long Clockms; // 1 millisecond clock
unsigned long Clockcs; // 100 millisecond
unsigned long Clocksec; // 1 second clock
 
static unsigned char t100ms=0;
static unsigned int t1sec=0;
 
...
 
else if (PIR3bits.TMR4IF) /* TIMER 4 INTERRUPT */
{
  /** This provides us with a clock for timing events **/
  PIR3bits.TMR4IF = 0; /* Clear Timer interrupt flag */
  WriteTimer4(6);	/* Reset Timer to overflow at 4ms */
  Clockms += 4; /* milliseconds */
  if (++t100ms >= 25)
  {
	t100ms = 0;
	Clockcs++; /* tenths of seconds */
	if (++t1sec >= 10)
	{
	  t1sec = 0;
	  Clocksec++; /* seconds */
	}
  }
}
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 12-03-2004 at 10:13.
  #20   Spotlight this post!  
Unread 12-03-2004, 10:29
10intheCrunch's Avatar
10intheCrunch 10intheCrunch is offline
Who's John V-Neun?
AKA: Alex Baxter
None #0254 (Cheesy Poofs)
Team Role: College Student
 
Join Date: Feb 2004
Rookie Year: 2004
Location: San Jose, CA
Posts: 129
10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough
Send a message via AIM to 10intheCrunch
Re: quick question: TIMERS

Quote:
Originally Posted by Astronouth7303
I have had problems with interupts.c and timers. I use Timer 2 (and/or 1) to increment a variable and if that variable overflows, it increments another one. The problem is that I can't ever seem to get either to change. Help?
Why not just use a long? You won't overflow it (depending on the timer you use you'll have a couple thousand hours of timer before the long cycles).
__________________
~Alex Baxter
Programming, Arms operation, Team 254
  #21   Spotlight this post!  
Unread 12-03-2004, 11:20
Xufer's Avatar
Xufer Xufer is offline
8 Seasons and as stable as ever
AKA: Working, 2/4 degrees complete still schooling...
FRC #1740 (The Cyber Colonels)
Team Role: Engineer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Waterford, CT
Posts: 231
Xufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to behold
Send a message via AIM to Xufer Send a message via MSN to Xufer Send a message via Yahoo to Xufer
Re: quick question: TIMERS

now if i was to use the timers that kevin has on his site inorder to do a dedreckoning autonomus what would it look like ? I begin to have a little more trouble when the interrupts are thrown in there i looked through the actuall clock.c file and the user_routines_fast.c file how would i specify time lengths for an action ? Im not too sure how the interupts work i read the first white paper on them but my understanding of them are still kinda wavy.
__________________


If saftey is first and i put FIRST ahead of everything, then i must be the safest guy in the world.

Team 521 Alumni -- Team 1740 Mentor-- Go Go 1740!
Sometimes I think I've been doing this too long and other times I think I haven't done this enough... but all the times I'm sure I'm crazy
Photonics, It's Your Future
  #22   Spotlight this post!  
Unread 12-03-2004, 11:42
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,825
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: quick question: TIMERS

Quote:
Originally Posted by Xufer
now if i was to use the timers that kevin has on his site inorder to do a dedreckoning autonomus what would it look like ? I begin to have a little more trouble when the interrupts are thrown in there i looked through the actuall clock.c file and the user_routines_fast.c file how would i specify time lengths for an action ? Im not too sure how the interupts work i read the first white paper on them but my understanding of them are still kinda wavy.
In Kevin's examples you can use the "Clock" variable as your check.
e.g.,
Code:
if (Clock < 10) // Clock is in tenths of seconds
	// Do first thing
else if (Clock < 30) // @ 3 second
	// Do another thing
else if (Clock < 60) // @ 6 seconds
	// Keep adding stuff to do
.
.
.
else if (Clock < 150) // @ 15 seconds
	// Make sure you stop all engines at the end
There are lots of other autonomous examples spread through the forums.

[edit] Corrected the ">" , typed too freely. Thanks Jamie!
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 12-03-2004 at 19:08.
  #23   Spotlight this post!  
Unread 12-03-2004, 13:49
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: quick question: TIMERS

The timer (1-4, actually) is initialized, and I have checked the enabled bit. The overflow variable (a char) is to slow it down. I send the long both over the terminal and through the dashboard. Both always say 0. The code looks like it should work, but doesn't. This is my ISR:
Code:
extern char TICK;
extern long TIME;
extern long AUTOCLOCK;

void Timer_1_Int_Handler(void)
{
 TICK++;
 if (TICK == 255)
 {  TIME++; }
 AUTOCLOCK++;
}
Also, have "Clock > 150" first and "Clock > 0" last (Descending order), I found this out in some EDU trials. "Clock > 0" will be true if "Clock > 150", so if >0 is before >150, >150 never happens because >0 does.
  #24   Spotlight this post!  
Unread 12-03-2004, 14:35
jacob_dilles's Avatar
jacob_dilles jacob_dilles is offline
Registered User
AKA: theshadow
FRC #0620 (WarBots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Vienna, VA
Posts: 245
jacob_dilles will become famous soon enough
Send a message via AIM to jacob_dilles
Re: quick question: TIMERS

make sure its not only enabled, but i think you have to start it too
__________________
--------------------------
"You're not a real programmer until all your sentences end with semicolons;"
  #25   Spotlight this post!  
Unread 12-03-2004, 15:22
Xufer's Avatar
Xufer Xufer is offline
8 Seasons and as stable as ever
AKA: Working, 2/4 degrees complete still schooling...
FRC #1740 (The Cyber Colonels)
Team Role: Engineer
 
Join Date: Jan 2003
Rookie Year: 1999
Location: Waterford, CT
Posts: 231
Xufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to beholdXufer is a splendid one to behold
Send a message via AIM to Xufer Send a message via MSN to Xufer Send a message via Yahoo to Xufer
Re: quick question: TIMERS

i got kevins interrupt code and i looked through it, how do i call one of the timers to start counting ? then how would i implement it into autonomus ?
__________________


If saftey is first and i put FIRST ahead of everything, then i must be the safest guy in the world.

Team 521 Alumni -- Team 1740 Mentor-- Go Go 1740!
Sometimes I think I've been doing this too long and other times I think I haven't done this enough... but all the times I'm sure I'm crazy
Photonics, It's Your Future
  #26   Spotlight this post!  
Unread 12-03-2004, 15:27
10intheCrunch's Avatar
10intheCrunch 10intheCrunch is offline
Who's John V-Neun?
AKA: Alex Baxter
None #0254 (Cheesy Poofs)
Team Role: College Student
 
Join Date: Feb 2004
Rookie Year: 2004
Location: San Jose, CA
Posts: 129
10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough10intheCrunch is a jewel in the rough
Send a message via AIM to 10intheCrunch
Re: quick question: TIMERS

Call the start method in the User_Initialization function (Timer2Start() or Timer4Start() or whatever it is). Then, use the state machines that we told you about in the first page of this thread. In the StateInit() function, set a new variable like StartTime or something to keep track of where the timer was when you moved into the next state. Then just subtract the start from the actual, and when that value is larger than the one you want (how long you want to stay in the state), move to the next state and call the Init function.
__________________
~Alex Baxter
Programming, Arms operation, Team 254
  #27   Spotlight this post!  
Unread 12-03-2004, 18:02
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: quick question: TIMERS

Initialize_Timer_X, And you have to modify the line that reads: TxCONbits.TMRxON = 0; to TxCONbits.TMRxON = 1;, else the timer won't go.
  #28   Spotlight this post!  
Unread 12-03-2004, 19:28
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,825
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: quick question: TIMERS

Quote:
Originally Posted by Astronouth7303
The timer (1-4, actually) is initialized, and I have checked the enabled bit. The overflow variable (a char) is to slow it down. I send the long both over the terminal and through the dashboard. Both always say 0. The code looks like it should work, but doesn't. This is my ISR:
Code:
extern char TICK;
extern long TIME;
extern long AUTOCLOCK;
 
void Timer_1_Int_Handler(void)
{
TICK++;
if (TICK == 255)
{ TIME++; }
AUTOCLOCK++;
}
Fixed my earlier post. Thanks for noticing my error.

Your code looks file of course.
Have you tried displaying TICKS on the dashboard or terminal to see if it is also not getting incremented?
I have to run now, but I'll be back later and try to duplicate what you did in a test program.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #29   Spotlight this post!  
Unread 12-03-2004, 20:00
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: quick question: TIMERS

Quote:
Originally Posted by Mark McLeod
Your code looks file of course.
Have you tried displaying TICKS on the dashboard or terminal to see if it is also not getting incremented?
I have to run now, but I'll be back later and try to duplicate what you did in a test program.
Not incrementing. Here's the declarations (In Variables.h, which is included in Interupts.c)
Code:
extern long TIME;
extern long AUTOCLOCK;
extern char TICK;
They are actually defined in Variables.c.

The User_Routines_Fast.c Interuptor (Actually executed by proc) is this, just to check:
[code]#pragma code InterruptVectorLow = LOW_INT_VECTOR

void InterruptVectorLow (void)
{
_asm
goto InterruptHandlerLow // jump to InterruptHandlerLow()
_endasm
}

#pragma code

//...

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

void InterruptHandlerLow()
{
//...
}[/check]

I didn't edit this (to my knowledge ), so I can't imagine that would be it. The code is compiling fine, no errors or warnings.
  #30   Spotlight this post!  
Unread 12-03-2004, 20:03
jacob_dilles's Avatar
jacob_dilles jacob_dilles is offline
Registered User
AKA: theshadow
FRC #0620 (WarBots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Vienna, VA
Posts: 245
jacob_dilles will become famous soon enough
Send a message via AIM to jacob_dilles
Re: quick question: TIMERS

Quote:
Originally Posted by Astronouth7303
Initialize_Timer_X, And you have to modify the line that reads: TxCONbits.TMRxON = 0; to TxCONbits.TMRxON = 1;, else the timer won't go.
this is what im talking about. just set TxCONbits.TMRxON = 1 when you want it to start, and TxCONbits.TMRxON = 0 when you want it to stop. if you put this line outside of the while(auton) loop (before and after respectivly), it will work perfectly
__________________
--------------------------
"You're not a real programmer until all your sentences end with semicolons;"
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
Quick Question Burgabot Programming 31 02-12-2003 19:22
Quick <hr> question Jack Website Design/Showcase 1 31-01-2003 22:19
A quick question Joelster Technical Discussion 6 10-02-2002 09:09
quick question about qualifying points Hymnson General Forum 4 25-09-2001 21:19
Quick Question, i guess Andrew Rudolph Motors 1 12-08-2001 14:39


All times are GMT -5. The time now is 12:47.

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