STM32 motor-control pack using the FOC algorithm
User manual
UM2538
Introduction
The P-NUCLEO-IHM03 pack is a motor-control kit based on the X-NUCLEO-IHM16M1 and NUCLEO-G431RB boards. Used with the STM32 Nucleo board through the ST morpho connector, the power board (based on the STSPIN830 driver of the STPIN family) provides a motor-control solution for three-phase, low-voltage, PMSM motors. This is shown in Figure 1 with the power supply that is also provided.
The STSPIN830 device on the power board is a compact and versatile FOC-ready driver for a three-phase motor. It supports both single-shunt and three-shunt architectures, and embeds a PWM current controller with user-settable values of reference voltage and off time. With a dedicated mode input pin, the device offers the freedom to decide whether to drive it through six inputs (one for each power switch), or the more common three PWM directly driven inputs. In addition, it integrates both the control logic and a fully protected low-RDS(on), triple-half-bridge power stage. The NUCLEO-G431RB control board provides an affordable and flexible way for users to try out new concepts and build prototypes with the STM32G4 microcontroller. It does not require any separate probe, as it integrates the STLINK-V3E debugger and programmer.
This motor-control evaluation kit is fully configurable to support closed-loop control (FOC only). It can be used in either a speed-sensor mode (Hall or encoder), or in a speed-sensorless mode. It is compatible with both single-shunt and three-shunt current-sense topologies.
Figure 1. P-NUCLEO-IHM03 pack
Picture is not contractual.
Features
X-NUCLEO-IHM16M1
- Three-phase driver board for BLDC/PMSM motors based on STSPIN830
- Nominal operating voltage range from 7 V dc to 45 V dc
- Output current up to 1.5 A rms
- Overcurrent, short-circuit, and interlocking protections
- Thermal shutdown and under-voltage lockout
- BEMF sensing circuitry
- Support of 3-shunt or 1-shunt motor current sensing
- Hall-effect-based sensors or encoder input connector
- Potentiometer available for speed regulation
- Equipped with ST morpho connectors
NUCLEO-G431RB
- STM32G431RB 32-bit microcontroller based on the Arm® Cortex®-M4 core at 170 MHz in an LQFP64 package with 128 Kbytes of flash memory and 32 Kbytes of SRAM
- Two types of extension resources:
- ARDUINO® Uno V3 expansion connector
- ST morpho extension pin headers for full access to all STM32 I/Os
- On-board STLINK-V3E debugger/programmer with USB re-enumeration capability: mass storage, Virtual COM port, and debug port
- 1 user and 1 reset push-buttons
Three-phase motor:
- Gimbal motor: GBM2804H-100T
- Maximum DC voltage: 14.8 V
- Maximum rotational speed: 2180 rpm
- Maximum torque: 0.981 N-m
- Maximum DC current: 5 A
- Number of pole pairs: 7
DC power supply:
- Nominal output voltage: 12 V dc
- Maximum output current: 2 A
- Input voltage range: from 100 V ac to 240 V ac
- Frequency range: from 50 Hz to 60 Hz
STM32 32-bit microcontrollers are based on the Arm® Cortex®-M processor. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
Ordering Information
To order the P-NUCLEO-IHM03 Nucleo pack, refer to Table 1. Additional information is available from the datasheet and reference manual of the target STM32.
Table 1. List of available products
Order code | Board | Board reference | Target STM32 |
---|---|---|---|
P-NUCLEO-IHM03 | X-NUCLEO-IHM16M1 | No board reference(1) | STM32G431RBT6 |
NUCLEO-G431RB | MB1367(2) | ||
1. Power board | |||
2. Control board |
Codification
The meaning of the codification of the Nucleo board is explained in Table 4.
Table 2. Nucleo pack codification explanation
P-NUCLEO-XXXYY | Description | Example: P-NUCLEO-IHM03 |
---|---|---|
P-NUCLEO | Product type: P: Pack composed of one Nucleo board and one expansion board (called a power board in this pack), maintained and supported by STMicroelectronics | P-NUCLEO |
XXX | Application: code defining the application type of specialized components | IHM for industrial, home appliance, motor control |
YY | Index: sequential number | 03 |
Table 3. Power board codification explanation
X-NUCLEO-XXXYYTZ | Description | Example: X-NUCLEO-IHM16M1 |
---|---|---|
X-NUCLEO | Product type: X: expansion board, distributed on ST website, maintained and supported by STMicroelectronics | X-NUCLEO |
XXX | Application: code defining the application type of specialized components | IHM for industrial, home appliance, motor control |
YY | Index: sequential number | 16 |
T | Type of connector: A for ARDUINO® M for ST morpho Z for ST Zio | M for ST morpho |
Z | Index: sequential number | IHM16M1 |
Table 4. Nucleo board codification explanation
NUCLEO-XXYYZT | Description | Example: NUCLEO-G431RB |
---|---|---|
XX | MCU series in STM32 32-bit Arm Cortex MCUs | STM32G4 series |
YY | MCU product line in the series | STM32G431xx MCUs belong to the STM32G4x1 product line |
Z | STM32 package pin count: R for 64 pins | 64 pins |
T | STM32 flash memory size: B for 128 Kbytes | 128 Kbytes |
Development Environment
System Requirements
- Multi-OS support: Windows® 10, Linux® 64-bit, or macOS®
- USB Type-A or USB Type-C® to Micro-B cable
Note: macOS® is a trademark of Apple Inc., registered in the U.S. and other countries and regions. Linux® is a registered trademark of Linus Torvalds. Windows is a trademark of the Microsoft group of companies.
Development Toolchains
- IAR Systems® - IAR Embedded Workbench®(1)
- Keil® - MDK-ARM(1)
- STMicroelectronics - STM32CubeIDE
(1) On Windows® only.
Demonstration Software
The demonstration software, included in the X-CUBE-MCSDK STM32Cube Expansion Package, is preloaded in the STM32 flash memory for easy demonstration of the device peripherals in standalone mode. The latest versions of the demonstration source code and associated documentation can be downloaded from www.st.com.
Conventions
Table 5 provides the conventions used for the ON and OFF settings in the present document.
Table 5. ON/OFF conventions
Convention | Definition |
---|---|
Jumper ON | Jumper fitted |
Jumper OFF | Jumper not fitted |
Jumper [1-2] | Jumper fitted between pin 1 and pin 2 |
Solder bridge ON | Connections closed by 0 Ω resistor |
Solder bridge OFF | Connections left open |
Getting Started (Basic User)
System Architecture
The P-NUCLEO-IHM03 kit is based on the usual four-block architecture for a motor-control system:
- Control block: it interfaces the user commands and configuration parameters to drive a motor. The P-NUCLEO-IHM03 kit is based on the NUCLEO-G431RB control board that provides all the needed signals to perform the proper motor-driving control algorithm (for instance FOC).
- Power block: the P-NUCLEO-IHM03 power board is based on a three-phase inverter topology. Its core on board is the STSPIN830 driver that embeds all the necessary active power and analog components to perform a low-voltage PMSM motor control.
- PMSM motor: low-voltage, three-phase, brushless DC motor.
- DC power supply unit: it provides the power for the other blocks (12 V, 2 A).
Figure 2. Four-block architecture of the P-NUCLEO-IHM03 pack
Description: The system comprises a Power supply unit, a Control board, a Power board, and a PMSM motor.
Configure and run the motor control from the STM32 Nucleo motor-control pack
The P-NUCLEO-IHM03 Nucleo pack is a complete hardware development platform for the STM32 Nucleo ecosystem to evaluate a motor-control solution with a single motor.
Hardware Configuration Steps:
- The X-NUCLEO-IHM16M1 must be stacked on the NUCLEO-G431RB board through the CN7 and CN10 ST morpho connectors. There is only one position allowed for this connection. In particular, the two buttons on the NUCLEO-G431RB board (blue user button B1 and black reset button B2) must be kept uncovered, as shown in Figure 3.
Figure 3. X-NUCLEO-IHM16M1 and NUCLEO-G431RB assembled
Description: Image shows the X-NUCLEO-IHM16M1 board stacked on the NUCLEO-G431RB board, highlighting key connectors and buttons.
The interconnection between the X-NUCLEO-IHM16M1 and the NUCLEO-G431RB board is designed for full compatibility with many control boards. No modification of solder bridges is required for the use of the FOC algorithm.
- Connect the three motor wires U,V,W to the CN1 connector as shown in Figure 4.
Figure 4. Motor connection with X-NUCLEO-IHM16M1
Description: Image shows the three-phase motor wires (U, V, W) connected to the CN1 terminal block on the X-NUCLEO-IHM16M1 board.
- Select the jumper configuration on the power board to choose the desired control algorithm (FOC) as described below:
- On the NUCLEO-G431RB board, check the jumper settings: JP5 on position [1-2] for 5V_STLK source, JP8 (VREF) on position [1-2], JP6 (IDD) ON.(1)
- On the X-NUCLEO-IHM16M1 board(2): Check the jumper settings: J5 ON, J6 ON. For FOC control, set the jumper settings as: JP4 and JP7 solder bridges OFF, J2 ON on position [2-3], J3 ON on position [1-2].
- Connect the DC power supply (use the power supply provided with the pack or an equivalent one) to the CN1 or J4 connector and power on (up to 12 V dc for the gimbal motor included in the P-NUCLEO-IHM03 pack), as shown in Figure 5.
Figure 5. Power-supply connection for X-NUCLEO-IHM16M1
Description: Image shows the DC power supply connected to the CN1 or J4 connector of the P-NUCLEO-IHM03 pack.
- Press the blue user button on NUCLEO-G431RB (B1) to start spinning the motor.
Hardware Settings
Rotate the potentiometer on X-NUCLEO-IHM16M1 to regulate the motor speed.
1. To supply the NUCLEO-G431RB from the USB, the jumper JP5 must be connected between pin 1 and pin 2. For further details on the Nucleo settings, refer to [3].
2. The supply voltage must be off before changing the control mode.
Table 6 shows the jumper configuration on the X-NUCLEO-IHM16M1 board as shown in Figure 6. According to the jumper selection, it is possible to choose the single-shunt or three-shunt current-sensing mode, the Hall sensors or encoder with pull-up, or the external supply for the NUCLEO-G431RB board.
Table 6. Jumper settings
Jumper | Permitted configuration | Default condition |
---|---|---|
J5 | Selection of the FOC control algorithm. | ON |
J6 | Selection of the FOC control algorithm. | ON |
J2 | Selection of the hardware current limiter threshold (disabled in the three-shunt configuration by default). | [2-3] ON |
J3 | Selection of fixed or adjustable current limiter threshold (fixed by default). | [1-2] ON |
JP4 and JP7(1) | Selection of single-shunt or three-shunt configuration (three-shunt by default). | OFF |
(1) JP4 and JP7 must have both the same configuration: both left open for the three-shunt configuration, both closed for the single-shunt configuration. On the silkscreen, the correct position for three shunts or single shunt is indicated together with the default position.
Table 7 shows the main connectors on the P-NUCLEO-IHM03 board.
Table 7. Screw terminal table
Screw terminal | Function |
---|---|
J4 | Motor power supply input (7 V dc to 45 V dc) |
CN1 | Three-phase motor connector (U,V,W) and motor power supply input (when J4 is not used) |
The P-NUCLEO-IHM03 is stacked on ST morpho connectors, with male pin headers (CN7 and CN10) accessible from both sides of the board. They can be used to connect the X-NUCLEO-IHM16M1 power board to the NUCLEO-G431RB control board. All signals and power pins for the MCU are available on the ST morpho connectors. For further details, refer to the "ST morpho connectors" section in [3].
Table 8. Connector description
Part reference | Description |
---|---|
CN7, CN10 | ST morpho connectors |
CN5, CN6, CN9, CN8 | ARDUINO® Uno connectors |
U1 | STSPIN830 driver |
U2 | TSV994IPT operational amplifier |
J4 | Power supply jack connector |
J5, J6 | Jumpers for FOC use |
SPEED | Potentiometer |
CN1 | Motor and power supply connector |
J1 | Hall sensor or encoder connector |
J2, J3 | Current limiter use and configuration |
Table 9. Connector description (continued)
Part reference | Description |
---|---|
JP3 | External pull-up for sensors |
JP4, JP7 | Current measurement mode (single shunt or three shunts) |
D1 | LED status indicator |
Figure 6. X-NUCLEO-IHM16M1 connectors
Description: Diagram showing the location of various connectors and jumpers on the X-NUCLEO-IHM16M1 board.
Upload the firmware example
The example for the motor-control application example is preloaded in the NUCLEO-G431RB control board. This example is using the FOC (field-oriented control) algorithm. This section describes the procedure to reload the firmware demonstration inside the NUCLEO-G431RB and restart by the default condition. There are two ways to do it:
- Drag-and-drop procedure (suggested), as detailed in Section 5.4.1
- Through the STM32CubeProgrammer (STM32CubeProg) tool (free download available from the STMicroelectronics website at www.st.com), as shown in Section 5.4.2
Drag-and-drop procedure
- Install the ST-LINK drivers from the www.st.com website.
- On the NUCLEO-G431RB board, set the JP5 jumper in position U5V.
- Plug the NUCLEO-G431RB board to the host PC using a USB Type-C® or Type-A to Micro-B cable. If the ST-LINK driver is correctly installed, the board is recognized as an external memory device called "Nucleo" or any similar name.
- Drag and drop the binary file of the firmware demonstration (P-NUCLEO-IHM003.out contained in the X-CUBE-SPN7 Expansion Package) into the "Nucleo" device listed among the disk drives (click on the Start button of Windows®).
- Wait until the programming is complete.
STM32CubeProgrammer tool
- Open the STM32CubeProgrammer tool (STM32CubeProg).
- Connect the NUCLEO-G431RB board to the PC with a USB Type-C® or Type-A to Micro-B cable through the USB connector (CN1) on the NUCLEO-G431RB board.
- Open either the Potentiometer.out or Potentiometer.hex file as the code to be downloaded. The corresponding window appears as shown in Figure 7.
Figure 7. STM32CubeProgrammer tool
Description: Screenshot of the STM32CubeProgrammer software interface showing memory and file editing options.
Figure 8. STM32CubeProgrammer download
Description: Screenshot of the STM32CubeProgrammer software showing the download process and device information.
- Press the reset button (B2) on the NUCLEO-G431RB board to start using the motor.
Demonstration Usage
This section describes how to use the setup to spin the motor:
- Press the reset button (black) (NUCLEO-G431RB board).
- Press the user button (blue) to start the motor (NUCLEO-G431RB board).
- Check that the motor starts spinning and that LEDs D8, D9, and D10 are turned on (X-NUCLEO-IHM16M1 board).
- Rotate the user rotary knob (blue) clockwise to the maximum (X-NUCLEO-IHM16M1 board).
- Check that the motor is stopped and that LEDs D8, D9, and D10 are turned off (X-NUCLEO-IHM16M1 board).
- Rotate the user rotary knob (blue) counterclockwise to the maximum (X-NUCLEO-IHM16M1 board).
- Check that the motor is spinning at a higher speed compared to step 3 and that LEDs D8, D9, and D10 are turned on (X-NUCLEO-IHM16M1 board).
- Rotate the user rotary knob (blue) to one third of its maximum (X-NUCLEO-IHM16M1 board).
- Check that the motor is spinning at a lower speed compared to step 7 and that LEDs D8, D9, and D10 are turning on (X-NUCLEO-IHM16M1 board).
- Press the user button (blue) to stop the motor (NUCLEO-G431RB board).
- Check that the motor is stopped and that LEDs D8, D9, and D10 are turning off (X-NUCLEO-IHM16M1 board).
FOC Control Algorithm Settings (Advanced User)
The P-NUCLEO-IHM03 pack supports the ST FOC library. No hardware modification is needed to run the motor provided in a three-shunt current-sensing mode. To use the FOC in a single-shunt configuration, the user must reconfigure the X-NUCLEO-IHM16M1 board to select the single-shunt current sensing and the current-limiter features according to the jumper settings as given in Table 6. Jumper settings. The MC SDK installation is required to reconfigure the P-NUCLEO-IHM03 project for single-shunt current sensing, generation, and use.
For further information about the MC SDK, refer to [5].
References
Table 9 lists STMicroelectronics related documents available at www.st.com for supplementary information.
Table 9. STMicroelectronics reference documents
ID | Reference document |
---|---|
[1] | Getting started with the X-NUCLEO-IHM16M1 three-phase brushless motor driver board based on STSPIN830 for STM32 Nucleo user manual (UM2415). |
[2] | Getting started with the X-CUBE-SPN16 three-phase brushless DC motor driver software expansion for STM32Cube user manual (UM2419). |
[3] | STM32G4 Nucleo-64 boards (MB1367) user manual (UM2505). |
[4] | Compact and versatile three-phase and three-sense motor driver datasheet (DS12584). |
[5] | STM32 MC SDK software expansion for STM32Cube data brief (DB3548). |
[6] | Getting started with STM32 motor control SDK v5.x user manual (UM2374). |
[7] | How to use STM32 motor control SDSK v6.0 profiler user manual (UM3016) |
P-NUCLEO-IHM03 Nucleo Pack Product Information
Product Marking
The stickers located on the top or bottom side of all PCBs provide product information:
- First sticker: product order code and product identification, generally placed on the main board featuring the target device. Example: Product order code, Product identification
- Second sticker: board reference with revision and serial number, available on each PCB. Example: MBxxxx-Variant-yzz syywwxxxxx
On the first sticker, the first line provides the product order code, and the second line the product identification. On the second sticker, the first line has the following format: "MBxxxx-Variant-yzz", where "MBxxxx" is the board reference, "Variant" (optional) identifies the mounting variant when several exist, "y" is the PCB revision, and "zz" is the assembly revision, for example B01. The second line shows the board serial number used for traceability.
Parts marked as "ES” or “E” are not yet qualified and therefore not approved for use in production. ST is not responsible for any consequences resulting from such use. In no event will ST be liable for the customer using any of these engineering samples in production. ST's Quality department must be contacted prior to any decision to use these engineering samples to run a qualification activity.
"ES" or "E" marking examples of location:
- On the targeted STM32 that is soldered on the board (for an illustration of STM32 marking, refer to the STM32 datasheet Package information paragraph at the www.st.com website).
- Next to the evaluation tool ordering part number that is stuck, or silk-screen printed on the board.
Some boards feature a specific STM32 device version, which allows the operation of any bundled commercial stack/library available. This STM32 device shows a "U" marking option at the end of the standard part number and is not available for sales.
To use the same commercial stack in their applications, the developers might need to purchase a part number specific to this stack/library. The price of those part numbers includes the stack/library royalties.
P-NUCLEO-IHM03 Product History
Table 10. Product history
Order code | Product identification | Product details | Product change description | Product limitations |
---|---|---|---|---|
PNIHM03$AT1 | P-NUCLEO-IHM03 | MCU: STM32G431RBT6 silicon revision "Z" MCU errata sheet: STM32G431xx/441xx device errata (ES0431) Board: MB1367-G431RB-C04 (control board) X-NUCLEO-IHM16M1 1.0 (power board) | Initial revision | No limitation |
PNIHM03$AT2 | P-NUCLEO-IHM03 | MCU: STM32G431RBT6 silicon revision "Y" MCU errata sheet: STM32G431xx/441xx device errata (ES0431) Board: MB1367-G431RB-C04 (control board) X-NUCLEO-IHM16M1 1.0 (power board) | MCU silicon revision changed | No limitation |
PNIHM03$AT3 | P-NUCLEO-IHM03 | MCU: STM32G431RBT6 silicon revision "X" MCU errata sheet: STM32G431xx/441xx device errata (ES0431) Board: MB1367-G431RB-C04 (control board) X-NUCLEO-IHM16M1 1.0 (power board) | MCU silicon revision changed | No limitation |
PNIHM03$AT4 | P-NUCLEO-IHM03 | MCU: STM32G431RBT6 silicon revision "X" MCU errata sheet: STM32G431xx/441xx device errata (ES0431) Board: MB1367-G431RB-C05 (control board) X-NUCLEO-IHM16M1 1.0 (power board) | Packaging: carton box format changed Control board revision changed | No limitation |
Board Revision History
Table 11. Board revision history
Board reference | Board variant and revision | Board change description | Board limitations |
---|---|---|---|
MB1367 (control board) | G431RB-C04 | Initial revision | No limitation |
G431RB-C05 | LEDs references updated due to obsolescence. Refer to the bill of materials for further details | No limitation | |
X-NUCLEO-IHM16M1 (power board) | 1.0 | Initial revision | No limitation |
Federal Communications Commission (FCC) and ISED Canada Compliance Statements
FCC Compliance Statement
Part 15.19
This device complies with Part 15 of the FCC Rules. Operation is subject to the following two conditions: (1) this device may not cause harmful interference, and (2) this device must accept any interference received, including interference that may cause undesired operation.
Part 15.21
Any changes or modifications to this equipment not expressly approved by STMicroelectronics may cause harmful interference and void the user's authority to operate this equipment.
Part 15.105
This equipment has been tested and found to comply with the limits for a Class B digital device, pursuant to part 15 of the FCC Rules. These limits are designed to provide reasonable protection against harmful interference in a residential installation. This equipment generates uses and can radiate radio frequency energy and, if not installed and used in accordance with the instruction, may cause harmful interference to radio communications. However, there is no guarantee that interference will not occur in a particular installation. If this equipment does cause harmful interference to radio or television reception which can be determined by turning the equipment off and on, the user is encouraged to try to correct interference by one or more of the following measures:
- Reorient or relocate the receiving antenna.
- Increase the separation between the equipment and receiver.
- Connect the equipment into an outlet on circuit different from that to which the receiver is connected.
- Consult the dealer or an experienced radio/TV technician for help.
- Use only shielded cables.
Responsible party (in the USA)
Terry Blanchard
Americas Region Legal | Group Vice President and Regional Legal Counsel, The Americas
STMicroelectronics, Inc.
750 Canyon Drive | Suite 300 | Coppell, Texas 75019
USA
Telephone: +1 972-466-7845
ISED Compliance Statement
This device complies with FCC and ISED Canada RF radiation exposure limits set forth for general population for mobile application (uncontrolled exposure). This device must not be collocated or operating in conjunction with any other antenna or transmitter.
Compliance Statement
Notice: This device complies with ISED Canada licence-exempt RSS standard(s). Operation is subject to the following two conditions: (1) this device may not cause interference, and (2) this device must accept any interference, including interference that may cause undesired operation of the device.
ISED Canada ICES-003 Compliance Label: CAN ICES-3 (B) / NMB-3 (B).
Déclaration de conformité
Avis: Le présent appareil est conforme aux CNR d'ISDE Canada applicables aux appareils radio exempts de licence. L'exploitation est autorisée aux deux conditions suivantes: (1) l'appareil ne doit pas produire de brouillage, et (2) l'utilisateur de l'appareil doit accepter tout brouillage radioélectrique subi, même si le brouillage est susceptible d'en compromettre le fonctionnement.
Étiquette de conformité à la NMB-003 d'ISDE Canada : CAN ICES-3 (B) / NMB-3 (B).
Revision History
Table 12. Document revision history
Date | Revision | Changes |
---|---|---|
19-Apr-2019 | 1 | Initial release. |
20-Jun-2023 | 2 | Added P-NUCLEO-IHM03 Nucleo pack product information, including: Product marking P-NUCLEO-IHM03 product history Board revision history Updated System requirements and Development toolchains. Updated Ordering information and Codification. Removed Schematics. |