PDA

View Full Version : Light switch sensing



George
- 12th July 2006, 00:41
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

BobK
- 12th July 2006, 02:54
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

George
- 14th July 2006, 00:34
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

ardhuru
- 14th July 2006, 12:55
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

George
- 17th July 2006, 01:31
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

Charles Linquis
- 17th July 2006, 05:04
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.

George
- 19th July 2006, 00:50
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.

Charles Linquis
- 19th July 2006, 02:02
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.

George
- 19th July 2006, 22:17
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

Charles Linquis
- 20th July 2006, 00:29
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.

mister_e
- 20th July 2006, 01:54
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???

Luciano
- 20th July 2006, 11:08
Hi,

See picture below.

Best regards,

Luciano

http://img6.picsplace.to/img6/23/triac_v.PNG (http://picsplace.to/)

George
- 20th July 2006, 21:55
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!!!

Luciano
- 20th July 2006, 22:56
... 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/en/AppNotes/00521c.pdf

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

* * *

Enjoy your holiday!

Luciano