0% found this document useful (0 votes)
10 views52 pages

FM3, Inverter Sensor Washing Machine

FM3, Inverter Sensor Washing Machine Firmware User Manual

Uploaded by

Zeynel Sağcan
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)
10 views52 pages

FM3, Inverter Sensor Washing Machine

FM3, Inverter Sensor Washing Machine Firmware User Manual

Uploaded by

Zeynel Sağcan
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

FM3

Inverter Sensor Washing Machine Firmware


User Manual
Doc. No. 002-04442 Rev. *A

Cypress Semiconductor
198 Champion Court
San Jose, CA 95134-1709
[Link]
Contents

Copyrights
© Cypress Semiconductor Corporation, 2015-2016. The information contained herein is subject to change without notice.
Cypress Semiconductor Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a
Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted nor
intended to be used for medical, life support, life saving, critical control or safety applications, unless pursuant to an express
written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as critical components in life-
support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The
inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use
and in doing so indemnifies Cypress against all charges.
Trademarks
All other trademarks or registered trademarks referenced herein are property of the respective corporations.
Source Code
Any Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by
and subject to worldwide patent protection (United States and foreign), United States copyright laws and international treaty
provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create
derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom
software and or firmware in support of licensee product to be used only in conjunction with a Cypress integrated circuit as
specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source
Code except as specified above is prohibited without the express written permission of Cypress.
Disclaimer
CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described
herein. Cypress does not assume any liability arising out of the application or use of any product or circuit described herein.
Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure
may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support
systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all
charges.
Use may be limited by and subject to the applicable Cypress software license agreement.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 2
Contents

Contents

1. Introduction .................................................................................................................................................................... 5
1.1 Purpose ................................................................................................................................................................. 5
1.2 Definitions, Acronyms and Abbreviations .............................................................................................................. 5
1.3 Document Overview .............................................................................................................................................. 6
1.4 Reference Documents ........................................................................................................................................... 6

2. System Hardware Environment .................................................................................................................................... 7

3. Development Environment ........................................................................................................................................... 8

4. System Firmware Design .............................................................................................................................................. 9


4.1 FW Feature ............................................................................................................................................................ 9
4.2 FW Structure ....................................................................................................................................................... 10
4.3 Files Description .................................................................................................................................................. 13
4.4 FW Control Flow .................................................................................................................................................. 14

5. System Function .......................................................................................................................................................... 15


5.1 Macro Definition ................................................................................................................................................... 15
5.2 Global Structure and Variable Definition .............................................................................................................. 15
5.2.1 Variables for Motor Running ................................................................................................................... 16
5.2.2 Variables for FOC ................................................................................................................................... 18
5.2.3 Variables for Speed and Position ............................................................................................................ 20
5.2.4 Variables for PID Control ........................................................................................................................ 20
5.2.5 Variables for Washing Machine Application ............................................................................................ 22
5.3 Function List ........................................................................................................................................................ 23

6. Event Function ............................................................................................................................................................. 24


6.1 Function List ........................................................................................................................................................ 24

7. Driver Function ............................................................................................................................................................ 26


7.1 Function List ........................................................................................................................................................ 26

8. Interrupt Function ........................................................................................................................................................ 27


8.1 Function List ........................................................................................................................................................ 27
8.2 Interrupt Priority Setting ....................................................................................................................................... 27
8.3 Interrupt Generation............................................................................................................................................. 28
8.3.1 MFT ........................................................................................................................................................ 28
8.3.2 Hall Capture ............................................................................................................................................ 28

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 3
Contents

8.3.3 DTTI ........................................................................................................................................................ 29

9. Demo System ............................................................................................................................................................... 30


9.1 Demo System Introduction .................................................................................................................................. 30
9.1.1 Hardware Connection ............................................................................................................................. 31
9.2 Motor Debug ........................................................................................................................................................ 33
9.2.1 FW Interface Configuration ..................................................................................................................... 34
9.2.2 HW Check............................................................................................................................................... 43
9.2.3 Hall Check .............................................................................................................................................. 43
9.2.4 Run Motor ............................................................................................................................................... 47
9.2.5 Speed Acceleration and Deceleration ..................................................................................................... 48
9.3 Troubleshooting ................................................................................................................................................... 49
9.3.1 Motor Start-up ......................................................................................................................................... 49
9.3.2 Protection................................................................................................................................................ 49
9.3.3 Drum Direction Reversed........................................................................................................................ 50
9.3.4 Power Consumption Higher .................................................................................................................... 50

10. Additional Information ................................................................................................................................................ 51

11. Revision History .......................................................................................................................................................... 52


Document Revision History .................................................................................................................................................... 52

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 4
1. Introduction

Scope of This Document


This user manual describes the following products:

Series Product Number


FM3 Series MB9AF111K, MB9AF312K,MB9BF121J

1.1 Purpose
This user manual describes Cypress inverter sensor washing machine solution, and describes how to use
inverter washing machine FW library.
This document will help you acquire a quick understanding of how to build a washing machine project and how to
debug the motor with inverter sensor washing machine FW library.
The document introduces the basic information of the washing machine solution including hardware, firmware,
initial functions, basic motor setting functions and FOC drive modules. When you have understood these
contents, you can get an overview of a whole washing machine project. And you can run a motor following the
demo project step.

1.2 Definitions, Acronyms and Abbreviations


API - Application Programming Interface
FOC - Field Oriented Control
FW - Firmware
HW - Hardware
I/O - Input and output
CW - Clockwise
CCW - Counter clockwise
WM - Washing Machine

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 5
Introduction

1.3 Document Overview


The rest of document is organized as the following:
Chapter 2 explains System Hardware Environment
Chapter 3 explains Development Environment
Chapter 4 explains System Firmware Design
Chapter 5 explains System Function
Chapter 6 explains Event Function
Chapter 7 explains Driver Function
Chapter 8 explains Interrupt Function
Chapter9 explains. Demo System

1.4 Reference Documents


HW User Manual: MCU-UM-510115-E-12-WM-EVB_HW.pdf

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 6
2. System Hardware Environment

The following lists the MCUs used in washing machine inverter board
CPU chip: MB9AF111K/ MB9AF312K
CPU Frequency: 40MHz
MCU pin number: 48pin
RAM Space: 16Kbytes
Code Space: 128Kbytes
Demo HW version: WM-MAINBORAD-V0.3.1

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 7
3. Development Environment

Table 1. MCU Development Environment

Name Description Part Number Manufacturer Remark

IAR bedded FW code edit , compile and N/A


N/A N/A
Workbench6.40 debug

J-Link Debug and Load FW by JTAG N/A N/A N/A

SPANSION FLASH N/A


Flash download program N/A N/A
LOADER

Source Insight V3.50 Source code edit N/A N/A Editor

Eclipse Source code edit N/A N/A Editor

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 8
4. System Firmware Design

This chapter introduces the FW structure of inverter washing machine project.

4.1 FW Feature
The features of the sensor inverter washing machine solution are shown in Table 2
Table 2. Feature List of Sensor WM Solution

No Feature Description Remark


Hall status self-check
Hall phase angle self-check
Hall Self-check
Check whether the hall circuit in hardware part is
normal.
Hardware Self -check Check whether the current sample by A/D is right
Carrier frequency can be set by the corresponding
Adjustable Carrier Frequency
variable in user interface
Rotor electrical phase angle was corrected by hall
Hall Angle Control
edge jump interrupt

Motor Speed Calculate Calculate speed by hall signals

Field Weaken Control Run motor in field weaken area to raise speed
FOC Control Using FOC control algorithm

Self-adaption Start Up Adaptive to different load to start-up motor

This function is used to speed up or slow down a


