Go Down

Topic: Timer Library for Arduino DUE (Read 1 time) previous topic - next topic

ivanseidel

Mar 30, 2013, 11:21 pm Last Edit: Apr 08, 2013, 11:27 pm by ivanseidel Reason: 1
Hi!
As i like libraries, i have done one for Timers on the Arduino DUE.

You can check it out here: https://github.com/ivanseidel/DueTimer

All 6 9 timers are fully implemented, and ready to play with...

iyahdub

Wow, ill check them... Thanks...
10 LET Loop=Infinite
20 GO TO 10

Gericom

Subscribe my youtube channel: http://www.youtube.com/user/MKDS3

SomeRandomGuy

#3
Apr 01, 2013, 11:52 pm Last Edit: Apr 01, 2013, 11:54 pm by SomeRandomGuy Reason: 1
I also have a timer library I have been working on. It can be found here: https://github.com/SomeRandomGuy/DueTimer

ivanseidel's library is a very nice implementation!

I have a function that picks the clock that will produce the smallest error for the frequency entered by the user. I am curious how helpful that will be.

Would also appreciate some thoughts and feedback.

Cheers!

SomeRandomGuy

ivanseidel

Nice!
Can i add your implementation to the library? or, if you want, you can join me in the project! and you can add the implementation...
What do you preffer?

ivanseidel

Obs.: This is very weird, because i didn't saw your project on github before doing my library, and the name is the SAME! =]

SomeRandomGuy


Obs.: This is very weird, because i didn't saw your project on github before doing my library, and the name is the SAME! =]


Yea, I noticed that too. I don't know what happened there. I think our libraries do essentially the same thing. I think I like yours better because it follows the object oriented format that the timer libraries on the older Arduinos use. The only thing I would like to add to your library is the chunk that picks the best clock to use based on what frequency the user inputs. This was suggested to me by another user, and it results in a smaller clock error. That is the "pickClock" function in my code. Any thoughts on that?

Again, nice work on the library. I would be more than happy to join you on your library, if that is the format that everyone likes better. I did mine as purely functions, you did yours with timer objects, which I think is closer to the Arduino standard.

Does everyone generally agree on this??

Cheers!
SRG

ivanseidel

You are more than welcome...  :)

SomeRandomGuy

Because you have included this line:
Code: [Select]
TC_Configure(t.tc, t.channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4); in your object constructor instead of your "setFrequency" function, there is no way to modify which clock is used for a given timer after the user has declared it. Here, you are using
Code: [Select]
TC_CMR_TCCLKS_TIMER_CLOCK4 for every timer, which is the way cmaglie originally posted his example.

I am trying to figure out if this line can be moved down to your "setFrequency" function. If so, then adding in support for the dynamic clock selection will be really easy. :]

Cheers!
SRG

ivanseidel

#9
Apr 04, 2013, 11:54 pm Last Edit: Apr 05, 2013, 02:03 am by ivanseidel Reason: 1
I will create a branch to fix that. We could also include in the class, a static int[] containing each timer period, so that we can add "getPeriod()" and "getFrequency()".

Might i create it? (is there another place so that we can chat? Facebook maybe?)

Go Up