## Monday, February 20, 2012

### Electronics Basic Lessons: Home Automation

The last two lessons were pretty short and sweet, kind of a hey look you can get light dependant resistors, and temperature dependant resistors.

Now I'm going to use those to create a little environmental control project.

This isn't like some kind of fully fledged multi zone control thing. it's just a simple set of monitoring circuits that switch appliance outlets where you would plug in domestic equipment.

Lets define some component parameters of this circuit.
The light dependant resistor when fully dark has a resistance of 1Mohm, and when fully light will measure some 200 Ohms,
The Thermistor will have values that follow a linear pattern with temperature, 10 degrees = 1M, 20 degrees = 500K Ohms, 30 degrees = 250K Ohms
the transistors have a turn on voltage of 0.5v
The supply voltage is 9v

So lets start at the left side of the circuit and investigate the sorts of values of resistor that need to be used in the light sensor.

When the room is light, the LDR is 200 Ohms, and we need the base voltage to be below 0.5

0.4v = (9v/(?+200))*200

so we re-arrange that
0.4/200 = 9/ ? + 200
0.002 = 9 / ?+200
0.002 * (200 + ?) = 9.
200 + ? = 9 / 0.002
200 + ?  = 4500
? = 4300

We know that the resistor must be at least 4300 Ohms for the device to switch off the mains lighting when the LDR is in full brightness. the closest value would be 4.7K
? = (9 / 4700 + 200) * 200
? = 9/4900 = 0.36v
(so with a 4.7K we know for sure that the light will not turn on in full bright sunshine)

As well as the 4700 resistor (which we consider on it's own as we imagine that the variable resistor is turned right down and set to zero in full light turn on conditions)
We now need to make sure that we can set the turn on level over a wide enough range.
At full dark the LDR is 1M, and we need to make sure that the base voltage is 0.5v or above.

So we do the same equations again, (but we do have to include the resistor that we worked out earlier).
0.6v = (9v/4700 + 1000000 + ?) * 1000000
0.0000006 = 9v/1004700 + ?
(1004700 + ?) * 0.0000006 = 9
1004700 + ? = 9/0.0000006
1004700 + ?= 15000000
? = 13995300

So we need a variable resistor in the realms of 13Mohm to make sure that we can set the light not to come on in full dark, and adjust the light sensor to possibly keep the lamp switched on all the way up to near full light.

Temperature
The Temperature sensing part of the circuit works roughly the same. but since the resistor / variable resistor and thermistor network is the opposite way around the equations needed are

transistor V desired = (v/(R Thermistor + ?)) * ?
So at 10 degrees we want the thing to turn on, the thermistor = 1 MOhm

This time we'll use a slighly different equation, instead of Vjunction = (Vsupply/Ra+Rb) * Rb we'll use the equations

Rb = Ra/((Vsupply / Vjunction) -1)

in this case :

Vrb + Rb = 1000000 / ((9 / 0.6) -1)
Vrb + Rb = 1000000 / (15 -1)
Vrb + Rb = 1000000 / 14 = 71428

So we want our fixed resistor for ensuring that the heater turns on in the cold (and with the thermistor turned all the way up, (which in this case will actually set the temperature lower!) to around 71K

For the it's definitely far too hot turn off the heater temperature (30 degrees) the thermistor changes to 250K
Lets put that into the equation, (again assuming that the variable resistor is now turned all the way up.

VRb + rb = 250000 / ((9 / 0.4 ) -1)
VRb + rb = 250000 / 22.5
Vrb + Rb = 111111

From this we know that the resistor Rb must be 111111 (11.1K)
And the variable resistor must be 71k - 11k = 60K