How to make a contact-less digital tachometer using IR-light reflection technique. Part 2. Circuit setup
Part 1. How to make a contact-less digital tachometer using IR-light reflection technique. Part 1. Theory
As I mentioned earlier, I am using StartUSB for PIC board for demonstration of this technique, and therefore, I am not providing the detail circuit diagram of this project. Rather, I will be showing the connections of LCD and the sensor unit (described above) to the board, as shown below. LCD data bits D4-D7 (11-14) are driven through RB4-RB7 pins, whereas the control pins, RS (4) and E (6) are connected to RC6 and RC7 pins of PIC18F2550. The transmission of infrared light is controlled by RA3 pin, whereas the reflected pulses are fed to the T0CKI pin.
The microcontroller runs at 48.0 MHz using its internal PLL. The circuit diagram for the StratUSB board itself can be shown bellow.
Timer0 Module in PIC18F2550
The Timer0 module in PIC16F series is 8-bit but in case of PIC18F2550, it is software selectable for 8- or 16-bit mode. Its operation is controlled by T0CON register; the function of each bit in the T0CON register is shown below.
For our purpose, the Timer0 module will be configured as a 16-bit counter to count the number of pulses arriving at RA4/T0CKI input pin. The counter will be active for 1 sec and the number of pulses arrived during this interval will be recorded, and later multiplied by 60 to get the RPM of the disc. Without an overflow, the Timer0 in 16-bit mode can count up to 65535, that corresponds to 3932100 RPM. However, in this project, we will limit the range up to 99960 RPM. To serve our need, we will clear T08BIT (16-bit mode) and T0SE (increment on high-to-low transition on T0CKI pin) bits, and set T0CS (counter mode) and PSA (no prescaler) bits.
As usual, I used my favorite mikroC compiler from mikroElektronika for programming the PIC. No external programmer is required with StartUSB board as the on-board PIC has pre-programmed with mikroElektronika’s fast USB bootloader. The programming part is not very tough for this. It involves the initialization of I/O ports and Timer0 control register. The LCD interfacing part uses mikroC’s built-in LCD library functions.
Once the program is loaded into the microcontroller, reset the StartUSB board and wait for 5 sec till it comes out of bootloader mode and starts running the application for your contact-less tachometer.
A digital tachometer based on an infrared light reflection technique has been demonstrated successfully. Its major advantage is that it doesn’t require any physical contact with the rotating shaft to measure its speed. This project can be extended further by adding data logging feature to it. This is required in certain applications where the RPM of a rotating shaft is needed to be monitored. The data logger will keep the records of varying RPM over time, and those records can be later transferred to a PC through the USB interface.
mikroC project files - download
News on theme: