0% found this document useful (0 votes)
48 views

GPM32F011XBV10 Sensorless SMO Control of PMSM Using GPM32F011xB User (English Version)

This document provides a user's manual for sensorless SMO control of a PMSM motor using the GPM32F011xB microcontroller. It begins with introductions to the PMSM motor math model and sliding mode observer technique. It then describes the GPM32F011xB hardware features for motor control. The document concludes with explanations of the sample code, including overall structure, main flow, interrupt handling, and use of the SMO library.

Uploaded by

ISHAK CHERGUI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

GPM32F011XBV10 Sensorless SMO Control of PMSM Using GPM32F011xB User (English Version)

This document provides a user's manual for sensorless SMO control of a PMSM motor using the GPM32F011xB microcontroller. It begins with introductions to the PMSM motor math model and sliding mode observer technique. It then describes the GPM32F011xB hardware features for motor control. The document concludes with explanations of the sample code, including overall structure, main flow, interrupt handling, and use of the SMO library.

Uploaded by

ISHAK CHERGUI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Sensorless SMO Control of PMSM

Using GPM32F011xB USER’S MANUAL


V1.0 –Jun. 05, 2023
Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

Generalplus Technology Inc. reserves the right to change this documentation without prior notice.
Information provided by Generalplus Technology Inc. is believed to be accurate and reliable.
However, no responsibility is assumed by Generalplus Technology Inc. for errors, omissions or any
loss of profit resulting from the use of information contained in this documentation. In addition,
Generalplus products are not authorized for use as critical components in life support
devices/systems or aviation devices/systems, where a malfunction or failure of the product may
reasonably be expected to result in significant injury to the user, without the express written
approval of Generalplus.

Generalplus Technology
No.19, Industry E. Rd. IV, Hsinchu Science Park, Hsinchu City, 30077, Taiwan, R.O.C.
Tel: 886-3-666-2118
Fax: 886-3-666-2117
www.generalplus.com

 Generalplus Technology Inc. 2 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

REVISION HISTORY

Revision Date By Remark


st
V1.0 2023.06.05 Jim 1 Edition

 Generalplus Technology Inc. 3 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

TABLE OF CONTENT

1. Introduction ........................................................................................................................................... 5
1.1. General Description.................................................................................................................................... 5
2. PMSM Math Model ................................................................................................................................ 6
2.1. General Description.................................................................................................................................... 6
3. Sliding Mode Observer (SMO) ................................................................................................................. 7
3.1. General Description.................................................................................................................................... 7
3.2. Current Observer ........................................................................................................................................ 8
3.3. Counter EMF Estimation and Calculation ................................................................................................... 8
3.4. Motor Position Estimation and Calculation ................................................................................................ 9
4. GPM32F011xB Introduction .................................................................................................................. 10
4.1. GPM32F011xB Motor Control Module Introduction................................................................................ 10
4.2. Hardware MATH Cordic Module............................................................................................................... 10
5. Sample Code Description ...................................................................................................................... 12
5.1. Hardware General Description ................................................................................................................. 12
5.2. Sample Code File Description ................................................................................................................... 13
5.3. Overall Program Structure ........................................................................................................................ 13
5.4. Main Program Flow Description ............................................................................................................... 14
5.5. PWM Interrupt Program Flow .................................................................................................................. 14
5.6. SMO Library Usage Description ................................................................................................................ 15
6. Appendix: Related Documents .............................................................................................................. 19

 Generalplus Technology Inc. 4 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

1. Introduction

1.1. General Description


As an extension of Sensored FOC Control of PMSM Using GPM32F011xB_V1.0.pdf, this user’s manual
illustrates the sensorless SMO angle estimation. Please refer to “Sensored FOC Control of PMSM
Using GPM32F011xB_V1.0.pdf” first.

 Generalplus Technology Inc. 5 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

2. PMSM Math Model

2.1. General Description


PMSM consists of coil winding, silicon lamination, permanent magnet and so on. The electrical
structure of permanent magnet motor is composed of input power supply, winding resistance,
winding inductance and counter EMF, as shown in Figure 2.1.

is R L es

N S
vs
m

Figure 2.1 PMSM Model

