Secund counter, again.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Secund counter, again.

Post by jgu1 »

Hi all!

I am again, try and use the interrupt hours2 in a study. I made this second count. Although I have copied Martin's FC in a previous project, I can not get the time to fit exactly. When I compare with the stopwatch, it looks like the counter lose time when it flip over from 59 to 00. :?: What am I doing wrong?

Is there anyone who can help.

Thank you in advance.

Best regard

jgu1
Attachments
UrInt2.fcf
(6.5 KiB) Downloaded 284 times

dbasnett
Posts: 125
Joined: Mon Aug 15, 2011 1:54 pm
Has thanked: 8 times
Been thanked: 11 times

Re: Secund counter, again.

Post by dbasnett »

You are doing a lot in the interrupt code, including updating the LCD. What if the interrupt code just added 1, and the rest of the code was in a different macro that was called from within the loop?

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: Secund counter, again.

Post by jgu1 »

Hi DBSNETT and all!


Exactly, solved!. I moved the display update. And now it work´s.

Thank´s! :D

Best regard.

jgu1.
Attachments
UrInt2.fcf
(6.5 KiB) Downloaded 296 times

dbasnett
Posts: 125
Joined: Mon Aug 15, 2011 1:54 pm
Has thanked: 8 times
Been thanked: 11 times

Re: Secund counter, again.

Post by dbasnett »

See attached (not tested BTW)
Attachments
UrInt2-1.fcf
(7.5 KiB) Downloaded 307 times

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: Secund counter, again.

Post by jgu1 »

Hi DBASNET!

Thank you for your examble! I am testing. So it´s best when the interrupt timer expires, it must not make too much.

Now I learn some new. :D

Thank´s

Best regard

jgu1

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

Re: Secund counter, again.

Post by medelec35 »

Hi jgu1
If you look here:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936
I covered this about About half way down the page some time ago:
medelec35 wrote:
Timer interrupts macros:

It is important that you do not place any delays or components that will have delays in like LCD displays ,RS232 etc within timer interrupts. Keep interrupt macros as short as possible.
Components like LEDs and calculation icons are OK to use.
If you do use delays which lasts for longer than the timer interrupt takes to trigger, then corruption will occur giving unexpected results.
If you want to update a LCD display after an interrupt has occurred, then set a flag to 1 within interrupt. E.g. update_lcd=1
then for your LCD have a decision branch E.g
If lcd=1 then display macros : lcd=0
Martin
Martin

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times

Re: Secund counter, again.

Post by jgu1 »

Thank you Martin. I will follow the instructions. :D

Best regard

jgu1

dbasnett
Posts: 125
Joined: Mon Aug 15, 2011 1:54 pm
Has thanked: 8 times
Been thanked: 11 times

Re: Secund counter, again.

Post by dbasnett »

medelec35 wrote:Hi jgu1
If you look here:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936
I covered this about About half way down the page some time ago:
medelec35 wrote:
Timer interrupts macros:

It is important that you do not place any delays or components that will have delays in like LCD displays ,RS232 etc within timer interrupts. Keep interrupt macros as short as possible.
Components like LEDs and calculation icons are OK to use.
If you do use delays which lasts for longer than the timer interrupt takes to trigger, then corruption will occur giving unexpected results.
If you want to update a LCD display after an interrupt has occurred, then set a flag to 1 within interrupt. E.g. update_lcd=1
then for your LCD have a decision branch E.g
If lcd=1 then display macros : lcd=0
Martin
In the code provided by the OP it appears that the LCD update happens once per second, and there is already code to check for that. The problem was that all of the code was in the interrupt routine, and as you pointed out, that is not a good idea.

Post Reply