Page 1 of 2
DELAY for day's
Posted: Mon Jul 09, 2012 7:08 pm
by electron67
Hi,
Is possible have a Delay in day's ? I do a test for one day (day's * 24 and hour * 3600) of delay and active in 5 hours but I test for 8 hour (hours * 3600) and work fine. I have wrong something ?
Thank You
Electron67
Re: DELAY for day's
Posted: Mon Jul 09, 2012 7:47 pm
by JohnCrow
Hi
Not sure if Im understanding you correcly but:
A day has 86400 seconds
I think that value is too large for the delay variable
Im sure the delay icon takes integer with a max value of 32767 (8 hours is 28800 which I think should be ok)
Im sure the guys at Matrix will have an answer
Ive never needed to use anything as large as that. Cound you have 2 or 3 delays in the flowchart?
Re: DELAY for day's
Posted: Mon Jul 09, 2012 7:58 pm
by medelec35
Hi Electron67,
This should work the way you intend.
A0 can go off after any set some you desire.
E.g 1 day to 255 days
1 second to 60 seconds
1 hour to 23 hours.
With more decision branches, you could for example set delay for 16 days 5hours and 28 seconds.
Although I have set flowchart with the required 10 day delay
Rather than a delay icon flowchart uses timer2 interrupt.
Hope it helps.
Martin
Re: DELAY for day's
Posted: Mon Jul 09, 2012 8:09 pm
by electron67
I test the program.
Thank You
Electron67
Re: DELAY for day's
Posted: Mon Jul 09, 2012 8:16 pm
by medelec35
No problem.
I saw variable DAY=10
and assumed you wanted 10 Days but reading your post it looks like you only wanted 1 day and not 10.
So you will need to change Set_Days = 10
to Set_Days = 1
I'm assuming your using a 20MHz crystal oscillator?
Martin
Re: DELAY for day's
Posted: Mon Jul 09, 2012 8:20 pm
by electron67
Yes I use 20 mhz, I want of 1-30 day; work the same program for 30 day ?
Re: DELAY for day's
Posted: Mon Jul 09, 2012 8:27 pm
by medelec35
Yes just change Set_Days = 10
to
Set_Days = 30
Maximum delay = 255 days
I can also alter flowchart so every 30 days (or what ever days is set to) port A0 will change state, or count in 1's etc
So if count in binary you could tell how many days or lots of 30days has elapsed.
You could send number or days, hours minutes and seconds elapsed via RS232 for displaying on a pc
or via LCD or 7Seg LED's
Re: DELAY for day's
Posted: Mon Jul 09, 2012 8:39 pm
by electron67
Yes I select: second, minutes, hours and now day's; and display in LCD.
Re: DELAY for day's
Posted: Mon Jul 09, 2012 10:21 pm
by medelec35
electron67 wrote:Yes I select: second, minutes, hours and now day's; and display in LCD.
Can you do that ok or do u need any help?
Re: DELAY for day's
Posted: Tue Jul 10, 2012 12:26 am
by electron67
Let me test the program in the hardware, but I need least one day.
P.S. The program DELAY2 that you send me not work with delay's ?
Thank You
Re: DELAY for day's
Posted: Tue Jul 10, 2012 7:56 am
by medelec35
electron67 wrote:
P.S. The program DELAY2 that you send me not work with delay's ?
I'm a bit puzzled how you can tell this early?
I posted Flowchart at 8pm UK time yesterday and you stated it does not work 4 & 1/2 hours later.
Yet it's a day delay at the minimum.
Can you post your flowchart please if you have changed settings for delay to last less than 5 hours and I can look a it for you.
Also I would advise you to add to flowchart a LED that flashes at 1Hz e.g
So you can test hardware is working.
If your have modified DELAY2.fcf e.g for showing time elapsed on LCD and it's that which is not working, then if you post that I can have a look for you to see what the issue is.
Re: DELAY for day's
Posted: Tue Jul 10, 2012 10:14 am
by Enamul
Hi Electron67,
I am attached here a RTC using TMR1 and crystal 32.768KHz connected in RC0 & RC1 besides 20MHZ PIC main crystal.. This can give you monthly calender..i.e, sec, min, hour and day accurately..
I have reset day variable after 7 to show rotation of week days if you change the day variable to INT and check for 365...it will work for year..
If you need any particular customization...you can tell me I can do that.
I have disabled the time setting macro here...but you can enable that and use 4 push-to-make switch to configure time..
Hope that will help
Enamul
Re: DELAY for day's
Posted: Tue Jul 10, 2012 3:44 pm
by electron67
Hello Medelec,
I apologize if I misspoke, I not have good English but I try to make myself understood, I believe that I not express in English correctly, I am translating this into google, not yet tested the program when you wrote, what I wanted to say is that the eye did not see a block (DELAY) in the diagram and I've never used TMRO I use whenever I use the DELAY delays that was referring to my question, never say quize not work, I ask again apologize, it is difficult to express in English when you do not understand 100%.
P.S. I test the program now and I hope you can follow to help me in the future
APOLOGIZE
Electron67
Enrique Trevino
Hola Medelec,
Te pido disculpas si me exprese mal, no tengo buen ingles pero trato de hacerme entender, creo que no me exprese en ingles correctamente, esto lo estoy traduciendo en google, todavia no probaba el programa cuando te escribi, lo que te queria decir es que a simple vista no veia un block (DELAY) en el diagrama y yo nunca he usado TMRO yo siempre que uso retardos utilizo el DELAY a eso se referia mi pregunta; nunca quize decir que no trabajaba, te pido otra vez disculpas, es dificil expresarse en ingles cuando no lo entiendes al 100%
Espero puedas seguirme ayudando en el futuro
Disulpas
Electron67
Enrique Trevino
Re: DELAY for day's
Posted: Tue Jul 10, 2012 3:55 pm
by electron67
Hi Enamul,
I just downloaded the program I'm going to try this excellent, I telling to Medelec that I have not worked with TMRO but I think I'll start using it to know how they function.
Thank You
Electron67
Re: DELAY for day's
Posted: Tue Jul 10, 2012 4:37 pm
by medelec35
Hi electron67
I understand now.
It should be me apologising for misreading your post!
Not using a delay because if delay is long then during delay program has to wait for delay to finish
So using timer interrupt which interrupt current process at the same set time period and access interrupt macro. When macro is serviced, then interrupted process will continue form where it left off.
If you double click on timer interrupt
and select properties, you will see ‘Interrupt frequency: 83.001Hz’ This means the Timer2_Tick macro is accessed 83 times a second (or once every 1/83 = 12ms) so if you count each time macro is accessed, when count is = 83 then one second has elapsed.
So reset count to 0 and seconds = seconds +1
After 60 seconds is 1 minute etc.
That’s how I used timer to count days. There is just a decision branch that sates if days = or grater then 10 then turn porta0 off.
Hope this helps to understand how flowchart works to generate long delays a bit more.
Martin
Re: DELAY for day's
Posted: Tue Jul 10, 2012 5:04 pm
by electron67
Thanks Martin

Re: DELAY for day's
Posted: Tue Jul 10, 2012 5:12 pm
by medelec35
Your welcome electron67,
I remember my fist time of using timer interrupts so I do know how confusing they are when first encountered.
Hi. Enamul,
I like what you have done with the flowchart!
just one comment which if im right may help?
If Using timer 1 then you should be able to get 80.00 Hz by using
tmr1h = 0x0B;
tmr1l = 0xDC;
If using:
tmr1h = 0x0B;
tmr1l = 0x28;
then interrupt frequency is:
79.77 Hz
Martin
Re: DELAY for day's
Posted: Tue Jul 10, 2012 5:54 pm
by Enamul
Hi,
Thanks a lot for the info.
Enamul
Re: DELAY for day's
Posted: Tue Jul 10, 2012 9:24 pm
by electron67
Hi Martin,
I test the program, attach with other program, but not on led, the day select with keypad, the number 01-30 and store in the eeprom, after read the eeprom (Set_Day) and the program DELAY begin; but not work in the hardware, send you the program with a little change.
You can see that is wrong ?
Re: DELAY for day's
Posted: Tue Jul 10, 2012 11:23 pm
by electron67
I think that the variables DAYS, Count, Minutes, Hours need initiate = 0 .... Is correct ?

I test in hardware but I need await one day to know.
Re: DELAY for day's
Posted: Tue Jul 10, 2012 11:34 pm
by medelec35
electron67 wrote:I think that the variables DAYS, Count, Minutes, Hours need initiate = 0 .... Is correct ?
Yes that's correct.
You must initialise all variables that are read before they are written to.
Reason is variables will all contain random numbers (unlike Flowcode simulator all = 0) when power is first applied to chip.
This would mean timing of days would be wrong, since if days not initialised then Days could start at 5 or 20 or any other random number.
You don't need to initalise V1.V2, V3 etc since they are written to first.
Re: DELAY for day's
Posted: Wed Jul 11, 2012 3:16 pm
by electron67
Thanks Martin.
DELAY for day's
Posted: Wed Jul 11, 2012 4:36 pm
by electron67
Hi Martin
I test the program DELAY2 in minutes, hour and work excelent, now is test in day; one question: I want use 5 TMR2 in the same program, but the copilar show :
Flow5PIC18F4620Mc.c(20293): WARNING: This interrupt has previously been enabled, so the macro <Timer2_Tick> may never get called.
Flow5PIC18F4620Mc.c(20311): WARNING: This interrupt has previously been enabled, so the macro <Timer2_Tick> may never get called.
Flow5PIC18F4620Mc.c(20329): WARNING: This interrupt has previously been enabled, so the macro <Timer2_Tick> may never get called.
Flow5PIC18F4620Mc.c(20347): WARNING: This interrupt has previously been enabled, so the macro <Timer2_Tick> may never get called.
Flow5PIC18F4620Mc.c(20365): WARNING: This interrupt has previously been enabled, so the macro <Timer2_Tick> may never get called.
I see to TMR0, TMR1, TMR3 but are diferent configuration ? to Timer2_Tic add Timer3_Tic, Timer4_Tick, Timer5_Tick, but show the same Warning; What I can do