Speed regulate motor by the command from host via UART or
debugger
Stop motor by braking down
Brake
Speed Slow down by braking algorithm
Dual shunts sample
Current Sample
Single shunt sample algorithm
DC voltage protection
A/D offset protection
Lock rotor protection
Protect Power protection
Hall single line lost protection
IPM temperature protection
Motor phase lost protection

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 9
System Firmware Design

Over Current Protection


OOB Out of balance (OOB) load detection
Weight The weight of the load detection
Motor can switch running direction (CCW and CW)
Un-Stop Running
without stopping motor
UART Receive and transform data to Host PC

4.2 FW Structure
There are 5 layers in the FW structure of IAR, which are shown in Figure 1.
Figure 1. Structure of FW

The C source and Header files which are included in each layer are shown in Table 3
Table 3. Directory Description of Project

Layer Folder Description


H01_global,
global MCU system file
S01_global
H02_driver,
driver MCU register setting function such as GPIO, interrupt, MFT, AD
S02_driver

H03_module, Algorithm folder for basic motor control such as FOC frame transform , SVPWM,
module
S03_module math, PID, filter

H04_app, Application folder for the files of application functions such as speed and position
app generator by hall sensor, protection, motor start-up, field weaken, brake, weight,
S04_app OOB,UART, and etc.
H05_User,
user Customer interface folder for the files for motor Configuration and HW setting
S05_User

Note: if you want to quick start the motor, you can refer to the setting for user layer at 9.2.1 FW
Interface Configuration and Chapter 5. System Function

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 10
System Firmware Design

The sub-files in each folder are shown in Figure 2 and the structure of header files is the same as C files.
Figure 2. Sub-files in Each Layer

The relationship between each layer is shown as the diagram in Figure 3

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 11
System Firmware Design

Figure 3. Sensor WM FW Architecture

User
Layer User interface Main program entrance Interrupt vectors

App Layer
Hall Self Check HW Self Check Single Shunt Sample

Motor Start-up Motor Speed Set Brake

Un-Stop Running Hall Phase Angle Control Rotor Angle Generate

Speed Calculation Voltage and Current


Limit
OOB Weight UART

Power Protect A/D Offset Protect Over Current Protect

Lock Rotor Protect Lose Phase Protect Hall Lost Protect

IPM Temperature Protect Voltage Protect

Timer Event Motor Interface

Module
Layer
Clarke Transformer Inverse Clarke PI Regulator
Transformer
Park Transformer Inverse Park SVPWM
Transformer
LPF Math A/D Sample

Drive Layer

Global Layer

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 12
System Firmware Design

4.3 Files Description


The detailed descriptions for each file are shown in Table 4
Table 4. Sensor WM FW Architecture

Folder File Description


S01_global G04_Cm3.c The file for MCU driver
G04_Debug.c Debug information for MCU driver
EquTrans.c FOC axis convert
Filter.c One order low pass filter
S03_module Math.c The math module including the function such as SQRT,COS and SIN
PID.c The PID module for current and speed PI
PWM.c The SVPWM module
ADC_Sample.c The ADC process module based on the ADC ISR
Angle_Generate.c The rotor angle generation module
Brake.c The brake module including the speed down by brake
CV_Limit.c The FOC current and voltage limitation module
FieldWeaken.c The Field Weaken module
Hall_Capture.c Hall capture module
Hall_Check.c Hall check module
HW_Check.c HW check module
Initial.c MCU system initialization including interrupt priority list
ISR.c The ISR file for all of the interrupt routine of the MCU
Motor_Run.c The main file of the motor control including the main function of FOC process
of motor and the start/stop function of motor
S04_app Motor_Startup.c The motor start-up module
OOB.c The OOB detect module
PID_Control.c The PID control module that including the Speed PI, current PI, PI parameter
self-changing
Position_Calulate.c The position calculate module
Protect.c The protect module
SingleShunt.c The single shunt module
Speed_Calculate.c The speed calculate module
SpeedSet.c The speed setting module
Timer_Event.c Timer event module
UART.c The UART module
UnStop.c The Unstop running module
Weight.c The electrical weight module
S02_Driver Ignored
CustomerInterface.c The motor parameter setting
S05_User Main.c Main function
Vector_Table.c MCU interrupt vector list

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 13
System Firmware Design

4.4 FW Control Flow


The control flow for the motor is shown as Figure 4. There are 4 interrupts that are red highlighted for the motor
FOC control, hall capture and AD converter. The timer events are executed in the end-less loop and the timers
are generated in the zero detection interrupt ‘ISR_MFT_FRT’ of the free run timer 0.
Figure 4. Diagram of the Control Flow

End-less loop in Main.c ISR_Hall


Hall Interrupt

Hall status check


Start

Hall correct angle


InitPowerOn generate
Speed Calculate from Hall
FeedWDT
ISR_ADC_unit1
Motor Start/Stop
IPM temperature
sample and calculate
Timer_Event

Uart_Communicate Current U\V\W sample

DC bus sample and


calculate
ISR_ADC_unit0
ISR_MFT_FRT

FOC control PID SVPWM Other algorithms

Current Speed &Position Weight & Protection(High


restoration Generate OOB Priority)

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 14
5. System Function

This chapter introduces the system function of the macro definition, global structure definition, and function
definition in detail.

5.1 Macro Definition


The macro definition for the user will be described in section 9.2.1 FW Interface Configuration

5.2 Global Structure and Variable Definition


The variable for user interface can be found in section 9.2.1 FW Interface Configuration’.
Any structure or variable that you want to watch can be pasted into the ‘Live Watch’ window of IAR as shown in
Figure 5.
Figure 5. Diagram of Live Watch

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 15
System Function

5.2.1 Variables for Motor Running


Motor_stcRunParam
The structure is used to control motor run or stop and the basic running information for the motor such as real
running speed, DC bus voltage, washing machine work mode, etc. Detailed information can be found in the
comments for each variable.

typedefstruct

{
int16_t i16WmCommandSpdRpm;//the command speed of drum from UART or debugger
online,unit:rpm
int16_t i16WmTargetSpdRpm;//the middle speed for the reference speed of speed
PI,unit:rpm
int16_t i16WmSpdRpmRt; //the real-time drum speed of washing machine
int16_t i16WmSpdRpmLPF; //the filtered drum speed of washing machine
int16_t i16MotorSpdRpmRt;//the real-time motor speed of washing machine
int16_t i16MotorSpdRpmLPF;//the filtered motor speed of washing machine
char_tcWorkMode; //wash or spin work mode
char_tcRunStatus; //run status: 0--stop,1--Run
char_tcRunDir; //run direction: CW or CCW
uint16_t u16FaultCode; //protection fault code
uint8_t u8InitStage; //the start initial state machine
uint16_t u16Vbus; //the DC bus voltage, unit:V
uint16_t u16VbusLpf; //the DC bus voltage lpf value

uint32_t u32Q22_RotorEleTheta;//the rotor position angle


uint16_t u16BrakeTime; //brake time, unit:1ms
char_tcStartupcomplete;//flag for motor startup finish
char_tcCloseloop; //flag for the motor closed loop running
} stc_MotorRunParam_t;
externstc_MotorRunParam_t Motor_stcRunParam;

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 16
System Function

SpdSt_stcSpdSet
The structure is used to set the drum speed. It is the global structure for the Speed Set module that is realized in
file ‘S04_app/ SpeedSet.c’. Detailed information can be found in the comments for each variable, the variables in
this structure are not recommended to modify.

