hands-on stm32 pmsm-foc-sdk

STM32 PMSM FOC SDK 4.2
Hands-on workshop with hardware tools
Rev 1.5
Objectives
The purpose of this hands-on workshop is to:
• Get you up and running with the STM32 PMSM FOC SDK
using the ST MC Workbench with the final purpose of
running a PM synchronous motor with STEVAL boards.
• Show you where to go for documentation, firmware
libraries and application notes and additional ecosystem
support
• Help you obtain additional technical support
2
Systems check
• Everyone should have:
•
•
•
•
•
•
•
A Windows laptop (XP, Vista or Win 7, Win 8)
A ST-LINK dongle (optional)
USB to RS-232 dongle and a null modem cable (optional)
The permanent magnet motor you want to run
A multimeter (optional)
An oscilloscope with current probe (optional)
An insulated DC and or AC power supply
• Ready to begin?
3
Hardware setup
Step #1 – Hardware setup
• It is possible to choose one of the following offers:
• Complete Motor Control Kit.
• One of the complete inverters currently in stock.
• Any STM32 evaluation board combined with one of the ST evaluation
power stages both including the MC connector.
• The following slides report all available boards present in
the ST stock that can be used to arrange a motor control
system.
• Follow the instructions in the related user manual to set up each board.
5
Motor control board offer
MC kit
Inverters
Kit: from isolated debug probe to motor
Control
board
Power
board
6
MC kit
Motor control kits
Part Number
Description
ST Link
on-board
Type
STM32100B-MCKIT
Motor control starter kit for STM32F100 (128KB Flash) Value Line MCUs
Yes
Single drive
STM3210B-MCKIT
Motor control starter kit for STM32 (128KB flash) Performance and
Access Line microcontrollers
No
Single drive
P-NUCLEO-IHM001
STM32 Nucleo Pack FOC and 6-step control for Low voltage 3-ph motors
Yes (embedded)
Single drive
The motor control kit connections represented below can also be applied when combining STM32
control boards and evaluation power boards.
STM3210B-MCKIT STM32100B-MCKIT
Serial communication RS232
P-NUCLEO-IHM001
7
Inverters
ST complete inverters
Part Number
Description
ST Link
on-board
Type
STEVAL-IHM034V2
Dual motor control and PFC demonstration board featuring the
STM32F103 and STGIPS20C60
No
Single/Dual
drive
STEVAL-IHM036V1
Low power motor control board featuring the SLLIMM™
STGIPN3H60 and MCU STM32F100C6T6B
No
Single drive
STEVAL-IHM038V1
BLDC ceiling fan controller based on STM32 and SLLIMM-nano
No
Single drive
STEVAL-IHM040V1
BLDC/PMSM driver demonstration board based on STM32 and the
SLLIMM nano™
No
Single drive
STEVAL-IHM042V1
Compact, low-voltage dual motor control board based on the
STM32F303 and L6230
Yes
Single/Dual
drive
STEVAL-IHM043V1
6-Step BLDC sensorless driver board based on the STM32F051
and L6234
No
Single drive
STEVAL-IFN003V1
DC PMSM FOC motor drive
No
Single drive
STEVAL-IHM034V2
STEVAL-IHM036V1
STEVAL-IHM042V1
STEVAL-IHM043V1
STEVAL-IFN003V1
STEVAL-IHM038V1
STEVAL-IHM040V1
8
STM32 evaluation boards
with MC connector
Control
board
Part Number
Description
ST Link on-board
Type
STM32072B-EVAL
Evaluation board with STM32F072VB MCU
Yes
Single drive
STM3210E-EVAL
Evaluation board for STM32 F1 series - with STM32F103 MCU
No
Single drive
STM3220G-EVAL
Evaluation board for STM32 F2 series - with STM32F207IG MCU
Yes
Single drive
STM32303E-EVAL
Evaluation board for STM32F303xx microcontrollers
Yes
Single/Dual drive
STM3240G-EVAL
Evaluation board for STM32F407 line - with STM32F407IG MCU
Yes
Single drive
STEVAL-IHM022V1
High density dual motor control demonstration board based on the
STM32F103ZE microcontroller
No
Single/Dual drive
STEVAL-IHM039V1
Dual motor drive control stage based on the STM32F415ZG
microcontroller
No
Single/Dual drive
STM32072B-EVAL
STM3220G-EVAL
STM3240G-EVAL
STM3210E-EVAL
STEVAL-IHM022V1
STM32303E-EVAL
STEVAL-IHM039V1
(1) Only necessary for high-voltage applications or if not included with the evaluation board:
In-circuit debugger/programmer..
 ST-LINK/V2
 ST-LINK/V2-ISOL (2500 VRMS high isolation voltage)
