Should be simple...but i'm new!

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
TezzaMcTezza
Posts: 5
Joined: Mon Sep 10, 2012 8:02 pm

Should be simple...but i'm new!

Post by TezzaMcTezza »

Hi,
I have been teaching myself electronics for a while now but have only recently started teaching myself about PIC and programming them, I have flowcode V5 and am so far able to do simple things like make outputs react with inputs.

So I thought id try make a simple program for the following application but I am having trouble.

Basically its a light controller with a pir sensor.

When the pir sensor is triggered it turns the light on.
There is a control panel that controls it all.

The control panel consists of 3 buttons each with a status led.

So my inputs are as follows:
Button one: Power, Nothing works without power being on - Connected to A0
Button two: Buzzer, If this is selected a buzzer sounds when the PIR is triggered - Connected to A1
Button three: Timer, If this is selected the light/buzzer only lights for 1minute. Also acts as a reset, when pressed turns off alarm light - Connected to A2
Alarm Input: Connected to A3

So my outputs are as follows:
LED one: Power LED, Indicates On/Off - Connected to B0
LED two: Buzzer LED, Lights if the buzzer will sound - Connected to B1
LED three: Timer LED, Lights if the light/buzzer will only sound for 1minute - Connected to B2
Alarm Light: Lights when power is on, and A3 is triggered - Connected to B3
Buzzer: Sounds when A0 in on, A1 is on and A3 is on.

I thought it should be quite easy. (If you actually understand what I want to accomplish)

But all I have managed to do is create the on / off section, anything inside of this decision doesn't seem to work.

Any suggestions on how you would do it?

I'll try and upload what I've achieved when I'm back on my windows machince

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times

Re: Should be simple...but i'm new!

Post by dazz »

hi
if post your flowchart then we will be able to help out
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times

Re: Should be simple...but i'm new!

Post by JohnCrow »

Hi
I made a simple PIR board some time ago
Maybe this will help

http://www.matrixmultimedia.com/mmforum ... hilit=+pir
1 in 10 people understand binary, the other one doesn't !

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times

Re: Should be simple...but i'm new!

Post by Enamul »

Hi,
Here is the flowcode according to your requirement. In the attached code, I have made 1 min using TMR0 which is used to run the light ON for 1 minute if PIR triggered. Buzzer is driven by 4.8 KHz PWM signal which will also last for 1 minute. Rest of the control logic is as you said.
Simulation of 1 minute will be longer than in practice. Please let me know how you are getting into..
Attachments
Simple_example.fcf
(18.19 KiB) Downloaded 259 times
Enamul
University of Nottingham
enamul4mm@gmail.com

TezzaMcTezza
Posts: 5
Joined: Mon Sep 10, 2012 8:02 pm

Re: Should be simple...but i'm new!

Post by TezzaMcTezza »

Hi!
Thanks for all your help! One thing i forgot to mention is that i have to use momentary push buttons, which is why i think i'm struggling. I have pretty much got everything working now apart from when the buttons are pressed i obviously need to push them again to switch them off and i cant work out how to do it.

For the purpose of simulating i have set the timer to 10secs to make it quicker when running.
I have used a push button to simulate the pir input
I have used a led to simulate the buzzer
For now, until i work out how to turn the outputs off when the buttons are pressed again i have made a macro to turn all outputs off at the beginning.

As i said i have everything working but at the moment i am having to end and re-start the simulation to reset the inputs.

I hope every one gets all that! I have attached my file below, they'll prob be 100 easier ways to do this but there we are!
Attachments
Try3a.fcf
(33.55 KiB) Downloaded 261 times

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

Re: Should be simple...but i'm new!

Post by medelec35 »

Hi TezzaMcTezza,

I have not fully finished your flowchart, just altered enough to give you an idea.

Power, buzzer and timer can now be toggled.
I'm using the = ! which is just toggle (well its really a logical NOT so NOT 1 = 0.

so evey time say Power = !Power is accessed then if power = 0 it will be changed to 1.
Conversely if power = 1 it will be changed to 0.

I have also included a loop containing a read port within.
That just halts program if a key is held down, until its released.

Martin
Attachments
Try3b.fcf
(35.19 KiB) Downloaded 259 times
Martin

Post Reply