Timer in Flowcode V6

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Alex
Posts: 2
Joined: Tue Jan 28, 2014 6:31 pm
Contact:

Timer in Flowcode V6

Post by Alex »

Hi there,

I am looking to start a timer which will count from 0 in mili seconds (1.23 seconds) and then display this count on an LCD display and at any point when a switch is pressed the counter will stop and display the time on the LCD display. Not sure the best way to do this. any advice would be great!

Alex

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Timer in Flowcode V6

Post by medelec35 »

The timer should be easy enough to create using a timer interrupt, but how will you observe the change in ms on an LCD?
one value will merge into the next value. Your eyes will not be able to differentiate the individual ms.
I would of thought You will see just 8's until display has stopped.
Martin

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Timer in Flowcode V6

Post by JonnyW »

Hi.

Try adding into a timer interrupt something like:

counter = counter + 1
update_flag = ((counter & 31) == 0)

Then in your main loop add a decision:

if (update_flag)
lcd_clear()
lcd_print( counter )

This might slow the display down so it is not constantly working giving you values you can never see anyway. Vary the 31 (always a power of 2 minus 1, so 3, 7, 15, 31, 63...) to get a decent refresh rate.

Cheers,

Jonny

Alex
Posts: 2
Joined: Tue Jan 28, 2014 6:31 pm
Contact:

Re: Timer in Flowcode V6

Post by Alex »

It doesn't have to show the individual ms when counting up however i just need it to display the ms at the end when the timer has stopped.

thanks for the help guys

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Timer in Flowcode V6

Post by medelec35 »

That should be ok to do.
You can get a timer interrupt to increment a int variable by 1 every 1ms. You can either use a variable ot bypass the count when timing is not required, or just disable timer to interrupt to stop counting.

What hardware will you be using e.g target device, type of osc and its running frequency?
Martin

Post Reply