I need a recommendation on how to increase the resolution of the timer functions. I currently use “micros()”.
My application: Six events take place in the outside world which I monitor with digital input pins on the Arduino. The events happen in no particular order. My sketch waits for the first one and reads and saves the current time (via micros). As each subsequent event takes place, it saves the time of each event. The final event happens within about 5ms from the first.
After reading all the event times, I send them up to a PC for postprocessing. The PC thus knows the time interval between events and the order of events. I then reset the sketch to wait for the next set of events. That wait could be many minutes.
The sketch does not use interrupts.
Using “micros()” I only get 4us resolution. Based on when the external events occur within the 4us window, the overall accuracy from the application’s viewpoint works out to +/- 4us.
The basic physics of what the overall problem requires a little bit better resulution. To that end, I have produced a counter board containing about 25 ICs. It runs at 10MHz which is just fine for accuracy. It monitors the outside events directly. As events happen, the counter board strobes the value of its internal clock into latches whose contents can be serially shifted out. The Arduino sketch handles this nicely.
I believe the application can live with plus/minus 1us or, better yet, 500ns.
I want to eliminate the 25 IC counter board. (Cost, hassle, packaging issues.) To do that, I need better resolution from the Arduino. I don’t know how to get it. Any ideas?
Many posts to the forum (and other places) refer to lower level programming available for the Arduino. In particular I see references to constructs like “timer2”. Unfortunately there is no nice, high level user documentation on what these constructs are, how to access them, or how to write additional code to use them. I assume at the hardware level, these are features which exist in the microprocessor but the Arduino developers have chosen (probably very wisely!) not to surface them – not to make available to the users.
Alternatively perhaps someone can suggest a different microcontroller system? Probably key would be an easy to use development environment such as the one that Arduino offers. By easy to use I would include: Integrated edit/compile/download, fully assembled PC board containing the microcontroller and support chips including what’s needed for downloading the program. A godsend would be a true debugger but I can live with print statements.
Feel free to reply to the forum or to me directly via email.
Thanks,
--jim Hahn Hahn_02493@yahoo.com