User is able to derive the motor math model from the motor electrical model, and it’s shown as the
following formula: is is the motor current vector; vs is the input voltage vector; es is the
counter EMF vector; R is the winding resistance and L is the winding inductance.

d
vs  Ris  L is  es … (Formula 2.1)
dt
or

is   is  vs  es  … (Formula 2.2)


d R 1
dt L L

 Generalplus Technology Inc. 6 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

3. Sliding Mode Observer (SMO)

3.1. General Description


Sliding Mode Observer (SMO) uses sliding control to make the state of motor math formula as close
to the real motor as possible. User can also obtain counter EMF messages from the motor math
formula, as shown in Figure 3.1.

Sliding mode
controller
vs PMSM is
+K
ERROR

d  R 1
is   is  (vs  es  z )
-K
dt L L i s

Figure 3.1 SMO Diagram

In Figure 3.2, SMO consists of current observer and sliding control. With sliding control, the observer
current will be seen as the actual current, and this makes the motor math model approximate to the
actual motor state. User can thus obtain the counter EMF messages in the motor math model, and
can also calculate and estimate the motor angle.

Figure 3.2 SMO Diagram

 Generalplus Technology Inc. 7 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

3.2. Current Observer


Add sliding control factor z in motor math formula, as shown in Formula 3.1. Use sliding control
(Formula 3.2) to make the error between observer current and real current 0.

d *
dt
R
L
1

is   is*  vs  es*  z … (Formula 3.1)
L

 
z  k  sign is*  is … (Formula 3.2)

Rewrite Formula 3.1 and 3.2 as discrete function Formula 3.3 and 3.4.

 
is* n  1  F  is* n  G  vs n  es* n  zn … (Formula 3.3)

 
zn  k  sign is* n  is n … (Formula 3.4)

1  Ts 
R R
 Ts
While F  e L
and G  1  e L  .

R 

3.3. Counter EMF Estimation and Calculation


With the low-pass filter in Formula 3.5, sliding control factor z can be filtered and user is able to
estimate and calculate counter EMF.

d *
es  0es*  0 z … (Formula 3.5)
dt

0 is defined as 0  2f 0 , where f 0 is the filter cutoff frequency. In discrete form, Formula 3.5

can be transformed into Formula 3.6.

 
es* n  1  es* n  2f 0 zn  es* n … (Formula 3.6)

 Generalplus Technology Inc. 8 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

3.4. Motor Position Estimation and Calculation


From counter EMF formula in Formula 3.7, user is able to calculate the motor angle from the
estimated counter EMF, as shown in Formula 3.8.

3   sin  
es  ke   … (Formula 3.7)
2  cos  

e*  arctan  es*,es*  … (Formula 3.8)

 Generalplus Technology Inc. 9 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

4. GPM32F011xB Introduction

4.1. GPM32F011xB Motor Control Module Introduction


GPM32F011xB is a dedicated IC design for motor control of PMSM.
Its features are listed as follows:
■ 6 channels independent PWM or 3 pairs of complementary PWM output.
■ 2 sets of 16 channels 12bit ADC input with 1M SPS, which can sample two channels
simultaneously. It can sample at any PWM point at the same time as well.
■ 32/32bit Fast Divider
■ CORDIC Arctan Calculation
■ 2 Built-In Over Current Protection Comparators
■ 4 Built-In Current Sensoring Operational Amplifiers
■ 3 types of serial communication function provided: I2C, SPI and UART.

4.2. Hardware MATH Cordic Module


GPM32F011xB Cordic only includes arctan operation, and the operation time takes 19 system cycles.
As shown in the following figure, fill in X and Y axis coordinates in register MATH_CORDIC_XD and
MATH_CORDIC_YD, and if MATH_CORDIC_CTRL[0] = 1, arctan operation starts. When MATH_INTF[8]
is set as 1, it means the operation is completed, and user can read the result in register
MATH_CORDIC_ANGLE.

 Generalplus Technology Inc. 10 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

ITERATION + 4 clock cycles

Clock

CORD_STR

FORMAT_SEL “0”

ITERATION 0x0F

CORDIC_XD 0x7FFF

CORDIC_YD 0x7FFF

CORD_BUSY

CORD_INTF

CORDIC_ANGLE 0x100015

Figure 4.1 GPM32F011xB Hardware MATH Cordic Sequence Diagram

