There are only two major components one is IC555 and other is micro controller 89C2051. As explained earlier function of IC555 is to generate pulses according to the revolutions of motor. These pulses will be given to controller. It will count the pulses calculate the RPM and send it to main controller.
Connections: -
IC 555 is configured in monostable mode with time period of 10 ms (this depends upon components R1 & C1). LDR is biased in such a manner that when laser light falls on it, it will trigger IC 555. The output of IC 555 is inverted through transistor (2N2222A type) and connected with INT1 (pin no.-7) and T0 (pin no.-8) pins of controller. One LED (L1) is also connected to output of IC 555. Two more LEDs L2 and L3 are connected with P1.7 (pin no.-19) and P1.6 (pin no.-18). 12 MHz crystal is connected as shown. Push button switch S1 is connected with reset pin of controller.
Operation: -
·
As motor starts rotating the laser light will fall on LDR from the slotted wheel
· This will trigger IC555 every time when motor completes one revolution and it will generate one pulse that is indicated by LED L1
· As the first pulse arrives it will generate an interrupt for controller and immediately it will start counting these pulses. This is indicated by LED L2.
· Controller will count these pulses for the period of 10 sec. after then it will store the count and multiply it by 6 to have final RPM count (if we count external pulses for 1 sec then to get RPM we have to multiply it by 60 as 1 RPM=60 RPS but here we are counting external pulses for 10 sec so count×6 = RPM).
· Finally after getting the RPM controller will send this value serially to main controller and give indication on LED L3.
· Again if motor is running interrupt will arrive and the same process repeats.
Software: -
The heart of this section is the program that is embedded in to 89C2051. The program is written in C language
and it is compiled by keil (IDE) cross compiler. As we already know what is the function of microcontroller just we have to write the suitable code for it. Whole program is made up of four different functions. In the main function there is only initialization rest all the tasks are performed by these functions. And these functions are int1, delay1, delay2 and hextodesi. Let’s see what each function is for.
Int1: -
its interrupt function and it is automatically called when external interrupt 1 arrives, means when a high to low edge occurs on EXT1 (P3.3 or pin no. 7). It performs only one task that is counting RPM. For this it will start internal counter (T0) then generate 10 sec delay, stop counter, store and multiply the count by 6 to get the final RPM count and then call the hextodesi function to finish rest of the tasks.
Delay1: - this is 100 ms delay that is used in between transmitting characters serially one by one through Tx pin
Delay2: - this is 10 sec delay that is generated to count external pulses. It is called after internal counter is start and when this delay finishes counter will stop counting
Hextodesi: -
whatever the count value we shall get will be in hex format. So this function first converts this hex value into equivalent decimal value and then because we want to display this value on to LCD again this decimal value is converted in to ASCII format. Finally these ASCII values are transmitted serially one by one through Tx pin.
Finally in the main program performs these tasks
-
Initialization of timer modes. T0 as counter and T1 as timer
-
Initialization of serial communication mode
-
setting of baud rate
-
enabling of external interrupt 1
click here for complete code in C