9
ST evaluation power boards
with MC connector
Power
board
Part Number
Description
STEVAL-IHM021V2
100 W, 3-phase inverter based on L6390 and UltraFASTmesh™ MOSFET for speed FOC of 3-phase PMSM motor drive
STEVAL-IHM023V3
1 kW 3-phase motor control evaluation board featuring L6390 drivers and new IGBT STGP10H60DF
STEVAL-IHM025V1
1 kW 3-phase motor control demonstration board featuring the IGBT SLLIMM™ STGIPL14K60
STEVAL-IHM028V2
2 kW 3-phase motor control demonstration board featuring the IGBT intelligent power module STGIPS20C60
STEVAL-IHM032V1
150 W inverter featuring the L639x and STGD3HF60HD for 1-shunt based sinusoidal vector control and trapezoidal scalar
control
STEVAL-IHM035V2
3-phase high voltage inverter power board for FOC and scalar motor control based on the STGIPN3H60 (SLLIMM™-nano)
STEVAL-IHM045V1
3-phase high voltage inverter power board for FOC based on the STGIPN3H60A (SLLIMM™-nano)
STEVAL-IPM05F(1)
3-phase motor control power board featuring STGIF5CH60TS-L
STEVAL-IPM07F(1)
3-phase motor control power board featuring STGIF7CH60TS-L
STEVAL-IPM10F(1)
3-phase motor control power board featuring STGIF10CH60TS-L
STEVAL-IPM10B(1)
3-phase motor control power board featuring STGIB10CH60TS-L
STEVAL-IPM15B(1)
3-phase motor control demonstration board featuring STGIB15CH60TS-L
Note 1: Available Q4/15
10
Flexible MC platform
Power board
Flexible approach:
STEVAL-IPMxx
• The STEVAL-IPMnmx evaluation board is a universal, fully-tested and populated-design consisting
of a 3-phase inverter bridge based on the SLLIMM™ 2nd series IPM.
• The main characteristics are small size, minimal BOM and high efficiency. It consists of an interface
circuit (bus and VCC connectors), bootstrap capacitors, snubber capacitor, short-circuit protection,
fault event circuit, temperature monitoring, single/three shunt resistors and filters for input signals.
• A double current sensing option is provided: three dedicated on-board op amps or by using the op
amps embedded on MCU.
• Hall/encoder part completes the circuit.
11
Flexible MC platform
Power board
STEVAL-IPMxx
Features and architecture
• Inverter evaluation board based on
2nd series of ST’s SLLIMM™ IPM trench-gate field-stop technology IGBT
STGIxxCH60x full-molded or DBC package
• Input bus voltage: 125 ÷ 450 VDC
• Current capability: from 5 to 30 A (nominal)
• Hardware overcurrent protection using SLLIMM’s Smart
Shut Down
• Motor current sensing: single or three shunt
configuration
• ST’s MC connector compatible
SLLIMM™ card
+15÷20 V
DC
MC connector
3 shunt/single
and network sensing
Hall/encoder
sensors
• Nominal power: from 300 W to 3 kW
• Two options for sensing: on-board op amps or the
MCU’s
• DC bus voltage sensing to MCU
• Hall sensors (3.3/5 V) / encoder inputs (3.3/5 V) to MCU
• Testing pins for all IPM signals
• Very compact size
+450 V
DC
12
STEVAL-IPMnmx
SLLIMM™ “cards”
Flexible MC platform
Power board
TOP
13
Hardware key features 1/3
Reference /
bundle
Voltage
Power
Motor type /
control type *
STEVAL-IHM034V2
230 VAC Nominal
Up to 1.3k W
PMSM,
Dual Motor (FOC) +
digital PFC
STEVAL-IHM036V1
90 – 285 VAC
125 – 400 VDC
Up to 100 W
PMSM,
FOC
STEVAL-IHM038V1
90 – 265 VAC
Up to 40 W
STEVAL-IHM040V1
120/230 VAC
nominal (60/50 Hz)
Up to 100 W
PMSM/BLDC
FOC/Six step
STEVAL-IHM042V1
8 - 48 V
Up to 10 W
PMSM,
FOC
Single/3 shunt
ST parts
STEVAL-IHM043V1
7 to 42 VDC
Up to 35 W
BLDC
Six-step motor control
STEVAL-IFN003V1
8 - 48 V
Up to 45 W
PMSM,
FOC
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
STEVAL-IFN004V1
8 - 48 V
Up to 35 W
BLDC
Six-step motor control
• 1x STM8S
• 1x L6230Q
PMSM,
FOC
Application focus
1x STM32F103C8T6
1x STGIPS20C60
1x Viper16L
Complete drive: compressors,
room air conditioning,
1x STM32F100C6
1x STGIPN3H60
1x Viper16
Water pumps, dish washers,
washing machines
1x STM32100
1x STGIPN3H60
1x L6562A
Complete drive: fans, ceiling
fans, pumps.
1x STGIPN3H60
1x STM32F100C8T6
1x VIPer16
Complete drive: pumps, fans
2x L6230
1x STM32F303
1x ST1S14
Complete drive: fans, blowers,
toys
1x L6234
1x STM32F051C6T6
1x L78L33ACD
Complete drive: pumps,
security systems, ATMs.
1x STM32F103C
1x L6230PD
Complete drive: pumps,
security systems, ATMs
Complete drive: pumps,
security systems, ATMs
14
Hardware key features 2/3
Reference /
Voltage
bundle
Power
Motor type /
control type *
ST parts
Application
focus
Up to 100 W
PMSM/BLDC
FOC/Six step
3 shunts
• 3x L6390
• 1x Viper12
• 6x STD5N52U
Power board: water pumps,
fans, dish washers, washing
machines
• 3x L6390
• 1x Viper16
• 7x STGP10H60DF
Power board: pumps,
compressors, washing
machines and more
• 1x STGIPL14K60
• 1x Viper16
• 1x STGP10NC60KD
Power board: pumps,
compressors, washing
machines and more
STEVAL-IHM021V2
120/230 VAC nominal
(60/50 Hz)
STEVAL-IHM023V3
90 – 285 VAC
125 – 400 VDC
Up to 1 kW
PMSM/BLDC
FOC/Six step
Single/3 shunts
STEVAL-IHM025V1
90 – 285 VAC
125 – 400 VDC
Up to 1 kW
PMSM/BLDC
FOC/Six step
STEVAL-IHM028V2
90 – 285 VAC
125 – 400 VDC
Up to 2 kW
PMSM/BLDC
FOC/Six step
single/3-shunt
STEVAL-IHM032V1
230 VAC nominal
86 to 260 VAC
Up to 150 W
PMSM/BLDC
FOC/Six step
single/3-shunt
STEVAL-IHM035V2
120/230 VAC nominal
Up to 100 W
PMSM/BLDC
FOC/Six step
single-shunt
• 1x STGIPN3H60
• 1x VIPer16L
Power board: pumps,
compressors, fans, dish
washers and more
STEVAL-IHM045V1
30 – 270 VAC
40 – 400 VDC
Up to 100 W
PMSM
FOC
Single/3-shunt
• 1x STGIPN3H60A
• 1x VIPer06L
• 1x TSV994
Power board: pumps,
compressors, fans, dish
washers and more
•1x STGIPS20C60
• 1x VIPer26LD
• 1x STGW35NB60SD
• 2x L6392D
• 1x L6391D
• 1x Viper12
• 6 x STGD3HF60HD
Power board: pumps,
compressors, air conditioning
and more
Power board: pumps,
compressors, fans, dish
washers and more
15
NEW
Hardware key features 3/3
Reference /
Voltage
bundle
Power
Motor type /
control type *
ST Parts
Application focus
STEVAL-IPM05F(1)
Up to 500 W
PMSM/BLDC
FOC/Six step
3shunts
• 1 x STGIF5CH60TS-L
• 1x TSV994
Power board: water pumps,
fans, dish washers and more
• 1 x STGIF7CH60TS-L
• 1x TSV994
Power board: water pumps,
fans and more
125 – 450 VDC
STEVAL-IPM07F(1)
125 – 450 VDC
Up to 700 W
PMSM/BLDC
FOC/Six step
Single/3 shunts
STEVAL-IPM10F(1)
125 – 450 VDC
Up to 1 kW
PMSM/BLDC
FOC/Six step
• 1 x STGIF10CH60TS-L
• 1x TSV994
Power board: pumps,
compressors, washing
machines and more
STEVAL-IPM10B(1)
125 – 450 VDC
Up to 1.5 kW
PMSM/BLDC
FOC/Six step
single/3-shunt
• 1 x STGIB10CH60TS-L
• 1x TSV994
Power board: pumps,
compressors, air conditioning
and more
STEVAL-IPM15B(1)
125 – 450 VDC
Up to 2 W
PMSM/BLDC
FOC/Six step
single/3-shunt
• 1 x STGIB15CH60TS-L
• 1x TSV994
Power board: pumps,
compressors, fans, dish
washers and more
Note 1: Available Q4’15
16
SDK workflow
SDK workflow 1/5
ST MC Workbench
• Open the ST MC Workbench and create a new project (see Step #6).
18
SDK workflow 2/5
ST MC Workbench
SDK
.h
Parameter
files
User project
MC library
project
(Source code)
• Generate the configuration (.h) files for the firmware library (see Step #9).
19
SDK workflow 3/5
ST MC Workbench
SDK
IDE
1010010..
.h
Parameter
files
1110010..
.OBJ
User project
MC library
project
.OBJ
1000010..
.OBJ
Linker
110111010101
001011110001
101010101..
.EXE
1100100101010
0010100101001
0101001..
.LIB
(Source code)
• Compile the FW library using available IDE (IAR, Keil) (see step #10).
20
SDK workflow 4/5
ST MC Workbench
SDK
IDE
1010010..
.h
Parameter
files
1110010..
.OBJ
User project
MC library
project
.OBJ
1000010..
.OBJ
Linker
110111010101
001011110001
101010101..
ST-LINK
.EXE
1100100101010
0010100101001
0101001..
.LIB
(Source code)
• Flash the executable into the microcontroller using ST-LINK (see Step
#10).
21
SDK workflow 5/5
ST MC Workbench
Serial communication for "run-time" feedback
SDK
IDE
1010010..
.h
Parameter
files
1110010..
.OBJ
User project
MC library
project
.OBJ
1000010..
.OBJ
Linker
110111010101
001011110001
101010101..
ST-LINK
.EXE
1100100101010
0010100101001
0101001..
.LIB
(Source code)
• Establish a real-time communication with the firmware using the
monitor feature of ST MC Workbench to start the motor, set the speed
and get feedback (see Step #12).
22
Software setup
Step #2 – Software setup
• Download and install the STM32 PMSM FOC SDK
• You can find it at www.st.com and searching for part number STSW-STM32100
• It contains both the firmware package and the ST MC Workbench (PC GUI)
• After installation, you will have the following new folders:
ST MC Workbench
FW package
24
Step #3 – IDE setup
• An IDE (Integrated development environment) is required to compile,
flash and debug the application.
• Two IDEs are supported: IAR EWARM and KEIL µVision.
• They are available at the following addresses:
• IAR Embedded Workbench for ARM - IAR Systems (http://www.iar.com/)
• Keil Embedded Development Tools for ARM, Cortex-M ... (http://www.keil.com/)
25
Step #4 – ST-LINK installation
• If the control board or the complete system doesn’t embed the ST-LINK, a
stand-alone dongle is required.
• In any case, you must install the ST-LINK driver that can be found in the ST
website searching for part number ST-LINK/V2 or ST-LINK/V2-ISOL
• Click on Design Resources, download and install the STSW-LINK009
26
Step #4 – ST-LINK installation
• On the same page, download and install also the
STSW-LINK004 – STM32 ST-LINK utility
(This will be required to flash the LCD FW code into the MCU).
27
Step #5 – Connect ST-LINK
• Using the USB cable, connect the control board with ST-LINK embedded
(or the ST-LINK dongle) to the A male connector into your laptop.
• Wait for Windows to recognize
the ST-Link device and follow
any steps required to install the
driver.
• Upon successful driver
recognition, the ST-Link device
should be fully enumerated in
the Windows Device Manager
as shown:
28
Step #5 – Driver trouble-shooting
1. Open Device Manager.
2. Right-click on the
“STM32 STLink” Driver icon.
3. Select “Update Driver
Software”.
29
Step #5 – Driver trouble-shooting
4. Select “Browse my computer
for driver software”.
5. Select “Let me pick from a list of
device drivers of my computer”.
6. Click “Next”.
30
Step #5 – Driver trouble-shooting
• The “STMicroelectronics ST-Link dongle” should be listed.
7. Click “Next”.
31
Step #5 – Driver trouble-shooting
• A warning message may appear.
8. Select “Install this driver software anyway”.
32
Step #5 – Driver trouble-shooting
• You should receive a message:
“Windows has successfully
updated your driver software”.
• Re-check Device Manager to
ensure “STMicroelectronics
STLink dongle” is functioning
normally.
33
Set up workbench project
Step #6 – Create a new WB project based
on the ST evaluation board
Choose: New Project
35
Step #6 – Create a new WB project based
on the ST evaluation board
Choose:
1. Applications
1
36
Step #6 – Create a new WB project based
on the ST evaluation board
Choose:
2
2. Single or dual motor
37
Step #6 – Create a new WB project based
on the ST evaluation board
Choose:
3
3. Board approach:
• Choose if you are using Inverter,
MC Kit or Power plus Control
boards.
• Select the board used or create
your own custom board.
38
Step #6 – Create a new WB project based
on the ST evaluation board
39
Choose:
4
4. Motor:
Choose motor from a motor
database. (You can save your motor
parameters from your project.)
Step #6 – or Create a new WB project
based on an example project
• Choose the WB example project that best fits your needs.
• Choose the one with the same name of the ST evaluation board you are using, or
• choose the one with the same microcontroller you are using.
40
Step #6 – Create a new WB project
• Starting from the board selection or example project, the control stage
parameters will be populated with the correct values.
• For a custom project, the user can set all the parameters.
STM32303C-EVAL
41
Step #6 – Set up power stage
• Starting from the board selection or example project, the power stage
parameters will be populated with the correct values.
• For a custom project, the user can set all the parameters.
42
Step #6 – Set up drive parameters
• Starting from the board selection according to the chosen application,
drive parameters will be populated with the correct values.
• For a custom project, the user can set all the parameters.
Applications
43
Step #6 – Drive parameter tricks
• In Drive settings, decrease cut-off frequency of torque and flux regulator down to 2000 rad/s if power
stage → current reading topology is single shunt.
• In Sensing enabling and FW protections, uncheck the sensing options not supported by power stage
and check any “Set intervention threshold to power stage xxx” buttons.
• In Drive settings, initially set default target speed to at least 20% of maximum application speed.
• In additional features, start without any additional method (possible to add them later).
44
Step #6 – Drive parameter tricks
• In Drive settings, choose a correct PWM frequency and torque and flux execution
𝑃𝑊𝑀 𝑓𝑟𝑒𝑞
rate in such a way that the 𝐹𝑂𝐶 𝑟𝑎𝑡𝑒 =
is compatible with the
𝐸𝑥𝑒𝑐𝑢𝑡𝑖𝑜𝑛 𝑟𝑎𝑡𝑒
maximum FOC rate according to the microcontroller used.
STM32F4xx, STM32F3xx
STM32F103x HD/XL, STM32F2xx
STM32F103x LD/MD
Motor
Profiler
STM32F100x, STM32F0xx
Ne
1shunt
Flux
Weakening
IPMSM MTPA
3shunt
Dual FOC
HFI(1)w
Feed Forward
Sensor-less
(STO + PLL)
Sensor-less
(STO +
Cordic)
FreeRTOS
Max FOC(3)
Max FOC(3)
F103, F2xx
F103 ~23kHz
F2xx ~40kHz
F3xx ~ 30kHz
F4xx ~50kHz
Hall sensors
Startup
on-the-fly
ICS(2)
Encoder
ST MC
Workbench
support
USART based
Max FOC
com protocol F100 ~11kHz
add-on
F0xx ~12kHz
Max
FOC(3)
~23kHz
Max Dual
FOC(3)
Max Dual
FOC(3)
F103 ~20kHz
F2xx ~36kHz
F3xx~27kHz
F4xx~45kHz
(1) High Frequency Injection
(2) Supported only for STM32F103, STM32F2, STM32F4
(3) Max FOC estimated in sensorless mode
45
Step #6 – Drive parameter tricks
• If motor profiler is not used, in start-up parameters, select the basic profile.
• Set current ramp initial and final values equal to motor nominal current value / 2 (if load is low at low
speed, otherwise it can be set up to 0.8-1.0 times nominal current value).
• Set speed ramp final value to around 30% of maximum application speed.
• According to motor inertia it may be required to increase the speed ramp duration.
• Set minimum start-up output speed to 15% of maximum application speed (if required, decreased it
later).
• Set estimated speed band tolerance lower limit to 93.75%
• Enable the alignment at the beginning of your development (duration 2000 ms, final current ramp
value from 0.5 to 1 times motor nominal current according to load)
Basic
46
Step #7 – Set up motor parameters
• ST MC Workbench – Motor section contains:
• Electrical motor parameters
• Motor sensor parameters
• In this hands-on session, we will configure the system for sensor-less
control using a motor with a surface-mounted magnet.
• For a custom project, the user can set all the parameters.
47
Step #7 – Set up motor parameters
48
• If motor parameters are unknown (or instrumentation to measure
them are missing), and if supported by the hardware, it is possible to
use the new Motor Profiler feature.
Example
Hardware supporting
the Motor Profiler
(M.P.)
Step #7 – Setup Motor Profiler
These parameters must be set by the user
• Motor pole pairs
• Maximum application speed
• Nominal speed of the motor will be computed and used to validate the maximum application
speed selected by the user.
• Nominal current
49
Step #7 – Setup Motor Profiler
• Verify that the Motor Profiler check box is selected.
50
Step #7 – Setup Motor Profiler
• Choose the kind of load.
51
Step #7 – Generate and compile the FW
• Before running the Motor Profiler, execute Steps #9, #10 and #11 (#11
only if LCD is present in the board) to generate and compile the
firmware.
ST MC Workbench
SDK
IDE
1010010..
.h
Parameter
files
1110010..
.OBJ
User project
MC library
project
(Source code)
.OBJ
1000010..
.OBJ
1100100101010
0010100101001
0101001..
.LIB
Linker
110111010101
001011110001
101010101..
.EXE
52
Step #7 – Run Motor Profiler
• Using the ST MC Workbench, run the Motor Profiler procedure.
53
Step #7 – Run Motor Profiler
• To execute the Motor Profiler procedure, connect the PC to the
microcontroller board via the USART connection.
• Connect the PC to the control board with the USB to RS-232 dongle (and a
null modem cable).
• Select COM port and communication speed (as set in the Control Stage ->
Digital I/O).
54
Step #7 – Run Motor Profiler
• Press Connect.
• Press Start.
55
Step #7 – Run Motor Profiler
• Procedure will end in about 60 seconds.
Motor stopped
•
•
•
Rs measurement
Ls measurement
Current regulators set-up
10 sec
Open loop
•
•
•
Ke measurement
Sensorless state observer set-up
Switch over
5 sec
Closed loop
•
•
•
Friction coefficient measurement
Moment of inertia measurement
Speed regulator set-up
45 sec
56
Step #7 – Motor Profiler complete
• At the end of the procedure, the measured parameters will be shown
on a dedicated window.
• It is possible to import them on the workbench project and save them
for later use.
57
Step #8 – Set up motor parameters
manually
• Select Surface Mounted PMSM in Motor → Electrical parameters →
Magnetic structure.
58
Step #8 – Set up motor parameters manually
• Set Max Rated Speed with the maximum motor speed according the application
specs.
• Set Nominal Current with maximum peak current provided to each of the motor
phases according the motor specs.
• Set Nominal DC Voltage with value of DC bus provided to the inverter or the rectified
value of AC input.
• Keep checked the “Auto” button near “Demagnetizing Current”.
59
Step #8 – Set up motor parameters manually
Pole pair number
• The number of pole pairs is usually provided by the motor supplier,
but in case it’s not or if you’d like to double check it:
• Connect a DC power supply between two (of the three) motor phases and provide
up to 5% of the expected nominal DC bus voltage. (You may also set current
protection to nominal motor current.)
• Rotate the motor with your hands, you should notice a little resistance, otherwise:
• If you are not able to rotate the motor, decrease the applied voltage.
• If the motor does not generate any resistance, gradually increase the applied voltage.
• The number of rotor stable positions in one mechanical turn represents the number
of pole pairs.
+
DC voltage source
60
Step #8 – Set up motor parameters manually
Stator resistance and inductance
• Using the multimeter, measure the DC stator resistance phase-tophase (Rs) and divide it by two.
• Connect the DC voltage between two motor phases.
• Connect the oscilloscope voltage and current probes as shown in the
figure.
• Increase the voltage up to the value where the current equals the
nominal value, rotor with align.
• Don’t move the rotor anymore.
I
+
V
DC voltage source
61
Step #8 – Set up motor parameters manually
Stator resistance and inductance
• Disable the current protection of DC voltage source.
• Unplug one terminal of the voltage source cable without switching it off.
• Plug the voltage source rapidly and monitor on the scope the voltage and
current waveform until you get something like the one shown in the figure.
• The measurement is good if the voltage can be assimilated to a step and the
current increase such as I∞ * (1-e- t *L/R).
• Measure the time required to current waveform to rise up to 63%.
• This time is Ld/Rs constant. Multiply it by Rs and you’ll get Ld value.
V
0.63*I∞
τ = L/R
I∞
62
Step #8 – Set up motor parameters manually
Back EMF constant Ke
• The Back-EMF constant represents the proportionality constant
between the mechanical motor speed and the amplitude of the BEMF induced into the motor phases:
VBemf = Ke · ωmec
• To measure Ke, it usually suffices to turn the motor with your hands
(or using a drill or another motor mechanically coupled) and use an
oscilloscope to look for the phase-to-phase induced voltage (VBemf )
+
-
63
Step #8 – Set up motor parameters manually
Back EMF constant Ke
• Measure the VBemf frequency (fBemf) and the peak-to-peak amplitude
(VBemf –A)
• Compute Ke in VRMS / KRPM:
Ke 
VBemf  A [V peak  to  peak ]  pole pairs number 1000
2  2  f Bemf [ Hz ]  60
64
Generate, compile, debug and run
Step #10 – Parameter generation
• Once all the parameters have been entered in the ST MC Workbench, select
the output path in the option form and choose ‘SystemDriveParams’ present
in the FW working folder.
• Click on the ‘Generation’ button to configure the project.
66
Step #11 – Compile and program the MCU
• Run the IAR Embedded Workbench.
• Open the IAR workspace (located in Project\EWARM) folder according to the
microcontroller family (e.g. STM32F10x_Workspace.eww for STM32F1).
• Select the correct user project from the drop-down menu according to the control stage
used (e.g. STM32F10x_UserProject - STM3210B-EVAL).
• Compile and download.
Select
project
Compile
& program
67
Step #11 – Compile and program the MCU
• Optionally, run Keil uVision.
• Open the Keil workspace (located in Project\MDK-ARM) folder according to the
microcontroller family (e.g. STM32F10x_Workspace.uvmpw for STM32F1).
• Select the proper user project from the drop-down menu according to the control stage
used (e.g. STM3210B-EVAL).
• Compile and download.
Compile
Select
project
Program
68
Step #12 – Program LCD firmware
• Run the ST-LINK Utility.
• File → Open file… and select the .hex file (located in LCDProject\hex) according to the
control stage used (e.g. STM3210B-EVAL.hex).
• Target → Program…
69
Step #13 – Run the motor
• Arrange the system for running the motor:
• Connect the control board with the power board using the MC cable.
• Connect the motor to the power board.
• Connect the power supply to the power board and turn on the bus.
• If the board is equipped with the LCD:
• Press joystick center on Fault Ack button to reset the faults.
• Press joystick right until the Speed controller page is reached.
• The press joystick down to reach the Start/Stop button.
• Press the center of the joystick to run the motor.
70
Step #13 – Run the motor
• Optionally you can start the motor using the ST MC Workbench.
• Connect the PC to the control board with the USB to RS-232 dongle (and a null modem
cable).
• Open the Workbench project used to configure the firmware and click on Monitor
button.
• Select the COM port and click Connect button. This establish the communication with
the firmware.
• To clear the fault, click Fault Ack and then Start Motor button to run the motor.
Monitor
Connect
Select COM
port
Start
Fault ACK
71
Releasing your creativity
with the STM32
/STM32
@ST_World
www.st.com/stm32
st.com/e2e
72