|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
sleep()
In our code, we want to use the sleep() function. When we try to compile we get an error saying it can't find the function sleep(). What would we need to include in order to get this to work?
|
|
#2
|
||||
|
||||
|
Re: sleep()
I dont think you want to use any of the sleep modes - there is code that has to run for the RC to function correctly - the code runs in one continious loop - if you put the uP to sleep, it will stop till an interrupt occurs - I think it would cause the RC to lock up or reset on you.
Sleep modes are normally for low power applications, like PDAs or cell phone - your bot will be drawing 50 to 100 amps during a match, so whats 0.1 Amps more or less going to accomplish? |
|
#3
|
||||
|
||||
|
Re: sleep()
what about a pause function? Same results?
|
|
#4
|
||||
|
||||
|
Re: sleep()
same problem, you have to let the main loop run, or the code that is buried in the RC (that we dont see) will say "hey, the user code stopped running, turn off all the victors and relays until it comes back"
( of course it says that in binary: 00011000101010101101101 :c) |
|
#5
|
||||
|
||||
|
Re: sleep()
I was just informed it will be sleep(1); will that 1 millisecond make a difference and cause those problems?
|
|
#6
|
||||
|
||||
|
Re: sleep()
What you could do(for autononmous) was have a start time and an end time to all things. Sort of like this:
Code:
//Autonomous code go(1,0,18); //Go forward (1 = fwd, 2 = rev), start at 0, and end at 1800ms turn(1,19,25); //Turn (1 = left, 2 = right), start at 1900ms end at 2500ms //Notice the 1000ms delay! moveArm(2,35,40); //Move arm ( 1 = up, 2 = down), start at 3500ms end at 4000ms |
|
#7
|
|||||
|
|||||
|
Re: sleep()
So is there a way to 'wait' while still having interrupts going? this would be the easiest way to write a Autonomous Script. You know, Left=255;Right=255;Wait(600);.
|
|
#8
|
||||
|
||||
|
Re: sleep()
Quote:
|
|
#9
|
|||||
|
|||||
|
Re: sleep()
There's something called a "FOR LOOP". In this loop, you can specify how long it stays in the loop. You could increment a variable there if you wanted to 'wait' for a certain amount of time. Or, you could use what we like to call a "TIMER". Timers count time. Time can be used for waiting.
Maybe you should be a little more specific on what you're trying to do. |
|
#10
|
||||
|
||||
|
Re: sleep()
Quote:
|
|
#11
|
||||
|
||||
|
Re: sleep()
Quote:
Code:
for(initiazation; test; increment)
{
// body of loop
}
Code:
// Somewhere at the top
unsigned int i;
// Later on
for(i = 0; i < 10; i++)
{
// Do nothing
}
Note that if you were using this as a timer, it would be different at different battery charges as the controller would run slower. Anyways, if anyone cares, there it is. |
|
#12
|
|||||
|
|||||
|
Re: sleep()
instead of going to sleep, i would count loops till the required delay has passed. stoping a program is a bad thing, just because of the way the program loop is structured. if that doesnt work, i would use a timer with an inturupt.
|
|
#13
|
||||
|
||||
|
Re: sleep()
Quote:
Getting back to the original focus of this post ... why do you want a sleep function? If you post the reason for your request for a sleep function, you'll probably get much better help. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How much sleep are you going to get??? | ttedrow | General Forum | 34 | 11-01-2004 02:27 |
| Sing me a SONG! | Biggs717 | Chit-Chat | 78 | 09-05-2003 07:59 |
| Sweet sweet sleep | DavidAusTex | General Forum | 26 | 25-02-2003 00:38 |
| LET ME SLEEP!!!!! | archiver | 2001 | 2 | 24-06-2002 01:08 |
| Speaking of sleep and dew....see the pic... | archiver | 2001 | 3 | 24-06-2002 00:54 |