In this article, we are going to demonstrate how you can use SOLO’s ARDUINO Library to control the speed of a brushless motor using only UART communication in sensorless mode.
- 1 The Wiring
- 2 SOLO Setup
- 3 The Motor
- 4 The Code
- 5 Code Explanation
Here, the only wiring you need to apply will be only 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 MINI 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 “teknic m-2310P-LN-04K” and you can download its datasheet from here. Practically this motor is a brushless motor with sinusoidal shape BEMF and they are known also as Brushless AC or PMSM motors.
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
To know more, read this post on ARDUINO website.
Lines 15 to 42
Definition of some variables that are being used within the code
Lines 48 to 56
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
Like this, we are trying to make sure the correct connection between SOLO and ARDUINO is established and working. If the connection line is not in place, the program will wait before starting to communicate with SOLO.
Lines 97 to 98
Lines 102 TO 137
This is the looping part of the code that firstly tries to ask SOLO to spin the Motor with 5000RPM in Clockwise direction and stay in this condition for a while, then by changing the direction and reducing the speed to 1500 RPM and then finally stopping the motor for a short time.
You can read more about our SOLO Motor Controller ARDUINO Library here.