Does Arduino 101 have a timer?

Hello! I am relatively new to using Ardunios/c++, and I was wondering if the Arduino 101 has a timer clock that I could use. What I am interested in doing would follow this type of logic:

turn on blood pressure, heart rate, and breathing recording inputs
15 seconds in, turn on the blood pressure cuff pump motor
turn off motor when it reaches specific pressure
1 minute in, calculate BP, heart rate, breathing rate and reset loop

However, I am not sure how to use the clock to program an interrupt at 15 seconds and 1 minute in the arduino c++, especially since the 101 is a 32MHz clock, which the other arduinos are not. I am able to have my code work using loops and counters, but since I am making a medical device for my senior design project, timing accuracy is important to me.

Does anyone know how to code this?


Hi, to control timers you can use the CurieTimerOne library (preview here) which will be included in the next 101 core update. Hope it helps!

Thanks! Do you know when the core comes out?

Does Curie have a datasheet with documentation on its hardware timers?

I maintain several libraries which use timers. Today most support only AVR and maybe a couple other chips. Someday (perhaps in my dream world where there are many more hours in every day) I'd like to look into making timer abstraction layers. Atmel, Microchip, ST, NXP/Freescale all document their timer hardware very well in reference manuals or datasheets.

Can anyone point me to where Intel does this for their new chip?

Does Curie have a datasheet with documentation on its hardware timers?

No. Not accessible without corporate NDA with Intel, anyway. The Intel OS API is supposed to go open-source sometime this month.

In addition to the timerOne library, there is also the CurieTime library (included in the current IDE) that should be sufficient for reading times of ~1s granularity. It doesn't support an alarm/interrupt function, though.

And millis() should work fine.

For the time delays you are interested in, an Arduino State Machine pattern, using millis() to calculate what time has elapsed, would probably work well. The Arduino Tutorial How to make a state machine is a thorough example. See how that code uses the variable "ts" to change states based on time.

For your design, my first thought would be states like START, RECORDING_ON, MOTOR_ON, MOTOR_OFF, CALCULATE. The state transitions would be something like the following. I assume you want to continuously take blood pressure measurements at 1 minute intervals.

in setup() state = START;

in START state, turn on blood pressure, heart rate, and breathing recording inputs, then set state to RECORDING_ON.

In RECORDING_ON state, if 15 seconds have passed (ts + (15 * 1000L)), turn on the blood pressure cuff pump motor , then set state to MOTOR_ON.

In MOTOR_ON state, if the BP has reached the desired pressure, turn off motor, then set the state to MOTOR_OFF.

In MOTOR_OFF state, if 1 minute has passed (ts + (60 * 1000L)), calculate BP, heart rate, breathing rate, then set state to START.

I love State Machines. Their formal name is "Finite State Machines" or just "FSM". They are a formal concept/pattern that is tremendously valuable in designing Arduino Sketches that do sequences of behavior.