typedefstruct stc_SpdSet
{
int16_t i16SetSpeed; //setting speed of drum, unit:rpm
int16_t i16SetSpeedPre; //previous setting speed of drum,
unit:rpm
uint16_t u16SpdChgTime; //speed change time from spd A to B
uint16_t u16CommandSpeed;//the command speed of drum,unit:rpm
char_t cWorkMode; //the WM working mode: wash or spin
uint16_t u16SpdChgCounter;//the speed regulate counter
uint8_t u8SpdChgStep; //the speed change step for speed
regulate
Char_t cMotorStartFlag;//motor start flag
Char_t cMotorStopFlag; //motor stop flag
char_tcRotateDir; //motor running direction
uint16_t u16AcceLmt; //the acceleration limit at speed up
uint16_t u16DeceLmt; //the acceleration limit at speed down
uint16_t u16SpeedMax; //the maximum speed limit of drum speed
uint16_t u16SpeedMin; //the min speed limit of drum speed
} stc_SpdSet_t;
stc_SpdSet_t SpdSt_stcSpdSet;

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 17
System Function

5.2.2 Variables for FOC


The variables for the FOC control are introduced in this section.
D&Q axis Current and Voltage

Reference current value on the 2 axis rotation


frames
Reference current on D-axis ‘Idref’
Reference current on Q-axis ‘Iqref’
Cosine value of the rotor position used for the
frame transform
Sine value of the rotor position used for the frame
transform
current value on the 2 axis rotation frames
Real-time current on D-axis ‘Id’
Real-time current on Q-axis ‘Iq’
Cosine value of the rotor position used for the
frame transform
Sine value of the rotor position used for the frame
transform

Voltage value on the 2 axis rotation frames


Real-time voltage on D-axis ‘Vd’
Real-time voltage on Q-axis ‘Vq’
Cosine value of the rotor position used for the
frame transform
Sine value of the rotor position used for the frame
transform

Motor_Offset
The AD middle points of amplifier part on the HW are got in this structure. If the middle voltage of the amplifying
circuit for the phase current is changed, the AD offset result will also be changed.
Motor_Offset
AD middle point for current Iu AD sample
AD middle point for current Iv AD sample
AD middle point for current Iw AD sample
2048 = 2.5V, the offset error threshold is set by
‘AD_OFFEST_MAX_VALUE’

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 18
System Function

Startup_stcCtrl
The structure is used for the motor start-up control. The detailed information can be found in the comments for
each variable.

Flag for motor startup complete,1→start finished


Flag for motor closed loop running,1→speed closed loop
Flag for the motor startup stage

Flag for the motor startup and running level

Limit_stcCalc
The structure is used for the FOC current and voltage limitation to ensure the reliability of the inverter. The
detailed information can be found in the comments for each variable.

D-axis voltage limit


Q-axis voltage limit
D-axis current limit, especially in field weaken
Q-axis current limit
Saturate phase current

FieldWeaken_stcCtrl
The structure is used for filed weaken control. The detailed information can be found in the comments for each
variable.

Flag for the field weaken execution


Counter for the field weaken PI
The cycle of field weaken PI ,unit:1ms
The base drum speed of motor without filed weaken
Exit the field weaken by the load disturbance
The cycle of field weaken PI ,unit:1ms
The recorded base speed of drum speed
The recorded DC bus voltage when enter the field weaken

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 19
System Function

5.2.3 Variables for Speed and Position


Angle_stcGenerate
The structure is used for rotor position generation. The detailed information can be found in the comments for
each variable.

Rotor's output angle


Rotor's forward angle every PWM
Rotor's min forward angle every PWM
Rotor's forward angle calculated factor
Rotor pass hall number when start up

Spd_stcPar
The structure is used for outputting the rotor speed calculation result. The detailed information can be found in
the comments for each variable.

The output motor average speed


The output motor real time speed
The output WM average speed
The output WM real time speed
1/trans-ratio

Motor's real-time electrical speed

5.2.4 Variables for PID Control


The structures used for PID control are introduced in this part.
Pid_stcCtrl
The structure is used for PID control that enables or disables the corresponding PI regulator. The detailed
information can be found in the comments for each variable.

Id PI Enable
Iq PI Enable
SpeedPI Enable
Field weaken PI Enable
Field weaken execution flag
Speed PI execution flag
Execute cycle of Id PI
Execute cycle of Iq PI
Execute cycle of speed PI, unit: ms
Execute cycle of field weaken PI, unit :ms

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 20
System Function

Pid_stcSpdPI
The structure is used for the speed PI regulator. The detailed information can be found in the comments for each
variable.

Kp parameter for speed PI, Q8 format


Ki parameter for speed PI, Q8 format
Kd parameter for speed PI, Q8 format
Pout of speed PI, Q16 format
Iout of speed PI, Q16 format
Dout of speed PI, Q16 format
Input error of speed PI, Q8 format
Previous input error of speed PI, Q8 format
Output of speed PI, Q8 format
Max output limit of speed PI, Q8 format
Min output limit of speed PI, Q8 format

Pid_stcIqPI
The structure is used for the q-axis current ‘Iq’ PI regulator. The detailed information can be found in the
comments for each variable.

Kp parameter for Iq PI, Q12 format


Ki parameter for Iq PI, Q12 format
Pout of Iq PI, Q20 format
Pout of Iq PI, Q20 format
Input error of Iq PI, Q8 format
Output error of Iq PI, Q8 format
Max output limit of Iq PI, Q8 format
Min output limit of Iq PI, Q8 format

Pid_stcIdPI
The structure is used for the d-axis current ‘Id’ PI regulator. The detailed information can be found in the
comments for each variable.

Kp parameter for Id PI, Q12 format


Ki parameter for Id PI, Q12 format
Pout of Id PI, Q20 format
Pout of Id PI, Q20 format
Input error of Id PI, Q8 format
Output of Id PI, Q8 format
Max output limit of Id PI, Q8 format
Min output limit of Id PI, Q8 format

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 21
System Function

FieldWeaken_stcPiParam
The structure is used for field weaken PI regulator. The detailed information can be found in the comments for
each variable.

Kp parameter for Field Weaken PI, Q8 format


Ki parameter for Field Weaken PI, Q8 format
Kd parameter for Field Weaken PI, Q8 format
Pout of Field Weaken PI, Q16 format
Iout of Field Weaken PI, Q16 format
Dout of Field Weaken PI, Q16 format
Input error of Field Weaken PI, Q8 format
Previous input error of Field Weaken PI, Q8 format
Output of Field Weaken PI, Q8 format
Max output limit of Field Weaken PI, Q8 format
Min output limit of Field Weaken PI, Q8 format

5.2.5 Variables for Washing Machine Application


The variables for the advanced application of the washing machine are introduced in this section.
Weight_stcCtrl
The structure is used for the weight control. The detailed information can be found in the comments for each
variable. The weight result and the inner data can be observed in this structure.

Weight start flag


Start detecting the power in weight
Flag for the speed acceleration finish
Weight finish flag, 1--finish 2--weight over time
Weight stage
Average power in one drum cycle at stable running N1
Sum power at weight speed up
Drum cycle at weight speed up
Original weight result of the load
Weight result of the load by the DC voltage compensation
Weight result of the load
Max weight time,unit:s

OOB_stcCtrl
The structure is used for OOB detect. The detailed information can be found in the comments for each variable.

OOB detect start flag


OOB detection stage, 4 means OOB finished
Original OOB data of the load
OOB result to host

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 22
System Function

UnStop_stcParam
The structure is used for un-stop running. The detailed information can be found in the comments for each
variable.

Start unstop running


Stop unstop running
Run in force status flag

Angle compose start flag


Angle error between rotor and hall
Compose angle speed

5.3 Function List


The functions for the system control are shown in Table 5
Table 5. System Function List

Prototype Description Remark


