LONG TIME TIMER
Moderator: Benj
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
LONG TIME TIMER
Dear sirs,
i would like to run a part of FC8 code for a long time ( some days to 1 month )...is it possible to do that and how ? when the code goes to that part ( a macro ) starts a timer that runs in the background...at the end of preset time, the code leave the macro and goes to a connection point...a code example that can add in the macro , will be very useful ...
i would like to run a part of FC8 code for a long time ( some days to 1 month )...is it possible to do that and how ? when the code goes to that part ( a macro ) starts a timer that runs in the background...at the end of preset time, the code leave the macro and goes to a connection point...a code example that can add in the macro , will be very useful ...
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: LONG TIME TIMER
Hi SILVESTROS9,
attached is a flowchart that sets a variable called to a value of 1 after 5 Days, 2 Hours, 3 minutes has elapsed.
The variable can be used in conjunction with a decision branch.
The time duration is set within TimerISR Macro.
For this to work, the timer interrupt has to be set up correctly which is determined by the clock speed of the target device.
attached is a flowchart that sets a variable called
Code: Select all
TimeUpFlag
The variable can be used in conjunction with a decision branch.
The time duration is set within TimerISR Macro.
For this to work, the timer interrupt has to be set up correctly which is determined by the clock speed of the target device.
- Attachments
-
- Very long delays.fcfx
- (10.81 KiB) Downloaded 215 times
Martin
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
Re: LONG TIME TIMER
Medelec35,
thanks for your answer...is there a way to test the timer without waiting days ? how to calculate and set up the clock speed of the target ? ( I'll use a PIC16F1939 ).
thanks for your answer...is there a way to test the timer without waiting days ? how to calculate and set up the clock speed of the target ? ( I'll use a PIC16F1939 ).
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: LONG TIME TIMER
I have created the flowchart so you can change the time delay to what ever time you want.
All you need to do is drag the calculation box from within the TimerISR call macro and place it within the Yes branch of
Then you only need to wait 1 minute.
You will need to place an output icon in the yes Decision branch of within Main.
Also, within main you will require variables to reset all the values, so that counting can start from scratch
All you need to do is drag the
Code: Select all
TimeUpFlag = 1
Code: Select all
If Seconds = 60
You will need to place an output icon in the yes Decision branch of
Code: Select all
If TimeUpFlag
Also, within main you will require variables to reset all the values, so that counting can start from scratch
Are you using Internal or external osc?SILVESTROS9 wrote:how to calculate and set up the clock speed of the target ? ( I'll use a PIC16F1939 ).
Martin
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
Re: LONG TIME TIMER
medelec35,
I use external oscillator ( a crystal 16 MHz ).
about verylongdelays code ( at main ) in decision branch there is " if TimeUpFlag? "..... is this correct , or " if TimeUpFlag=1 ?
I use external oscillator ( a crystal 16 MHz ).
about verylongdelays code ( at main ) in decision branch there is " if TimeUpFlag? "..... is this correct , or " if TimeUpFlag=1 ?
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: LONG TIME TIMER
Hi SILVESTROS9.
If the value is left off, then it would be true (Yes branch) if the variable was any value except 0.
In that case:SILVESTROS9 wrote:I use external oscillator ( a crystal 16 MHz ).
Both are correct.SILVESTROS9 wrote:about verylongdelays code ( at main ) in decision branch there is " if TimeUpFlag? "..... is this correct , or " if TimeUpFlag=1 ?
If the value is left off, then it would be true (Yes branch) if the variable was any value except 0.
Martin
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
Re: LONG TIME TIMER
medelec35,
is it possible to calculate the accuracy of timer at 1 month period ? what are the factors that have effect in that ?
is it possible to calculate the accuracy of timer at 1 month period ? what are the factors that have effect in that ?
Last edited by SILVESTROS9 on Tue Aug 20, 2019 5:58 pm, edited 1 time in total.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: LONG TIME TIMER
You cant use flowcode simulator using a stopwatch as simulation is way quicker than real time.SILVESTROS9 wrote:medelec35,
I tested at simulator
Can you post your flowchart, and I will see if I can tell what the issue is.
What we can do is have another small delay, Reset values and start timing all over again
Martin
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
Re: LONG TIME TIMER
medelec35,
I think that there is no reset at variables after timer disable....below is the flowchart for your opinion... most important for me is the accuracy of timer at 1 month, and the max theoretical deviation at that period...
I think that there is no reset at variables after timer disable....below is the flowchart for your opinion... most important for me is the accuracy of timer at 1 month, and the max theoretical deviation at that period...
- Attachments
-
- HSC-S200-05-D-PW2L-demo.fcfx
- (94.67 KiB) Downloaded 185 times
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: LONG TIME TIMER
I can't see anything that will make the time shorter, except for clearing variables prior to timer interrupt being enabled.
I would recommend this: You will need to run on hardware to check timing.
Crystals accuracy also depends on the ambient temperature.
To see how much theoretical time difference, you need to know the ppm of the crystal circuit.
Supposing the maximum is 20PPM (Parts Per million).
As there are 86400 seconds per day, in one day the maximum seconds difference could be:
Just make sure you have the correct matching capacitors stated within the crystal datasheet.
I would recommend this: You will need to run on hardware to check timing.
That will be dependent on the crystal oscillator accuracy.SILVESTROS9 wrote:most important for me is the accuracy of timer at 1 month, and the max theoretical deviation at that period...
Crystals accuracy also depends on the ambient temperature.
To see how much theoretical time difference, you need to know the ppm of the crystal circuit.
Supposing the maximum is 20PPM (Parts Per million).
As there are 86400 seconds per day, in one day the maximum seconds difference could be:
Code: Select all
20 / 1000000 × 86400 = 1.728
Code: Select all
Per Month = 365.25 / 12 × 1.728 = 52.596
Code: Select all
Per Year = 1.728 × 365.25 = 631.152
Martin
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
Re: LONG TIME TIMER
medelec35,
I set the calculation box to clearing variables before timer interrupt enable...the timer works ok only the first time of password set after hardware reset ...the second time that I set the password without hardware reset , the timer works for 3 seconds...it seems that there is no variables clearing...is it possible to check the variables on simulator ?
I set the calculation box to clearing variables before timer interrupt enable...the timer works ok only the first time of password set after hardware reset ...the second time that I set the password without hardware reset , the timer works for 3 seconds...it seems that there is no variables clearing...is it possible to check the variables on simulator ?
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
Re: LONG TIME TIMER
medelec35,
the 5 variables was cleared....but we forget to add also in calculation box the TimeUpFlag=0...after that the timer works fine....
the 5 variables was cleared....but we forget to add also in calculation box the TimeUpFlag=0...after that the timer works fine....
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: LONG TIME TIMER
Good spot!
Yes I should have also included TimeUpFlag=0 with all the other variables being cleared.
So the timing is correct on hardware?
Yes I should have also included TimeUpFlag=0 with all the other variables being cleared.
So the timing is correct on hardware?
Martin
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
Re: LONG TIME TIMER
medelec35,
the timing is correct on hardware ...with a typical crystal the deviation is 2 seconds at 1 hour...its ok ... another issue...sometimes the security code not inserted correct ...it needs 2 or 3 times to get the message "security code ok "....its about accuracy or keyboard resistors ? what can I do to solve this ? a way I think is to display the security code at LCD ...how can do that ?
the timing is correct on hardware ...with a typical crystal the deviation is 2 seconds at 1 hour...its ok ... another issue...sometimes the security code not inserted correct ...it needs 2 or 3 times to get the message "security code ok "....its about accuracy or keyboard resistors ? what can I do to solve this ? a way I think is to display the security code at LCD ...how can do that ?
-
- Posts: 115
- Joined: Wed Aug 03, 2016 10:45 pm
- Has thanked: 24 times
- Been thanked: 11 times
- Contact:
Re: LONG TIME TIMER
medelec35,
ok, I found the way to display the numbers of security code...also I would like to reduce the number of buttons....a way is to use 3 buttons ...UP and DN to select the number 0-9 , and SET to input at circular buffer...is there a component for that , or a code example with numbers displayed on 4x20 LCD ?
ok, I found the way to display the numbers of security code...also I would like to reduce the number of buttons....a way is to use 3 buttons ...UP and DN to select the number 0-9 , and SET to input at circular buffer...is there a component for that , or a code example with numbers displayed on 4x20 LCD ?