On Sun, 13 Dec 1998, Wendy & Guy wrote: > How do these types of switches work? Are there any safety issues, eg if the > triac blows? The usual way is to connect the metal plate through a high value resistor to a diode-protected CMOS input. With a PIC input and 220V mains, 2M2 will work. The wiring and plate size are critical. To reduce sensitivity it is possible to add a small *capacitor* between the pin and GND. A capacitor is also used in series with the plate and resistor sometimes (0.1 uF PMP 400Vdc will be enough). The worst case leakage current is about 310V / 2.2E6 ~= 140 uA. Note that this is high enough to worry about its pumping up the Vdd supply of a PIC if it is sleeping at the time. Since the PIC input was never meant to be used like this, it is good to give it an initial DC polarization. I use a 47Meg resistor from the PIC input to GND for this. The software sees pulses at 50 Hz on the pin when the plate is touched, and nothing when not. It also sees high frequency glitch transitions when the input (slowly) passes through the CMOS input forbidden band. A debouncing system should be used to count a reasonable number of pulses / time before deciding that the plate is being touched. One should not assume that there are 50 pulses per second on the plate when touched ;). Last, this system is sensitive to RFI from ignition devices and small electric motors (razor, toys etc). The code should not decide that the plate is being touched if irregular pulses are arriving. This means, window or median filter on frequency domain samples, which are actually time domain samples due to the low frequency. One trick that I've used is to implement a kind of synchronous filtering. Since the input AC is coming from the same phase as the one the PIC is using for the light, the PIC can decide whether the plate is being touched or receiving ether signals by comparing the input to the AC zero crossing phase, over a few cycles, in the middle of the peak(s). This removes phase lag problems up to ~35 degrees, which happen due to the person's body R/C. Now, who ever said that dimmers are easy ? (And we haven't even touched upon the problems of early and late triac firing ;). hope this helps, Peter