Go to Post Oh and don't mind the lightening holes. Thats just how I waste time when I get bored :P - SerpentEagle [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 19-02-2004, 15:42
zainali's Avatar
zainali zainali is offline
Registered User
AKA: Syed Zain Ali
#1241 (Theory 6)
Team Role: Engineer
 
Join Date: Feb 2004
Location: Mississauga
Posts: 19
zainali is an unknown quantity at this point
question about autonomous timing

im bit confused about 26.2 ms loop area part

does that mean 1 = 26.2 ms when i set up a counter or something?
__________________
Rick Hansen Secondary School
Team 1241
www.Theory6.org

GO LEAFS GO
  #2   Spotlight this post!  
Unread 19-02-2004, 16:31
steven114 steven114 is offline
Programming Wizard and Team Captain
AKA: Steven Schlansker
FRC #0114 (Eaglestrike)
Team Role: Programmer
 
Join Date: Feb 2004
Location: Los Altos, CA
Posts: 335
steven114 is a jewel in the roughsteven114 is a jewel in the roughsteven114 is a jewel in the rough
Send a message via AIM to steven114
Re: question about autonomous timing

Quote:
Originally Posted by zainali
im bit confused about 26.2 ms loop area part

does that mean 1 = 26.2 ms when i set up a counter or something?
It means that the code within that area is executed approx. every 26.2ms, so if you increment a variable it should indicate time in approx. 26.2ms steps.
  #3   Spotlight this post!  
Unread 19-02-2004, 19:54
mightywombat's Avatar
mightywombat mightywombat is offline
bins? stacking?? NOOOOO!
AKA: Bill Rosemurgy
#0857 (Superior Roboworks)
Team Role: Programmer
 
Join Date: Dec 2003
Location: Houghton, MI
Posts: 93
mightywombat is on a distinguished road
Re: question about autonomous timing

a better way to set up a timer, if you are comfortable with it, is to use the processor interrupts. www.kevin.org/frc has some sample code that can be cut and pasted into your code. I knew nothing about interrupts and timers and such and after a few hours staring blindly at the screen everything clicked. its really sweet how everything works. search chiefdelphi for other threads related to interrupt driven timers
__________________
Bill Rosemurgy - Aspiring Programmer and Human Player (stack of 8 in <10 seconds...oh yeah... but I can't shoot for crap.)
www.team857.com
  #4   Spotlight this post!  
Unread 21-02-2004, 11:08
Jeff McCune's Avatar
Jeff McCune Jeff McCune is offline
Alpha Geek
#0677 (The Wirestrippers)
Team Role: Mentor
 
Join Date: Jan 2003
Location: The Ohio State University
Posts: 67
Jeff McCune is on a distinguished road
Send a message via ICQ to Jeff McCune Send a message via AIM to Jeff McCune
Re: question about autonomous timing

Quote:
Originally Posted by mightywombat
a better way to set up a timer, if you are comfortable with it, is to use the processor interrupts. www.kevin.org/frc has some sample code that can be cut and pasted into your code. I knew nothing about interrupts and timers and such and after a few hours staring blindly at the screen everything clicked. its really sweet how everything works. search chiefdelphi for other threads related to interrupt driven timers
Interrupts can be very dangerous and difficult to debug. I wouldn't recommend their use for rookie teams, espically at this late date.
__________________
Team 677 - The Wirestrippers - Columbus School for Girls and The Ohio State University
EMAIL: mccune@ling.ohio-state.edu

...And all you touch and all you see
Is all your life will ever be...
  #5   Spotlight this post!  
Unread 23-02-2004, 15:12
tml240's Avatar
tml240 tml240 is offline
bahh
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: Ann Arbor, MI
Posts: 63
tml240 is on a distinguished road
Re: question about autonomous timing

i want to know what 1 second equals to in this part
1000?
400?

what is it!?!?!?
__________________

OHL 2004- ultimate NHL 2004 MOD
  #6   Spotlight this post!  
Unread 23-02-2004, 16:16
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: question about autonomous timing

Quote:
Originally Posted by tml240
i want to know what 1 second equals to in this part
1000?
400?

what is it!?!?!?
The processor runs at 10 MHz, 10,000,000 clock cycles per second. The joystick info (etc) is only updated every 10 MHz / (2^18). That's 10,000,000 divided by 2 raised to the 18th power. 2^18 is 262144. So 10,000,000 divided by 262144 is 38.1469... cycles per second. One cycle has a duration of 1 / 38.14... = 0.0262144 second, or 26.2 milliseconds (ms).

So in one second, there are 38 or 39 cycles of the "main loop".

You can pre-calculate certain fixed periods of time (using pocket calculator or the Windows calculator accessory, not the robot controller), converting from seconds to cycles of 38 Hz:

To know when a certain pre-determined amount of time has passed, say, 11.7 seconds, figure out how many counts that would be:

11.7 / .0262144 = 446.3195801

and round to the nearest integer, because the controller works fastest with integers: 446.

A quicker way? Mutliply seconds by 38:

11.7 * 38 = 444.60000

which is 445 when rounded. A little different than 446. An even faster way that you could do in your head:

11.7 * 38 is about: 12 * 40 = 480

Close enough? Think like an engineer and make that decision yourself!

Remember, to count these cycles, declare a "static" variable. "static" means that the variable isn't lost every 26.2 ms cycle, which could happen otherwise.

Code:
static unsigned int cycleCounter = 0;
You might have some code that looks like this:

Code:
  if ( cycleCounter < 446 )
  {
    // this part gets used for the first 11.7 seconds
  }
  else
  {
    // this part gets used after the first 11.7 seconds has passed.
  }

  cycleCounter++;  // increase the cycle counter by 1.
-Norm

Last edited by gnormhurst : 23-02-2004 at 16:30.
  #7   Spotlight this post!  
Unread 23-02-2004, 22:58
tml240's Avatar
tml240 tml240 is offline
bahh
no team
Team Role: Alumni
 
Join Date: Jan 2004
Rookie Year: 2003
Location: Ann Arbor, MI
Posts: 63
tml240 is on a distinguished road
Re: question about autonomous timing

oooo ok thx for clearing that up
__________________

OHL 2004- ultimate NHL 2004 MOD
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
A better autonomous method.. randomperson Programming 4 24-02-2004 18:02
Initializing autonomous mode Mr. Lim Programming 7 02-02-2004 07:26
variable? manodrum Programming 11 01-04-2003 17:20
autonomous mode problem on field Chris_C Programming 17 26-03-2003 19:11
Autonomous Kill Switch UCGL_Guy Programming 8 15-01-2003 17:39


All times are GMT -5. The time now is 23:57.

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