Using internal clock pulse for ISR?

Hi All,
I am a newbie to both Arduino & C programming.
I am trying to figure out how to use the internal 16MHz clock pulse to run a counter, which will run a ISR say 100 times/second.

I assume there is a command for this & have been scouring the net for hours trying to find such an animal, but to no avail.

Can anyone point me in the right direction? :-[

Lots of ways of doing it, but 100Hz is pretty slow - why do you need an interrupt?
(I don't want to put you off, but interrupts are tricky beasts, and really best reserved for very fast events).

Hi Groove,
Thanks for your reply.

I want to use the Arduino to control an espresso machine. Specifically I want to add a adjustable pressure system to an espresso machine

At all times I want to monitor/control the following :-Steam boiler level sensor, Steam boiler temp, Hot water dispense switch, Flowmeter x 2, Steam boiler manual fill switch, Steam Boiler water intake solenoid, Brew switch x 2, ? brew boiler PID output, Group head thermocouple.

Also during the course of an extraction I want to monitor the following :- Group head pressure sensor, Manual pressure profile potentiometer, PWM signal to pump.

Any suggestions....... :-[

No specific suggestions, but 100Hz really isn't that quick.

Just bundle it all into "loop" - it'll probably end up easier to read and debug than any interrupt implementation.

(BTW, espresso machines have been working for a very long time without a 100Hz control loop)

Loop sounds like the way to go! ;D

BTW, controlling & changing the pressure during the course of an extraction is a new thing for the industry. :wink:

I want to write ramp ups/downs & possibly S-curves as well, but first is basic control/monitoring.

, controlling & changing the pressure during the course of an extraction is a new thing for the industry.

More than likely, but are the mechanical actuators capable (and economical) of greater than even, say 10Hz updates at 10-15 bar?

(I'd like to propose me as a Guinea Pig)

I'm a newbie to Arduino & C++ also, but if it's any help, using the TimedAction.h library setting up an interrupt is relatively easy.

PS. I use this for updating a 4*20 LCD etc. I see no point in running code full whack all the time.
In addition, with a little extra work you can use this base 100mS loop to generate ticks for 300mS, 500mS, 1000mS etc etc.

#include <TimedAction.h>
// Initializes TimedAction - Timer Interrupt
TimedAction Timedact01 = TimedAction(100,TimerService01); // 100mS

void setup() {
}

void loop() {
// Timed Action service
Timedact01.check();
}

void TimerService01() {
// This subroutine runs at 100mS so put what you want in here, i.e. your counter.
}

Ian.

Groove, you have a good point, perhaps 10Hz would be sufficient....

Ian, thanks for the timer interrupt! Much appreciated! :slight_smile:

@IanJohnston:
That's not an interrupt!
If you've got anything running in "loop" that takes a long time, then response to your scheduled event will also be delayed.

@IanJohnston:

? I see no point in running code full whack all the time.

The processor is running full wack all the time even if you have no code in loop.
Using interrupts can increase rather than decrease the amount of work the chip has to do because there is overhead in the saving and restoring registers that is done in the interrupt handler.

Anyway, as groove says, timedAction does not use interrupts.