Playing with Sensors. Making a decision taking device.
Sense is what makes humans different from machines and other animal. But to sense, we need a sensor which in our case is our nose, ears, tongue etc. We can sense happiness, guilt, love, anger, suffocation, wind, cold, hot, taste, smell, surroundings and much more. Similarly, in electronics, numerous numbers of sensors are present but these sensors are mostly meant for getting a feel of physical nature like sensing rise in temperature, light, humidity, obstacles, gas etc. These sensors plays an important role in electronics, they makes the system more intelligent as it has an ability to make decisions on its own.
In any circuit whatsoever it is, if it has a sensor in it, it follows the same steps as shown in above blocks. Let me explain this diagram:
Every sensor has its own property. Like:
“Light detecting Diode” (LDR) senses light.
“Temperature Sensor” (like LM35) senses temperature.
“Infrared sensor” (IrDA) senses obstacles.
“Tilt sensor” senses the movement (like mobile phone’s accelerator)
“Humidity sensor” senses humidity in air.
And so on….
To know about how sensor senses the environment, consider an example of light sensor (LDR). They are used to sense the light and dark. The resistance of the LDR in dark is very high which sometimes up to 1M ohms. But when light falls over its surface, the resistance decreases drastically and conduction through it takes place. In our today’s tutorial, we are going to take decisions on the output of sensors. But to make one let’s take an overview of decision making IC, we are going to use in our circuit.
Op-amp IC:
First of all let’s see how an op-am IC actually looks like. In my case I am using LM324 which is shown below:
The IC package has 14 pins Dual in-line package. This means that the pins are located in two parallel rows. The counting of the IC pins is done from left of the notch. The IC LM324 has four independent operational amplifiers. An operational amplifier looks like the one below:
So, inside the IC package, it looks like this:
Now, we know how it looks like let’s see how it works like.
The comparator here has two input values, Input (+) and input (-). These positive and negative inputs are called as non-inverting and inverting inputs respectively. Now, in digital world, the input voltage what we are providing to the circuit i.e. +5volts is called as ‘1’ (one) and the ground terminal is called as ‘0’ (zero). These one’s and zero’s are all that you computer or the digital electronics understand. So, in our Op-amp IC, the inverting terminal means that when input of +5 volt is applied at that terminal, it is first inverted that is, it is converted to Zero and then taken as input while at the non-inverting end, the +5volt is taken as it is and no inversion is done. But why this inversion is done? We will see this when we will make our decision making circuit. Now, in op-amp at any of the input (of same op-amp, say input 1 +), a reference voltage is provided. Reference voltage means a constant voltage through resistor is provided and at the other input (input 1 - ), the voltage to be compared is given. Whenever the input 1- exceeds the reference voltage, an output is produced at the output pin.
If you didn’t get the technical comparison process of Op-amp, let’s compare it with our day to day example: Op-amp is like fruit vendor’s weight scale. If you are buying apples say 1kg, the vendor will put 1kg weight on one side, this is the reference weight identical to the reference voltage in our Op-amp case. Now he starts putting apples on the other side of the scale. When the weight exceeds the reference weight, the scale will get down on the heavier side and if it is less than 1kg, it will remain at the side of reference weight. So now I consider myself that you got the idea behind op-amp IC’s.
So, the idea behind using an Op-amp as a decision making circuit is very clear, if the input to its pin crosses the predefined reference voltage, it will give the output and if it does not crosses it, the output will remain idle.
In our today’s circuit, as I promised in my last tutorial, we are going to make a literally useful cum fun circuit which will light up in dark and turns off automatically when in light.
The components we need are:
1. Breadboard with power supply (click here to have tutorial on making power supply)
2. IC LM324
3. LDR sensor (To detect light)
4. Resistor (10k, 125 ohms).
5. Potentiometer (10k) (What is this potentiometer?? We will discuss while implementing it).
6. LED (5mm)
7. Yup…like always…your enthusiasm.
If you got all this things let’s start making it.
Step 1.
Take your power supply and insert the IC LM324 in the breadboard as shown below. Remember that you insert the IC pins in a manner such that they does not short each other. See the image below:
Step 2.
Now connect pin number 4 to VCC and pin number 11 to ground. This step is also called as Biasing of the IC. So, provide proper biasing to the circuit and check the connections using multimeter:
Step 3.
After applying the biasing, insert the LDR near to the LM324 pin number 1. We are taking first Op-amp for this circuit. Now LDR doesn’t work on direct 5 volt supply. We need a resistor to have proper biasing. Connect the 10k ohm resistor in any of its pin (as it is a Bipolar device, means it does not depends on polarity, conducts in both directions like simple resistor). Take the resistor’s pin into VCC, connect the second pin of LDR with ground using single core wire.
Step 4.
Now, we need an output from the LDR which will go to the LM324’s comparison input. The output can be taken from any of the two pins of LDR, in our case, lets connect the ground pin of LDR to any of the two inputs of Op-amp in our LM324 IC which is pin number 2 or pin number three. I am connecting it to input 1(-) i.e. pin number 2 of LM324….I know it looks lame sometimes that I am saying connect the wire here and there without explaining but keep patience and believe me…the line where this post will end , your doubts will be cleared!!
Step 5.
That’s it, our LDR interfacing is completed. Now it’s time to introduce potentiometer to the circuit and to you. Potentiometer is a three terminal (3 pin) device which acts as a variable resistor. That means it can vary the value of resistance. The difference between our simple resistors and potentiometer is that a simple resistors have fix value of resistance for example resistor carrying 10k ohm of resistance value cannot be varied to 1k ohm but a potentiometer having value of 10k ohm can be varied right from zero ohms to 10 k ohms by rotating the screw over its head:
As from the above figure, the output resistance is the one we need to connect with the pin number 3 of Op-amp as a reference voltage. Right now don’t worry about varying the resistance or about the value of reference voltage. Just connect it to the pin number 2 of potentiometer with the pin number 3 i.e. input (+) of the Op-amp. See the figure below to have a quick idea.
Step 6.
As now our reference voltage and sensor are done, it’s time to insert LED in the circuit which will respond to the decisions taken by the LM324. Insert LED anywhere or preferably closer to LM324. Connect its positive leg to the pin number one of the LM324 which is the output of our Op-amp via resistor of 125 ohm. Connect another leg to the ground and we are all set to go. Our circuit is complete now and ready to make decisions.
But before our circuit works, we have to set a reference voltage using the potentiometer. To do so, check out the steps below:
Step 1:
Connect the circuit to the power supply/battery.
Step 2:
Take out your multimeter and insert its ground strobe inside the IC7805’s hole present in its metal heat sink (it is connected to ground). Now touch the positive strobe of multimeter with the pin number 2 of LM324. You will notice certain voltage on the multimeter screen. Now keeping the red strobe at the pin number 2, hover your hand over the LDR sensor. You will surely notice a drastic change in the value of voltage. If previously it was 3 volts, it will show 5 volts. This verifies that our sensor is working fine.
Step 3:
Now it’s time to set the reference voltage. So, to accomplish that, touch the positive strobe of multimeter with the pin number 3 of the LM324. You will see some voltage at this pin ranging between 0 to 5 volts. You have to set the value of voltage which is just above the output voltage of sensor in idle state i.e. in light. Say if your sensor output voltage was 3 volts in presence of light, you have to provide a reference voltage of 4 volts. So when you take the circuit in dark, the sensor output will exceed reference voltage and output of Op-amp will go high and our LED will light up.
The second case:
If your LED lights up as soon as you provide power to the circuit, then to overcome this problem, just interchange the connections at pin 2 and pin 3 of LM324. This can explain the phenomenon behind inverting and non-inverting input voltage. The sensor gives out zero as output when it senses the absence of light. The inverting port inverts it to some positive value voltage and then compares it to the second input which is non-inverting in nature. But if you connect the sensor output to the non-inverting pin, then the circuit will turn off when in dark and lights up when in light.
So, from today’s tutorial, I hope you got an idea how about simple decision making device. Identical circuits are being employed in street lights to have automatic switching. This decision making device is also used in making “Line follower robots” which I will cover after few tutorials. Similarly, if you run the horses of imagination and creativity, you can probably make many devices.
I hope you liked my today’s post. If you have any sort of query regarding the making of circuit or any other questions on electronics/digital electronics. Please post a comment below or you can send me mail at: letslearnelectronics@gmail.com.
Thank you, see you in next tutorial. Have a nice day.....:)
Playing with Sensors. Making a decision taking device.
Reviewed by haru
on
June 24, 2012
Rating:
No comments