Help with code please

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
User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Help with code please

Post by acestu »

Hi,

In another thread I am building a heating timer with the help of Enamul, ass an add on I want to make this unit that will give a "Zone ON" indication on an LCD if the corresponding port is high, and when the port is low the LCD reverts to saying OFF, I have started the cod but have got stuck really, I am enclosing a copy of the code, I would appreciate it if anyone could help.

thanks in advance
Acestu
Zone_status.fcf
(17.5 KiB) Downloaded 262 times
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

dbasnett
Posts: 125
Joined: Mon Aug 15, 2011 1:54 pm
Has thanked: 8 times
Been thanked: 11 times
Contact:

Re: Help with code please

Post by dbasnett »

It was close. Made a few minor changes.
Attachments
Flowcode1.fcf
(17.5 KiB) Downloaded 256 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: Help with code please

Post by medelec35 »

Hi Acestu,

Here is one version.

I will post another version without the switch command later.

Just want to show you some different methods of achieving what you have requested.

Martin

Edit posts have crossed.

So not seen how dbasnett has done is code.

It's still good to see how different other people so about solving the same task :)
Attachments
Zone_status1.fcf
(15.31 KiB) Downloaded 260 times
Martin

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Help with code please

Post by acestu »

Hey Thanks Guys,

2 different approaches, that's great for learning purposes, I have just looked at both of the codes and I think the way my logic would of done it was dbasnett's version I think, Martin the way that you did it , the LCD cursor setting I have only seen the settings as numbers ie 17,0 but you have used something like 17, zone_1 so I don't really know what is going on there, but thanks to both of you for the different views...

thanks
Acestu :D

P.S. My plan is to use these http://www.avagotech.com/pages/en/optoc ... hcpl-3700/

to connect the 230volt live wires to the inputs of the pic and switching the lcd status, what do you think ?
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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: Help with code please

Post by medelec35 »

acestu wrote: Martin the way that you did it , the LCD cursor setting I have only seen the settings as numbers ie 17,0 but you have used something like 17, zone_1 so I don't really know what is going on there
With the cursor command you can either enter a number e.g 17 for X and 0 for Y, or you can enter a variable.
Since zone steps from 1 to 2 to 3 to 4 then back to 1 then if you use 17 for X and zone-1 for Y then:
When: zone = 1, Y = zone-1 = 0 So Text is on line 0
zone = 2, Y= zone-1 = 1 So Text is on line 1
Etc

Martin
Martin

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

Re: Help with code please

Post by Enamul »

My plan is to use these http://www.avagotech.com/pages/en/optoc ... hcpl-3700/
to connect the 230volt live wires to the inputs of the pic and switching the lcd status, what do you think ?
I have used this sensor for AC Energy meter module to isolate ac part from PIC..very nice and reliable IC.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Help with code please

Post by acestu »

Hi Enamul,

Yes I was searching for something to use for this project the other night and found these they seemed just the job for voltage/current sensing, I am glad you think the same, I have ordered some from Farnell together with the chips for our Timer project, they should be here Monday...

Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: Help with code please

Post by Enamul »

I have ordered some from Farnell together with the chips for our Timer project, they should be here Monday
What you exactly want to know using this chip? I have also used another ic from the same company..they really very linear in output response..Do you want to measure voltage or current or just want to detect the presence of voltage?
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Help with code please

Post by acestu »

Hi Enamul,

For this project I just want to sense that a wire is live with 230volts, but I would love to learn more about it...

Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: Help with code please

Post by Enamul »

OK..this chip can easily do that. I can post figure to show how to use the chip.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Help with code please

Post by acestu »

Thanks Enamul,

that would be great...

Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: Help with code please

Post by Enamul »

Hi

Nice thing of the IC is that it can be used with AC/DC both..But I prefer to rectify outside the IC and filter the DC and drop the voltage low enough so that you can apply that to the input of the IC. GND1 is AC side GND and GND(Vss) is common with PIC. That means GND will be separated and so there will be no link with AC circuit to PIC circuit which can save you from lots of AC issues.
Attachments
ckt.png
(50.72 KiB) Downloaded 5176 times
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Help with code please

Post by acestu »

Thanks Enamul,

That's really handy, just what I want to do, would it be advisable to put a fuse on the AC input ?

Thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: Help with code please

Post by Enamul »

That's really handy, just what I want to do, would it be advisable to put a fuse on the AC input ?
Yes. You are absolutely right. I forgot to put..That's a very emergency one for ac.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Help with code please

Post by acestu »

Hi Enamul,

what sort of value fuse would you use because I suppose this device is drawing absolute minimal current ?

thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: Help with code please

Post by Enamul »

But in AC side you have to use at least 0.5A fuse.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
acestu
Posts: 1720
Joined: Thu Dec 01, 2011 9:36 pm
Location: Macclesfield UK
Has thanked: 783 times
Been thanked: 223 times
Contact:

Re: Help with code please

Post by acestu »

Hi Enamul,

Just wondering what diodes you have used for the voltage sensing circuit, would 1N4001 do because there is no real big power involved is there ?

thanks
Acestu
Laptop Mac Book Pro i7 retina El Capitan //// Tower/Intel i7-Windows 7 64 Bit, Toshiba i5 Laptop Windows 10
Computers are like air conditioners. They work fine until you start opening windows.

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

Re: Help with code please

Post by Enamul »

1N4001 is perfect for this application..180K is limiting current..so no problem
Enamul
University of Nottingham
enamul4mm@gmail.com

Post Reply