Sl-Alex home lab

RPM meter


I was about to mill some PCBs using my CNC machine when I realized I don’t know anything about my spindle motor. One of the most important things for milling is RPM (revolutions per minute) and this was exactly what I needed. I didn’t want to buy any factory-made RPM meter, so after thinking for about 100ms I came to the quite obvious conclusion - I want to build my own bike. Let’s use STM32F103C8 “Blue Pill” board and libopencm3/make instead of HAL/STM32CubeIDE.

The idea is simple - we use TCRT5000 sensor for RPM pulses generation, one timer for counting those pulses and another one for time measurement. Periodically we take that RPM counter, filter it a bit and output to the LCD. As an additional useful thing for the user we will count the time while the spindle motor is turned on and will display it when it is turned off. Here is a board with TCRT5000 sensor:

TCRT5000 sensor: small and reliable
TCRT5000 sensor: small and reliable

This sensor can detect frequencies up to 45kHz (2700000 RPM), which is far beyond any spindle motor capabilities. One of the best LCDs for this task would be this one:

Here is how it works in real time:

Here is a connection table:

STM32 pin Signal Description
A12 RPM_IN RPM input
B13 LCD_WR_CLK HT1621B write clock
B14 LCD_CS HT1621B chip select
B15 LCD_DA HT1621B data input

The code is here, just clone the repository with libopencm3 submodule and run script, which will take care of the rest.