void main(void) Main function of the whole project Main.c
InitPowerOn() The initial function for all the MCU resource initial Main.c
and key variable initial after the power is on
Motor_RunInit(Motor_CARRY_FREQ) The function for the motor start control but not for Motor_Run.c
the motor start-up.
Motor_StopControl() The function for the motor stop control Motor_Run.c
Uart_Communicate() The main function for the UART communication UART.c
static void The key variable and the register initial at the motor Motor_Run.c
Initial_Motor_RunPar(unsigned short start
sample_freq)
void Motor_Process(void) The main function of the motor control that is called Motor_Run.c
in each of the MFT zero detect ISR
void Debug_Process(void) The main function of the test mode for the hall and Motor_Run.c
HW check ,and is also called in each of the MFT
zero detect ISR
void Debug_Watch(void) The basic variable assignment for the motor Motor_Run.c
running
void Timer_Counter(void) The 1ms/5ms/50ms timer generated by the MFT TimerEvent.c
ISR
void Timer_Event(void) The timer event for the motor control or the TimerEvent.c
advanced function

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 23
6. Event Function

The primary functions for the motor inverter control are introduced in this chapter

6.1 Function List


The functions for the motor control that are called in the MFT ISR ‘Motor_Process()’ and timer ‘Timer_Event()’
are shown in Table 6 and Table 7
Table 6. Event Function List by the ‘Motor_Process()

Prototype Description
Hall_CaptureOn(); The hall status check at the first electrical cycle of the motor by the query
mode when the power is on
UnStop_Run() The main function for the un-stop running
Spd_EstimateCalculate() The speed calculate function by the estimator
Spd_Calculate() The speed calculate function by the estimator and hall module
Motor_Sense() The phase current restoration from ADC converter
ClarkeTransform(&Motor_3sCurrent, The function of the Clarke frame transform
&Motor_2sCurrent)
ParkTransform(&Motor_2sCurrent, The function of the Park frame transform
&Motor_2rCurrent)
Posi_Estimate(…) The function of the rotor position estimator
Posi_Calculate() The function of the rotor position calculation from the estimator and hall
module
Angle_Generate() The function of the rotor position generation
Current_PI(…) The d/q current PI regulator
Startup_HallMotor() The motor start-up function for the hall sensor motor
InvertParkTransform(…) The function of the inverse Clarke frame transform
InvertClackeTransform(…) The function of the inverse Park frame transform
SVPWM_Calc(…) The SVPWM function
Write_MFT_OCCP(…) The function for the OCCP register setting according to the SVPWM
calculate result
Weight_LoadMeasure() The function for the weight
OOB_Detect() The function for the OOB
Protect_HallLost(…) The protection function for the hall lost detect
Protect_OpenPhase(…) The protection function for the open phase detect

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 24
Event Function

Table 7. Event Function List by the ‘Timer_Event()’

Prototype Description Remark


SpdSt_SpeedSet(…) The speed set function used for the motor speed acceleration or 1ms
deceleration timer
SpdSt_SpeedRegulate(…) The speed regulation function for the middle speed generation
FieldWeaken_Control() The main function for the field weaken
Brake_SpeedDown() The function of the speed down by brake
PID_ParameterChange() The function of the PID Parameter Change
Speed_PI(…) The function of the speed PI regulator
Limit_Calculate() The function of the FOC current and voltage limitation 5ms
Protect_LockRotor() The function of the motor lock protection
Protect_Power() The function of the motor running power protection
Protect_Voltage() The function of the DC bus over and under protection
Protect_IpmTemperature() The function of the IPM temperature protection
Debug_Watch(); The basic variable assignment for the motor running 50ms
Uart_Protect(); The function of the UART lost protection

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 25
7. Driver Function

The MCU peripheral resources used for motor control are introduced in this chapter.

7.1 Function List


The MCU peripheral driver functions are mainly located in the file ‘S0’4_app/Initial.c
Table 8. Driver Function List

Prototype Description Remark


void InitNVIC(void) The interrupt enable and the priority set that used in the Initial.c
motor control
void InitClock(void) MCU clock initialization Initial.c
void InitWDT(void) Watch dog initialization Initial.c
void InitGPIO(void) The used GPIO initial, user can add the GPIO for other Initial.c
usage
void Motor_SVPWM_Init(void) The SVPWM initial such as the FRT mode and cycle, AD Initial.c
trigger source, OCCP mode, etc.
void Motor_SVPWM_En(void) Enable the SVPWM output Initial.c
void Motor_SVPWM_Dis(void) Disable the SVPWM output Initial.c
void InitADC(unsigned short The AD initial such as the port setting, converter time Initial.c
Motor_Sample_freq) setting, trigger point, etc.
void Motor_configPWM(void) Configuration the PWM such as the dead time of the Initial.c
SVPWM, max duty
void Brake_On(void) Porting setting for motor brake Brake.c
void Brake_Off(void) Release the port to finish the brake Brake.c

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 26
8. Interrupt Function

8.1 Function List


Table 9. System Used Interrupt Function

Prototype Description Remark


__root void ISR_HardWatchdog(void) The HW watch dog ISR S04_app/ISR.c
__root void ISR_SoftWatchdog(void) The software watch dog ISR S04_app/ISR.c
__root void ISR_Hall(void) Hall interrupt S04_app/ISR.c
__root void ISR_MFT_FRT(void) The MFT zero detect ISR for the motor control S04_app/ISR.c
__root void ISR_MFT_WFG(void) The HW over-current ISR S04_app/ISR.c
__root void ISR_ADC_unit0(void) The ADC unit0 ISR, trigger at the zero point for the 3 shunts S04_app/ISR.c
__root void ISR_ADC_unit1(void) The ADC unit1 ISR for the IPM temperature sample S04_app/ISR.c
__root void Isr_UartRx(void) UART receive interrupt by MFS3 S04_app/ISR.c
__root void Isr_UartTx(void) UART transmit interrupt by MFS3 S04_app/ISR.c
__root void DefaultIRQHandler (void) MCU exception interrupt S04_app/ISR.c

8.2 Interrupt Priority Setting


Each interrupt priority can be set by the function ‘void Init NVIC(void)’ which is located at the file
‘S04_app/Initial.c’. Users are not recommended to modify it. The priority used for motor control is shown in
Figure 6
Figure 6. Interrupt Priority Setting

voidInitNVIC(void)
{ // INT priority
ConfPriorityForIRQ(16 + MFS3RX_IRQn, 4, PRI_LEVEL_6); //UART receive
ConfPriorityForIRQ(16 + MFS3TX_IRQn, 4, PRI_LEVEL_6); //UART Transmit
ConfPriorityForIRQ(16 + WFG_IRQn, 4, PRI_LEVEL_0); //watchdog
ConfPriorityForIRQ(16 + EXINT0_7_IRQn, 4, PRI_LEVEL_0);//outside int
ConfPriorityForIRQ(16 + SWDT_IRQn, 4, PRI_LEVEL_1);//software watch dog
ConfPriorityForIRQ(16 + ADC0_IRQn, 4, PRI_LEVEL_2); //adc0
ConfPriorityForIRQ(16 + ADC1_IRQn, 4, PRI_LEVEL_4); //adc1
ConfPriorityForIRQ(16 + FRTIM_IRQn, 4, PRI_LEVEL_3); //frt
ConfPriorityForIRQ(16 + OUTCOMP_IRQn, 4, PRI_LEVEL_6); //outcompare
ConfPriorityForIRQ(16 + BTIM0_7_IRQn, 4, PRI_LEVEL_5); //hall
}

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 27
Interrupt Function

8.3 Interrupt Generation


The diagram of the interrupt used for the motor control is briefly introduced in this section.

8.3.1 MFT
The multifunction timer is used to generate the interrupt for the motor control algorithm and trigger the AD
sample at the zero point.
Figure 7. Free Run Timer Interrupt

ISR_MFT_FRT
Free run timer 0, UP/DOWN mode, PWM cycle: 62.5 us, 16K Hz

Trigger AD unit0 and FOC interrupt

A/D unit0: sample U,


V, W current
FOC interrupt to drive
motor

8.3.2 Hall Capture


The PWC timer is used to capture the hall status change and the pulse of the edge of the hall signal.
Figure 8. Base Timer Interrupt

ISR_Hall
One motor electrical cycle
Hall signal Voltage High or Low level
H

Trigger Hall interrupt

Hall Edge
change Motor speed
interrupt calculate and rotor
and base phase angle core
timer over
flow
interrupt
Base timer Count Over Flow

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 28
Interrupt Function

8.3.3 DTTI
The DTTI0 is used to trigger the HW fault protection from the IPM. When the phase current is large enough to
trigger the HW over-current fault, the interrupt is got and all of the drive signals for the motor control will shut off
immediately.
Figure 9. DTTI Interrupt

ISR_MFT_WFG
IPM fault signal low voltage
H

Trigger over current


interrupt,
PWM closed

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 29
9. Demo System

This chapter introduces one example of inverter washing machine project and help you run a motor quickly.

9.1 Demo System Introduction


The sensor washing machine solution can be adaptive to any type of washing machine which uses the PMSM or
BLDC motor. The connection diagram for debugger is shown in Figure 10.
Figure 10. System Connection

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 30
Demo System

9.1.1 Hardware Connection


It is necessary to connect below 4 lines:
1. Connect motor’s hall signal to inverter board, shown as below.
Figure 11. Hall Signal Line Connection

Hall port

The Hall signal line connection is defined in the following table.


Table 10. Hall Connection

Motor’s line Inverter board circuit port


Hall A Hall A
Hall B Hall B
Hall C Hall C
+5V VCC
GND GND

Note:
 If there are only 2 hall signals on the motor, the hall A and B line can be only connected to the inverter’s
Hall A and Hall B port. Don’t connect to the Hall C port on the board.
 VCC and GND must be connected rightly, otherwise the hall won’t work properly and the motor will also
not run.
2. Connect motor’s U, V, W phase lines to inverter board, shown as below.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 31
Demo System

Figure 12. Motor Line Connection

U, V, W

Motor’s U, V, W line can be optionally connected to Inverter’s IPM’s output U, V, W.


3. Connect JTAG to Inverter, shown as below.
Figure 13. JTAG Line Connection

J-Link

Note:
If there is no isolator between the J-link and the HW, you must unplug the AC power and use the battery of your
note book.
4. Connect AC power to Inverter board, shown as below.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 32
Demo System

Figure 14. AC Plug

AC Power

9.2 Motor Debug


The debug method on the new motor is described in this section when you finish the hardware connection with
the motor.
Click the IAR program to open the IAR, and open the ‘EWW’ file of the inverter washing machine work space as
shown in Figure 15.
Figure 15. Open the Workspace

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 33
Demo System

9.2.1 FW Interface Configuration


All of the variables reserved for the user interfaces are located in the file ‘S05_user/CustomerInterface.c’ and the
macro definitions are located in the file ‘H05_user/Customer Interface.h’. Both files are highlighted, as shown in
Figure 16
Figure 16. Interface File Diagram

[Link] Basic Setting


The motor can be started easily after basic setting. So the basic variables and macro definitions must be
correctly set for the motor demo running.
All of the HW settings in this section must be based on Hardware User Manual.
A. Basic Variables Setting
The basic variables can be set in the c source file ‘S05_user/CustomerInterface.c’.
Motor Parameter Configuration
The motor parameter must be correctly set except the hall related parameters that is red highlighted in Figure 17
When the hall related parameter is self-checked by hall check module, it must be set correctly according to.
Motor Parameter.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 34
Demo System

Motor Parameter.
Figure 17. Motor Parameter Set

/** UI_0101 configure motor parameter */


#define MOTOR_ID 0 // motor ID number
// 0 --> new motor param,
// >=1 -->already debug motor,add at the end of this
file
#if 0== MOTOR_ID // new motor param -->LS BLDC
uint8_t Motor_pole_pairs = 12; // the pole pairs of rotor
uint8_t Motor_HallNumber = THREE_HALL; // 3or 2 hall number of the motor
float Motor_CurrentMax = 6.0; //max peak phase current,unit,A
float Motor_Rs = 6; // phase resistor of motor,unit:ohm
float Motor_Ls = 24; // phase inductance of motor,unit:mH
uint8_t Motor_HallStatuList[7] = {0,3,1,5,4,6,2};// hall status change sequence
int32_t Motor_HallAngleCCW[7] =
{0,DEGREE(210),DEGREE(90),DEGREE(150),DEGREE(330),DEGREE(270),DEGREE(30)};

int32_t Motor_HallAngleCW[7] = {0,DEGREE(90),DEGREE(330),DEGREE(30),\

DEGREE(210),DEGREE(150),DEGREE(270)};
#endif

WM Parameter Setting
Figure 18. Washing Machine Parameter Setting

/** UI_0102 configure WM parameter */


char_tWM_cType = DD; // washer type:DD,DDM,BLDC,BLDCMjust copy it
floatWm_TransRate= 1; // TransRate of washer,DD-->1, BLDC-->TBD
int32_t WM_MinSpd = 20; // min speed of drum,unit:rpm
int32_t WM_MaxSpd = 1200; // max speed of drum,unit:rpm

Note:
 The washing machine type must be correctly set, the drum running direction maybe reversed by the
incorrect setting.
 The transmission ratio of the motor for the washing machine must be correctly set also. Otherwise the
drum speed will be incorrect. Wm_TransRate =1 for the DD and DDM washing machine.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 35
Demo System

Inverter Parameter Configuration


The inverter carrier frequency can be set by the reserved variable, but the variables in this part are not
recommended to modify for the washing machine application.
Figure 19. Inverter Parameter Set

/** UI_0103 configure inverter parameter*/


uint16_t Motor_CARRY_FREQ = 16000; //carrier frequency of motor
driver,unit:Hz
uint32_t RelayDelayOnTms = 2000; // time delay for relay switched
on,unit:ms
float Motor_Dead_TimeUS = 2; //dead time for IPM PWM drive,unit:us

The carrier frequency of the washing machineis16KHz. The phase current AD sample frequency is 16 KHz. And
the dead-time of the SVPWM is 2µs
B. Basic setting for HW
The basic settings for the HW can be set in the H file ‘H05_user/ CustomerInterface.h’
ADC Port and Coefficient Setting
Figure 20. ADC Port Setting

/** UI_0301 ADC port and coefficient set */


#define MOTOR_SHUNT_NUMBER 2 // current sample resistor
#define CURRENT_RS 0.02 // Iuvw sample resistor,unit:ohm
#define Current_Amplifier_Multiple 10 // Iuvw calculation factor
#define VDC_Amplifier_Multiple 96.0 //Vdc calculation factor

#define DC_V_PIN ADC_CH_2// Vdc sample channel


#define MOTOR_U_PIN ADC_CH_0// Iu sample channel
#define MOTOR_V_PIN ADC_CH_1// Iv sample channel
#define MOTOR_W_PIN // Iw sample channel
#define IPM_TEMP_PIN ADC_CH_3// IPM temperature sample channel

The Demo Board’s current sample resistor is 0.02Ω, current amplification factors 10 times, DC Bus voltage
sample factor is 96.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 36
Demo System

Relay and Other GPIO Setting


Figure 21. GPIO Port Set

/** UI_0302 configure relay and other GPIO*/


