Connecticut
Offline
Edison Member
Karma: 16
Posts: 1214
RTFD (Datasheet in our case)
|
 |
« on: February 24, 2011, 03:48:21 pm » |
How can I trigger a timer interrupt to, say, go off every 10 seconds? I know I can make and external interrupt on pins 2+3, but can I do software interrupts like this? Or will I need a 555 timer in astable mode?
|
|
|
|
|
Logged
|
I'm not kidding. If I am asking a question whose answer is found within the concerned product's datasheet, shame on me. If I am answering a similar question, shame on you!
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 116
Posts: 10144
|
 |
« Reply #1 on: February 24, 2011, 03:53:48 pm » |
Processor? Clock speed?
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #2 on: February 24, 2011, 03:57:22 pm » |
How can I trigger a timer interrupt to, say, go off every 10 seconds? I know I can make and external interrupt on pins 2+3, but can I do software interrupts like this? Or will I need a 555 timer in astable mode?
Use http://www.arduino.cc/playground/Main/MsTimer2Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Connecticut
Offline
Edison Member
Karma: 16
Posts: 1214
RTFD (Datasheet in our case)
|
 |
« Reply #3 on: February 24, 2011, 04:00:10 pm » |
Processor? Clock speed? I just want to have an interrupt triggered every x seconds, which will then run a specified function, just like in attachIntterupt().
|
|
|
|
|
Logged
|
I'm not kidding. If I am asking a question whose answer is found within the concerned product's datasheet, shame on me. If I am answering a similar question, shame on you!
|
|
|
|
Connecticut
Offline
Edison Member
Karma: 16
Posts: 1214
RTFD (Datasheet in our case)
|
 |
« Reply #4 on: February 24, 2011, 04:01:40 pm » |
Sorry lefty... I posted while you posted.
Thanks for that! It's exactly what I had in mind. So it has a min. resolution of 1 ms?
|
|
|
|
|
Logged
|
I'm not kidding. If I am asking a question whose answer is found within the concerned product's datasheet, shame on me. If I am answering a similar question, shame on you!
|
|
|
|
Sweden
Offline
Newbie
Karma: 0
Posts: 13
|
 |
« Reply #5 on: February 24, 2011, 04:12:20 pm » |
Dont know about timer2 resolution, but if you dont think you are able to program your own timed event interrupt then you can "cheat" by manually change the code in MsTimer2.cpp to fit your needs with a suitable program like "source editor".
|
|
|
|
|
Logged
|
|
|
|
|
Western New York, USA
Offline
Faraday Member
Karma: 17
Posts: 3461
|
 |
« Reply #6 on: February 24, 2011, 05:23:25 pm » |
...change the code in MsTimer2.cpp to fit your needs ... Not exactly. That's a good idea for short delays but for his needs he will have to use the interrupt to update a software counter and use that counter to determine when to run his specified function. I think he already figured this out.Don
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15314
Measurement changes behavior
|
 |
« Reply #7 on: February 24, 2011, 06:11:31 pm » |
Thanks for that! It's exactly what I had in mind. So it has a min. resolution of 1 ms? Yep, the time variable is a long, so max timed interrupt is like 55 days or so. I used it my 5x5x5 led cube to generate 2msec interrupts. Worked great. Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Singapore
Offline
Newbie
Karma: 4
Posts: 25
Arduino rocks
|
 |
« Reply #8 on: February 24, 2011, 10:19:56 pm » |
I find aikoevents to be a really simple way of making things happen at regular intervals- regardless of how long those particular events take or how long the rest of your program takes to loop. I was using before a messy code filled with millis() and interrupts to determine how long each event/iteration took, then adding times together to do one simple thing- which is repeat a task reliably at the same interval. It was impossible to get accuracy- and not to mention made the code a mess. Simple=good 
|
|
|
|
|
Logged
|
|
|
|
|
|