Page 1 of 1
Nested desisions
Posted: Sat Aug 09, 2014 11:06 pm
by Bill Felker
OK, here is my dilemma - I am designing a phase missing detection board I have 3 adc inputs that I am declaring as being OK if all 3 phases are >90 . Now I have 4 outputs that are for 3 leds (one to show each of the phases is present) and one that when high opens up a relay that drop our my controlling signal that fires the SCRS in the power supply . Now I am having a brain fart on how to show which phase is out while the other 2 are still on or if there is more than one phase out . The relay is still ON until either the power is restored or the system is turned off to fix. I am hoping this makes sense to someone . I will attach what I have so far and see if anyone can send me on the right path. I've been looking at my design for to long today I guess.
Bill Felker
Re: Nested desisions
Posted: Sun Aug 10, 2014 10:51 am
by medelec35
Hi Bill,
Try either of the attached flowcode and see if it works for you.
I have modified your flowchart to indicate which phase has triggered the relay and to work at 4MHz internal oscilator by adding:
Phase Detector V2a LED of the phase thats >90 will light
Phase Detector V2b LED of the phase thats >90 will be extinguished.
Not sure which version was required?
Internal osc can run at 8MHz if required.
I have also modified your flowchart to work with watchdog enabled.
When you have tested on hardware, if all is working, then I would recommend enabling watchdog timer within configuration settings.
Since you're using a registered Flowcode version V5 I would recommend
registering so you can post in the V5 section
Martin
Re: Nested desisions
Posted: Sun Aug 10, 2014 3:41 pm
by Bill Felker
Martin, WOW . I am once again amazed by the willingness of others here to help out. I preferred V2a over V2b because the lights represent the "working" phases and when it a phase or 2 go out you will be able to see that the power supply has fuses blown. What made you go down the road to use the watchdog timer? I am new to this and I guess I do not really understand the WDT all that well. I have a copy of my design in eagle if anyone would want it.
Bill
ps. I did modify the phaseFail loop to "loop until" so that if for some reason the sense circuit causes a false fail it would continue on or if for some reason the incoming power glitches on one phase.
Re: Nested desisions
Posted: Sun Aug 10, 2014 3:55 pm
by Bill Felker
OK after playing with this for a while I noticed that if I get a fail the relay on (green LED) comes on but if the phase fail goes away the only way to turn off the Green LED is to power off or reset the program. I don't think this would be a big problem because the phase fail is usually a fuse in the power supply and to change it we have to turn off the power anyway but if it was only a power glitch on a phase then it may be a problem. I must muse on this for a while.
Bill
ps. after musing it over I found out where I needed to put an output to zero bit 0 I will now post the latest version.
Re: Nested desisions
Posted: Sun Aug 10, 2014 4:49 pm
by medelec35
Hi Bill,
Bill Felker wrote:OK after playing with this for a while I noticed that if I get a fail the relay on (green LED) comes on but if the phase fail goes away the only way to turn off the Green LED is to power off or reset the program.
Bill Felker wrote:The relay is still ON until either the power is restored or the system is turned off to fix.
Ahh, sorry I thought you meant remove supply to microcontroller, not the phases.
My mistake.
So I thought (wrongly ) that once relay goes on, it stays on (until microcontroller is reset).
So not a bug , it was deliberate.
I now understand, So I have modified the flowchart again to allow a the relay to go off when all phases are correct.
I have also added a delay, so relay does not rapidly enable/disable.
I can also modify flowchart so it ignores glitches?
Bill Felker wrote: am new to this and I guess I do not really understand the WDT all that well
Microcontrollers like PC's can get corrupt and freeze.
WDT in controlled by an independent timer.
Within every every 18ms the WDT needs to see a command
to reset to prevent it from rolling over.
If WDT does not see this command within 18ms (if for example stuck in a loop or frozen or even a bug) then the microcontroller resets.
I thought using WDT in the case of power supply monitoring its important there is no freezing.
Re: Nested desisions
Posted: Sun Aug 10, 2014 7:41 pm
by Bill Felker
Martin, thank you so much. I've now got 2 examples that both work doing it slightly different ways. I love it. I can't wait to wire it up and try it.
Bill
Re: Nested desisions
Posted: Sun Aug 10, 2014 11:02 pm
by medelec35
Your welcome Bill,
Two version are better than one
Hope they do work on hardware.
Martin
Re: Nested desisions
Posted: Mon Aug 11, 2014 12:00 am
by Bill Felker
OK, one more stupid question. The Master Clear Enable my choices are internal or external which on disables this?
Bill
Re: Nested desisions
Posted: Mon Aug 11, 2014 12:39 am
by medelec35
If you choose external, then MCLR must be at +suppy voltage (usually via a pull-up resistor. shorting to ground will keep chip in reset condition.
So do disable MCLR it must be set to internal.
Re: Nested desisions
Posted: Mon Sep 15, 2014 9:13 pm
by Bill Felker
Sorry it took so long to get back .I've tested the program and it works as it is suppose to , but I've yet to try the circuit in a real world environment to see if it will do what I wanted it to do. A BIG THANKS once again to all who helped me out with this and educated me further in flowcode and PIC coding in general. Your guys on this forum are the greatest.

Bill