Page 1 of 1

Help with code please

Posted: Fri Nov 23, 2012 8:19 pm
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 319 times

Re: Help with code please

Posted: Fri Nov 23, 2012 9:59 pm
by dbasnett
It was close. Made a few minor changes.

Re: Help with code please

Posted: Fri Nov 23, 2012 10:01 pm
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 :)

Re: Help with code please

Posted: Fri Nov 23, 2012 10:28 pm
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 ?

Re: Help with code please

Posted: Fri Nov 23, 2012 10:53 pm
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

Re: Help with code please

Posted: Fri Nov 23, 2012 10:59 pm
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.

Re: Help with code please

Posted: Fri Nov 23, 2012 11:08 pm
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

Re: Help with code please

Posted: Fri Nov 23, 2012 11:14 pm
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?

Re: Help with code please

Posted: Sat Nov 24, 2012 12:04 am
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

Re: Help with code please

Posted: Sat Nov 24, 2012 12:56 am
by Enamul
OK..this chip can easily do that. I can post figure to show how to use the chip.

Re: Help with code please

Posted: Sat Nov 24, 2012 1:08 am
by acestu
Thanks Enamul,

that would be great...

Acestu

Re: Help with code please

Posted: Sat Nov 24, 2012 2:32 am
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.

Re: Help with code please

Posted: Sat Nov 24, 2012 12:12 pm
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

Re: Help with code please

Posted: Sat Nov 24, 2012 12:37 pm
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.

Re: Help with code please

Posted: Sat Nov 24, 2012 7:38 pm
by acestu
Hi Enamul,

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

thanks
Acestu

Re: Help with code please

Posted: Sat Nov 24, 2012 8:28 pm
by Enamul
But in AC side you have to use at least 0.5A fuse.

Re: Help with code please

Posted: Sun Nov 25, 2012 5:31 pm
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

Re: Help with code please

Posted: Sun Nov 25, 2012 5:39 pm
by Enamul
1N4001 is perfect for this application..180K is limiting current..so no problem