Go to Post The great thing about posting questions here is everybody can see the answers. - Kevin Thorp [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
  #16   Spotlight this post!  
Unread 22-02-2004, 20:53
jacob_dilles's Avatar
jacob_dilles jacob_dilles is offline
Registered User
AKA: theshadow
FRC #0620 (WarBots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Vienna, VA
Posts: 245
jacob_dilles will become famous soon enough
Send a message via AIM to jacob_dilles
Re: sleep()

im sorry that i have to reiterate this, but you CAN NOT stop the program code from looping! no matter if it is with a non exastant "wait()" command or a for loop that devides PI by 100 million 50 thousand times, dont do it! it is much better, and perhaps the only viable solutuion, if you count the loops rather then trying to stop in the middle of one. each loop is ~26 ms. its not that hard to make 1 variable. comon guys.
__________________
--------------------------
"You're not a real programmer until all your sentences end with semicolons;"
  #17   Spotlight this post!  
Unread 22-02-2004, 21:12
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: sleep()

It's not that, it's that the main loop has different iteration times depending on what is executed. Besides, It'd be so much cooller if we got it to work.

And like I said, just put calls to putdata and getdata in the loop.
  #18   Spotlight this post!  
Unread 22-02-2004, 21:21
KevinB's Avatar
KevinB KevinB is offline
Registered User
AKA: Alum
no team
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2001
Location: AL
Posts: 188
KevinB will become famous soon enoughKevinB will become famous soon enough
Send a message via ICQ to KevinB
Re: sleep()

Quote:
Originally Posted by Texan
Note that if you were using this as a timer, it would be different at different battery charges as the controller would run slower.
Ken was right when he said that the timer will always run at the same speed. Texan probably meant that the motors being controlled by the timer would run slower ... which is true.

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.
  #19   Spotlight this post!  
Unread 22-02-2004, 21:22
jacob_dilles's Avatar
jacob_dilles jacob_dilles is offline
Registered User
AKA: theshadow
FRC #0620 (WarBots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Vienna, VA
Posts: 245
jacob_dilles will become famous soon enough
Send a message via AIM to jacob_dilles
Re: sleep()

if your going to the point where the diffrence between 23 and 26 ms matters, then use a timer inturupt. this is not a basic stamp lol
__________________
--------------------------
"You're not a real programmer until all your sentences end with semicolons;"
  #20   Spotlight this post!  
Unread 22-02-2004, 21:33
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
Re: sleep()

Any wait/pause code is the basis of a DriveForTime() Routine
  #21   Spotlight this post!  
Unread 22-02-2004, 21:35
jacob_dilles's Avatar
jacob_dilles jacob_dilles is offline
Registered User
AKA: theshadow
FRC #0620 (WarBots)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Vienna, VA
Posts: 245
jacob_dilles will become famous soon enough
Send a message via AIM to jacob_dilles
Re: sleep()

Quote:
Originally Posted by Astronouth7303
Any wait/pause code is the basis of a DriveForTime() Routine
yesm. i think were arguing the same thing here.
__________________
--------------------------
"You're not a real programmer until all your sentences end with semicolons;"
  #22   Spotlight this post!  
Unread 22-02-2004, 21:56
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
Re: sleep()

Quote:
Originally Posted by Astronouth7303
Any wait/pause code is the basis of a DriveForTime() Routine
What? DriveForTime should do some driving for a given time ... but I don't see how any waiting is implicit in the function. Am I grossly mistaken? You can use a timer interrupt to drive for the specified amount of time, all you do is say:
Code:
if (time_from_start < time_to_drive) { put code to drive here }
else { as you are done driving, move on to the next thing }
Where's the need to wait? If you are 'pausing' (stuck in the loop for some reason), you sure aren't driving. Care to elaborate your thinking on the matter?
  #23   Spotlight this post!  
Unread 23-02-2004, 00:00
KevinB's Avatar
KevinB KevinB is offline
Registered User
AKA: Alum
no team
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2001
Location: AL
Posts: 188
KevinB will become famous soon enoughKevinB will become famous soon enough
Send a message via ICQ to KevinB
Re: sleep()

Although there are easy ways to make the processor "pause" or "wait" as described above, they are probably not the best way to implement this function on the IFI Controller. The Master processor expects to receive a data packet from the user processor every 26.2ms.

This means you cannot pause the controller for longer than 26.2ms at a time and still have the control system function.

The best bet is to increment a counter every time a new data packet is received from the master processor. If you need finer control than that, use a timer interrupt.
  #24   Spotlight this post!  
Unread 23-02-2004, 17:06
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: sleep()

Quote:
Originally Posted by Astronouth7303
It's not that, it's that the main loop has different iteration times depending on what is executed.
Do you mean "execution times"? I take "iteration time" to be the time between iterations of the 26.2 ms loop area. I actually measured this with a scope on Saturday, it was very interesting:

Code:
  while (1)   /* This loop will repeat indefinitely. */
  {

    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. */
      rc_dig_out17 = 1;   // take pin 17 high      
      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 */
    rc_dig_out17 = 0;  // clear pin 17                                      /* I'm fast!  I execute during every loop.*/
  } /* while (1) */
This made a pulse of about 4 ms in duration (the "exectution time" of my code), with a (measured) cycle time ("iteration time") of about 26 ms. Hitting certain buttons would change the 4 ms to something else like 3 ms as my code changed modes, but the period remained 26 ms. It seemed pretty rock-solid. Except when very strange things were happening; see my earlier post on that. But that was something broken.

One reason a delay might be useful is to reduce the frequency of calls to Generate_Pwms(). See the reply from Kevin Watson to the post mentioned above.

-Norm
  #25   Spotlight this post!  
Unread 23-02-2004, 17:12
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: sleep()

Ive been wanting to scope the loop myself, but havent got to it yet- thanks for instrumenting your RC.

One thing I have not been able to figure out. The main loop looks for new input from the OI, and if it doesnt see it, it call the user_fast code

I dont see anything in the fast code to throttle it back - can you put your toggles at the beginning and end of the fast section and see how fast it runs with your scope for us?

I thought they said it runs every 4mS or so, and you have to be carefull not to overwhelm the pwms by changing them too fast - I also think you cannot do a get_analog_value... too quickly either?

but does anyone know - is the fast code loop timed by some event (the get or put data maybe?)

and is its period consistant?

BTW - if you are looking at timing be sure to comment out all your printf statements - there seems to be a whole library of code behind them, I think they will make a drastic reduction in your loop speed.

Last edited by KenWittlief : 23-02-2004 at 17:14.
  #26   Spotlight this post!  
Unread 23-02-2004, 22:22
mtrawls's Avatar
mtrawls mtrawls is offline
I am JVN! (John von Neumann)
#0122 (NASA Knights)
Team Role: Programmer
 
Join Date: Mar 2003
Location: Hampton, VA
Posts: 295
mtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to beholdmtrawls is a splendid one to behold
Send a message via AIM to mtrawls
Re: sleep()

Quote:
Originally Posted by KenWittlief
BTW - if you are looking at timing be sure to comment out all your printf statements - there seems to be a whole library of code behind them, I think they will make a drastic reduction in your loop speed.
I can say from experience that the printf libraries do make a difference. All the "horror" stories my SICP instructor told me a couple of years ago about debug statements causing or removing bugs (the act of observing disturbs the observed?) have come true. Using the timing interrupts and for our auton code (on the EduBot at least), I've come across situations where putting a printf statement causes problems .. and then where it removes them. Needless to say, it was a pain figuring out that the printf statement caused it -- luckily my old teacher had warned me, or I wouldn't have even thunk it.
  #27   Spotlight this post!  
Unread 23-02-2004, 22:30
velocipenguin velocipenguin is offline
Registered User
#0246 (Overclocked)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Boston, MA
Posts: 77
velocipenguin is on a distinguished road
Send a message via AIM to velocipenguin
Re: sleep()

Quote:
Originally Posted by mtrawls
All the "horror" stories my SICP instructor told me a couple of years ago about debug statements causing or removing bugs (the act of observing disturbs the observed?) have come true.
Bugs like those are colloquially known as "Heisenbugs", after Heisenberg's Uncertainty Principle, which states that observing something will alter that which you are trying to observe. They're ever-so-fun to track down.
  #28   Spotlight this post!  
Unread 24-02-2004, 07:42
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: sleep()

putting debug statements in code is a significant change to its content.

HW guys have it even worse - Every HW engineer I know can tell you about some circuit they worked on that they were testing with a scope, and as long as the scope was connected, the circuit worked, but when you remove the probe it stopped working

all due to the slight capacitance of the probe altering the circuit they were trying to see.
  #29   Spotlight this post!  
Unread 24-02-2004, 10:05
gnormhurst's Avatar
gnormhurst gnormhurst is offline
Norm Hurst
AKA: gnorm
#0381 (The Tornadoes)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Trenton, NJ
Posts: 138
gnormhurst will become famous soon enoughgnormhurst will become famous soon enough
Re: sleep()

Quote:
Originally Posted by KenWittlief
I've been wanting to scope the loop myself, but havent got to it yet- thanks for instrumenting your RC.
Thanks, but I got the idea from someone on this forum.

Quote:
One thing I have not been able to figure out. The main loop looks for new input from the OI, and if it doesnt see it, it call the user_fast code.

That took me a little time to figure out. The fast code (Process_Data_From_Local_IO()) is called every loop of the while(1) loop. The "slow" user code is called in addition very occasionally in the while(1) loop when new data is ready (if (statusflag.NEW_SPI_DATA) ).

Quote:
Don't see anything in the fast code to throttle it back - can you put your toggles at the beginning and end of the fast section and see how fast it runs with your scope for us?
I did that, too, at the time, just to see. I didn't measure the rate, but it looked like hundreds of times for each call of Process_Data_From_Local_IO(). An easier, non-scope way would be to run a counter in the main while( 1 ) loop, then print it and reset it just before calling Process_Data_From_Local_IO().

...I was doing integer division in a few places in my joystick calculations and I was worried that my code was too slow, but was relieved to see that it runs in only 4 ms. Whew!
  #30   Spotlight this post!  
Unread 24-02-2004, 11:10
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: sleep()

Don't worry - for the most part, integer division is just fine. It's only when you get into floating-point numbers that math operations start to kill you.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
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
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


All times are GMT -5. The time now is 03:07.

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