BlueTachometer is a wireless Hall sensor-based tachometer that transmits measured RPM (revolutions per minute) via Bluetooth to the PC. A Python script called "DataVisualizer" is used to plot incoming data from the tachometer (Fig. 1). After the measurement session is complete, the collected data can be saved in .csv format.
- RPM measurement range: 0.017 to 9000000 RPM.
- Data rate: up to 125 samples per second (5000 bits/s)
Resolution | RPM |
---|---|
<5 | 18972 |
<1 | 8486 |
<0.5 | 6000 |
<0.1 | 2683 |
Resolution depends on CPU clock frequency (1.2 MHz). The greater the RPM value, the larger CPU frequency is needed to measure it. The closer the measured RPM value is to the CPU limit, the worse the resolution is. This characteristic is illustrated in Fig. 2. The graph shows that there are two limits, one is the
- ATtiny13 microcontroller.
- HC-05 Bluetooth module (https://components101.com/wireless/hc-05-bluetooth-module).
- A1120LUA-T Hall sensor.
- 2 X Ceramic capacitor 100 nF.
- 2 X Resistor 1 k.
- Resistor 2 k.
- Resistor 10 k.
- NdFeB magnet Ø10x0.6mm N35 (not shown in schematic).
BlueTachometer uses a Hall sensor to detect the presence of a magnetic field. A magnet with its south pole facing the hall sensor is mounted on the rotating object that is to be measured. A south pole of sufficient strength turns the output on. Removal of the magnetic field turns the output off. Hall sensor output gives a digital signal and is open-drain. Upon activation, it pulls the line LOW (active LOW signal). An external pullup resistor is used to pull the line HIGH when the hall sensor is deactivated. The measurement of the signal is performed by the MCU which executes the program shown in Fig. 4. To get a better visual understanding, Fig. 5 shows how the MCU measures the signal step by step. Essentially, the MCU measures the period of the signal. This is done by using a timer to increment a counter register. When the timer is stopped the MCU sends the counter value via UART to the Bluetooth module. The data is then transmitted to the PC. Knowing the CPU clock frequency, the counter value can be converted to time (signal period) by calculating the CPU clock period and multiplying it by the counter value
DataVisualizer script uses 4 libraries:
- pyserial for communication with HC-05.
- matplotlib for data plotting.
- numpy for temporary data storage in numpy array.
- pandas for data export to .csv.
Firstly, the script tries to open a serial port over Bluetooth to receive data from HC-05. If it succeeds, then the graph is configured (figure, labels, grid, etc). After that, an empty graph is displayed, and the script enters a loop and waits for data. The received data is converted to RPM and displayed on the screen. Finally, after closing the figure window (click X), the script asks if data should be saved to .csv.
- Assemble the circuit.
- Download and extract the repository ZIP file.
- Program the microcontroller using Microchip Studio.
- Configure HC-05 Bluetooth module: Slave mode, 9600 baud rate (default settings).
- Create a Python virtual environment that satisfies the requirements found in DataVisualizer/requirements.txt.
- Attach a magnet to a rotating object to be measured.
- Power up the tachometer.
- Switch on Bluetooth on your PC and pair it with HC-05.
- In the DataVisualizer Python script, configure the COM_PORT and SAVE_DIRECTORY parameters (X_LIMIT and Y_LIMIT are optional).
- Run the DataVisualizer Python script.
- Measure RPM.
- Currently there is a reliability issue because there is no mechanism to track and prevent data loss during transmission. In addition, there is no checking which byte of the four-byte data packet is being read. When the first byte is being read, it is only assumed that it is the first byte. This leads to incorrect calculation of RPM. It seems like this issue can be avoided if the script is first started and only then the measurement is performed. The only time this issue was observed was when the script was started during measurement.
- Measures only every other signal period. This issue comes from the fact that Attiny13 has only one timer and it is used for both the measurement and UART communication. If there were at least two timers, then one timer could be dedicated solely to measurement, and instead of stopping, it could simply be reset and continue to measure during communication.
- Data rate is slow. The communication speed could be improved if a greater baud rate was used. Also, the pyserial read() function takes quite a significant time to execute (15-32 ms).