|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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 ![]() |
|
#2
|
|||
|
|||
|
Re: What type of timers for autonomous?
Quote:
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |