Projects/CorridorLight: Difference between revisions

 
(3 intermediate revisions by the same user not shown)
Line 89:
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 it'sits behaviour.
 
<br clear=all>
Line 105:
 
==Third stage: PCB Layout==
[[File:Fritzing schematic.png|thumb|150px300px|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.
 
==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==