Pages: [1]   Go Down
Author Topic: "Virtual" Timer Template Sketch  (Read 1979 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi.
I'm an industrial control systems integrator. Have been since Noah was playing with toy boats, it seems, and i program PLC's for my bread and butter. Back in the day, i spent many hours programming PC's in C. Other languages too, but C was always my favorite.

One of my clients keeps bending my ear about converting one of his mills to CNC, cheaply of course. I happened on the Arduino with the 3 axis stepper shield and the grbl library, which is about as cheap as it gets. I cut my teeth on CNC systems and that combination simply blew me away.

Anyway, thinking to get up to speed with the Arduino, i thought i'd code a template sketch using a timed interrupt to drive any number of "virtual" timers. I call virtual timers those that are software driven. I used to do this on PC's - taking control of the system timer, and reprogramming it to "tick" every millisecond, instead of 18.2 times per second.

I've attached the sketch. It doesn't do much, in fact it's not connected to the outside world in any way, but it may be useful as a starting point for sketches requiring more timers than the hardware provides. It does count the number of loop() scans per second, which is always useful info, and i have two timers set up for lamp flashing.

Jeff

* TimerTemplate_0001.pde (2.75 KB - downloaded 16 times.)
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13705
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Maybe you should provide some more example sketches with "real life problems" to show its value ...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Edison Member
*
Karma: 19
Posts: 1041
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That looks exactly like millis(), except less efficient.
Logged

Pages: [1]   Go Up
Jump to: