A fully functional Digital Tachometer (RPM meter) designed from scratch, integrating mechanical CAD, optical signal conditioning, and low-level embedded C programming. The system uses an ITR8102 optical sensor to detect the rotation of a DC motor through a custom 3D-printed 20-slot encoder disk. A PIC18F4550 microcontroller calculates the RPM in real-time using Hardware Interrupts (INT0) and Timers (Timer1), displaying the result on a 16x2 LCD.
- 1x PIC18F4550 Microcontroller (Tested on Miuva development board)
- 1x ITR8102 Optical Sensor (Photointerrupter)
- 1x DC Motor
- 1x 16x2 LCD Display
- 2x 10kΩ Resistors (for pull-ups/sensor conditioning)
- Custom 3D-printed parts (Base, legs, motor stand, and 20-slot encoder disk)
- 1x Microcontroller Programmer (e.g., PICkit 3 / PICkit 4)
- 1x Variable DC Power Supply
This project relies heavily on real-time processing using the microcontroller's hardware peripherals rather than blocking delays:
- Hardware Interrupt (INT0): The ITR8102 sensor output is connected to the
RB0/INT0pin. In the current implementation, the microcontroller triggers an interrupt on every falling edge (H_TO_L), accurately counting the 20 slots of the disk.- 💡 Engineering Insight: Through testing and experience, I realized that configuring the interrupt to trigger "on change" (detecting both rising and falling edges) would count 40 pulses per revolution instead of 20, effectively doubling the sensor's resolution.
- Timer1 (Timekeeping): Timer1 is configured with an internal clock and a 1:8 prescaler. It triggers an interrupt every 12.5 ms. A counter keeps track of these interrupts; when 80 ticks pass, exactly 1 second has elapsed.
- RPM Calculation: With 20 slots per revolution, the base formula is:
RPM = (60 seconds * Pulses counted in 1 second) / 20 slotsSimplified in code to save CPU cycles:RPM = 3 * pulses
The 3D printed base, legs, and motor stand were designed in SolidWorks. It's worth noting that this mechanical assembly is a rapid overnight prototype. It was designed and printed in a single night to meet a tight deadline. While it isn't structurally perfect or highly optimized, it successfully fulfills its core purpose: keeping the motor shaft, the encoder disk, and the optical sensor perfectly aligned for accurate readings.
To validate the sensor's signal integrity and the software's mathematical accuracy, the optical pulses were measured using a digital oscilloscope alongside the LCD output.
In the video above, we can observe two readings:
- LCD Display: ~240 RPM
- Oscilloscope: ~80 Hz (80 pulses per second)
Does the math add up? Yes!
- Convert the LCD RPM to Revolutions Per Second (RPS):
240 RPM / 60 seconds = 4 RPS - Multiply by the number of slots on the encoder disk (20 slots = 20 pulses per revolution):
4 RPS * 20 pulses/rev = 80 pulses/second = 80 Hz
This perfectly confirms that the microcontroller is reading the physical hardware exactly as intended without losing any pulses.
RPM-METER-PIC18F4550/
│
├── binaries/
│ └── rpm_meter.hex # Compiled file ready to flash
│
├── docs/
│ ├── render.jpg # SolidWorks 3D Render
│ ├── render_vs_physicalmodel.jpg # CAD vs Reality comparison
│ ├── schematic.png # Proteus circuit schematic
│ ├── scope_view.gif # Oscilloscope validation gif
│ ├── uC-P4_TACOMETRO_DIGITAL.pdf # Full project report (Spanish)
│ └── working_project.gif # Gameplay/Working demonstration
│
├── firmware/
│ ├── 18F4550.h # PIC18F4550 definitions
│ ├── MLCD.c # Custom 16x2 LCD driver library
│ ├── rpm_meter.c # Main logic, INT0, and Timer1 ISRs
│ └── rpm_meter.ccspjt # CCS C Compiler project file
│
├── hardware/
│ └── Encoder.pdsprj # Proteus simulation file
│
├── mechanical/
│ ├── base.STL # 3D printable base
│ ├── legs_x4.STL # 3D printable legs
│ ├── motor_stand_x2.STL # 3D printable motor stand
│ └── solidworks_rpm_mete_pack_and_go.zip # Full SolidWorks source files
│
└── README.md # This documentation file
- Compiler: CCS PIC C Compiler
- Simulation: Proteus Design Suite
- CAD Software: SolidWorks (To open the
.zipin themechanical/folder) - Flashing Tool: MPLAB X IPE (or PICkit standalone software)
- Slicer Software Just in case you want to 3D print the provided
.STLfiles
- Clone this repository.
- Mechanical: Unzip
solidworks_rpm_mete_pack_and_go.zipto modify the 3D design, or directly slice the.STLfiles in the/mechanicalfolder to 3D print the parts. - Firmware: Open
rpm_meter.ccspjtin CCS C Compiler and compile it to generate a new.hexfile. - Flash the
.hexto your PIC18F4550 using a programmer. - Wire the circuit according to
schematic.png, power the motor, and watch the RPMs update in real-time!


