Detect 240V with a PIC


Closed Thread
Results 1 to 40 of 49

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi, Master

    may be there's your idea here ...


    Alain
    Attached Images Attached Images
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  2. #2
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    mackrackit, I have a glass of water here that i was using to test the water sensor.

    skimask, The problem with 50Hz or any oscillating input is that the PIC detects multiple inputs. Im sure its easy enough to program around that but ive not got that far yet

    Acetronics, that looks just slightly complicated. I dont think ive got half the components in that diagram anyway

    dhouston, Its a PIC16F877A. Doesnt really matter much about which pin. I guess it wouldnt hurt to add diodes in myself just to be sure. I did a search for "clamp" in the datasheet so thats why i didnt find anything. "clamp" wont find a diagram

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    mackrackit, I have a glass of water here that i was using to test the water sensor.
    For an electrical fire ?

    skimask, The problem with 50Hz or any oscillating input is that the PIC detects multiple inputs. Im sure its easy enough to program around that but ive not got that far yet
    Rectifiers do not care...do they?
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    That was a joke by the way! I probs should get a fire extinguisher though with some of the things i do.

    My point with 50Hz is that the PIC thinks the smoke machine is ready then not ready 100 times a second. Ive been thinking about the code for that and it should be really easy. Just a variable that counts down to 0 from whatever value (i havnt worked that out yet). If it gets to 0 then there is no power, otherwise the input will turn on again before it reaches 0 and reset the variable to its start value

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    My point with 50Hz is that the PIC thinks the smoke machine is ready then not ready 100 times a second.
    Ahh...
    But what if there was a capacitor across that PIC and ground along with a high-ish value resistor to bleed that charge off the capacitor?
    Anything click yet?

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    That was a joke by the way! I probs should get a fire extinguisher though with some of the things i do.
    And safety glasses. I always wear them when I write code.
    My point with 50Hz is that the PIC thinks the smoke machine is ready then not ready 100 times a second. Ive been thinking about the code for that and it should be really easy. Just a variable that counts down to 0 from whatever value (i havnt worked that out yet). If it gets to 0 then there is no power, otherwise the input will turn on again before it reaches 0 and reset the variable to its start value
    As skimask said
    You'll probably have to put a diode inline with the PIC pin and maybe a small R/C network behind that to filter out the 50hz half-wave and get a decent reading at the PIC
    Should not be a problem.
    Dave
    Always wear safety glasses while programming.

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Talking Can't believe it ... !!!

    Quote Originally Posted by The Master View Post
    Acetronics, that looks just slightly complicated. I dont think ive got half the components in that diagram anyway
    LOL ...

    .... just think you only need D1,D2,D3,D4, R1 and IC1 ... and you do what you want with the O.C. transistor.

    Is there someone with a brain, on this forum ???????????????????????????????

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Is there someone with a brain, on this forum ???????????????????????????????
    Alain
    I've got one...bought it at Walmart on sale...rarely use it though...it gets in the way too often...

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Is there someone with a brain, on this forum ???????????????????????????????
    I have lost the manual for mine, and I can not find the receipt.
    Dave
    Always wear safety glasses while programming.

  10. #10
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    ...you only need D1,D2,D3,D4, R1 and IC1 ...
    Thats not so bad then, Im not sure what the rest of it does.

    BTW, i do have a brain but its not working today! I didnt get to bed till 7:30 this morning then my dad woke me up at 12:00 to figure out why all the text on someones PC was too small. Ive replaced the beer with coffee but its still not enough.

    I forgot about using a cap/resistor. Im sure i can squeeze them in somewhere.

    The best place to connect the inputs is on portb. Ive checked the datasheet and it says those pins have the diodes so that should be fine.

    I have got some safety glasses but i usually only use those for woodwork

  11. #11
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    dhouston, Its a PIC16F877A. Doesnt really matter much about which pin. I guess it wouldnt hurt to add diodes in myself just to be sure. I did a search for "clamp" in the datasheet so thats why i didnt find anything. "clamp" wont find a diagram
    Look at the diagrams in section 4.0 I/O PORTS. Most of the pin diagrams have the following... Note 1: I/O pins have protection diodes to VDD and VSS.

  12. #12
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    skimask, The problem with 50Hz or any oscillating input is that the PIC detects multiple inputs. Im sure its easy enough to program around that but ive not got that far yet
    The first edge sets the interrupt bit which stays set until you clear it.

  13. #13
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dhouston View Post
    The first edge sets the interrupt bit which stays set until you clear it.
    I wasnt gonna use interrupts for this. I need 3 inputs and i dont think this PIC has 3 interrupt pins. I would still have the same problem of needing to reset the interrupt after a certain length of time. Using the cap/resistor method should make it really easy though

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    I wasnt gonna use interrupts for this. I need 3 inputs and i dont think this PIC has 3 interrupt pins. I would still have the same problem of needing to reset the interrupt after a certain length of time. Using the cap/resistor method should make it really easy though
    Since an input pin is a high impedance input, it won't draw any current (well, very very little current), so, if you're dealing with 50Hz, half-wave, it's almost a simple matter of figuring out what R/C time constant you want depending on values of parts you have on hand, keeping in mind that generally 5 R/C time constants is considered a full 'charge' or 'discharge'...so...
    1ohm @ 1f = 1 second, 1ohm @ 1uF = 1us, 100ohm @ 1uf = 100us...and so on and so on...
    50hz = 20ms per pulse, 5x = 100ms, so...just thinking in general here...
    Put the signal into your PIC, tie a 10uF capacitor into that line with a 10K resistor hanging off the other end of the capacitor going to ground.
    10000ohm x 10uf = 100ms
    IF my figuring is right, it should work like a champ and 'hold' your signal there for the PIC to see. The only 'problem' is that it'll take the cap (and therefore the PIC pin) about 100ms to bleed off completely and your PIC might think power is still on for a few ms after it's actually off.

  15. #15
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Ive got some random capacitors hanging around somewhere and i thnk ive got some 10uf's in there.

    Right now i have another problem. If i connect either of the AC wires from the smoke machine to GND on the breadboard the smoke machine light goes off. Im not sure why the light simply goes off. If it was a short i should be sat here in darkness by now. It works fine if i inplug the USB/Serial converter from my laptop :S

  16. #16
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Master View Post
    I wasnt gonna use interrupts for this. I need 3 inputs and i dont think this PIC has 3 interrupt pins. I would still have the same problem of needing to reset the interrupt after a certain length of time. Using the cap/resistor method should make it really easy though
    Four pins of PortB have InterruptOnChange. You don't need to use interrupts, you merely need to monitor the interrupt flag bits.

  17. #17
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Im not sure this whole thing is going to work. I tested it earlier by using a plug with 2 wires connected to the circuit. It seemed to work fine. Now with the smoke machine its not working. Ive had a look at how the smoke machine is wired and it seems that the bulb and motor are shorted out by default and in series with the heater coil. When the coil reaches a set temperature it removes the short which allows the light and motor to be operated.

    For some reason when the neutral wire of the smoke machine and the GND of my serial port are connected it shorts the bulb and motor out again. It doesnt seem to be affecting anything but since its 240V being shorted through my laptop im gonna stop here.

    I think the best way to go is to use opto isolators. I might not bother doing that for halloween but ill try it out in the future. Another thing i could try is completely re-wiring the smoke machine and putting a PIC inside it. That would let me do some extra advanced stuff like keeping the coil warm (safely) so i never have to wait for it to reheat. I could use the same protocol as my lights.

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Detecting 240V with a PIC (Part2)
    By The Master in forum Off Topic
    Replies: 7
    Last Post: - 18th March 2009, 19:10
  3. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  4. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14
  5. pic detect amperage
    By jetpr in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th February 2005, 05:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts