Pages: [1]   Go Down
Author Topic: Timer Library for Arduino DUE  (Read 1646 times)
0 Members and 1 Guest are viewing this topic.
Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: April 08, 2013, 04:27:40 pm by ivanseidel » Logged


Offline Offline
Sr. Member
****
Karma: 0
Posts: 351
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wow, ill check them... Thanks...
Logged

10 LET Loop=Infinite
20 GO TO 10

The Netherlands
Offline Offline
Full Member
***
Karma: 1
Posts: 139
MKDS hacker and Programmer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well done!
Logged

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

Cookeville, TN
Offline Offline
Newbie
*
Karma: 3
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: April 01, 2013, 04:54:41 pm by SomeRandomGuy » Logged

Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged


Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Cookeville, TN
Offline Offline
Newbie
*
Karma: 3
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You are more than welcome...  smiley
Logged


Cookeville, TN
Offline Offline
Newbie
*
Karma: 3
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Because you have included this line:
Code:
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:
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
Logged

Brasil
Offline Offline
Full Member
***
Karma: 4
Posts: 125
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?)
« Last Edit: April 04, 2013, 07:03:31 pm by ivanseidel » Logged


Pages: [1]   Go Up
Jump to: