In this project we will control Room light intensity using microcontroller. We will use infrared transmitter and receiver for this purpose. Infrared sensor available in the market we will use. In this circuit as we will get the signal from the sensors. As the number of persons entering in the room will increase intensity. We will 89c051 microcontroller for this purpose. We will program microcontroller with assembly language i.e. the programming will be in assembly language. In this project we will sense the signal from infrared sensor then according to increasing no of persons in the room microcontroller will increase the intensity of the room. This project will help in controlling many applications like in machinery to control machine with increasing strength of material.
We will use two set of ir sensors . one will count the no of persons increasing other will decrease the no of count decreasing.
We will use 12Mhz crystal to provide Clock to microcontroller.
There will IC 7805 as a voltage regulator. And two 1000µf and 470µf as a filtering capacitors.
How to control sensors
What is a voltage divider?
You are going to find out but don’t be in too much of a hurry. Work through the Chapter and allow the explanation to develop.
The diagram below shows a light dependent resistor, or LDR, together with its circuit symbol:
The light-sensitive part of the LDR is a wavy track of cadmium sulphide. Light energy triggers the release of extra charge carriers in this material, so that its resistance falls as the level of illumination increases.
A light sensor uses an LDR as part of a voltage divider.
The essential circuit of a voltage divider, also called a potential divider, is:
What happens if one of the resistors in the voltage divider is replaced by an LDR? In the circuit below, Rtop is a 10 resistor, and an LDR is used as R :
Suppose the LDR has a resistance of 500 , 0.5 , in bright light, and 200 in the shade (these values are reasonable).
When the LDR is in the light, Vout will be:
In other words, this circuit gives a LOW voltage when the LDR is in the light, and a HIGH voltage when the LDR is in the shade. The voltage divider circuit gives an output voltage which changes with illumination.
A sensor subsystem which functions like this could be thought of as a ‘dark sensor‘ and could be used to control lighting circuits which are switched on automatically in the evening.
Perhaps this does not seem terribly exciting, but almost every sensor circuit you can think of uses a voltage divider. There’s just no other way to make sensor subsystems work.
Here is the voltage divider built with the LDR in place of Rtop :
Temperature sensors
A temperature-sensitive resistor is called a thermistor. There are several different types:
The resistance of most common types of thermistor decreases as the temperature rises. They are called negative temperature coefficient, or ntc, thermistors. Note the -t° next to the circuit symbol. A typical ntc thermistor is made using semiconductor metal oxide materials. (Semiconductors have resistance properties midway between those of conductors and insulators.) As the temperature rises, more charge carriers become available and the resistance falls.
Although less often used, it is possible to manufacture positive temperature coefficient, or ptc, thermistors. These are made of different materials and show an increase in resistance with temperature.
How could you make a sensor circuit for use in a fire alarm? You want a circuit which will deliver a HIGH voltage when hot conditions are detected. You need a voltage divider with the ntc thermistor in the Rtop position:
How could you make a sensor circuit to detect temperatures less than 4°C to warn motorists that there may be ice on the road? You want a circuit which will give a HIGH voltage in cold conditions. You need a voltage divider with the thermistor in place of Rbottom :
This last application raises an important question: How do you know what value of Vout you are going to get at 4°C?
Key point: The biggest change in Vout from a voltage divider is obtained when Rtop and Rbottom are equal in value
Components required:
Microcontroller 89c051
Crustal 12Mhz
Cap 27pf
IC base 40 pin
7805 voltage regulator
diode in 4001
resistances 8.2k
cap 10 µf 15v
transformer 909v
ir tx rxer
copper clad board
ply board
micro switches.
Applications:
· To control room light intensity acc. To manpower
· To controlling parking light intensity acct. to no of cars
· To change the motor speed according to increasing material in a machine.
AVRs are ideal for learning assembler
Assembler programs are a little bit silly: the chip executes anything you tell it to do, and does not ask you if you are sure overwriting this and that. All protection features must be programmed by you, the chip does exactly anything like it is told, even if it doesn’t make any sense. No window warns you, unless you programmed it before.
To correct typing errors is as easy or complicated as in any other language. Basic design errors, the more tricky type of errors, are also as complicated to debug like in any other computer language. But: testing programs on ATMEL chips is very easy. If it does not do what you expect it to do, you can easily add some diagnostic lines to the code, reprogram the chip and test it. Bye, bye to you EPROM programmers, to the UV lamps used to erase your test program, to you pins that don’t fit into the socket after having them removed some dozen times.
Changes are now programmed fast, compiled in no time, and either simulated in the studio or checked in-circuit. No pin is removed, and no UV lamp gives up just in the moment when you had your excellent idea about that bug.
Test it!
Be patient doing your first steps! If you are familiar with another (high-level) language: forget it for the first time. Behind every assembler language there is a certain hardware concept. Most of the special features of other computer languages don’t make any sense in assembler.
The first five instructions are not easy to learn, after that your learning speed rises fast. After you had your first lines: grab the instruction set list and lay back in the bathtub, wondering what all the other instructions are like.
Serious warning: Don’t try to program a mega-machine to start with. This does not make sense in any computer language, and just produces frustration. Start with the small „Hello world“-like examples, e. g. turning some LEDs on and off for a certain time, then explore the hardware features a bit deeper.
Recommendation: Comment your subroutines and store them in a special directory, if debugged: you will need them again in a short time.
Have success!
How the CPU worksMost important for understanding assembler is to understand how the CPU works. The CPU reads instructions (instruction fetch) from the program storage (the flash), translates those into executable steps and executes those. In AVRs, those instructions are written as 16 bit numbers to the flash storage, and are read from there (first step). The number read then translates (second step) e. g. to transporting the content of the two registers R0 and R1 to the ALU (third step), to add those (fourth step) and to write the result into the register R0 (fifth step). Registers are simple 8 bit wide storages that can directly be tied to the ALU to be read from and to be written to.
Hardware for AVR-Assembler-Programming
Learning assembler requires some simple hardware equipment to test your programs, and see if it works in practice.
This section shows two easy schematics that enable you to home brew the required hardware and gives you the necessary hints on the required background. This hardware really is easy to build. I know nothing easier than that to test your first software steps. If you like to make more experiments, leave some more space for future extensions on your experimental board.
If you don’t like the smell of soldering, you can buy a ready-to-use board, too. The available boards are characterized in this section below.
3.1 The ISP Interface of the AVR processor family
Before going into practice, we have to learn a few essentials on the serial programming mode of the AVR family. No, you don’t need three different voltages to program and read an AVR flash memory. No, you don’t need another pre-programmed microprocessor to program the AVRs. No, you don’t need 10 I/O lines to tell the chip what you like it to do. And you don’t even have to remove the AVR from the socket on your your experimental board, before programming it. It’s even easier than that.
All this is done by a build-in interface in the AVR chips, that enable you to write and read the content of the program flash and the built-in-EEPROM. This interface works serially and needs only three signal lines:
•SCK: A clock signal that shifts the bits to be written to the memory into an internal shift register, and that shifts out the bits to be read from another internal shift register,
•MOSI: The data signal that sends the bits to be written to the AVR,
•MISO: The data signal that receives the bits read from the AVR.
What is a register?
Registers are special storages with 8 bits capacity and they look like this:
Bit 7 |
Bit 6 |
Bit 5 |
Bit 4 |
Bit 3 |
Bit 2 |
Bit 1 |
Bit 0 |
Note the numeration of these bits: the least significant bit starts with zero (mathematically: 20 = 1).
A register can either store numbers from 0 to 255 (positive number, no negative values), or numbers from -128 to +127 (whole number with a sign bit, located in bit 7), or a value representing an ASCII-coded character (e. g. ‘A’), or just eight single bits that do not have something to do with each other (e. g. for eight single flags, used to signal eight different yes/no decisions).
The special character of registers, compared to other storage sites, is that
•they are connected directly to the central processing unit called the accumulator,
•they can be used directly in assembler instructions, either as target register for the result or as read register for a calculation or transfer,
•operations with their content require only a single instruction word.
There are 32 registers in an AVR. They are originally named R0 to R31, but you can choose to name them to more meaningful ones using a so-called assembler directive. An example:
.DEF MyPreferredRegister = R16
Assembler directives always start with a dot. Instructions or labels do NEVER start with a dot. Note that assembler directives like this are only meaningful for the assembler but do not produce any code that is executable in the AVR target chip. The name “MyPreferredRegister” will not show up in the assembled hex code, and therefore this name cannot be derived from that hex code.
Instead of using the register name R16 we can now use our own name “MyPreferredRegister”, if we want to use R16 within an instruction. So we write a little bit more text each time we use this register, but we have an association what might be the content of this register.
Using the instruction line
LDIMyPreferredRegister, 150
which means: load the number 150 immediately to the register R16, LoaD Immediate. This loads a fixed value or a constant to that register. Following the assembly, or translation of this code into binary or hex, the program storage written to the AVR chip looks like this:
000000 E906
This will show up in the listing, a file called *.lst produced by the assembler software, which is a simple text file. All numbers are in hex format: The first hex number is the address (000000), where the instruction is written to in the program flash memory of the AVR, the second is the instruction code (E906). E906 tells the processor three different things in one word, even if you don’t see this directly:
●a basic load instruction code, that stands for LDI,
●the target register (R16) where the value 150 is to be written to,
●the value of the constant (150).
Don’t be afraid: you don’t have to remember this coding because the assembler knows how to translate all this to finally yield E906 and the AVR executes it.
Within one instruction two different registers can play a role. The easiest instruction of this type is the copy instruction, MOV. The naming of this instruction MOV deserves a price for the most confusing definition, because the content of a register cannot be moved (what would be left in a register, if you MOVE its content to somewhere else?). It should better be named COPY, because it copies the content of one register to another register. Like this:
component | qty | rate |
AVR 8535 or atmega32 | 1 | 60 |
ULN2003, | 1 | 30 |
Diodes in4001, | 4 | 1 |
IC 7805 | 1 | 15 |
Optocoupler PC817 | 4 | 12 |
Tr548 | 4 | 3 |
Tr 558 | 4 | 3 |
Motors 12v | 2 | 250 |
IC base 20 pin | 1 | 10 |
Crystal 12 Mhz | 1 | 25 |
Resiatncec 10k | 4 | .25 |
4k | 4 | .25 |
Cap 10µf | 1 | 5 |
Connecting wires | 1 | 20 |
Ir sensors | 3 | 120 |
· Software:-
Keil compiler or UMPS for programming
Window xp
Component List | COST | ||||
S.No. | Item | Quantity | Rate/Unit | ||
1 |
Atmega 32 |
0 |
80 |
||
RF module |
1 |
600 |
|||
HT12E | 1 | 35 | |||
HT12D | |||||
IC91214 |
1 |
25 |
|||
3 |
IC4049 |
0 |
25 |
||
4 |
IC8870 |
1 |
40 |
||
5 |
IC555 |
0 |
10 |
||
6 |
IC817 |
1 |
15 |
||
7 |
IC3021 |
0 |
15 |
||
Push to On Sw |
3 |
12 |
|||
8 |
SOLDERING WIRE |
1 |
25 |
||
9 |
SOLDERING IRON |
1 |
120 |
||
10 |
FLUX |
1 |
10 |
||
11 |
CONNECTING WIRE |
1 |
50 |
||
12 |
TR548 |
2 |
2 |
||
13 |
TR558 |
0 |
2 |
||
14 |
RESISTENCES |
20 |
0.5 |
||
15 |
CAPACITORS | ||||
1000µf |
2 |
10 |
|||
100µf |
1 |
5 |
|||
470µf |
4 |
5 |
|||
16 |
DIODES |
8 |
1 |
||
17 |
LED |
8 |
1 |
||
Crystal 12MHz |
2 |
25 |
|||
18 |
IC BASE |
3 |
5 |
||
IF set |
120 |
1 |
|||
19 |
IC 7805 Volt. Reg |
2 |
15 |
||
20 |
TRANSFORMER 9 V |
1 |
30 |
||
21 |
SOCKETS |
3 |
10 |
||
22 |
RELAY 9V |
3 |
25 |
||
23 |
MILER CAP |
5 |
3 |
||
24 |
CRYSTAL 3.579545 |
2 |
20 |
||
25 |
IC136 |
2 |
15 |
||
26 |
HOLDER |
2 |
10 |
||
27 |
PLY BOARD |
1 |
100 |
||
28 |
TAPE ROLL |
1 |
10 |
||
29 |
Copper Clad Board |
1 |
100 |
||
30 |
FeCl3 |
1 |
100 |
||
31 |
ZENER |
0 |
3 |
||
Screws/bolt |
2 |
2 |
|||
Betteies |
1 |
15 |
|||
TOTAL COST |
ADVANTAGES
- Low cost
- Reliable
- Portable
- Flexible due to microcntroller
- Easy to use- system is very easy to understand
Features-
Microcontroller
LCD display
IR sensors
Alarm Indication
Visual display