// Relay port setting
#define RELAY_PORT PORT5
#define RELAY_PIN PIN2
// other GPIO setting

Other GIPO used by customer can be set in this part.


Hall I/O and Pin set
Figure 22. Hall Port Set

/** UI_0303 configure hall I/O and Pin */


#define HALL_A_PORT PORT4 //Port 4
#define HALL_A_PIN PIN9 //P49
#defineHALL_A_TIMER BT_CH_0//timer 0
#defineHALL_A_TIMER_CH 0 //timer 0_0
#define HALL_B_PORT PORT4 //Port 4
#define HALL_B_PIN PIN10 //P4A
#defineHALL_B_TIMER BT_CH_1//timer 1
#defineHALL_B_TIMER_CH 0 //timer 1_0
#define HALL_C_PORT PORT6 //Port 6
#define HALL_C_PIN PIN1 //P61
#defineHALL_C_TIMER BT_CH_2//timer 2
#defineHALL_C_TIMER_CH 2 //timer 2_2

The hall I/O is recommended to connect to the port the same as HW demo due to the special MCU peripheral
usage.
Selectable Function Setting
Figure 23. Function Selection

/** UI_0304 Function set */


char_t FW_TEST_MODE FALSE// HW\Hall check set
//TRUE: work in debug mode for testing HW and Hall
//FALSE: work in normal mde and disable Hall check

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 37
Demo System

The advanced functions are set in this part, if you want to run the hall and HW check functions, the variable:
FW_TEST_MODE can be set to TRUE to run these functions.

[Link] Advanced Variables Setting


If the motor runs well in any working condition, the settings in this section do not need to be changed.
The settings can be changed to improve the corresponding performance of the module.
Advanced Setting for MCU
These parts are not recommended to modify for the inverter washing machine solution in the
file‘H05_user/CustomerInterface.h’
MCU Clock Setting
The MCU on the Demo Board is MB9AF111K. The maximum machine frequency is 40MHz.
Figure 24. MCU Clock Setting

/** UI_0401 MCU clock setting */


#define FREQ_XTAL 4L // MHz
#define SYS_CLOK Main_Frequency_40M

A/D Converter Setting


Figure 25. A/D Converter Setting

/** UI_0402 A/D sample setting */


#define ADC_Digit12
#define ADC_MAX (1 << ADC_Digit)
#define ADC_REF 5.0
#define MOTOR_ADC_FORWARD_TIME 2

#define AD_OFFEST_MAX_VALUE 200//100


#define CURRENT_NORMAL_OFFEST (1 << (ADC_Digit - 1))
#define CURRENT_OFFEST_MAX (CURRENT_NORMAL_OFFEST +
AD_OFFEST_MAX_VALUE)
#define CURRENT_OFFEST_MIN (CURRENT_NORMAL_OFFEST - AD_OFFEST_MAX_VALUE)

Advanced Setting for FW


These variables in this part can be modified if the performance of corresponding module is not so good or you
want to change the setting for a different washing machine, and you can find the
file‘S05_user/CustomerInterface.c’.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 38
Demo System

Motor Start-up and Start/stop Setting


The parameter for the motor start-up and the brake stop to end speed can be set in this part.
Figure 26. Variables Setting for Motor Running

/** UI_0201 Motor start-up variables setting */


int32_t Motor_StartSpd = 20; // start up drum speed,unit:rpm
float Startup_InitCur = 0.2; //initial startup current, unit:A
float Startup_IncCur = 0.2; //initial startup current, unit:A
/** UI_0202 Motor start/stop setting*/
uint16_t BrakeEndSpdRPM = 0; //the brake end speed of
drum ,unit:rpm

/** UI_0203 Motor Down Speed by Brake*/


char_t DecSpdByBrakeFlag = TRUE;//down speed weather brake

PI Parameter Setting
Figure 27. PI Parameter Setting

/** UI_0204 PI parameter setting*/


uint16_t PI_SPD_Doing_Cycle = 1; //speed PI cycle, unit:1ms
float PI_Spd_Kp_Min = 15;
float PI_Spd_Kp_Max = 50;
float PI_Spd_Ki_Min = 0.2;
float PI_Spd_Ki_Max = 0.5;
float PI_Idq_Kp_Wash = 11.0;
float PI_Idq_Kp_Spin = 5.0;
float PI_Idq_Ki_Wash = 0.03;
float PI_Idq_Ki_Spin = 0.03;
uint16_t PI_Field_Doing_Cycle = 60; //Field weaken PI cycle, unit:1ms
float PI_FieldWeaken_Ki_Init = 0.3;
float PI_FieldWeaken_Kp_Init = 1.0;
float PI_FieldWeaken_Ki_End = 0.05;
float PI_FieldWeaken_Kp_End = 0.1;

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 39
Demo System

Field Weaken and Limitation Setting


The minimum field weakening running current, the FOC current and the voltage limit can be set in this part.
Figure 28. Field Weaken and Limitation Setting

/** UI_0205 Field Weaken variables setting*/


float FieldWeaken_IsMin = -0.05; //min current in field weak,unit:A
//IsMax = Motor_CurrentMax*Limit_IdUsage calculate on-line,unit:A
/** UI_0206 FOC limit setting */
float Limit_VsUsage = 1.00; //DC voltage usage rate for FOC
float Limit_VdUsage = 0.98; //d-axis voltage usage rate for FOC
float Limit_IsUsage = 0.95; //d and q axis current usage rate
for the FOC
float Limit_IdUsage = 0.8; //d axis current usage rate in the
field weaken

UART Setting
Figure 29. UART Setting

/** UI_0207 UART setting */


uint16_t u16Baudrate = 2400; // Baud rate of UART, unit:bps
char_t cParityEn = FALSE; // TRUE -- Parity check
enable,FALSE--Disable
char_t cParitySel =
ODD_NUMBER_PARITY;//ODD_NUMBER_PARITY,EVEN_NUMBER_PARITY
uint16_t u16DataLen = 8; //data length, default 8bit
uint8_t u8StopBitLen = 1; //stop bit,default 1bit
uint8_t u8Direction = LSB_FIRST; //bit direction
//LSB_FIRST -- low bit first,MSB_FIRST -- high bit first
uint8_t Uart_u8CommErrTime= 6;//time delay for the comm error or
resume,unit:s
uint8_t Uart_u8CommDelay = 0;//time delay between Rx and Tx
switch,unit:ms
// PORT and other macro setting in UART.h

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 40
Demo System

Speed Setting
Figure 30. Speed Setting

/** UI_0208 Speed set parameter setting */


int32_t Wm_SpinSpd = 70; // switch drum speed between wash
and spin state,unit:rpm
float SpdSet_BaseTime = 0.1; //the time unit of the speed change
time from UART,unit:s, range 0~1
uint16_t SpdSet_u16AcceLmt =100; //maximum acceleration of drum
speed,unit:rpm/s
uint16_t SpdSet_u16DeceLmt = 20; //maximum deceleration of drum
speed,unit:rpm/s
uint16_t DefaultAcce = 50; //the default acceleration
for debug mode

OOB and Weight Setting


The OOB detect speed and the weight speed can be set in this part.
Figure 31. OO Band Weight Parameter Setting

/** UI_0209 OOB parameter setting */


uint16_t OOB_u16OobSpd = 89; //OOB detect speed
uint16_t OOB_u16OobSpd1 = 90; //the Second OOB detect speed
uint8_t OOB_u8StableTime = 4; //stable run time before OOBDetect
stage,unit:s

/** UI_02010 weight parameter setting */


