Page 1 of 1
multiple delays and loop with 12F609
Posted: Tue Jul 03, 2012 7:26 am
by ionize
Although I have built many devices over the years, I'm a newbie with little programming experience and I am trying to implement multiple delays using an interrupt and have an independent loop. Not sure if I'm headed in the right direction with this flowchart. The loop works as intended but the other delays don't seem to trigger off although they turn on. This is on a 12F609 but I have several 8 pin devices I could use. An 8 pin dip socket is what is already on the circuit board. Any suggestions?
I composed this flowchart with V5 but it says its a V4. I have both.
Thanks,
Scott
Re: multiple delays and loop with 12F609
Posted: Tue Jul 03, 2012 9:31 am
by Benj
Hi Scott,
Could the problem be that you are setting T_Cycle, T_Val and T_Count to 0 in the interrupt routine. Should these instead be set to 0 at the start of the program and then allowed to accumulate in the interrupt service routine?
Re: multiple delays and loop with 12F609
Posted: Fri Jul 06, 2012 11:18 pm
by ionize
Thanks BENJ for answering my call for help!
I tried your suggestion but no go. I also tried removing the loop and no go. I also removed the equalizing code at the start of the tick macro and still nothing yet. any more suggestions will greatly appreciated!
Re: multiple delays and loop with 12F609
Posted: Sat Jul 07, 2012 12:16 am
by medelec35
Hi Scott,
Take a read of this:
http://www.matrixmultimedia.com/mmforum ... 448#p32448
It may help?
If you would like to say what times you want to elapse and what you want hardware to do after each elapsed time, then I can help you to create a flowchart that works the way you have intended.
Martin
Re: multiple delays and loop with 12F609
Posted: Sat Jul 07, 2012 1:09 am
by ionize
Thanks for your answer. I read the posts you referenced above while I was trying to come up with something and looking for some example code. What I need is a loop of say 10 minutes on and 10 off on port a bit 0 and 1, plus a delay that stays on of 1 hour on port a bit 2, 2 hours on port a bit 4 and 4 hours on port a bit 5 and if possible, reset at 5 hours. the port's bits would be turning on 2n3904 transistors. Hope that is clear. The loop section works great. (which I learned from you in other posts elsewhere) Thanks for your help and advice. I will keep playing with working code with interrupts from the example files until I understand whats going on better.
Scott
Re: multiple delays and loop with 12F609
Posted: Sat Jul 07, 2012 8:34 am
by medelec35
I forgot to ask if you are using a crystal or resonator for external osc or internal oscillator.
What is frequency of your oscillator?
For example I will create, I'm assuming your going to use internal oscillator at 8MHz.
This will give you more I/O pins.
Flowchart of course can be altered with different settings at anytime
I will post flowchart today
Martin
Re: multiple delays and loop with 12F609
Posted: Sat Jul 07, 2012 10:23 am
by medelec35
As promised as have created two flowcharts.
Both do the same thing, but V2 has more control e.g if push a switch then timer can be reset on any individual port bit.
E.g Press a switch to reset 4 hour timer.
This makes it a bit more complex and uses more rom.
V3 is a bit more simple and takes up less room on target device.
Since both flowcharts should do what you want them to do, creating more delays should be straight forward.
If there is anything you don't understand then just let me know.
Martin
Edit:
Bug with V2.
Corrected in V2b.
Re: multiple delays and loop with 12F609
Posted: Sat Jul 07, 2012 8:15 pm
by ionize
Martin, Werner is right- you are the Professor of Flowcode! You have blown me away with these charts. I've got to digest them and I'll get back to you, thanks
Re: multiple delays and loop with 12F609
Posted: Sat Jul 07, 2012 9:12 pm
by medelec35
Hi Scott.
I do wish I knew enough to earn the title, but with other things in the pot stops me from learning in depth.
Also my memory is not good enough.
Thanks for the nice comments
Martin