Microprocessors and microcontrollers can be used to design some tools or systems to perform some special tasks. Using microcontrollers, we can make different types of modules or systems. Here is a list of some systems that can be designed by using microcontrollers −
Electronic Voting Machine
RFID based Access Control System
Heart Rate monitoring system
Automatic Plant watering system
Ultrasonic range finding system
Water level controlling system
Gas leakage detection system
Temperature measuring system
There are many such systems that can be made by using some microcontrollers.
To design a system, we have to follow some basic steps. We have to design the overview of the system, and some functional block designs to construct the system easily. Then we have to design the circuit diagrams, and apply the component values after doing some calculations. Then after checking the entire circuit diagrams, at last we should start the work practically. In this phase we will implement the circuits by using required components.
In this article we will see how we can design a Digital Tachometer using microcontroller. Here we are using the Intel 8051 Microcontroller.
A Tachometer is basically a system that can measure the revolution/second of some rotating wheel, disc, shaft etc. Our tachometer can measure up to 255 revolution/second at an accuracy of 1 revolution/second.
Now let us see how the circuit diagrams will be for this digital tachometer.
We can divide this circuit into some several parts. In the first part we will see how the circuit is taking information physically. There are two components Q4 and D4. The Q4 is a photo transistor (2N5777), and D4 is one Red LED. If light comes into this photo transistor, it collector current turns drops towards 0. At first we have to attach some rotating disc on the shaft, and there will be one punch hole. When the disc is rotating, at the upper portion of the disc the LED is attached, and at the lower portion the photo transistor is set. When the disc comes in the same line, the light hits the photo transistor, and the collector current drops down to zero. This following figure is showing how it will be looking if we see that using an oscilloscope.
In the next part we can see there is an OPAMP (Operational Amplifier) in the circuit. For the OPAMP, we have used LM234 Chip. This chip is holding four OPAMPs, but here we have used one of them. In this circuit the OPAMP is connected as a voltage comparator. Here the reference voltage is 3.5V. So if the output voltage of the photo transistor is greater than 3.5V, then it will generate high pulse, otherwise it will generate 0 level signal. From this comparator we will get the square wave pulses of the previous output.
From this falling edge we can understand that hole has come, so there is one revolution. This clock pulse is fed into the microcontroller. This signal can be used to count the number of revolutions.
At the third part the microcontroller is working. This microcontroller is performing two tasks together. These two tasks are −
Counting the number of negative edges from the output of the comparator.
Do necessary mathematics, and display the count on the seven segment display array.
To count the revolutions, we have used both the timers (Timer0 and Timer1) of 8085. Here Timer1 is configured as auto-reload 8-bit counter, and for registering the number of incoming zeros are stored into Timer0. The Timer0 is set as 16-bit timer, and it generates the necessary one second time span for the Timer1 to count.
Program of 8051 for the Digital Tachometer
ORG 000H MOV DPTR,#LUT ; Loads the address of LUT to DPTR MOV P1,#00000000B ; Sets P1 and P0 as an output port MOV P0,#00000000B MAIN: MOV R6,#14D SETB P3.5 MOV TMOD,#01100001B ; Sets Timer1 as Mode2 & Timer0 as Mode1 timer MOV TL1,#00000000B ; loads starting value to TL1 MOV TH1,#00000000B ; loads starting value to TH1 SETB TR1 ; starts Timer1 (counter) BACK: MOV TH0,#00000000B ; loads starting value to TH0 MOV TL0,#00000000B ; loads starting value to TL0 SETB TR0 ; starts Timer0 HERE: JNB TF0,HERE ; checks for Timer 0 roll over CLR TR0 ; stops Timer0 CLR TF0 ; clears Timer Flag 0 DJNZ R6,BACK CLR TR1 ; stops Timer1 (counter) CLR TF0 ; clears Timer Flag 0 CLR TF1 ; clears Timer Flag 1 ACALL DLOOP ; Calls subroutine DLOOP for displaying the count SJMP MAIN ; jumps back to the main loop DLOOP: MOV R5,#100D BACK1: MOV A,TL1 ; loads the count to the accumulator MOV B,#100D DIV AB ; isolates the first digit of the count SETB P1.0 ACALL DISPLAY ; converts the 1st digit to 7 seg-display pattern MOV P0,A ; puts the pattern to Port 0 ACALL DELAY ; 1mS delay ACALL DELAY MOV A,B MOV B,#10D DIV AB ; isolates the second digit of the count CLR P1.0 SETB P1.1 ACALL DISPLAY ; converts the 2nd digit to 7 seg-display pattern MOV P0,A ACALL DELAY ACALL DELAY MOV A,B ; Loads the last digit of the count to accumulator CLR P1.1 SETB P1.2 ACALL DISPLAY ; converts the 3rd digit to 7 seg-display pattern MOV P0,A ACALL DELAY ACALL DELAY CLR P1.2 DJNZ R5,BACK1 ; repeats the subroutine DLOOP 100 times RET DELAY: MOV R7,#250D ; Subroutine to generate 1mS delay DEL1: DJNZ R7,DEL1 RET DISPLAY: MOVC A,@A+DPTR ; gets 7 seg digit drive pattern for current value in A CPL A RET LUT: DB 3FH ; Look up table for 7-seg-display DB 06H DB 5BH DB 4FH DB 66H DB 6DH DB 7DH DB 07H DB 7FH DB 6FH END