Pages: [1]   Go Down
Author Topic: SoftTimer library  (Read 1833 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear Arduino Friends,

  I proudly introduce you my latest work, the SoftTimer Arduino library.

  This is not just an other multitasking/time-sharing implementation, but also a new way of programing Arduino. In this case you do not implement the "loop()" function, instead you can focus on the tasks need to be done by the software.
  Please visit the project page at: http://code.google.com/p/arduino-softtimer/

  Furthermore SoftTimer comes with a lot of useful tools like software PWM, blinking helper, debouncer, melody player, etc. These function always made trouble by blocking the program. But not any more with SoftTimer.

  I'm really excited what you think about my idea.
  Please feel free to download the library, and share your opinion with me! Thanks!

Best regards,
Balazs
« Last Edit: November 08, 2012, 11:03:51 am by Balázs » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice lib, really useful,
did not dive in the details yet how it is implemented.

some questions came up:
- how do you handle interrupts in this model?
- if a task is running and another 'alarms' is it started or delayed?
- how to handle user input? (serial?

- what can i do with the *Me pointer?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 1
Posts: 34
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear Balazs

I am new to arduino. I am trying to make an electronic football scoreboard. It is meant to be operated using an LCD screen and five buttons as digital inputs. I have managed to code the LCD side of things but I am having some difficulty coding the timer. Your library seems be the perfect answer to the problems I am having with the timer part of the code.

Attached is flow diagram showing what the LCD screen shows and what the seven segments are suppose to do.

I am basically trying to use four variables:
start_time
match_length
end_time
injury_time

An additional variable called match_stage is used to determine if the match is in first half or first half injury or second half or second half injury or penalties.
I want to drive the timer variables using the following logic:

if match_stage is first half then
start_time = 0
end_time = match_length / 2
set injury_time to user entered value
if injury_time value is greater than 1 then
start_time = injury_time
end_time = 0

At the end of injury count down or if injury_time = 0
match_stage = second half

if match_stage is second half then
start_time = match_length / 2
end_time = match_length
set injury_time to user entered value
if injury_time value is greater than 1 then
start_time = injury_time
end_time = 0

Could you please give me some direction as to how can I use your library to achieve this.

* LCD Menu flow diagram w Seven Segment Output.pdf (562.81 KB - downloaded 21 times.)
Logged

Sydney, Australia
Offline Offline
Sr. Member
****
Karma: 6
Posts: 397
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear Balazs

I am new to arduino. I am trying to make an electronic football scoreboard. It is meant to be operated using an LCD screen and five buttons as digital inputs. I have managed to code the LCD side of things but I am having some difficulty coding the timer. Your library seems be the perfect answer to the problems I am having with the timer part of the code.

Attached is flow diagram showing what the LCD screen shows and what the seven segments are suppose to do.

I am basically trying to use four variables:
start_time
match_length
end_time
injury_time

An additional variable called match_stage is used to determine if the match is in first half or first half injury or second half or second half injury or penalties.
I want to drive the timer variables using the following logic:

if match_stage is first half then
start_time = 0
end_time = match_length / 2
set injury_time to user entered value
if injury_time value is greater than 1 then
start_time = injury_time
end_time = 0

At the end of injury count down or if injury_time = 0
match_stage = second half

if match_stage is second half then
start_time = match_length / 2
end_time = match_length
set injury_time to user entered value
if injury_time value is greater than 1 then
start_time = injury_time
end_time = 0

Could you please give me some direction as to how can I use your library to achieve this.

He gives a couple of good examples with his code and it is fairly easy to understand how to put it together.

Essentially this is designed to take you away from having to sprinkle delay(); statements everywhere and hence have the Arduino "idle" and do nothing.

it takes a little to wrap your head around at first as things no longer happen in a linear fashion - so if you are used to writing output to an LCD screen and it just scrolling down as more text is added then you need to be careful.

What i initially did when converting my code was to take each of the functions that i had previously written and called from the Loop() and instead called each of them with a timer.

So if i wanted to take a temperature measurement every 30 seconds then put a call to that in a timer. Where is gets tricky is if something else is going to operate on the output of that function (say something that would average the temperature readings when they are taken) - in that case you need to put a little more thought into how those two functions would work together

Craig
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some questions came up:

1- how do you handle interrupts in this model?
2- if a task is running and another 'Alarms', is it started or delayed?
3- how to handle Serial?
4- what is the Task *Me pointer?

My guesses:

1- I assume you setup the interrupt in setup(), and define an interrupt routine?
2- I guess it's delayed.
3- Serial can be called within the Task routine?
4- ?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I really liked your Library!  What happened?  Can you answer our questions?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Pages: [1]   Go Up
Jump to: