Nested desisions

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Bill Felker
Flowcode v5 User
Posts: 47
Joined: Tue Sep 24, 2013 7:21 pm
Has thanked: 18 times
Been thanked: 12 times
Contact:

Nested desisions

Post 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. :roll:

Bill Felker
Attachments
Phase Detector.fcf
(17.44 KiB) Downloaded 293 times

medelec35
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: Nested desisions

Post 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:

Code: Select all

osccon=0x60;
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
Attachments
Phase Detector V2b.fcf
(20.39 KiB) Downloaded 282 times
Phase Detector V2a.fcf
(20.39 KiB) Downloaded 268 times
Martin

Bill Felker
Flowcode v5 User
Posts: 47
Joined: Tue Sep 24, 2013 7:21 pm
Has thanked: 18 times
Been thanked: 12 times
Contact:

Re: Nested desisions

Post 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. :D

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.

Bill Felker
Flowcode v5 User
Posts: 47
Joined: Tue Sep 24, 2013 7:21 pm
Has thanked: 18 times
Been thanked: 12 times
Contact:

Re: Nested desisions

Post 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.
Attachments
Phase Detector V2a1.fcf
(20.46 KiB) Downloaded 296 times

medelec35
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: Nested desisions

Post 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

Code: Select all

MX_CLEAR_WATCHDOG;
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.
Attachments
Phase Detector V2a2.fcf
(19.16 KiB) Downloaded 298 times
Martin

Bill Felker
Flowcode v5 User
Posts: 47
Joined: Tue Sep 24, 2013 7:21 pm
Has thanked: 18 times
Been thanked: 12 times
Contact:

Re: Nested desisions

Post 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. :D

Bill

medelec35
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: Nested desisions

Post by medelec35 »

Your welcome Bill,
Two version are better than one :)
Hope they do work on hardware.

Martin
Martin

Bill Felker
Flowcode v5 User
Posts: 47
Joined: Tue Sep 24, 2013 7:21 pm
Has thanked: 18 times
Been thanked: 12 times
Contact:

Re: Nested desisions

Post by Bill Felker »

OK, one more stupid question. The Master Clear Enable my choices are internal or external which on disables this?

Bill

medelec35
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: Nested desisions

Post 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.
Martin

Bill Felker
Flowcode v5 User
Posts: 47
Joined: Tue Sep 24, 2013 7:21 pm
Has thanked: 18 times
Been thanked: 12 times
Contact:

Re: Nested desisions

Post 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. :D Bill

Post Reply