int16_tWeight_i16WtSpdN1 = 90; //stable running at weight speed n1
int16_tWeight_i16WtSpdN2 = 130; //speed accelerate to n2
char_t Weight_cEn = TRUE;//weight function enable
float Weight_fCoe = 7.0; //coefficient of the weight data
with DC bus(BLDC)default acceleration for debug mode

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 41
Demo System

Un-Stop Setting
Figure 32. Un-Stop Parameter Setting

/** UI_02011 UnStop parameter setting */


uint8_t UnStopCCW_EleCycle = 10; //configure the unstop CCW running
ele-cycle
uint8_t UnStopCW_EleCycle = 10; //configure the unstop CW running
ele-cycle
int16_t i16UnStopSpd = 45; //configure the unstop running spd

Protection Setting
The protection setting is just the prompt. The detailed information can be found in the FW.
Figure 33. Protection Parameter Setting

/** UI_02012 protect variable setting ******/


char_t LockRotorProtectEn = TRUE;
uint32_t LockMinSpd = 10; //configure the locked min speed: 10r/min
uint32_t LockMaxTime = 4000; //configure the check lock max time: 4000ms

char_t DCVoltageProtectEn = TRUE;


uint16_t DCVoltageMax = 400; //configure the over voltage protect value:
400V
uint16_t DCVoltageMin = 200;//150; //configure the under voltage protect
value: 150V
uint32_t OverVoltageProtectTime = 50;//200; //configure the over
voltage protect max time 200ms
uint32_t UnderVoltageProtectTime = 30;//2000;//configure the under
voltage protect max time 2000ms
uint32_t RecoverVoltageProtectTime = 2000; //configure the voltage
back normal from error's time 2000ms

//other variable seen at corresponding part in file ‘S05_user/


CustomerInterface.c’

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 42
Demo System

9.2.2 HW Check
The HW performance can be self-checked by the HW check module.
If the HW has been already used for a long time, this module can be ignored. And the motor can be normally
started as shown in section ‘9.2.4 Run Motor.’
Note: The HW performance must be validated and the related FW setting must be also correctly set, otherwise
the hall self-check and the motor may not run well.

[Link] FW Setting
Set the variable FW_TEST_MODE TRUE to 1 to make the control system run in debug mode.
Set the real DC bus that is measured by multi-meter between the PN points on the HW to the macro definition as
following:
#define DC_INPUT 310 //the DC input voltage to inverter board in test mode, unit:V

[Link] HW Check Run

Click the debugger button to connect the J-link, and paste the global structure
‘HwCheck_stcPar’ into the Live Watch in the IAR debug online.
Enable the HW check function by the variable ‘cStart’ that is shown in Table 11,the HW performance such as DC
sample and HW over-current point can be self-checked by this function.
Table 11. Global Structure for HW Check

HW checkstartcommand
HW checkstopcommand
HW check finished flag
Flag for HW check error
Flag for DC voltage check error
Flag for current sample check error
Value of the HW over-current protection

When the HW check finished flag ‘cover’ is set to ‘1’, the HW check result is output by the global structure as
shown in Table 11

9.2.3 Hall Check


When the basic setting has been finished, the hall information can be self-checked by the hall check module if
the hall information is not known, take one of the DD motor for top loading washing machine for example.
And if the hall information has been known, this section can be ignored and the motor can be normally started
and then take the reference at section 9.2.4 Run Motor.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 43
Demo System

[Link] FW Setting
Set the variable FW_TEST_MODE TRUE according to Figure 24 to make the control system run in debug mode
Figure 34. Macro Definition for the Test Mode

Set the ‘motor pole pairs’ according to the motor SPEC from manufacturer to the flowing variable.
/** UI_0101 Configuration motor parameter */
uint8_t Motor_pole_pairs = 12; // the pole pairs of rotor
floatMotor_CurrentMax = 6.0; //max peak phase current,unit,A
floatMotor_Rs = 6; // phase resistor of motor,unit:ohm
floatMotor_Ls = 24; // phase inductance of motor,unit:mH
Motor_Rs: This parameter is used for the hall check validation and it can be measured by multi-meter.
Motor_Ls: This parameter is used for the hall check validation.
Set the washing machine parameters according to the following variables.
/** UI_0102Configuration WM parameter */
char_tWM_cType = DD; // washing machine type:DD,DDM,BLDC,BLDCM, just copy it
floatWm_TransRate= 1; // TransRate of washing machine, DD-->1, BLDC-->TBD

[Link] Hall Check Run

Click the debugger button to connect the J-link, and paste the global structure
‘HallCheck_stcPar’ into the Live Watch in the IAR debug online.
Enable the hall check function by the variable ‘cStart’ as Table 12 and the hall information of the motor can be
self-checked by this function. When the hall check finished flag ‘cover’ is set to ‘1’, the hall information is output
by the global structure as Table 12 and Figure 35.
Note: the load in the drum must be empty for the hall check.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 44
Demo System

Table 12. Global Structure for Hall Check

=
Hall checkstartcommand
Hall checkstopcommand
Hall check finished flag
Hall check stage
Flag for Hall check error
Flag for Hall number error
Flag for Hall status error
Flag for Hall check time-out error
The hall number of the motor
The status list table
The CCW angle table
The CW angle table

Figure 35. Hall Check Result

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 45
Demo System

[Link] Motor Parameter Configuration


The data output by the hall check function in the Figure 35 must be filled into corresponding variables or array for
the motor’s normal running in the file ‘S05 user/CustomerInterface.c’ as follows.
Figure 36. Configure Parameter to Test the Hall Phase Angle

/** UI_0101 configure motor parameter */


#define MOTOR_ID 0// motor ID number
// 0 --> new motor parameter,
// >=1 --> already debug motor,add at end of this file
#if 0== MOTOR_ID // new motor param -->LS BLDC
uint8_t Motor_pole_pairs = 12; // the pole pairs of rotor
uint8_t Motor_HallNumber = THREE_HALL;// 3or 2 hall number of the motor
float Motor_CurrentMax = 6.0; //max peak phasecurrent,unit,A
floatMotor_Rs = 6; // phase resistor of motor,unit:ohm
float Motor_Ls = 24; // phase inductance of motor,unit:mH
uint8_t Motor_HallStatuList[7] = {0,4,6,2,3,1,5};
// hall status change sequence
int32_t Motor_HallAngleCCW[7] =
{0,DEGREE(270),DEGREE(150),DEGREE(210),DEGREE(30),DEGREE(330),DEGREE(90)};
int32_t Motor_HallAngleCW[7] = {0,DEGREE(150),DEGREE(30),DEGREE(90),\

DEGREE(270),DEGREE(210),DEGREE(330)};
#endif

MOTOR_ID: The motor ID for user, if the new motor is used for the debug, the motor can be set in the region ‘#if
0== MOTOR_ID’ and set the MOTOR_ID = 0. If the motor runs well with these motor parameters, these
parameters can be fixed and added at the end of the ‘S05 user/CustomerInterface.c’’. And you can switch the
motor debug more conveniently and quickly if you have the debugged parameter
Motor_pole_pairs : lt must be got by the manufacturer
Motor_CurrentMax: It can be got by the manufacturer or determined by the phase peak current at
the motor brake stable stage
Motor_Rs: The parameter of motor phase resistor, it can be measured by the multi-meter.
Motor_Ls: The parameter of motor phase inductance.
Motor_HallStatuList[7]: The hall status change sequence, it can be self-checked and filled sequentially according
to buffer ‘HallCheck_stcPar .u8StatusTable[8]’ that is shown in Figure 36
Motor_HallAngleCCW[7]: The hall angle matched with each hall status for CCW running, it can be self-checked
and filled sequentially according to buffer ‘HallCheck_stcPar .i32Q22_AngleCCW[8]’ that is shown in Figure 35

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 46
Demo System

