A little help, review, suggestions

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
hawk44
Posts: 13
Joined: Mon Jun 16, 2014 10:08 pm
Has thanked: 9 times
Been thanked: 6 times
Contact:

A little help, review, suggestions

Post by hawk44 »

Greetings !
I am very new with FlowCode. Having purchased (ver. 6 PRO) I am determined to learn it. Suggestions etc. welcome.
I will attempt to attach my program. The idea is to push a button when the lights are off, set a variable to 1 and turn the
lights on. When someone pushes the button again (second time)the variable is cleared (for next time) and the lights go out.

The program works ok when I step through it but is a little if'y when running faster. I added delays I thought might help, but didn't really solve the problem. Oh, important....this is all during simulation. I havn't burned it to a micro yet, they seem to run faster still when you do so thought I'd see what might be needed first.

All suggestions welcome, except......one....the one that suggests I just use a latching switch. :lol:

Reason: I will probably try to add motion control or something later. :lol:

Much Thanks, David
Attachments
Garage Light.fcfx
(6.87 KiB) Downloaded 233 times

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: A little help, review, suggestions

Post by GTF »

You will need to include a component macro to read the state of the switch. You may also use one to turn ON/OFF the LED. There are many ways to do what you want. I think the second example I attached is more like what you intended, although it could still use some improvement. Using an interrupt would be another option....experiment and learn as I am still doing.
Grant
Attachments
Garage Light_1.fcfx
(4.88 KiB) Downloaded 208 times
Garage Light_2.fcfx
(6.04 KiB) Downloaded 227 times

hawk44
Posts: 13
Joined: Mon Jun 16, 2014 10:08 pm
Has thanked: 9 times
Been thanked: 6 times
Contact:

Re: A little help, review, suggestions

Post by hawk44 »

Thank you GTF,

i come from an assembly, C programming background and I find it a little difficult to know what to put where in Flowcode. Considering how long it takes to otherwise program I still think Flowcode is the way to go. And writing as much as you can in the way of programs is the way to learn.

Thanks for the reply and your time to add examples. I be going over them next.

Have a great day.

David

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: A little help, review, suggestions

Post by Benj »

Hi David,

I've had a quick go at simplifying your program and hopefully it should now be pretty reliable.
Garage Light.fcfx
(6.27 KiB) Downloaded 210 times

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: A little help, review, suggestions

Post by GTF »

Sorry David. For some reason I did not notice the Input icon in your chart, which works fine for reading the switch state. :oops:

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: A little help, review, suggestions

Post by medelec35 »

I thought I would show an alternative way that takes switch bounce into account.
This would be the way in which I would tackle things.
the =! is the same as logical NOT so if variable = 0 then after =!, variable will = 1 so its toggled (or inverted)
like wise if variable = 1 then after =!, variable will = 0
Rest of the flowchart is not that dissimilar to Bens method.

Martin
Attachments
Garage Light Alternative.fcfx
(5.67 KiB) Downloaded 203 times
Martin

hawk44
Posts: 13
Joined: Mon Jun 16, 2014 10:08 pm
Has thanked: 9 times
Been thanked: 6 times
Contact:

Re: A little help, review, suggestions

Post by hawk44 »

Thank you everyone.

You guys are great !

I hope to be able to sometime be of some help to you all sometime.

Got to get past this learning curve. I'm still going over what you have given me to learn as much as I can from it, thanks.

David

Post Reply