|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
programs and timeing.
I am writing a autonomous function and I need to know if
there is a function or command that returns the time. elapsed time or just the current time is ok. I will call this command from with in the fast.c program. In C there is the function clock() but it requires the <time.h> file as an include file. This file is not with our software for this robot. Also I need a function to pause the program. In assembly I beleive the command "pause" does this but I need to do it in C. Thanks; |
|
#2
|
||||
|
||||
|
Re: programs and timeing.
There are library timers included with the compiler. Look in the attched file to find out how to use them. (Look for the timers section)
I'm not sure of how you are thinking of doing the pause, but you'll have to make sure that get/putdata() is called at least every 26.2ms or the master processor on the RC will halt the program. --EDIT-- Oh, yeah, since you at least konw what asembly is: to do asembly instructions in C do something like: Code:
asm asmembly instruction; The file is too large to upload, but it can be found on the microchip website. (Don't remember where exactly) Last edited by Ryan M. : 19-02-2004 at 14:42. |
|
#3
|
||||
|
||||
|
Re: programs and timeing.
Quote:
-Kevin |
|
#4
|
||||
|
||||
|
Re: programs and timeing.
Why do you need to pause the program?
For testing purposes? If so, you can code a switch, when closed allows the code to execute, when released if stops. Code:
if ((autonomous_mode = 0) || (AUTON_SWITCH = 1))
{
execute auton code
}
![]() AUTO_SWITCH - is an alias to one of the O/I joystick triggers for testing only. Make sure to remove it before comp. Phil |
|
#5
|
|||||
|
|||||
|
Re: programs and timeing.
Quote:
How about this? In main.c: Code:
while (1) /* This loop will repeat indefinitely. */
{
#ifdef _SIMULATOR
statusflag.NEW_SPI_DATA = 1;
#endif
if (!PAUSE_SWITCH)
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{ /* I'm slow! I only execute every 26.2ms because */
/* that's how fast the Master uP gives me data. */
Process_Data_From_Master_uP(); /* You edit this in user_routines.c */
if (autonomous_mode) /* DO NOT CHANGE! */
{
User_Autonomous_Code(); /* You edit this in user_routines_fast.c */
}
}
Process_Data_From_Local_IO(); /* You edit this in user_routines_fast.c */
/* I'm fast! I execute during every loop.*/
}
} /* while (1) */
|
|
#6
|
||||
|
||||
|
Re: programs and timeing.
Quote:
Code:
if ((autonomous_mode = 0) || (AUTON_SWITCH = 1))
{
execute auton code
}
Quote:
I'd carefully analyze why you want to pause. But there are several ways to go about it -- you have a timer interrupt, so you can program a pause function easily enough to pause for a given amount of time. A quick solution, if that's all you need it for, is just to have an empty for loop that executes some pre-determined amount. e.g., Code:
for (waste_time = 0; waste_time < TIME_TO_WASTE; waste_time++) ; // remember: declare waste_time elsewhere, and define TIME_TO_WASTE |
|
#7
|
||||
|
||||
|
Re: programs and timeing.
note that if you pause the robot, you should still be calling putdata every 26.2ms, otherwise the frc will shut down.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|