![]() |
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; |
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) |
Re: programs and timeing.
Quote:
-Kevin |
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))AUTO_SWITCH - is an alias to one of the O/I joystick triggers for testing only. Make sure to remove it before comp. Phil |
Re: programs and timeing.
Quote:
How about this? In main.c: Code:
while (1) /* This loop will repeat indefinitely. */ |
Re: programs and timeing.
Quote:
Code:
if ((autonomous_mode = 0) || (AUTON_SWITCH = 1))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++) ; |
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.
|
| All times are GMT -5. The time now is 04:22. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi