tag:blogger.com,1999:blog-5416726460697111362.post1149866446076740039..comments2024-03-13T11:50:16.986-07:00Comments on Dr. Monk's DIY Electronics Blog: Arduino Timer LibrarySimon Monkhttp://www.blogger.com/profile/11397717497833049913noreply@blogger.comBlogger47125tag:blogger.com,1999:blog-5416726460697111362.post-23809398132515946932014-10-23T14:35:15.809-07:002014-10-23T14:35:15.809-07:00Hi
Im creating an event outside setup() and I cant...Hi<br />Im creating an event outside setup() and I cant get it to trigger at the right time. The call is made mS after the event is created rather than seconds. What noob error am i making??<br /><br />timerEventId6=t.after(pumpSpinUpTime, stopPumpSpinTimer);bobhttps://www.blogger.com/profile/01954637545759940823noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-14122308436885997782014-10-11T06:02:06.630-07:002014-10-11T06:02:06.630-07:00Thank you very much for the fine library which I b...Thank you very much for the fine library which I believe it is essential!<br />I have a question while I am using it for implementing wall clock. It is little bit slow. I assigned it to invoke every 1 sec. After several minutes, I found my clock runs little bit lagging. Would you take a look into it? Thank you.hongjunyhttps://www.blogger.com/profile/06676713762186365656noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-84632653866976198312014-10-08T07:48:47.522-07:002014-10-08T07:48:47.522-07:00Dear Simon, I hope that I did not miss something o...Dear Simon, I hope that I did not miss something obvious, but my concern is about how sensitive the implementation of the "after" is to the mills rollover issue.<br /><br />I want to use the lib in a 24/7 system, and don't want to it to fall into a extremely long wait after 49 days :)<br /><br />Thanks.Anonymoushttps://www.blogger.com/profile/07227940639268278230noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-11549516382017938402014-09-25T03:49:22.082-07:002014-09-25T03:49:22.082-07:00ey!! I owe you a beer! I've succeed in activa...ey!! I owe you a beer! I've succeed in activate/deactivate 32 relays with differents intervals.<br /><br />I've modified the parameter:<br />#define MAX_NUMBER_OF_EVENTS (10)<br />to <br />#define MAX_NUMBER_OF_EVENTS (32)<br /><br />For changing the state of a digital output,I used the method: pulseImmediateVellamyhttps://www.blogger.com/profile/17655562996608543563noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-51798896411067626632014-07-22T13:35:06.708-07:002014-07-22T13:35:06.708-07:00Hi, I'm using your libary and also run into a ...Hi, I'm using your libary and also run into a problem with longer times (over 30 seconds). Problem is I use values from diffrent Arrays to calculate the time: t.pulse(dosingPins[dosing[i].pinAddr],long(60000 * dosing[i].mldosing / dosingMlMin[i]);, LOW);<br />dosing[i].mldosing is int 50, dosingMlMin[i] is int 55, so time will be 54545,45.<br />But it only sets the pin High and never LOW again. With value dosing[i].mldosing=25 it works fine. Do you have an Idea how to fix it? My aproche at the moment is:<br />long time =long(60000L * dosing[i].mldosing / dosingMlMin[i]); t.pulse(dosingPins[dosing[i].pinAddr],time, LOW);<br />But also without luck...<br />Take Care MoritzAnonymoushttps://www.blogger.com/profile/08490592449752289384noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-91371036781666113802014-07-05T05:50:27.781-07:002014-07-05T05:50:27.781-07:00I have 2 events in timer (event1, event2). How can...I have 2 events in timer (event1, event2). How can I start only event1 ? then wait button is pressed then start event2<br /><br />ThankThuongNguyenChihttps://www.blogger.com/profile/15909946361318172598noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-35663502900904701082014-06-27T07:00:14.671-07:002014-06-27T07:00:14.671-07:00is this library support microseconds value ? i th...is this library support microseconds value ? i think it's a bit lack, because it can't be used for system that need more precision and accurate time, i hope you can fix it as soon as possible.Warga Muslim Indonesia bukan Nusantarahttps://www.blogger.com/profile/09102810956011500416noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-34719977076010536332014-06-27T06:59:30.420-07:002014-06-27T06:59:30.420-07:00is this library support microseconds value ? i th...is this library support microseconds value ? i think it's a bit lack, because it can't be used for system that need more precision and accurate time, i hope you can fix it as soon as possible.Warga Muslim Indonesia bukan Nusantarahttps://www.blogger.com/profile/09102810956011500416noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-45732401634892008022014-05-26T23:44:55.267-07:002014-05-26T23:44:55.267-07:00how do i update a particular event associated with...how do i update a particular event associated with a given timer am actually not servicing all event at the same time so do i need to do something like t.update(eventid) like in the stop function thanks Anonymoushttps://www.blogger.com/profile/03413554895733378511noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-32802825480501257182014-04-01T08:51:29.876-07:002014-04-01T08:51:29.876-07:00Can i ask how t.every() function works? I want to ...Can i ask how t.every() function works? I want to write a Flowchart for my programm and i don't know how to categorize this function operation (like thread?) <br /><br />ThanksAnonymoushttps://www.blogger.com/profile/15137405136595292227noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-44971724195185685532014-03-11T01:20:46.196-07:002014-03-11T01:20:46.196-07:00Hi Simon,
it would be much easier for beginners if...Hi Simon,<br />it would be much easier for beginners if you would correct the pulse sample, cause it does not the same as the sample with delay. To achieve the same you have to use pulseImmediate wich is not mentioned in the referenz.<br />That would make it easier for beginners to use and understand your great library.<br />Thanks<br />MarkAnonymoushttps://www.blogger.com/profile/11695130720205442947noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-75400468950853128702014-03-11T01:14:12.125-07:002014-03-11T01:14:12.125-07:00Hi Simon,
you should change your example, cause i...Hi Simon,<br /><br />you should change your example, cause it doesn't do the same as the code sample with the delay. I needed a while to figure out that I have to use pulseImmediate instead of pulse to achhieve what I wanted. PulseImmediate isn't mentioned in your referenz. This would make it easier for beginners to use this great lib.<br />Thanks<br />MarkAnonymoushttps://www.blogger.com/profile/11695130720205442947noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-30773779268495228142014-02-16T11:12:36.283-08:002014-02-16T11:12:36.283-08:00Hi Dr. Monk,
What a great library. I was wonderin...Hi Dr. Monk,<br /><br />What a great library. I was wondering if it is possible to adjust the duty cycle of the oscillations. I saw this was asked earlier but I couldn't find answer. <br /><br />Thanks!Anonymoushttps://www.blogger.com/profile/17470886338319036867noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-21414941256992928172014-01-04T04:06:36.388-08:002014-01-04T04:06:36.388-08:00Hi,
Just discovered your libray and wanted it to s...Hi,<br />Just discovered your libray and wanted it to switch a relay for 1 hour, triggered from an event in the main loop.<br /><br />It looks like you examples are not configured for this and a few others have already asked similar questions but there doesn't seem to be any responses.<br />Anyway I thought it was worth asking again.<br />How can I trigger a output for a period of time from within the main loop based on a user input?<br /><br />Cheers and thanks for your eforts.Gadjethttps://www.blogger.com/profile/03523239254572573477noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-26381987679936193622013-11-26T03:19:00.812-08:002013-11-26T03:19:00.812-08:00Hi, your library is'nt correctly settled
Have...Hi, your library is'nt correctly settled<br /><br />Have you seen "Installing Additional Arduino Libraries" ?<br /><br />This method does'nt work with arduino ide 1.5.4. <br /><br />My method :<br />Create a file :"library.properties" with text below<br /><br />name=Timer Event<br />author=Simon Monk<br />email=<br />sentence=Libary for the Arduino Timer event shield.<br />paragraph=With this library you can instantiate callback function.<br />url=http://www.doctormonk.com/2012/01/arduino-timer-library.html<br />architectures=avr<br />version=1.0<br />dependencies=<br />core-dependencies=arduino (>=1.0.0)<br /><br /><br />To install the library, first quit the Arduino application<br />Copy the components of MyLib (.cpp, .h library.properties, keywords.txt, /examples/*.* files) into the folder : ./arduino-1.5.x/libraries/MyLib<br /><br />NB : .cpp and .h into folder MyLib/src<br /><br />eg : for the library Timer<br />arduino-1.5.4/libraries/Timer_Event/examples/Blink2/*.ino<br />arduino-1.5.4/libraries/Timer_Event/src/*.cpp;*.h<br />arduino-1.5.4/libraries/Timer_Event/keywords.txt<br />arduino-1.5.4/libraries/Timer_Event/libraries.properties<br /><br />restart ARDUINO IDEJackhttps://www.blogger.com/profile/14518437743153015571noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-1879602026934783702013-11-23T15:02:14.955-08:002013-11-23T15:02:14.955-08:00Answer to Kevin :
you should add NULL as last par...Answer to Kevin :<br /><br />you should add NULL as last parameter when calling every or after.<br />In your case:<br />t.every(10000,turnoff,NULL); //how long to wait till you kill the light.<br /><br />And what is more, you should modify your function declaration :<br />void turnoff(void *context) { ...<br /><br />Don't know why, but it works ;-)<br /><br />EnjoySpaceInvaderhttps://www.blogger.com/profile/03625881719024550731noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-63112499799422824192013-11-21T09:47:05.430-08:002013-11-21T09:47:05.430-08:00You wrote that you wanted to hear from similar pro...You wrote that you wanted to hear from similar projects. <br />If have written a statemachine library that is (in my opinion) very useful. <br />It is found here:<br />http://playground.arduino.cc/Code/SMlib<br /><br />It is NOT primarily a timer library but it can be used for running multiple timers as well by putting the timer action in the head function and having a timeout do a restart in the body. <br />Unknownhttps://www.blogger.com/profile/17254266949914568762noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-89954599698026719782013-11-15T13:41:53.269-08:002013-11-15T13:41:53.269-08:00Dr Monk. I'm having an issue in getting a &q...Dr Monk. I'm having an issue in getting a "no matching function for call to 'Timer::every(long int, void (&)())'. i can't figure out why I'm getting that error<br /><br />My code is: <br /><br />#include "Timer.h"<br />#define PIN 0<br />Timer t;<br /><br />int mode = 0; // set the mode of what program to run<br />int pin = 0;<br /><br />void setup() {<br /> t.every(10000,turnoff); //how long to wait till you kill the light.<br />}<br /><br />void loop() {<br />t.update();<br />}<br /><br />///Interrupts/////<br />void turnoff()<br /> {mode=3;}Kevinhttps://www.blogger.com/profile/10572902416680405721noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-43179593601097016332013-10-26T19:58:23.193-07:002013-10-26T19:58:23.193-07:00Thank you for a great bit of code here. I am usin...Thank you for a great bit of code here. I am using it to turn off an LCD backlight after a timeout period. I am running to to trouble however with the .stop command. It doesn't seem to stop the timer. Are there any known issue with .stop?Anonymoushttps://www.blogger.com/profile/06921719452358392749noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-91648290055491386322013-09-16T10:45:24.301-07:002013-09-16T10:45:24.301-07:00Hi Dr Monk. Thanks for the library. I have been ...Hi Dr Monk. Thanks for the library. I have been trying to switch on a relay for 15 sec and then switch it off for 15 min. I have tried various combinations of your "calls" without success. Do you have any suggestions?Anonymoushttps://www.blogger.com/profile/03630643436665755962noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-19486901575739917792013-08-16T03:58:00.857-07:002013-08-16T03:58:00.857-07:00Hi. A very simple library that does well it's ...Hi. A very simple library that does well it's work. <br /><br />BUT<br /><br />I think it'a a bad thing search for "first unused int timer" and reuse it . <br />Stop function doesn't work well in this way. <br />Sometimes I need to stop a timer, in a stupid manner ( it could be active or not ... ) . Whith "dynamic" timers numeration I risk to stop a wrong timer ( first time I used this library it happened, and I spent a lot of time before understand that reading the source ). <br /> <br />I think ( I did ) it's better to bind with the function " t.oscillate( Timer_n .... ) " the identifier of the timer.<br /><br />Also I think a "delayed start" could be a good addition, without using a lot of "after" and functions. For example if I need to blink a led like a morse code to show an even I could do t.oscillate(delayed,stuff,x,100,4);<br />t.oscillate(delayed + 500,x,50,10);<br /> <br />Hi<br />Anonymoushttps://www.blogger.com/profile/08028572586777243538noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-42364433136502833682013-08-12T20:28:59.113-07:002013-08-12T20:28:59.113-07:00Jaren, I'm a newbie also, and am trying to do ...Jaren, I'm a newbie also, and am trying to do similar but using relays to blink and turn two lasers and a motor off and on. You can change the code above to this to get it to shut off.<br /><br />{<br /> Serial.println("stop the led event");<br /> t.stop(ledEvent);<br /> t.oscillate(13, 500, LOW, 5);<br /> }<br /> <br />Changed from "HIGH" to "LOW". I don't know if this is the correct proceedure, for turning it off, but it works, even though the timer continues counting... I too would like to know how to use a momentary button to control the on off switching, and also be able to alternate between two outputs in a repetative sequence for a givin time.Anonymoushttps://www.blogger.com/profile/07060446538153706959noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-10758765824632375342013-08-12T20:27:56.354-07:002013-08-12T20:27:56.354-07:00Jaren, I'm a newbie also, and am trying to do ...Jaren, I'm a newbie also, and am trying to do similar but using relays to blink and turn two lasers and a motor off and on. You can change the code above to this to get it to shut off.<br /><br />{<br /> Serial.println("stop the led event");<br /> t.stop(ledEvent);<br /> t.oscillate(13, 500, LOW, 5);<br /> }<br /> <br />Changed from "HIGH" to "LOW". I don't know if this is the correct proceedure, for turning it off, but it works, even though the timer continues counting... I too would like to know how to use a momentary button to control the on off switching, and also be able to alternate between two outputs in a repetative sequence for a givin time.Anonymoushttps://www.blogger.com/profile/07060446538153706959noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-65273015381199661962013-07-31T16:29:33.211-07:002013-07-31T16:29:33.211-07:00The first timer id that is created with t.after is...The first timer id that is created with t.after is 0 so i can't check if (!t) because it reports i have to create it when it really exists..<br /><br />this is a sample code that i can't fix<br />the first time that alarm=0 the loop is executed 2 times, .after internally creates the timer 0 so it runs twice<br /><br />if (!active)<br /> {<br /> alarm=1;<br /> Serial.println("on");<br /> if (timeralarm)<br /> {<br /> timer.stop(timeralarm);<br /> Serial.println("stop timer"); <br /> }<br /> }<br /> else<br /> {<br /> alarm=0;<br /> if(!timeralarm)<br /> {<br /> Serial.println("start timer");<br /> Serial.println("timeralarm");<br /> Serial.println(timeralarm);<br /> timeralarm=timer.after(timedelay,function);<br /> Serial.println(timeralarm);<br /> delay(200);<br /> }<br /> }mactskhttps://www.blogger.com/profile/14065386528553425209noreply@blogger.comtag:blogger.com,1999:blog-5416726460697111362.post-55290508088848062152013-07-12T18:11:01.780-07:002013-07-12T18:11:01.780-07:00Is there a way to catch when t.oscillate stopped w...Is there a way to catch when t.oscillate stopped working?Anonymoushttps://www.blogger.com/profile/11662445506634301485noreply@blogger.com