Re: DELAY for day's
Posted: Wed Jul 11, 2012 4:55 pm
by Benj
Hello,
Martin may have a better suggestion but my suggestion would be to use a single timer resource (timer 2) and maybe increment multiple count variables. Maybe you don't even need to do this could you just have one set of count variables, tick, sec, min, hour, day etc and then multiple sets of Set_Days type variables.
You could even move the Set_Days type variables to an array and then have a loop which cycled through the array one at a time so you don't have to add another set of decisions for every new delay period you add.
Re: DELAY for day's
Posted: Wed Jul 11, 2012 5:29 pm
by medelec35
Benj wrote:my suggestion would be to use a single timer resource (timer 2) could you just have one set of count variables, tick, sec, min, hour, day etc and then multiple sets of Set_Days type variables.
You could even move the Set_Days type variables to an array and then have a loop which cycled through the array one at a time so you don't have to add another set of decisions for every new delay period you add.
Hi Ben,
That's just how I did DELAY2.fcf posted in an earlier post.
We are thinking on the same lines
@electron67
You could ignore warnings only if timer2 has been disable then re-enabled.
Rather than disable interrupt, it may be better to have a variable called enable.
Then in timer2 macro have something like:
So if Enable is set to 1 then time will count up. If Enable is set to 0 then time will be paused.
You could have another variable or use different values of enable to say reset hours seconds days etc. With Flowcode your only limited to your imagination.
If you are having a problem with Flowcode, then if you post flowchart, we can take a look at it for you.
Martin