Note:
 Due to the check error, the angle can be set to the integrate number nearby. If
‘HallCheck_stcPar .i32Q22_AngleCCW[1]=269’ is shown in Figure 35, we fill the buffer
‘Motor_HallAngleCCW[1]=270’ as Motor_HallAngleCW[7]: The hall angle matched with each hall status for CW
running, it can be self-checked and filled sequentially according to buffer
‘HallCheck_stcPar .i32Q22_AngleCW[8]’ that is shown in Figure 36

9.2.4 Run Motor


When the hall angle and status list have been checked and the HW performance check is correct by the FW
TEST MODE, the motor can be started for the demo show.
1. Reset the variable FW TEST MODE macro definition in ‘S05_user/Customer Interface.c’ as following.
char_t FW_TEST_MODE TRUE // HW\Hall check set
2. Check the basic motor and HW parameter setting in the user interfaces. If the setting does not match the real
HW and washing machine parameter, there will be an unexpected running error in the motor running.
3. Compile project and download program to inverter board by the J-link.
a) Click button A that is shown in Figure 37 to connect the J-link and download the FW into the MCU,
b) Click button B to run the FW online.
c) After two seconds the relay is switched on, you can enter none-zero speed value to start the motor in
the structure that is shown as C.
For example, when the variable ‘Motor_stcRunParam.i16WmCommandSpdRpm = 90’ by your online input, the
drum speed of the washing machine will CCW run to 90rpm.
Figure 37. Motor Run by J-link

A D B

And you can take the Table 13 for your detailed reference for the speed command.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 47
Demo System

Table 13: Drum Running Status by the Command Speed

Motor_stcRunParam.
Drum Direction Motor’s status
i16WmCommandSpdRpm
>0 CCW Running
<0 CW Running
=0 Stop Stop

Note:
 All of the command speed from the debugger or UART is defined as the drum speed.
 Do not click the button D to break the FW running, the HW over-current or DC over fault may appear and
damage the HW if you do that.
4. Watch the important variable to check the motor running performance such as whether the real motor is
achieved the command speed and running speed is stable. Detailed meaning about the important variable is
shown in the previous section ‘5.2 Global Structure and Variable Definition’ for your reference.

9.2.5 Speed Acceleration and Deceleration


After run motor normally, you can run motor in any speed, and the type speed of the drum for front loading
washing machine can be taken for the reference at Table 14
Table 14. Typical Running Status by the Command Speed

Motor_stcRunParam. Drum
Description
i16WmCommandSpdRpm Direction
30~50 CCW The Drum speed runs at 30~50rpm for the wash mode
-30~-50 CW The Drum speed runs at 30~50rpm for the wash mode
The Drum speed runs at 89rpm for the OOB detection before the
89 CCW
spin mode
400 CCW The Drum speed runs at 400rpm for the pre-spin
The Drum speed runs at 100rpm to drain away water by the host
100 CCW
after the pre-spin
1000 CCW The Drum speed runs at 1000rpm for the spin mode
1200 CCW The Drum speed runs at 1200rpm for the spin mode
0 Stop motor The motor will stop working

The default speed changing time is 10, which means 1s as shown in 9.2.1.2Advanced Variables Setting.
If you want to change the default acceleration, you can disable the UART macro definition ’UARTEN ’ in UART.h
and set the default acceleration ‘DefaultAcce’ or the maximum acceleration ‘SpdSet_u16AcceLmt’ as you want.
When the motor needs to reverse the running direction, you should stop the motor and then restart the motor to
run in another direction.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 48
Demo System

9.3 Troubleshooting
9.3.1 Motor Start-up
When the motor can’t start-up normally, there may be 2 reasons:
1. The Hall Angle found in debug mode is fault. Even if the washing machine’s load is empty, it also can’t
Start-up.
2. The startup parameter is not set correctly. User should change the parameter in ‘S05_user/Customer
Interface.c’ and refer to the section ‘Motor Start-up’

9.3.2 Protection
When the motor is stopped without the normal stop command, the protection fault may appear, you can see the
value of the variable ‘Motor_stcRunParam.u16FaultCode’ in the watch window and the code is assigned by the
bit OR operation. The fault codes for each protection are shown as below. You can match the value with these
fault codes to find what protection is performed.
#define NORMAL_RUNNING 0x0000 //no error
#define OVER_VOLTAGE 0x0001 //DC bus over-voltage
#define UNDER_VOLTAGE 0x0002 //DC bus under-voltage
#define SW_OVER_CURRENT 0x0004 //over-current
#define MOTOR_OVER_CURRENT 0x0008 //over-current of HW
#define MOTOR_LOSE_PHASE 0x0010 //motor lose phase
#define NO_CONECT_COMPRESSOR 0x0020 //no motor connected
#define AD_MIDDLE_ERROR 0x0040 //current sample 2.5V offset error
#define SF_WTD_RESET 0x0080 //FW watch dog reset
#define MOTOR_LOCK 0x0100 //motor lock
#define UNDEFINED_INT 0x0200 //undefined interrupt
#define HW_WTD_RESET 0x0400 //HW watch dog reset
//washing machine fault code
#define POWER_OVER 0x0800 //motor over-power
#define IPM_TEMPOVER 0x1000 //IPM over current
#define HALL_LOST 0x2000 //Hall lost fault
#define COMM_ERROR 0x4000 //communicate error code
#define SINK_ERR 0x8000 //IPM circuit fault
There may be different processing logic about the protection.
The fault code may not be cleared except the DC bus voltage protection for the inverter DEMO. That is the FW
may not run again when the protection fault happens. You can access the variable
‘Motor_stcRunParam.u16FaultCode’ to make your own protection processing logic.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 49
Demo System

9.3.3 Drum Direction Reversed


If the running direction of the drum does not match the requirement of washing machine, there are two
possibilities for this trouble.
 The type of washing machine is not correctly set as section WM Parameter Setting. The CCW direction of
motor and drum are different from DD or DDM for the belt drive washing machine.
 The U V W of the motor phase is not correctly connected on the corresponding port on the HW. If the
motor phase is not correctly connected, the Hall status list and angle must be re-checked and modified to
the motor parameter shown in section 9.2.3 Hall Check.

9.3.4 Power Consumption Higher


If the power or the phase current is bigger than other solution, and you can watch the value of d-axis voltage
‘Motor_2rVoltage.Q8_d’on the rotating frame at the speed of 45rpm.
If the variable’s value is out the range of -10V to 10V, which indicates the rotor angle corrected by the hall may
not be so accurate.
You can do as follows:
 The Hall status list and angle must be re-checked and modified to the motor parameter shown in section
9.2.3 Hall Check.
 If the power consumption is still higher, you can make the same offset on correct angle for each hall
status, the array is ‘Motor_HallAngleCCW[7], Motor_HallAngleCW[7]’ that is located at file
‘S05_user\CustomerInterface.c’. Re-compile the projection and debug at the same working condition, and
you can find the best angle list when the power is the best.

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 50
10. Additional Information

For more Information on Cypress semiconductor products, visit the following websites:
English version address:
[Link]
Chinese version address:
[Link]
Please contact your local support team for any technical question
America: [Link]
Other: [Link]

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 51
11. Revision History

Document Revision History

Document Title: FM3, Inverter Sensor Washing Machine Firmware User Manual

Document Number:002-04442

Revision Issue Date Origin of Description of Change


Change
** 01/26/2015 CBZH Initial Release
*A 02/24/2016 CBZH Migrated Spansion guide “AN706-00095-1v0-E “to Cypress format

FM3, Inverter Sensor Washing Machine Firmware User Manual, Doc. No. 002-04442 Rev. *A 52

You might also like