Skip to content

A Device for the Monitoring of the BLDC Motor Controller

A device has been designed and created to monitor and visualize the state of the BLDC motor controlled by a dedicated controller. Moreover, it has been used to generate a set value for the controller and to tune the controller settings.

Main features of the device

  • Show basic information on an LCD screen
    • Temperature of the motor, measured with DS18B20 sensor
    • The rotational speed of the motor, measured by AS5040 magnetic encoder
      Power supply voltage and the current consumed by the motor
  • LEDs indicators
    • A state of the input voltage
    • A status of the communication with the BLDC controller by the I2C interface
    • A state of the communication with PC by UART interface
  • The device is responsible for the below items
    • Sending measurements to the PC
    • Sending set values to the BLDC controller
    • Taking commands from the user with a small keyboard that consists of four keys.

General architecture

The BLDC measurement unit device is just a part of a bigger project. It’s a middle layer between the BLDC motor controller and a user application. The user application (written in C++/Qt) will be introduced in the next post. Meanwhile, let’s focus on the measurement device.

The unit for the motor state monitoring has been equipped with multiple sensors but it also receives data from the motor controller. For example, it measures the rotational speed of the motor, the temperature of the motor, the consumed current, and phase voltages. The diagram shows the components of the system and the connections between them.

The next figure shows the real system that consists of the BLDC motor (from the HDD drive), the motor controller, and the unit for the measurements.

Measurement unit hardware

Power supply

The motor state monitoring unit needs input voltage in the range of 8 to 15 V DC. It was equipped with an additional connector for the motor controller (P2).

The device is protected against the reverse polarization of the input voltage. The protection circuit is based on the N-MOSFET (Q1) and resistor R1. To protect components against voltage spikes, some Transil diodes were used. Capacitors C1-C3 are used to filter and stabilize an input voltage.
The input voltage is passed into a linear LDO (Low DropOut) stabilizer which provides +5V on the output.

Microcontroller circuit

The device is based on the microcontroller AVR ATmega32A. Connections have been shown in the below scheme. The circuit contains three LEDs (D2-D3) to indicate the state of the device and four switches (S1-S4) to handle commands from a user.

Reference voltage

For better accuracy of the ADC (Analog/Digital Converter) measurements, the device has been equipped with an external reference voltage source. It used IC LM336D-5.0. The calibration of the reference voltage could be done with a potentiometer PR1.

LCD display

The LCD was used to show important information to the user, especially current process parameters. The device was equipped with a very popular HD4470 LCD which allows displaying of two lines with 16 signs in each. On the microcontroller side, to control the LCD, there are necessary four ports for data (4-bit mode) and three ports to set the control instruction. So, together seven lines between the microcontroller and LCD are necessary. The backlight level is controlled by the generated PWM signal and an external transistor Q2. The contrast of the LCD can be adjusted with the PR1 potentiometer.

Connectors

UART connector

The UART interface has been used to communicate with the measurement unit from an external device (mostly a PC with a proper UART-USB converter).

KANDA connector

A KANDA connector is used to flash the microcontroller with an external programmer. For programming, it’s used an SPI (Serial Peripheral Interface).

Temperature sensor (DS18B20) connector

The used DS18B20 sensor communicates with the microcontroller by a 1-wire interface, so it needs one signal wire, VCC wire, and GND wire. However, it can work also with only two wires: signal and GND. Then the signal line is used to load the capacitor in the external receiver.

Encoder connector

The encoder connector consists of three signal wires for the quadrature encoder, 5V power supply line, and GND. So, it could be used with any quadrature encoder supplied with 5 V.

Connector for BLDC motor controller

An additional connector has been used to connect the measurement unit with the BLDC motor controller. It contains I2C interface wires, but also motor phase voltages for measurements independent from the motor controller. For example to validate if commutations are done correctly. There is also an analog line with a voltage proportional to the current consumed by the motor. For future uses, it’s equipped also with the line A_LSB_U for the additional encoder.

Measurements

Rotational speed measurement

The rotational speed measurement has been realized with a magnetic encoder AS5040. It generates quadrature signals with a frequency proportional to the rotational speed of the motor shaft. Two quadrature (phase-shifted) signals are necessary to retrieve the rotation direction. It is used as a standard circuit for the encoder (based on the datasheet). It is equipped with additional LEDs to indicate if the magnet has been placed correctly which means the correct distance from the encoder device. If it’s too far, then the magnetic field is too low and that’s indicated by one LED. On the other hand, if it’s too close, another LED indicates that the magnetic field is too strong.

On the microcontroller side, the frequency approach has been implemented. In such a method, one timer measures the period (time window) in which all pulses of quadrature signal are counted (both rising and falling edges). To measure the time an 8-bit timer was utilized while for impulse counting the 16-bit was used. The speed formula is as follows

\omega = \dfrac{d\theta}{dt}=\dfrac{\Delta \theta}{t} = \dfrac{2 \pi \cdot \Delta n}{N_p \cdot t}[rad s^{-1}]\rightarrow \dfrac{60\Delta n}{N_p t}[RPM]

where:

  • N_p defines number of pulses per revolution,
  • \Delta n is number of detected pulses,
  • t is a time window in which pulses are counted.

The quantization error could be calculated as follows

\Delta \omega=\dfrac{2\pi}{N_p t}[rad s^{-1} \rightarrow \dfrac{60}{N_p t}[RPM]

Temperature measurement

For the temperature measurement, a DS18B20 sensor has been used. It has resolution equal to 0.5oC. When it’s set for the maximum resolution, one measurement takes 750 ms.

Current measurement

To measure the current consumed by the BLDC controller it was used a measuring resistor R=0.003\Omega, and a measuring amplifier with an amplification coefficient K=200. On the microcontroller side, it was used 10-bit ADC with reference voltage V_REF equal to 5V. The resolution of the measured voltage is as follows.

V_{RES} = \dfrac{V_{REF}}{2^{10}}  = 4.88~mV

On the other hand, the resolution of the measured current is like below.

I_{RES} = \dfrac{V_{RES}}{K \cdot R} = 0.00488 / (200 \cdot 0.003)  = 8.13~mA

Phase voltages and motor supply voltage measurements

To adjust the level of measured voltages (motor phases and power supply voltage) to allowable input levels of ADC, the voltage dividers were used. Also, to filter out higher frequencies of noise, low-pass RC filters were applied. It was especially important to cut-off frequencies related to the motor controller PWM signals (20 kHz).

To calculate the resolution of the input voltage measurements it’s necessary to find the resolution of the 10-bit ADC.

V_{RES} = \dfrac{V_{REF}}{2^{10}}  = 4,88 mV

Based on that, assuming that the output voltage from a voltage divider

U_{out} = U_{in} \cdot \dfrac{R_2}{R_1 + R_2},

the resolution on the input of voltage divides is as follows.

V_{RES2} = V_{RES} \dfrac{R_1+R_2}{R2}

For R_1=2.2k~\Omega and R_2=4.7k~\Omega it is

V_{RES2} =0.00488 \cdot \dfrac{4700 + 2200}{2200} = 15~mV.

Software

The software has been written in C. To handle LCD and DS18B20 sensor, dedicated libraries were used:

Communication with PC (UART)

The measurement unit can communicate with external devices, especially PC with a dedicated application. For this purpose, the UART interface was used on the microcontroller side but of course, it needs some kind of USB-UART converter to connect it to the PC. In the designed communication protocol all requests are sent to the measurement unit from the external device.

Communication with BLDC controller (I2C)

The I2C interface has been used to communicate the device with the motor controller. The controller works in a SLAVE mode and the measurement unit device in a MASTER mode. Therefore, all orders are created by the measurement unit and sent to the motor controller.

Conclusion

During the tests of the measurement unit with the motor controller, it has been noticed an issue with the rotational speed estimation. The rotational speed estimation based on the measured time between consequent commutations was very inaccurate. Because of that, the method was changed to the one based on the magnetic encoder. Such calculated value has been provided on the input of the PID controller.

Three different methods of control in the power stage of the BLDC controller were checked. The first method assumed switching only high-side transistors (unipolar +) in half-bridges. The second approach was based on the switching of low-side transistors (unipolar -). The last method was based on the idea of switching both low-side and high-side transistors (complementary method). In this case, it was necessary to use additional dead time in the complementary PWM generator to avoid short circuits.

Some additional photos of the measurement unit (PCB was done with a laser printer, laminate, and specific etcher).

bldc_station_1

bldc_station_2

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.