Pages: [1]   Go Down
Author Topic: Interrupts and Timekeeping  (Read 354 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey all,

I'm developing a software library for a kayak Ergometer (similar to the rowing machines you find in gyms) that depends on input from three hall effect sensors, wired to three interrupt pins on the Arduino MEGA. The way I've defined my class, I have three separate functions:

leftClick()
flyClick()
rightClick()

that are marked as interrupt service routines. When activated, they run through a variety of private functions to update a series of variables, which the main Arduino sketch can then pull through accessor methods.

The meat of the calculations relies on calls to micros(), as the hall effect sensors are measuring clicks from a ring of eight magnets centered around the axis of the ergometer flywheel. So, eight clicks per revolution. As data comes in, I update an Omega variable for the flywheel, calculated by:

2*pi / numMagnets * ((micros() - tLast))

The question is, while I'm inside this interrupt, will the value of micros keep incrementing? If the whole interrupt routine takes 50 microseconds, does my clock counter within hardware freeze for that long, or does it keep incrementing by one every microsecond, regardless of whether or not I'm in the ISR?

Also--say I call my ISR, it updates a counter variable and then calls another function. Once I leave the first function and jump into the second, am I still within the ISR?

I'm getting power readings out of this device, so it's sort of important that I can rely on the processor's time measurement between clicks. Any ideas, if I do indeed have a big problem?
Logged

Pages: [1]   Go Up
Jump to: