Go to Post I suggested it in brainstorming, but then people threw things at me. Apparently there ARE bad ideas in brainstorming. - Kevin Sevcik [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
  #1   Spotlight this post!  
Unread 05-02-2007, 14:56
Barchechath Barchechath is offline
Registered User
AKA: Ben Barchechath
FRC #1580
Team Role: Programmer
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Ashqelon Israel
Posts: 5
Barchechath is an unknown quantity at this point
Send a message via ICQ to Barchechath Send a message via MSN to Barchechath
Question 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.
  #2   Spotlight this post!  
Unread 05-02-2007, 15:07
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,801
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: 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.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #3   Spotlight this post!  
Unread 05-02-2007, 15:26
Barchechath Barchechath is offline
Registered User
AKA: Ben Barchechath
FRC #1580
Team Role: Programmer
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Ashqelon Israel
Posts: 5
Barchechath is an unknown quantity at this point
Send a message via ICQ to Barchechath Send a message via MSN to Barchechath
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.
__________________
Ben Barchechath
  #4   Spotlight this post!  
Unread 05-02-2007, 15:32
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,801
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: Commands

Quote:
Originally Posted by Barchechath View Post
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.
A couple of possible variations come to mind.

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?
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 05-02-2007 at 15:40.
  #5   Spotlight this post!  
Unread 05-02-2007, 18:55
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Commands

Quote:
Originally Posted by Barchechath View Post
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.
If I understand your needs properly, Eric is correct: what you want is a counter. Process_Data_From_Master_uP() is executed about every 26 milliseconds. Check the state of the button in that routine (or in another routine called from it). If the button is pressed, increment the counter; if the button is not pressed, set the counter to zero. If the counter reaches 76, you know the button has been held for two seconds, and you can take some action.

If that doesn't sound like what you need, please give some more detail about what you want the button to do.
  #6   Spotlight this post!  
Unread 05-02-2007, 15:29
ay2b's Avatar
ay2b ay2b is offline
Registered User
AKA: Andy
FRC #2928
Team Role: Mentor
 
Join Date: Mar 2004
Rookie Year: 1994
Location: Seattle, WA
Posts: 211
ay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant futureay2b has a brilliant future
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.
__________________

2011 - SD Quarterfinalists (980), LA Quarterfinalists (980)
2010 - LA (2404) Finalists (980), AZ Motorola Quality (980)
2009 - LA Semifinalists (980); Las Vegas Quarterfinalists (980); SD (2404); IRI #1 Seed, Finalist (980)
2008 - SD Quarterfinalists (980), LA Champions (980), LA Rookie Inspiration Award (2404); CalGames Finalists
2007 - So.Cal Finalists (980), SD Quarterfinalists (980); CalGames Finalists
2006 - So.Cal Regional Champion (4), Toronto Judge's Award Day 1 (4)
2005 - SVR Champions, Delphi "Driving Tomorrow's Technology" (980); AZ Xerox Creativity (980); So.Cal Finalists, RadioShack Innovation in Control (980); Championship Archimedes Division Semifinalists; IRI Finalists (980)
2004 - So.Cal Regional Champions, Leadership in Controls (980); AZ GM Industrial Design (980); Championship Galileo Division #2 Seed; IRI Champions
2003 - PNW Semi-finalists (488)
2002 - PNW Finalists (488)
2000 - X-bot / 488 - Mentor / Founder
1994 - Sunny Delight - Driver - champion
  #7   Spotlight this post!  
Unread 05-02-2007, 15:35
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
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(button_pressed && time_counter>desired_delay)
    do stuff;
    time_counter=0;

rest of code
desired_delay would be equal to the amount of time you want to delay in seconds divided by the frequency of your control loop. I think that frequency is 40Hz, but please someone correct me. Therefore, desired_delay = 2seconds / 40 Hz = 80.

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++);
This is bad for many reasons, but is useable as a quick and dirty solution for small delay times, as would be seen for hacking out a bad bit banger for serial comm.

Quote:
Originally Posted by Mark McLeod View Post
Any substantial delay in that version causes the processor to be disabled.
I am guessing that this means that there is a watchdog that is timing out. If you really want to, you could delay, pet the watchdog, delay some more, pet him again, delay more, etc. When you get to this point, you are probably doing something wrong.
  #8   Spotlight this post!  
Unread 05-02-2007, 15:46
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,801
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: Commands

Quote:
Originally Posted by EricVanWyk View Post
I am guessing that this means that there is a watchdog that is timing out.
Yes, the Master processor watches our User processor closely. If we don't talk back to it and miss a couple of communication packets (38 per second) then it shuts us down and displays the red OI "Code Error" LED of death.
A two second delay would be way too long.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
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
Relay Commands Matt Krass Programming 6 18-02-2006 23:03
Serial Commands on MPLAB tribotec_ca88 Programming 2 24-01-2006 16:26
at commands in c++ daroch Programming 1 04-03-2005 01:01
Kevin's Commands.h?? kshot Programming 3 17-02-2005 17:12
Voice Activated commands Amber H. Technical Discussion 40 03-11-2002 12:40


All times are GMT -5. The time now is 04:44.

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