How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode  | ESC | FOC | Sensorless 1
Written by Staff
How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode | ESC | FOC | Sensorless

This Tutorial is dedicated to guide you step by step into controlling speed of a permanent magnet synchronous motor which are also known as PMSM or AC brushless motors. The method proposed here is the sensorless closed loop speed control which will result in the elimination of the need for having any sensors like encoders or hall effect sensors, plus having the ability to keep the spinning speed of the motor constant while the load on the shaft of the motor varies.

What is a Brushless AC or PMSM motors?

Brushless AC or Permanent Magnet Synchronous Motors are one kind of Brushless Motors, The expression AC brushless Motor is used to indicate those Motors that utilize a synchronous machine with permanent magnets: the excitation magnetic field, in such machines, is provided by permanent magnets.
The scope of these Motors is mainly limited to low power (typically less than 50 kW) for the limitations imposed by the magnetic materials currently available to the construction of machines: the size and cost of the magnets are very high. However, this is an important field of application and in significant growth, including numerically controlled machine tools, industrial automation, robotics, light traction, heavy traction, wind generation. Furthermore, due to the virtual absence of rotor losses these machines do not require forced ventilation and are therefore suitable for applications like aerospace or contaminated environments.
These Motors consist of a cylindrical stators with symmetrical three phase windings resulting in generation of a sinusoidal magnetomotive force or BEMF, in simple language their BEMF has a sinusoidal shape in contrast to Brushless DC motors with Trapezoidal BEMF shape.

What is Field Oriented Control?

Field Oriented Control is a pretty new approach of driving and controlling various types of electrical motors, in this methodology in a very simple language, the goal is to control the Field and the Torque of the motors separately resulting in a much more robust and reliable results. Using this methodology one could reach higher performances in driving electrical Machines with smoother motions, better performance and higher efficiency. We will cover this topic in depth in our future articles.

What is Sensorless Control?

This term despite looking self-explanatory might be a little bit hard to grasp, so we’ll put it in this way:
The sensorless speed or Torque control refers to those type of controls in which they don’t require the user to use Encoders or other types of position sensors like Hall-Effect or Tactile sensors, so these controllers are able to detect and calculate the position and the speed of the rotor of the motors and subsequently eliminating the need for having any other kinds of sensors, but this is not their biggest advantage, their main advantages could be considered as:

1- Reduction of the components used, like sensors or the electronics used to run and condition the sensors outputs ( like the supplies, level shifters , … ) , which will reduce the probability of failure of the whole system due to having less components involved.

2- Reduction of Wiring in a system, so by using sensors of any kind, you’ll need to wire the sensors all the way from the position of fixation of the electrical motor to the control unit, this will make the assembly of the system harder plus bringing all the issues with wiring like limitation of distance, possibility of failure of the wire, bad junctions and so on.

3- Reduction of the Cost, it’s very apparent from the above mentioned reasons, how one can reduce the final cost of their system by eliminating the whole costs of sensors and wiring.
Of course like any other solutions, there will be pros and cons using sensorless methods, their main drawback can be considered as:

– Having a Minimum Speed restriction, these methods mostly rely on the feedbacks of voltage, current or BEMF coming back from the Motor, so if the motor doesn’t generate sufficient values the sensorless methods will have hard time to start their operation, as a result there’s a limit in minimum rotational speed defied, meaning that the sensorless controls can only start from a certain minimum speed in range of tens of RPM ( like 100 RPM ), so you can’t expect them to be very accurate in low speeds.
But altogether, the sensorless methods are very popular and desired in lots of systems like traction units and all the applications that the extreme precision of speed control is not a matter.

The steps of setupping a using SOLO alongside with ARDUINO

0. Turn off the system and Reset the Piano switch

Make sure you have disconnected the power supply connected to SOLO or any other peripheral which is in contact with SOLO, after that you need to push UP all the pins of the piano switch.

1. Apply the Wiring

To start with SOLO first you need to provide the Wiring of SOLO to ARDUINO as following:

How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode  | ESC | FOC | Sensorless 2

As you can see SOLO is also capable of supplying ARDUINO Directly through its 5V output and as a result you will not need to have ARDUINO connected to any other devices like a PC to provide you the power.


Make sure you don’t supply the ARDUINO both from your PC using USB or any other supply and Then the 5V from SOLO at the same time, you should use only one of the supplies especially in ARDUINO UNO models where they can’t switch the supplies and this might cause issue for the system
The “DIR” Pin is a 3.3V input, and it’s NOT 5v tolerant, to apply a 5V input you MUST use a resistor with a value between 1kΩ to 2.2kΩ, as can be seen in the diagram above.

2. Select the Motor type using Piano Switch

In this tutorial we are using a Brushless Motor with very low inductance ( around 400uH line to line) so in this case we have decided to put the switching frequency of SOLO at 80kHz to have a better current controlling. By putting Switch 1 and 2 of Piano Switch into ON position (UP) SOLO will be set on Brushless Motors with 80kHz of switching at the output (BLDC or PMSM). As a rule of thumb, for motors having phase inductances below 200uH (Line-to_Line inductance below 400uH) you can put the switching frequency higher than 50kHz up to 80kHz ( depending on the motor and it’s maximum allowable switching frequency to avoid saturating the core)

How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode  | ESC | FOC | Sensorless 3

3. Reset the Kp and Ki potentiometers

Just rotate the two blue potentiometers shown below all the way in Clockwise direction into the blocking point ( please treat them gently! ) , so their value becomes zero.

How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode  | ESC | FOC | Sensorless 4

