Go to Post ...he's acting like a programmer whose code is compiling...:yikes: - EricH [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 08-12-2003, 21:26
thoughtful's Avatar
thoughtful thoughtful is offline
Registered User
FRC #1219 (Emery Iron Eagle)
Team Role: Alumni
 
Join Date: Nov 2003
Location: Toronto,Canada
Posts: 291
thoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to beholdthoughtful is a splendid one to behold
Question What type of timers for autonomous?

Hey,
i read the white papers document on innovationfirst.com, n e ways i wanted to know if there are n e other ways of using real timers(not counters), And it will be really good if someone gives an short example
__________________
.:Bringling Brains to Life:.

03,04,05-Team 1219 Captain
2003 Rookie all Start @ GTR
2005 Galileo Semi-Finalist & Alliance captain
06-Team 1219 Mentor
2006 Radio Shack Innovation in control @ Waterloo
  #2   Spotlight this post!  
Unread 09-12-2003, 02:28
Jay Lundy Jay Lundy is offline
Programmer/Driver 2001-2004
FRC #0254 (The Cheesy Poofs)
Team Role: Alumni
 
Join Date: Jun 2001
Rookie Year: 2001
Location: Berkeley, CA
Posts: 320
Jay Lundy is a name known to allJay Lundy is a name known to allJay Lundy is a name known to allJay Lundy is a name known to allJay Lundy is a name known to allJay Lundy is a name known to all
Re: What type of timers for autonomous?

Quote:
Originally Posted by thoughtful
Hey,
i read the white papers document on innovationfirst.com, n e ways i wanted to know if there are n e other ways of using real timers(not counters), And it will be really good if someone gives an short example
Well, a timer really is just a counter, except you know there is a constant interval between increments, so you can get how much time has passed from the counter.

For autonomous mode, probably the best way to do it would be to set up a global timer with ms resolution. I used timer2 for this rather than timer1. Timer2 is easier to work with (8 bits rather than 16 bits) and easier to set up.

For ms resolution, set up timer2 as follows:
prescaler = 4
postscaler = 10
compareVal = 249

Use this equation to determine output freq:
Fosc Hz / 4 / prescaler / (compareValue + 1) / postscaler = out Hz

If you plug in the above values (Fosc = 40 MHz) you get 1 kHz, or 1000 cycles per second, or 1 cycle per ms.

Then just make sure you enable the interrupt and catch the interrupt flag and increment a global unsigned long int.

You can use that global variable anywhere in the program much the same way you would use TimeGetTime() in windows or System.getCurrentTimeMillies() in Java. It is the number of ms since your program started.

By the way, with a unsigned long your timer will overflow after 1193 hours. If you want to save a byte you can use an unsigned short long which will last 4.66 hours.
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
Moveable Type Sunny Thaper Website Design/Showcase 23 19-10-2003 01:17
Segway Type R fast frank Dean Kamen's Inventions 7 05-09-2002 14:44
Can I use any type of switch on my controler interface? archiver 2001 5 23-06-2002 23:09
WASH scouting fields Mike Soukup Scouting 0 04-02-2002 02:39
What will be the most effective robot type this year Rick General Forum 8 13-01-2002 22:10


All times are GMT -5. The time now is 19:58.

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