Take Q Format (MATH_CORDIC_CTRL[7] = 0) as an example, the arctan operation result 0~8388607


means physical quantity 0~360°.

 Generalplus Technology Inc. 11 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

5. Sample Code Description

5.1. Hardware General Description


As shown in Figure 5.1, the 3-phase inverter bridge is driven by 6 PWM signals. The shunt resistor is
used to measure the motor phase current and total current, and it’s able to detect over current
signal in order to protect the system from the damage caused by the over current.

Figure 5.1 Hardware Structure

 Generalplus Technology Inc. 12 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

5.2. Sample Code File Description


Sample code structure (Sensorless_SMO_FOC_3Shunt) contains the following files, and the
description of the files is listed below.

motor.h: Motor Controller Parameters


prodef.h: Functions to be used with other .c files.
Header Files
foc_v01.h: Variables of FOC Control Algorithm
smo_v01.h: Variables of SMO Control Algorithm
Main.c: Main Program
C Files Init.c: Configuration of IC initialization and variable initialization.
IRQ.c: Interrupt Service Functions
foc_v01.lib: FOC Control Algorithm
Library Files
smo_v01.lib: SMO Control Algorithm

5.3. Overall Program Structure


As shown in Figure 5.2, the two interrupt sources used by the program are OVC over current external
interrupt and eCCU6 PWM interrupt. PWM interrupt will calculate FOC SMO algorithm and the
system state; OVC over current interrupt will shut down the system.

Main Loop

eCCU6 Interrupt
OVC Interrupt
(PWM)

Figure 5.2 Program Structure

 Generalplus Technology Inc. 13 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

5.4. Main Program Flow Description


The main program is attached to main.c file, as shown in Figure 5.3. For the main program, user has
to configure the OPA, ACMP, GPIO, DMA, ADC and PWM function in IC. The sub function of the
related default setting is attached to Init.c file.

Reset
Init.c
OPA_Init();
ACMP_Init();
Initial Chip GPIO_Init();
DMA_Init();
ADC_Init();
CCU8x_PWM_Init();

Initial Variables

Main Loop

Figure 5.3 Main Program Flow Chart

5.5. PWM Interrupt Program Flow


PWM interrupt sub program is attached to IRQ.c file, and the program flow chart is shown as Figure
5.4. The program is mainly used to calculate phase current, FOC algorithm, SMO estimated angle and
so on. FOC algorithm program is attached to foc_v01.lib file, and it includes coordinate transfer, PI
control and SVPWM modulation. SMO algorithm is attached to smo_v01.lib file, and it includes
current observer and sliding control. Part of SMO program will be illustrated in the following
description. For FOC and other part of the program, please refer to Sensored FOC Control of PMSM
Using GPM32F011xB_V1.0.pdf.

 Generalplus Technology Inc. 14 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

Figure 5.4 PWM Interrupt Program Flow Chart

5.6. SMO Library Usage Description


SMO Library is shown as Figure 5.5. After user input 2-phase current (I_Alpha and I_Beta) and
2-phase voltage (V_Alpha and V_Beta), 2-phase counter EMF (E_Alpha and E_Beta) will be output.
The file name of SMO Library is smo_v01.lib.

V_Alpha pu
V_Beta pu pu E_Alpha
pu SMO
I_Alpha pu E_Beta
I_Beta pu

Figure 5.5 SMO Library Diagram

 Generalplus Technology Inc. 15 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

The Library variable is operated in Q15 format. All the variables used by the Library form a struct
SMO, and a variable name has to be declared when user is going to use it. Variables in the struct are
listed as Table 5.1. Variable struct definition is in smo_v01.h file, and it includes the configurations of
controller parameters and so on.

■ The content of smo_v01.h is shown as follows:


typedef struct {_iq DcBus_Volt;
_iq VBus_Alpha;
_iq VBus_Beta;
_iq V_Alpha;
_iq V_Beta;
_iq I_Alpha;
_iq I_Beta;
_iq E_Alpha;
_iq Z_Alpha;
_iq Gsmopos;
_iq EstI_Alpha;
_iq Fsmopos;
_iq E_Beta;
_iq Z_Beta;
_iq EstI_Beta;
_iq Ierr_Alpha;
_iq K_slide;
_iq Ierr_Beta;
_iq E_Kslf;
_iq E0;
_iq invE0;
}SMO;
void smo(SMO *v);

 Generalplus Technology Inc. 16 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

Table 5.1 Struct SMO Variable


Name Description Format Range (hex)
DcBus_Volt Terminal Voltage Q15 80000000-7FFFFFFF
V_Alpha  Axis Voltage Q15 80000000-7FFFFFFF
Input V_Beta  Axis Voltage Q15 80000000-7FFFFFFF
I_Alpha  Axis Current Q15 80000000-7FFFFFFF
I_Beta  Axis Current Q15 80000000-7FFFFFFF
E_Alpha  Axis Counter EMF Q15 80000000-7FFFFFFF
Output
E_Beta  Axis Counter EMF Q15 80000000-7FFFFFFF
Controller K_slide Sliding Control Parameter Q15 80000000-7FFFFFFF
Parameter E_Kslf Counter EMF Filter Parameter Q15 80000000-7FFFFFFF
VBus_Alpha  Axis Terminal Voltage Q15 80000000-7FFFFFFF
VBus_Beta  Axis Terminal Voltage Q15 80000000-7FFFFFFF
Ierr_Alpha  Axis Current Error Q15 80000000-7FFFFFFF
Internal Ierr_Beta  Axis Current Error Q15 80000000-7FFFFFFF
Variable EstI_Alpha  Axis Estimated Current Q15 80000000-7FFFFFFF
EstI_Beta  Axis Estimated Current Q15 80000000-7FFFFFFF
Z_Alpha  Axis Sliding Control Factor Q15 80000000-7FFFFFFF
Z_Beta  Axis Sliding Control Factor Q15 80000000-7FFFFFFF
Motor Corresponding
Gsmopos Q15 80000000-7FFFFFFF
Parameter
Internal Motor Corresponding
Fsmopos Q15 80000000-7FFFFFFF
Constant Parameter
E0 Sliding Control Constant Q15 4000
invE0 Sliding Control Constant Q15 10000

While using SMO Library, after the variables, 2-phase current (I_Alpha and I_Beta) and 2-phase
voltage (V_Alpha and V_Beta), are input, user will get output 2-phase counter EMF (E_Alpha and
E_Beta).

 Generalplus Technology Inc. 17 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

SMO Library sample code is shown as below:


#include "smo_v01.h"
SMO smo1 = SMO_DEFAULTS;
void periodic interrupt IRQ()
{
/***************************Calculate Terminal Voltage.******************************/
smo1.DcBus_Volt = ADC _data >> 1;
smo1.V_Alpha = foc1.V_Alpha;
smo1.V_Beta = foc1.V_Beta;
/************************FOC Library Calculation**************************/
foc(&foc1);
/************************SMO Library Calculation**************************/
smo1.I_Alpha = foc1.I_As;
smo1.I_Beta = foc1.I_Beta;
smo(&smo1);
/*****************************Angle Calculation*******************************/
MATH->CORDIC_YD = -smo1.E_Alpha;
MATH->CORDIC_XD = smo1.E_Beta;
MATH->CORDIC |= MATH_CORDIC_STR;
while((MATH->STS & MATH_STS_CORD_BUSY));
Theta = MATH->CORDIC_ANGLE >> 8;
}

 Generalplus Technology Inc. 18 V1.0 – Jun. 05, 2023


Sensorless SMO Control of PMSM Using GPM32F011xB
User’s Manual

6. Appendix: Related Documents

1. Description Document: Sensored FOC Control of PMSM Using GPM32F011xB_V1.0.pdf


2. Description Document: Sensorless SMO Control of PMSM Using GPM32F011xB_V1.0.pdf
3. Circuit Reference: E-BIKE GPM32F0118B DB V1.0.pdf
4. Sample Code: C:\ Generalplus\GPM32F011xB_BSP\E-BIKE
GPM32F0118B_DB_V10\Projects\Sensored_FOC_3Shunt
5. Sample Code: C:\ Generalplus\GPM32F011xB_BSP\E-BIKE
GPM32F0118B_DB_V10\Projects\Sensorless_SMO_FOC_3Shunt

 Generalplus Technology Inc. 19 V1.0 – Jun. 05, 2023

You might also like