Light switch sensing


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171

    Default Light switch sensing

    I've built a device that you plug your bedside lamp into, and after a preset time, it slowly dims down to a preset value (upto as far as not being illuminated) the trick is... I have to be able to sense the light switch at any phase of the operation - if switched off - then timer etc resets. I've done this by winding a current transformer and putting output to an opamp. However this has some drawbacks, namely if the amp is set too sensitive it gets triggered during the dimming phase soley by the capacitance in the lead and on the other hand not sensitive enough and it doesn't pick up lightbulb when either fully on or pretty much off - you can tune it so it works with a bulb of a certain wattage and a lead length of a certain amount - but not ideal!!! Any other ways anyone can think of for sensing when the light is turned on/off? I was thinking about trying to send a 5v pulse down the wire at every zero crossing to pick up if switch is on or off - but am a little unsure if it will work or how exactly to do it. Any ideas would be really appreciated.

    Cheers

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi George,

    www.Smarthome.com has 2-way X-10 devices that can tell you the status of the device you are controlling. But if you want to continue on with building your project yourself, Micromint sells a chip called the PLIX. It handles al of the X-10 coding so you don't have to. The chip is available both in parallel and serial configurations. Check out www.Micromint.com for more details. They have examples of using a PIC with the serial device and the parallel device is for use with your PC.

    BobK

  3. #3
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Thanks, tho I'd like to build myself, just for the experience if nothing else! I'm thinking of setting up an oscillator which will send a tone down the line at every zero crossing, however I'm not sure on how to receive the tone on the other end due to mains potential. So basically I have a triac powering - just before I fire the triac I'll be listening for the tone on the output of the lamp, if the switch on the lamp is turned off, no tone should come back.

    Does anyone have any ideas how I can isolate that nasty mains potential either side of my the lamp circuit (bear in mind also that there will be rapid voltage transitions when in the middle of dimming.

    Thanks
    Last edited by George; - 14th July 2006 at 00:36.

  4. #4
    Join Date
    Oct 2004
    Posts
    448


    Did you find this post helpful? Yes | No

    Default

    Hi Bob,

    Why not look for the 50/60 hz pulse itself, taken from the live side, and thru' an opto?

    Or am I missing what your reuirement?

    Regards,

    Anand

  5. #5
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Because if the triac has the light on, you won't see it as that side will be grounded, you could do it if you missed a pulse now and then - but you would also see that by the light flickering.

    Thanks

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Have you thought about using a Hall-effect current sensor. The output is directly proportional to the current, and can be heavily filtered eliminating any noise from the switching.
    Charles Linquist

  7. #7
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Yeah I have thought about that - but figured that it wouldn't be much different to what's happening now with my current transformer. With a 100W lamp on at 100% the current through a multimeter is 390mA - curiously as the % drops the current flow rises to a peak of 433mA - this is due to the combined lamp load and the capacitance of the cable when faced with the sharp turnon of the triac part way through the phase cycle. When the lamp has dimmed down to 3W (filament extinguished) there is 135mA of current flowing (this in my mind is the capacitance of the lead) - in perfect world would be 13mA. When the light switch is off and the dimming phase is part way, multimeter reads upto 180mA - which makes it impossible to figure if the light switch is turned on or off by current alone.

    This is why i was figuring I should send some sort of 'tone' down the line and listen for it on the other side - whether it be at zero cross only or all the time, I'm just not quite sure how to do it having such a large potential either side of my circuit.

  8. #8
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    It doesn't sound right.

    I'm sure that the load has little to do with capacitance. The resistance of a filament IS non-linear with respect to applied voltage, however.

    It would appear that the measurements from your current transformer are PEAK readings, not average. Since you are using a triac - even though the lamp is on only part of the time, the peak current won't drop much at lower brightness levels. If you are using a peak detector (diode) on the output of your current transformer - or even a regular voltmeter (which actually shows .707 * Peak reading, rather than true RMS), I would expect the type of readings you are seeing.

    If I was going to continue using the current transformer, I would put a load resistor across it, then feed the output to a diode into a capacitor, and then a resistor across that capacitor. My guess is that if you put a low enough value across that capacitor, you will find that it gives you a good average of the charge current, and is almost linear with respect to brightness.
    Charles Linquist

  9. #9
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Default

    Will give it a go thanks, if it has little to do with capacitance, why do you think the apparent current goes up 10% when I start to dim the bulb? I agree that the apparent current seems strange since the capacitance of the lamp wiring I'm currently using is only 500pF, but I thought that it's possible that those currents could be since it's going from zero volts upto possibly three hundred volts nearly instantaneously, rather than following a curve. The other thing that I thought I should try is to only read the current shortly after triggering the triac, currently I'm charging a cap from the opamp and reading this whenever.
    Thanks

  10. #10
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Yes, the risetime when the triac fires is pretty quick, but I'll bet that still won't give the current levels you are measuring. Look at the risetime on a scope and calculate it yourself. I = C* dv/dt "I" in amps, C in Farads, dv/dt in volts per second

    I still think your setup is showing you PEAK, not average current.

    Peak current can easily go up with reduced duty cycle. Consider the fact that if you were firing the triac at 60 degrees into the cycle, the bulb would not be at full brightness. Since the filament would be colder than normal, its resistance would be lower than the normal operational value (tungsten resistance is inversely proportional to temperature). The peak voltage (at 90 degrees phase angle) would still be the same as before, and working into the lower resistance of the colder filament, the peak current would be a bit higher.

    One other thing comes to mind: I'm not an expert in current transformers, but is it possible that they have a frequency-response component to their operation - that is, if the frequency goes up, their output does as well? If that is the case, the short risetime when the triac conducts would look like a high frequency signal and couple better than the normal 60 (50?) Hz stuff.

    Whenever I need to measure current, I use a Hall-effect device. It has perfect isolation, near perfect linearity, doesn't cost much, and Doesn't have any "funnies" that I have to deal with.
    Charles Linquist

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Sometime current transformer are great, sometime, when misplaced and/or not properly insulated they can ruine your life and reading... just think what happen if they're located to close of a transformer, or close to a switching power supply, or, or, or.

    EDIT: Did you place any kind of load at the output of your current transformer before sending it to your op-amp???
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    See picture below.

    Best regards,

    Luciano

    Attached Images Attached Images  
    Last edited by Luciano; - 20th July 2006 at 11:37.

  13. #13
    Join Date
    Oct 2005
    Location
    New Zealand
    Posts
    171


    Did you find this post helpful? Yes | No

    Talking

    Thanks Luciano,

    I had thought of that initially, but disregarded it as the TRIAC would have to be off at the same time as the light bulb is on. But seeing your picture made me think about it, and I figured that I can just measure the voltage there just after zero crossing and before I trigger the triac - either that or charge a little cap through a diode and read the cap anytime. Makes it a really simple circuit too!! Will try it as soon as I get back from holiday - am off to Fiji for a week, BULA!!!

  14. #14
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by George
    ... or charge a little cap through a diode and read the cap anytime.
    Yes, this was the idea.

    * * *

    AN521 Interfacing to AC Power Lines
    http://ww1.microchip.com/downloads/e...tes/00521c.pdf

    AVR182: Zero Cross Detector
    http://www.atmel.com/dyn/resources/p...ts/doc2508.pdf

    * * *

    Enjoy your holiday!

    Luciano

Similar Threads

  1. Stairwell light code from BS1 to PHP2.50a
    By vtt-info in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 21st December 2007, 17:32
  2. A/D on 16F767 for light tracking.
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th November 2007, 05:56
  3. Replies: 14
    Last Post: - 26th September 2007, 05:41
  4. PIC10F200 Automated IR Light Switch
    By Bruce in forum Code Examples
    Replies: 7
    Last Post: - 3rd May 2007, 11:40
  5. Newbie - 16F628A and switch latching
    By malc-c in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 19th May 2006, 02:35

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