Resuscitation of old laboratory stands with microcontrollers

The idea arose after laboratory work, in which it was necessary to measure the speed of an asynchronous machine. These measurements were carried out using an optical tachometer, which was available in one copy on three stands. Waiting for their turn greatly spoiled the impression of the experiments, in connection with which one of the teachers suggested independently creating an analog of the device used.
The basis was taken by the Atmega32 microcontroller. A ZX-03 reflective sensor was found with which it was possible to track the frequency of the appearance of a white mark on the rotor shaft, and a small LCD display to display information. The microcontroller was programmed using a home-made programmer, working through the MAX-232, and AVRprog. The program was written in C using AVRStudio.
The algorithm of the device is quite simple. The sensor generates a specific signal depending on the reflectivity of the surface to which it is directed. The microcontroller conditionally divides the received signals according to the level of radiation into dark and light. A white mark applied to the rotor shaft is perceived as a bright band, the rest of its surface as a dark one. By detecting the passage time of the black and white stripes using the internal timer, the microcontroller receives the time of one revolution of the machine rotor, and then calculates the frequency and displays the result on the display. To increase the accuracy of measurements, the revolution time is first summed up several times, so that when calculating the frequency, its average value is used. The following is the code directly performing the measurements:
TIM16_WriteTCNT1(0); // обнуляем таймер
while (1) // Ждем конца черной полосы
{
adc = Read_ADC(); //считываем показания датчика
if(adc>0x280) // проверяем, не началась ли белая полоса
break;
}
while (1) // Ждем конца белой полосы
{
adc = Read_ADC(); //считываем показания датчика
if(adc<0x280) // проверяем, не началась ли чёрная полоса
break;
}
// Тут уже считаем значение счетчика, которое отражает время одного оборота, измеренное в тактах
counter=TIM16_ReadTCNT1();
The device diagram turned out to be quite simple and was assembled on a breadboard, and then placed inside the box from the shoe brush.
After assembling the device and writing the program, it became clear that we are not using most of the capabilities of our microcontroller, such as EEPROM, interrupts, etc. In this regard, it was decided to expand the capabilities of the device by adding to it the function of storing the maximum measured value and the ability to control the short circuit time of the asynchronous machine, which was necessary for laboratory work.
Using EEPROM to memorize the measurements was not difficult. The standard AVRStudio library includes simple and intuitive functions for managing this type of memory.
Implementing short-circuit control turned out to be a little more difficult. To do this, it was necessary to create a cascade of two relays of different power, one of which is inside the tachometer and controls the other more powerful relay, directly commuting a short circuit. In addition, interrupts were applied to make faults, which allowed switching without interfering with the operation of the tachometer itself.
It is also worth adding that automation of short circuits was caused by practical necessity, since earlier the circuit was carried out by pressing and holding a button by a student. Since the duration of such a regime was not limited, the equipment used was at serious risk. Automation of this process using a microcontroller has significantly improved the reliability of the laboratory installation.

Sensor ZX-03 Reflector

Tachometer, assembled on a breadboard

Working tachometer

A device placed in a box from a shoe brush
The result was a device comparable in accuracy with the factory tachometer available, but overtaking it in terms of functionality and relatively cheaper to manufacture. It greatly facilitated the work with the laboratory installation, as well as increased its reliability level and, in general, breathed new life into the stand.