4. Turn On the system

Now you can turn on the main supply connected to SOLO’s power input (8-58V) and SOLO will immediately boot up with a blinking E2 LED while E1 LED is off which is the indication of a safe startup with no errors or malfunctions ( like over current, over voltage, … )

5. Put SOLO into Closed-loop mode

since the control type we are using here is among the closed-loop controls, you need to push the Piano switch number 5 Down while SOLO is turned ON, when you do that, SOLO in less than a second will identify your motor parameters and it will store them on it’s non-volatile memory, during this time if the shaft of the motor is free, you might witness some little vibrations which are totally normal. So as long as the Piano Switch number 5 is down, the last saved parameters will be used, even if you turn off the whole system and turn it back on later.

How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode  | ESC | FOC | Sensorless 5

Under the following conditions you need to pull up and push down again the piano switch number 5 :
– In case of changing the Motor
– In case of changing the wiring of the motor ( not mandatory but better to be done )
– The very first time you run SOLO and you put it into closed-loop ( after receiving the factory made module )

6. Put SOLO into Speed control Mode

Just psh the piano switch number 4 Down, so SOLO will go into speed control mode.

SOLO into Speed control Mode

7. Tune The Kp and Ki gains

Turn a little bit Kp ( like 5 degrees in counter clockwise direction ) and for a very small amount Ki ( much less than Kp, around 1 or 2 degrees), the best is you watch the video up there to master this. In general these two potentiometer are like some gains and in a very simple language:

Kp : defines for you how fast your motor should react and reach the speed you asked, so if you increase this value, your motor will be more reactive, but too much of this gain might make vibrations, so you need to tune it enough. Also another effect of this gain will be how “harshly” the controller ( here SOLO ) should react to the variation of the load on the shaft of the motor to keep the speed constant, so in case of using this functionality in a mobile robot as an instance, if you increase Kp of SOLO, and the robot reaches to some ramps, it will adjust it’s speed faster but also it might make your robot too fast. So it’s not always good to increase this gain, it totally depends on your system.

Ki: defines how good your motor during time should reach the goal, so by increasing this value your motor might reach the goal slower but more consistent. Also by increasing this gain too much your motor might get unstable. So you need to tune this similar to Kp with patience and accuracy. In general the first time you tune these two gains, as long as you are using the same Motor in the same system you won’t need to touch them, it’s only the matter of the first time.

8. Send PWM pulses from ARDUINO to SOLO control the speed

one of the methods of commanding SOLO is using pulse width modulation ( PWM) method, in this method you will send some digital pulses in which their high-state is 5V and their low-state is 0V to “S/T” input of SOLO from the analog input port. These pulses should have a frequency above 5kHz ( the higher the frequency the better the resolution). Now by varying the duty cycle of these pulses you can increase or decrease the speed of your motor from zero speed( 0% duty cycle ) to max allowable speed that SOLO can support.

Since here we have selected the Motor type Number 3 ( ultrafast brushless motors ), the maximum speed in this case will be 30000 RPM, meaning that at 100% duty cycle SOLO will try to force your motor to reach at 30000 RPM if the motor itself can sustain such a speed, but in most cases the nominal speeds of brushless motors might be lower than this, so you need to find out based on your motor’s specifications, what is the maximum duty cycle percentage applicable to be sent to SOLO into “S/T” pin to make your motor reach at its maximum speed.

How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode  | ESC | FOC | Sensorless 6

Speed in RPM for Ultrafast Brushless Motor = ((duty cycle of pulse applied on “S/T”)/(100)) *30000

To have accurate speed calculations, you need to set the proper number of Poles for your motor, The number of Poles by default in SOLO is set at 8 ( 4 Pole Pairs ) , you can either change this value using UART, USB or CAN or you can try to recalculate the value of Speed based on your motor number of poles and the mentioned formula above.

Number of Pole Pairs = Number of Poles / 2
For example in our case if we want to reach to 8000 RPM with a motor with 8 poles, we should apply on “S/T” input a pulse with duty cycle of 26.6% from Arduino: (8000/30000)*100 = 26.6

How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode  | ESC | FOC | Sensorless 3

9. Limit The current fed into your motor

You can limit the amount of current fed to your motor using the connection shown in the wiring section to “P/F” input of SOLO. Again here, you can use PWM pulses with any frequency above 5kHz, and by changing their duty-cycle, the value of the current limit will change based on the following formula:

The current Limit value = ((100 – duty cycle of PWM at P/F input)/100) * 32

For example if we put the duty cycle at 80%, the maximum current allowed into the motor will become 6.4 Amps = ((100-80)/100)*32 As you see, this input works in reverse, so if you leave it open, the maximum allowed current into your motor will be the default value of 32A and if you apply a 100% duty-cycle PWM into “P/F” input, the current limit will be set at 0 (no current allowed into the motor).

If you don’t want to limit the current into your motor, you can leave this input unconnected.


The image below is a real time plot of Torque-Speed of a brushless motor controlled by SOLO in closed-loop sensorless speed control mode. As you can see, the speed of the motor ( green plot) remained constant even at those moments where a load applied to the shaft of the motor, you can find those moments that the load has been applied from the Torque (the red track) , because whenever a load has been applied on the motor, SOLO automatically increases the Torque of the brushless motor to overcome the load and keep the speed constant.

How to control speed of PMSM using ARDUINO and SOLO in closed loop sensorless mode  | ESC | FOC | Sensorless 8


Submit a Comment

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

Related Articles

Share This

Share This

Share this post with your friends!