Projects/CorridorLight: Difference between revisions

No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 86:
 
* LED driver and soft starter
[[File:LED soft start.png|thumbnailthumb|150px|left|LED soft start circuit]]
When initially applying 5VDC the capacitor C1 starts charging through R4 and almost no current will flow through R2. The initial voltage on the positive terminal of the capacitor would be zero and it starts increasing at a rate that depends on the values of R4 and C1. As the voltage in the common node increases also does the voltage on the gate of the transistor Q1 (very small current through R2 means very small voltage drop across). Some of the current also flows through R2 and R3 operating as a voltage divider. As the capacitor charges the current through R4 goes down and so does the voltage drop, increasing the voltage on R2 which in turn will increase the voltage on the gate for Q1. When the voltage is sufficient Q1 will allow current to flow from the collector to the emitter and the LED will illuminate through the current limiting resistor R1. As the capacitor charges, the voltage on the base will be higher, the current from base to emitter will increase and the LED will shine brighter.
For switching off, after removing power the capacitor will discharge through R2 and R3 but it will still provide current to discharge through R4, R1 and D1 until the current in the gate of Q1 turns the LED off.
By chosing the values of all these components it's possible to simulate what the response time would be for the soft start/soft stop of the LED. In my case I had access to Proteus PCB Designer which includes a simulator so I could both build the schematic and test its behaviour.
 
<br clear=all>
* Op-amp as a comparator
[[File:Opamp as comparator.png|thumbnailthumb|150px|left|Op-amp as comparator]]
One of the multiple applications of an operational amplifier is working as a voltage comparator. In this configuration the op-amp works in saturated mode so it's output will change quickly from the positive supply rail voltage to the negative or ground voltage depending on whether the inverting input's voltage is higher or lower than the non-inverting input's voltage. In other words, looking at the schematic, if the voltage in terminal 3 is higher than the voltage in terminal 2, the voltage in terminal 6 will be the same voltage of terminal 7, but if the opposite happens then terminal 6's voltage will be that of terminal 4. In this case I'm using a rail-to-rail op-amp which makes this statement correct but other op-amps will have a small voltage drop and might not necessarily reach the rail voltages, either one or none of them. Connector J2 is the externally connected photodiode in photovoltaic mode with R11 as loading resistor. By adjusting the values of R9 and R10 I was able to simulate the different voltages at which I could make the op-amp trigger its output depending on the amount of light and the voltage created by the photodiode.
<br clear=all>
* AND gate with two NPN transistors
[[File:AND gate.png|thumbnailthumb|150px|left|AND gate with two NPN transistors]]
In this configuration both transistors have to be conducting for the emitter of Q3 to provide an output that's then sent to the LED soft starter. One of the conditions is the current through R8 that depends on the voltage output of the op-amp. The second condition is the PIR motion sensor output switching on when motion is detected. Resistor R7 is there to discharge quickly the gate of Q3 once the PIR output switches off.
 
<br clear=all>
*Full schematic
[[File:Full schematic.png|thumbnailthumb|450px|left|Complete schematic]]
<br clear=all>
 
==Third stage: PCB Layout==
[[File:Fritzing schematic.png|thumbnailthumb|300px|left|Fritzing model of the PCB]]
Once I was happy with the results of the simulation I moved on to building a prototype. Since I was confident at that point that the results would work, instead of building the circuit on a protoboard I went straigth into a prototyping PCB and from there I wanted to use it directly inside the enclosure I had already built so it had to be as compact as possible. Although Proteus has a built-in PCB layout program called Ares I haven't used it for over ten years. I thought that Fritzing was more user friendly for what I wanted to do so I started playing with it, trying to squeeze every single pin and cutting the necessary tracks to make it small. The result is on the picture.
<br clear=all>
 
==Final stage: Soldering and testing==
Once I had all the components layed out in Fritzing I moved onto building the board and soldering them. Unfortunately, some of the components at hand didn't have the exact same model so after a little tweaking I managed to get a functioning board and I was able to test the results. One caveat was the potentiometer used to set the level of light which ended up being a multiturn version instead of the one depicted. I also found a minor issue when the amount of light is low enough to trigger the op-amp but not so low that when the LEDs turn on the light the provide added to the ambient light make the op-amp switch off. To avoid this I added a hysteresis resistor from terminal 6 to terminal 3 of U1. By doing so, once the light level on the photodiode is smaller than that of the voltage divider (which I can adjust with the potentiometer I've just described) it will trigger the op-amp's output high which will add extra voltage in the form of a pull-up resistor to terminal 3. In that situation there has to be a lot more ambient light to make the op-amp swith off and the LEDs turning on would not be sufficient.
 
 
==Result==
[[File:Corridor Light Enclosure.jpg|thumbnailthumb|150px|left|Corridor light enclosure]]
[[File:Corridor Light Internal.jpg|thumbnailthumb|left150px|centre|Internal layout of corridor light]]
 
[[Category:Projects]]