How Can I program a Clock in Flow Code?

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

Moderators: Benj, Mods

Post Reply
VirusAlert
Posts: 2
Joined: Thu Aug 03, 2006 8:37 pm

How Can I program a Clock in Flow Code?

Post by VirusAlert »

I want to program a clock any ideas how i begin?

This is how I was coding

Loop while 1 Declared Variables - Seconds, Minutes, Hours

Calculation = Seconds=Seconds+1
Call Macro Start
Call Macro Clear
Cursor (6,0)
Call Macro Print (Seconds)
Decision Seconds=>59?
IF yes

Calculation Minute = Minute +1

Call Macro Start
Call Macro Cursor (4,0)
Macro Number Print " Minute"
Decision if Minute=>59?
Calculation = Minute = 1, Hour = Hour + 1

Decision if Hour =>12
calculation Hour=1


Am I doing it Wrong?? Can anybody give me any idea on how to do this and how to make inputs. This is my 3rd day with flow code. and am trying to program this clock, which is my first.

Ian
Posts: 110
Joined: Thu Sep 29, 2005 10:53 am
Location: Matrix Multimedia
Been thanked: 1 time
Contact:

Post by Ian »

The PIC already has a 'clock'.

The TMR0 Timer interrupt triggers at a rate of T times a second e.g 133Hz = 133 times a second. When ever it triggers it runs the code in the timer overflow macro.

By adjusting the pre-scaler value you can adjust the value of T that is convenient e.g. 75Hz rather than 128.5Hz.

Once you have that you can simply count to T and know that a second has passed.
then 60 seconds = 1 minute, 60 minutes.... etc.

The timer intterupt works in the background updating the clock variables - T, seconds, minutes etc. and the main program simply displays them.

Post Reply