Detect 240V with a PIC - Page 2


Closed Thread
Page 2 of 2 FirstFirst 12
Results 41 to 49 of 49
  1. #41
    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.

  2. #42
    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.

  3. #43
    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.

  4. #44
    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

  5. #45
    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

  6. #46
    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.

  7. #47
    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

  8. #48
    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.

  9. #49
    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 : 1

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