Motor Control FOC SDK Antonino Bruno, Dino Costanzo, Gianluigi Forte ABSTRACT

Motor Control FOC SDK
- key features for washing machines Antonino Bruno, Dino Costanzo, Gianluigi Forte
STMicroelectronics’ (ST) focus on three-phase motor controls
enables the company to develop an unprecedented portfolio of
dedicated HW and SW solutions. A new version of ST’s Motor
Control Field Oriented Control Software Development Kit (MC
FOC SDK) now enriches the MC Ecosystem with a new version
for permanent Magnet synchronous Motors (PMSM): STM32
PMSM FOC SDK v3.4 and ST MC Workbench v3.0.2. This new
version also supports the latest STM32F families -- the
STM32F30x MCU series. The STM32F30x series combines a 32bit ARM Cortex-M4 core with a DSP and FPU instructions
running at 72 MHz, with advanced analog peripherals, making it
the right product for single and dual motor control applications.
These tools, the result of deep knowledge and system expertise
accrued in digital and power system solutions from over 10 years,
speed up the time to market and evaluation of ST products. In fact,
the company supports all kinds of motors used in home appliances
thanks to a portfolio of innovative products ranging from power
discretes to intelligent power modules, motor driver ICs, and the
latest digital microcontrollers.
The ST MC FOC SDK features and dedicated algorithms add
value to the evaluation of ST products for white good applications
such as our example, washing machines.
Figure 1 - ST Motor Control Workbench
On one hand, the firmware library provides the fundamental
bricks of Field Oriented Control for PMSM (e.g. reference frame
transformations, sensorless algorithm based on motor model, phase
current sensing with shunt resistor(s) topology, PID phase current
regulation, speed regulation, Space Vector Modulation…), and on
the other, it presents very specific algorithms suit the tasks of home
appliance drives: namely - for a washing machine application flux weakening, feed forward current regulation, advanced
overvoltage protection, Maximum Torque per Ampere, and dual
motor control.
Flux weakening is needed to extend the speed operating range
of the motor. In fact, washing machines present two different
operating areas, washing and spinning; the first is slow and heavy,
and the second is fast and soft. Motors are chosen to match the
needs of the washing cycle, so as to bear the maximum load and
optimize energy efficiency, considering that the duration of
washing plus rinsing is by far the longest. Consequently, the motor
nominal speed results are lower – about one fifth - than that
required for spinning. The “closed loop” flux weakening algorithm
implemented in the STM32 MC library enables the motor to cover
the distance, paying the smallest price in terms of energy
efficiency and torque capability. The control loop is based on
stator voltage monitoring, in order to keep a voltage margin and
prevent the saturation of current regulators.
One scalable solution, this convenient software development
kit covers all the STM32 lines right for motor control: STM32F0,
STM32F100, STM32F103, STM32F2, STM32F3, and STM32F4.
STM32 performances driving 3phase PMSM motors in application
can be quickly evaluated, reducing development time. The SDK
includes a 3-layer motor control firmware library, PC software for
complete customization of pin-out assignments and drive behavior
and tuning (fig. 1), as well as comprehensive documentation from
API functions description to algorithms overview.
The extreme drum speeds, used to shorten and maximize
clothes drying times, translates in high frequency motor phase
currents, thus posing a challenge in terms of distance between first
harmonic and control frequency. In the STM32 MC library, this is
solved by enabling the Feed Forward algorithm that improves the
performance of PID current regulation by flanking a model based
calculation of the control variables. In particular, the feed forward
algorithm has been designed to compensate for the frequencydependent back EMFs and cross-coupled inductive voltage drops
in permanent magnet motors. For instance, by enabling this
control, a 16 kHz FOC frequency regulates a 1.2 kHz electrical
Again, the same operating area – spinning – requires extra
care from an electrical safety point of view. In fact, thanks to the
flux weakening techniques available, PMSM motors can run at
speeds that are multiples of their nominal; recalling that a PMSM
motor at nominal speed produces a voltage near that of the DC bus,
it’s easy to conclude that if something wrong happens to the
control when the motor is at maximum speed (say 5x the nominal)
an hazardous phase-to-phase voltage is generated in the range of
1.4 kV, which can destroy the board. Clearly, this risk is not due to
the specific implementation of flux weakening, but to the motor
physics that can suddenly “appear” if for any reason the control is
The STM32F3 has been specifically designed to cope with
this issue by means of its embedded comparators and double
emergency (or brake) function pins, with distinctive behavior in
response to overcurrent or overvoltage:
the BRK2 input works for over-current protection, opening
the six switches from the power stage.
the BRK input works for over-voltage protection, overriding
the over-current and closing the three low-side switches to
avoid current regeneration to build up bus voltage and exceed
capacitors rated voltage.
BRK has higher priority than BRK2. When both protections
are triggered, the predefined safe state related to BRK circuitry
overrides the inactive state related to the BRK2 input.
These functionalities are embedded in the STM32F3
microcontroller, and the STM32 PMSM FOC SDK v3.4 supports
their configuration.
A relative “new” trend in home appliances is to reduce the
total bill of material cost of the solution by exploiting the ability of
the last-generation microcontroller to execute simultaneous tasks.
In the specific case of washing machines, this can be done using a
single MCU to drive two electrical motors at the same time. This
kind of control, called dual drive, has been around for a few years
in the world of electronic designs. For instance in the “high-end”
washing machine, in which the drum and the drain pump - both
three phase PMSM motors - have to be driven at the same time
during the centrifuge spinning. Other examples are dish washer
main and drain pumps, multi-compressor fridges, outdoor units of
air-conditioners, and so on.
Since 2011, STMicroelectronics has focused on this kind of
solution with the introduction of STM32F103 high density product
and the related STM32 FOC SDK 3.x library. Today’s offering
that covers the dual drive solution includes the new STM32F3x
families, and in particular, the STM32F303 product that has been
designed to be the “ideal” solution for the dual drive. Figure 2
illustrates a dual drive block diagram.
Figure 2 - Dual motor drive block diagram
There are many new features present inside the STM32F303
conceived to address the dual drive, but two of them are illustrated
in this article: the core coupled memory (CCM) and the queue of
injected conversion (QIC).
The CCM is a region of RAM linked to the Cortex-M4
instruction bus, and it is intended to be used to store part of the
firmware code that must be executed at maximum speed. Designed
to get the highest performance for any kind of time critical tasks,
the CCM is suitable for use in the dual simultaneous execution of
field oriented control (FOC) of permanent magnet synchronous
motors (PMSM), reducing the total workload, by more than 40%,
than traditional solutions.
The QIC is useful when it is necessary to program an analog
to digital (ADC) conversion, or a sequence of ADC conversions,
that have to be enabled only after a specific event occurs (for
instance an update event of an internal timer) and unloads the
MCU from waiting for the occurrence of such event. This ST
patented method is implemented in hardware in the STM32F3
products by means of a queue of pre-programmed sequence of
conversions that are automatically activated without the
intervention of the MCU. It fits the needs of a dual drive in which
the motor phase currents sampling have to be programmed
synchronously with the PWM control signals, and the context
switching between one motor and the other is synchronized with
another event (timer update). Given the generality of that method,
it can also be applied for other kinds of synchronized conversions
(current sensing for digital PFC and so on).
Today, more than ever, the role of safety has become very
important for many electronics applications and in particular for
home appliances, subsequently raising the level of safety
requirements in electronic designs. With the introduction of
solutions based on a microcontroller, even for low end
applications, appliance manufacturers must consider both the
hardware and firmware aspects to comply with the regulations that
assure user safety.
STMicroelectronics offers a wide set of system evaluation
boards supporting diverse final applications. For example, all
motor control boards have a ST standard connector in order to
easily connect any control board (with different MCUs) with any
power boards (with different power rates and products). In Table 1
are reported the main system evaluation boards featuring 3-phase
motors for white goods.
The current safety recommendations and requirements are
specified by recognized international standards bodies like IEC, for
instance the 60335-1, and are verified and certified by authoritative
testing houses like VDE.
New software techniques for improving safety are
continuously being developed, and to help its customers, ST
provides a set of self-check, VDE certified routines to facilitate
and accelerate the software development and the certification
The basic principle of the safety of household electronics
appliances stated in the IEC60335-1 is that the appliance must
remain safe in case of concurrent component failure. This means
that in the case of a “standard” electronic component, it must stay
safe at least after two consecutive failures. In case of a
microcontroller based solution, if the safety of the appliance relies
on firmware, then that firmware has to be certified.
The IEC60335 annex Q defines three safety classes for
firmware: Class A when the safety does not rely on the firmware,
Class B when the firmware prevents some unsafe operation, and
Class C when the firmware is intended to prevent special hazards.
In many home appliances relying on microcontrollers to drive
electrical motors, like the drum in washing machines, pumps in
dish washers, or compressors in fridges, it is possible that the
safety of the appliance can be delegated to the firmware. In all of
these cases, usually, the firmware is certified as Class B.
In order to respect the requirements for Class B firmware, it is
necessary to test several components of the system such as the
MPU clock, register, memory, and peripherals. All aspects related
to the microcontroller are covered by the “STM32 self-check
routines” provided by ST, allowing users to focus only on what
concerns their application specific tests and basically reducing the
Moreover, as stated above, extra safety features are also
embedded “in hardware” in the STM32F3 families, strengthening
the already robust set of “safety-oriented” features. So on top of
the “smoke-inhibit” features like the locking of sensitive registers,
the CCS, two emergencies input with programmable behaviors are
present in the STM32F3 products.
Table 1: Main system evaluation boards for 3-phase motors
Motor control starter kit for
Evaluation board for
STM32F303xx microcontrollers
Evaluation board for STM32 F0
Control stage based on the STM32
for motor control with serial
communication user interface
150 W inverter featuring the L639x
and STGD3HF60HD for 1-shunt
based sinusoidal vector control and
trapezoidal scalar control
3-phase high voltage inverter power
board for FOC and scalar motor
control based on the STGIPN3H60
Dual motor control and PFC
demonstration board featuring the
STM32F103 and STGIPS20C60
BLDC/PMSM drive demonstration
board based on STM32 and the
1 kW 3-phase motor control
demonstration board featuring the
We have presented the latest version of ST’s MC FOC SDK,
and every year ST enriches these tools with new features
supporting new technologies and products, while enlarging
STMicroelectronics’ Motor Control Ecosystem in order to meet
new trends in home appliances in terms of efficiency, integration,
and cost optimization.