In this article, we are going to demonstrate how you can use SOLO’s ARDUINO Library to control the speed of a BLDC motor with 4150KV which will reach up to 30000RPM by applying 10V as the Battery or BUS voltage. In this example Closed-loop sensorless control will be used as this configuration will be an ideal setup for very fast RC cars or even flying Drones in terms of cost and ease of use.
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 ARDUINO.
SOLO UNO wiring to ARDUINO UNO
SOLO BETA wiring to ARDUINO UNO
In This example make sure you put SOLO into Closed-Loop control mode by pressing the Piano Switch PIN NO# 5 DOWN similar to image below:
The Motor used in this example is “Turnigy TrackStar SCT 5T Brushless Motor” with 4150KV and you can order it from here. This motor also features Hall sensor outputs which we didn’t use in this example as we are working in Sensorless Mode, but can be a good option for some other closed-loop FOC tests using Hall sensors.
Now we will try to explain the most important parts of the code given above, although the code is self-explanatory, but it will be helpful if you also have a deeper look on the detailed explanations below:
Important Note for ARDUINO UNO users
Lines 15 to 45
Definition of some variables that are being used within the code
Lines 52 to 60
Defining the data rate baudrate of UART between SOLO and Arduino, by default the UART baudrate of SOLO is 937500 bits/s or 921600 bits/s if you want to go with PC standards, but there is a possibility to have a different baudrate of 115200 [bits/s] for legacy devices like old version of ARDUINO that they don’t support higher baudrates with acceptable error margin.
However, we strongly recommend to use SOLO with its standard baudrate of 937500 [bits/s] as it offers the best performance and minimum data transmission delay which is critical for high speed operations that SOLO deals with, to control brushless motors.
You can select different baudrates for SOLO using SOLO Motion Terminal.
Here we are initializing the instance of SOLO object that we made previously, using such a way of instantiation, you’d be able to create multiple SOLO objects and deal with lots of SOLO’s connected in a network based on their device address up to 254 units.
Line 66 to 72
In this part, by reading a dummy parameter like the BUS or battery voltage we are trying to make sure the correct connection between SOLO and ARDUINO is established and working.
Lines 105 to 107
Here we are tuning the speed controller Kp and Ki gains, please remember, the Current controller gains are automatically tuned after the Motor Identification, so the only gains that you will need to tune are the Speed Controller gains. To know more you can visit here.
Lines 111 TO 152
This is the looping part of the code that firstly tries to ask SOLO to spin the Motor with 10000RPM in Clockwise direction and stay in this condition for a while, then by changing the direction and increases the speed to 30000RPM and then finally stopping the motor for a short time.
You can read more about our SOLO Motor Controller ARDUINO Library here.