Go Down

Topic: Interrupts and Timekeeping (Read 368 times) previous topic - next topic

sritchie09

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?

Go Up