![]() |
Commands
Hello!
I'm searching after the delay command (or the equivalent) in C. I'm sorry if it has been asked before but I hadn't found what I need with the "search"). Thanks allot, Ben Barchechath.:) |
Re: Commands
EasyC has a "Wait" function, however, the MPLAB C version default code cannot accommodate a lengthly delay. Any substantial delay in that version causes the processor to be disabled.
If you have a specific need we can suggest typical alternatives. |
Re: Commands
We are using the same switch of the joystick to do two jobs.
I some need kind of delay because when i press the button once the robot doing the open and close command too fast. And that is why i am searching for a delay of something like two seconds. P.S. I'm using the MPLAB. Thanks. |
Re: Commands
What is it that you're actually trying to do? There's no "wait" command but if you describe what you're trying to do, perhaps we can find an alternative way to do what you want.
|
Re: Commands
Quote:
1) You can program the joystick button to act one way when you hold it down and do the opposite when you let it go. For instance, close when you hold the button and open only when you release the button. 2) You can program the button to toggle so you have to push it and let go each time you want it to do something. For instance, push once and let go for close, then push once again to open. Either of these fit what you are trying to do? |
Re: Commands
There are two different types of delays: blocking and non blocking. A blocking delay halts execution of EVERYTHING for that amount of time. A non-blocking delay only affects a small portion of the code.
I believe you are looking for a non-blocking delay. I would suggest adding a counter to your code that increments at the top of the control loop. Code:
time_counter+=1;If you are looking for a blocking delay, you have several options, two of which I have outlined below. The simple (read "simple"" as "bad") way is to simply spin in a loop. Code:
for(i=0;i<DELAY_TIME;i++);Quote:
|
Re: Commands
Quote:
A two second delay would be way too long. |
Re: Commands
Quote:
If that doesn't sound like what you need, please give some more detail about what you want the button to do. |
| All times are GMT -5. The time now is 04:44. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi