Speed Controlling of BLDC with Raspberry Pi and SOLO using HALL Sensors [+ Code]

To control the Speed of a BLDC motor with Raspberry Pi as you might know, you will need a Motor Controller that can manage enough electrical power to spin an electrical motor as well as being smart enough to control the motor and resist against the physical disturbances that can occur like variation of the Load or Speed, your Motor controller also needs to be capable of communicating with Raspberry Pi through some data lines like UART, USB, SPI etc. that are existing natively on Raspberry Pi, a controller like SOLO will offer all these possibilities as it also has an extensive library written in Python for Raspberry Pi specifically.

One of the most common ways of controlling the speed of a BLDC motors is achieved by using the HALL sensors that are mounted on most of the BLDC motors and using their outputs so that the Motor Controller can estimate the mechanical position of the Rotor of the BLDC and subsequently measures the Electrical angle of the shaft and controls the Torque and Speed of the BLDC with higher accuracy compared to sensor-less methods, besides, you can reach to lower speeds with higher performance too, because in general the sensorless methods are good for high speed operations and if you want to have good low speed operation, using HALL sensors or Encoders will facilitate that.

If you Monitor the HALL sensor outputs while a brushless motor is spinning in an arbitrary direction you will see the HALL Sensors output something similar to Figure 1 below, and as can be seen, the signals are having 120 degrees phase shift with respect to each other.

Speed Controlling of BLDC with Raspberry Pi and SOLO using HALL Sensors [+ Code] 2

Figure 1- A possible output for HALL sensors mounted on a BLDC Motor.

So now the main question is how to achieve such a Motor controlling capability using Raspberry Pi, and as you might know, Raspberry Pi modules by their original hardware are not capable of driving Electric motors for two main reasons:

Raspberry Pi modules are just little computers or let’s say brains of your systems, they are great in processing arithmetic tasks and for programming, but by no means they have the capability or power to drive a relatively powerful motor electrically.

Raspberry Pi modules or their recent chips, are not well suited for offering extremely fast and real-time processing in the range of microseconds, remember that here we are talking about execution of thousands of codes in C language un-interrupted with fixed sampling rate for Analogue readings, so it’s not the same story as the total MIPS or RISK processing power of a CPU and SOLO manages all this by offering a unique Dual-core architecture with parallel processing, so finally Raspberry Pi modules are great for high level programmings which are by nature not suitable for very fast and timely deterministic systems ( like a motor controller), and even if we imagine they can, implementing a modern motor controlling algorithms on them like FOC will be very cHALLenging and time consuming.

For the mentioned reasons, a Raspberry Pi will be able to control a Motor once it comes alongside with a Motor controller like SOLO, that offers UART communication which exist on any Raspberry Pi modules with an extensive library of Python which brings all the available functions to basically read or set any available variable that is offered by SOLO inside a Python IDE or Shell within the Raspberry Pi Operating System, this Python library will enable your Raspberry Pi to do it’s main task which is more at operating system level by sending high level commands to SOLO like setting the desired Torque, Speed of the Motor and SOLO will take care of the rest itself, like interfacing with HALL Sensors and controlling the Motor in an smart way to follow the Raspberry Pi commands.

In this tutorial, we will see how the close-loop speed controlling is achieved using Raspberry Pi and SOLO in HALL sensor Mode, and how to tune various parameters.

THE WIRING

The only wiring you need to apply will be the connection of the Motor to SOLO and by just connecting UART_TX, UART_RX and GND lines between SOLO and Raspberry Pi as below, The wiring connection of the motor to SOLO is not important as we are operating in Sensorless Mode and it can only affect the direction of rotation of the Motor. SOLO UNO Data-line Wiring to Raspberry Pi
Speed Controlling of BLDC with Raspberry Pi and SOLO using HALL Sensors [+ Code] 3

SOLO’s SETUP

In This example make sure you put SOLO into Closed-Loop control mode by pressing the Piano Switch PIN NO# 5 DOWN in SOLO UNO similar to image below, the rest of the PINs can remain UP.
Speed Controlling of BLDC with Raspberry Pi and SOLO using HALL Sensors [+ Code] 4

THE MOTOR

To proceed with this setup we are using a Brushless DC Motor with part number of “DB56C036030-A” and the technical datasheet that can be read here.

Speed Controlling of BLDC with Raspberry Pi and SOLO using HALL Sensors [+ Code] 5

THE HALL SENSOR CALIBRATIONS AND MOTOR’S CONNECTION

If this is the first time you are connecting a motor to your SOLO, you need to make sure at least for one time, you have correctly calibrated the HALL sensors with correct connection of the Motor’s windings to ABC outputs of SOLO, to do that you need to read the article below and do the steps there at least one time, and as long as your Motor or the HALL sensors are the same or the HALL sensors mountings is not mechanically displaced with respect to the Motor, all the calibrated parameters will reside in long term memory of SOLO and they will be remembered after power recycling.

Read here the article.

The Code

The Results

As can be seen in the Python code, Raspberry Pi initially Command SOLO to fix the speed over 1000 RPM (Red Plots) as can be seen in Figure 1 below, and then after a while Raspberry Pi commands SOLO to stop the Motor and this time changes the direction of Rotation and asks for fixing the speed on 2000 RPM this time as can be seen in Figure 2 below:

Speed Controlling of BLDC with Raspberry Pi and SOLO using HALL Sensors [+ Code] 6

Figure 1- Step response for 1000 RPM speed reference Tracking commanded by Raspberry Pi.

Speed Controlling of BLDC with Raspberry Pi and SOLO using HALL Sensors [+ Code] 7

Figure 2- Step response for 2000 RPM speed reference Tracking commanded by Raspberry Pi.

The Torque or in better words the Quadrature current known as Iq is also shown in these plots with Blue color, Iq has direct relationship with the Torque on the shaft of the Motor as:

Brushless Motor’s Torque [N.m] = Iq Current [A] x Motor’s Torque Constant[N.m/A]

To test the robustness of the controller, we made a test by applying variable Loads on the shaft of the Motor as can be seen in Figure 3 below, and as shown, by increasing the load externally, SOLO has increased the Torque of the Motor to keep the Speed constant at 2000 RPM, you can see that in some moments the Iq is rising UP and Down which is the indication of increase or decrease of the Torque resulted by injection of more current into the Motor by SOLO.

Speed Controlling of BLDC with Raspberry Pi and SOLO using HALL Sensors [+ Code] 8

Figure 3- Speed Control stability and Robustness test, fixing the Speed with Load variation at 2000 RPM.

As can be seen in Figure 3, despite the fact that the Torque plot (Blue) is not steady and in some points SOLO had to increase the Torque, but the Speed Plot( Red) is stable and almost fixed at 2000 RPM +/- 50 RPM, the torque increase or decrease while you are using SOLO in Speed mode, can go to the max absolute value of Current Limit that you define for SOLO, so the user can change that value to a safe value for their Motors, for instance in this Example code the current limit is set at 12.5A which is suitable for the Motor we are using.

The control introduced in this article can be interesting for those applications like the conveyors, Robots, or Electric Vehicles that want to keep the Speed constant no matter how much load or weight is applied on the system which will guarantee a stable and fixed speed during the whole operation, if you have any questions or doubts regarding this article you can ask us in our Forum.

0 Comments

Submit a Comment

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

Related Articles

How to Connect and Calibrate Incremental Encoders with SOLO

How to Connect and Calibrate Incremental Encoders with SOLO

In this article we are going to demonstrate a practical method to correctly connect and setup your quadrature Encoder to SOLO for Torque, Speed and Position controlling purposes. To this end, based on the type of the motor you are using the tuning process will be...

Share This

Share This

Share this post with your friends!