
Contact-less digital tachometer using StartUSB for PIC and optical sensors
Theory
The contact with the rotating shaft is avoided with an optical sensing mechanism that uses an infrared (IR) light emitting diode and a photo detecting diode. The IR LED transmits an infrared light towards the rotating disc and the photo detecting diode receives the reflected light beam. This special arrangement of sensors is placed at about an inch away and facing towards the rotating disc. If the surface of the disc is rough and dark, the reflected IR light will be negligible. A tiny piece of white paper glued to the rotating disc is just enough to reflect the incident IR light when it passes in front of the sensor, which happens once per rotation (shown below).

Rotating disc with a reflector

IR sensors and signal conditioning circuit
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.

T0CON register
Circuit setup
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 board itself can be found here.

LCD and sensor module connections to StartUSB for PIC board

Complete circuit setup

IR light emitting and photo-detecting diodes with a blocker in between
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. Those who are not familiar with StartUSB for PIC board, read my previous article Getting started with PIC18F Microcontrollers. 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, read my article ‘How to interface a character LCD with PIC‘ if you are new to this.
Download mikroC project files
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.

Tachometer in action
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.