Latching MOSFET Switch
This project initially started out as an infrared contactless switch to turn a light on and off when a hand is waved in front of the sensor, but I abandoned the infrared sensor side of it as I couldn't achieve 100% reliabiity in all light conditions. The simple comparator circuit I built worked fine under artificial light or in shaded daylight, but when the light from outside was strong, the sensor became saturated and the set point altered. Things improved by adding an infrared filter window from a remote controller but it still needed re-calibrating everytime the light conditions changed. I tried a cheap ready made sensor as well to see if it was any better but it behaved the same. I gave up and purchased an industrial infrared proximity sensor which wasn't very expensive and works flawlessly. Details of this are given later
The requirement of the circuit is to switch 'ON' when a single voltage pulse is applied to the input and stay 'LATCHED ON' until a second voltage pulse is received, where it will switch 'OFF' and stay off until the cycle is repeated. There are several ways to acheive a latching function, but I just used a 4 Bit counter (74HC393) as I had some left over from another project. By using the Q0 output it simply acts as a divider which is the function needed. I thought it would be good to make the circuit general purpose and so it has Schmitt trigger inverters (74HC14) at the input which not only allow it to work with positive or negative going trigger pulses (leading edge) but also act as a contact debounce filter (formed by the 47K resistor and 1u capacitor). This makes the circuit compatible with any 5V logic source and gives immunity from false triggering, even if just a simple 'tact' switch with noisy contacts is used! Of course all this can be done in software but that's not what this site is about... and where would the fun be?
The circuit is designed to switch 12 volt loads but has an onboard 5 volt regulator to supply the logic ICs. The Q0 output from the counter directly feeds the gate of an N channel MOSFET transistor (STP55NF06L). 5 volts from a logic chip would not normally be enough to drive a MOSFET into full conduction but in this case I chose a device specifically designed for use with logic circuits (with a gate threshold voltage lower than 5V) so full saturation can be achieved. Because it is essentially a short circuit when fully on, it stays cool even without a heatsink. The MOSFET is configured as a high side switch meaning it grounds the low side of the load. This arrangement is quite normal for N type MOSFETS but may not suit all situations. I use it with a 12V LED bulb (with no particular reference to ground) and it works really well. For convenience there is a feed from the 5V regulator which can be used to power an external sensor. I managed to fit everything on a standard 9x25 hole veroboard by removing the unused IC pins (actually the socket pins). This allows the copper tracks to pass underneath, making the layout easier to design. The unused IC elements are shown Greyed out. Track cuts are indicated with a X
As mentioned earlier, this circuit came about due to a need for a contactless switch. The sensor I chose was the E18-D80NK which is readily available on eBay. There seems to be two versions being sold, Type 1 and Type 2, but apart from different wiring colour codes they appear to do the same thing (mine is Type 2). The signal output is normally high and goes low when an object is detected. It would require a 'pull up' resistor as it has an open collector NPN output stage, but with the MOSFET latch it uses the 4K7 connected to supply through the output of the first inverter. I have read that the LEDs in these sensors are pulsed at high frequency which is why they are very tolerant of changing light conditions. If this is the only sensor that is to be used with the circuit, the Schmitt trigger IC can actually be omitted and the signal connected directly to the clock input of the counter (with a pull up resistor). If a more basic sensor that uses a comparator IC is used, then the full circuit is required to avoid random triggering
Capacitive Touch Sensor
Momentary Push Switch