the power to amaze. - -spintrol technology · the power to amaze. ! example code v3 ... motor...

84
The Power to Amaze. EXAMPLE CODE V3 FOR SPEED INTEGRAL Name: Sam Wu Date: 8 August 2014

Upload: duongliem

Post on 29-Aug-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

The Power to Amaze. !

EXAMPLE CODE V3 FOR SPEED INTEGRAL !

Name: Sam Wu!

Date: 8 August 2014!

2

1.  What Improvements from Example Code V3 2.  File Structure of Example Code V3 3.  Main Loop & the Key Routines 4.  Something You Need to Know before the Tuning 5.  Parameters Tuning

a.  Motor Start Up at Standstill b.  Open/Close-Loop Speed Control c.  Angle Shift (AS) Correction d.  Motor Start Up at Forward Free Running e.  Motor Start Up at Reverse Free Running

AGENDA

3

f.  Change Direction on Running Motor g.  Over/Under Voltage Protection h.  Over Temperature Protection i.  Current Limit Protection j.  Motor Short Circuit Protection k.  Lock Rotor Protection

6.  Advanced Start-Up Methods 7.  Appendixes

AGENDA – cont.

4

1.  Enhance tuning/debug features with additional program functions (TuningAssist.c ).

a.  Status in each operation phase is indicated on AO pin. b.  Turning phase and result is indicated on AO pin. c.  Error codes are indicated on AO pin when error occurs. d.  Rotor alignment procedure to help tag and identify physical electrical angles.

2.  Various features to support fan applications. a.  New procedures to support direction changeover in a running fan. b.  Various user interface functions such as IR / RF remote control, EEPROM, UART, Rotor

position detection at standstill.

What Improvements from Example Code V3

5

3.  Easy for customization. a.  Parameter declarations in single header file (Parameter_SpeedIntegral.h). b.  I/O pin assignments in single header file (Parameter_SpeedIntegral.h). c.  Various software switches to enable/disable features, protection functions ( except OCH/OCL/

SHORT ), tuning/debug procedures.

4.  Same programs for both FCM8531QY and FCM8531RQY. 5.  Add IEC 60730-1 Error Handling procedures. 6.  Dual mechanisms for motor block protection.

What Improvements from Example Code V3 – cont.

6

File Structure of Example Code V3

Basic  Program  Files

Compiler-­‐Define.h

Main.c MCS51.c/h MotorCtrl.c/h Program.c/h

SVM_Table.c FCM8531.h MSFR-­‐Define.h

AMC  Library  UHlity  Files

AMC_SpeedIntegral.c/h AsTable_SpeedIntegral.h Parameter_SpeedIntegral.h

Add-­‐On  UHlity  Files

RPD_LV.c/h

EEPROM.c/h UART.c/h IR_Remote.c/h RF_Remote.c/h

RPD_HV.c/h TuningAssist.c/h

7

File Name Description

Main.c Main procedure

MCS51.c / h Initialization of MCS51 peripherals and Interrupt Service Routines

MotorCtrl.c / h Initialization of Motor Control peripherals and Interrupt Service Routines

Program.c / h User procedures

SVM_Table.c Space Vector Modulation Table

compiler-define.h Compiler declarations for Keil C and SDCC

FCM8531.h FCM8531 SFR declarations

MSFR-define.h FCM8531 MSFR declarations

File Structure of Example Code V3 Brief Introduction of Basic Program Files

8

File Name Description

AMC_SpeedIntegral.c / h Initialization of AMC and communication procedures for AMC between MCU

AsTable_SpeedIntegral.h Angle Shift (AS) Table and its declarations

Parameter_SpeedIntegral.h User parameters, I/O assignment, Conditional Compiling

File Structure of Example Code V3 Brief Introduction of AMC Library Utility Files – cont.

9

File Name Description

TuningAssist.c / h Tuning/Debug common procedures

EEPROM.c / h I2C EEPROM procedures

UART.c / h UART procedures

IR_Remote.c / h Example codes for IR remote control

RF_Remote.c / h Example codes for IR remote control

RPD_HV.c / h Position identification of Rotor Startup for high voltage motor

RPD_LV.c / h Position Identification of Rotor Startup for low voltage motor

File Structure of Example Code V3 Brief Introduction of Add-On Utility Files

10

Main Loop & the Key Routines Operation of Main Loop

Main

Is RUN?

Is Free?

Is Free?

Is Really OFF?

Turn Off Motor

Initialize Secondary Var.

Initialize Primary Var.

Check Motor Status

Update Duty & AS

Turn Run Motor

Output Operating Status / Error Code

to AOUT

Yes

No

Yes

Yes

Yes

No

No

No

11

Variable Description

_btMotor_Run_Ena Run/Stop control flag. “1”= Run, “0”= Stop. When SW1 is positioned to the“Run”side and VR1 output voltage is larger than VSP_THRESHOLD , this flag is set to“1”.

_btNoneLatch_Fault_Occurring Non-latched fault flag. “1”indicates non-latched fault occurs and motor stops immediately; motor resume to run when the fault is removed. “0” indicates no fault. Non-latched fault:OVP, UVP, OTP (optional), etc.

_btLatched_Fault_Occurring Latched fault fag. “1”indicates latched fault occurs and motor stops immediately; motor will not resume to run when the fault is removed until Run/Stop control flag (_btMotor_Run_Ena) is reset to “0”and set to “1”again. “0”indicates no fault Latched fault: SCP, AMC fault, Safety Warning RA State 2, OTP (optional), etc.

_btMotor_IsFree Motor Free status. “1”indicates motor is in Free state. “0”indicates motor is in RUN state. This flag is used to prevent frequent commands of Run/Free between MCU and AMC.

Main Loop & the Key Routines Key Variables of Main Loop

12

Main Loop & the Key Routines Operation of Key Routine: Motor_Status_Checking()

0 • Turn On Low-Side of U-Phase •  Read occurrence sequence of IB & IC and determine running direction of motor • Count interval time between IB 與 IC → _wCalculateSpeed_CNT.U16

1 • If :no phase current occurrence within the time window of LOWEST_LINKUP_SPEED_120DT • Then:it means motor is at standstill or very low speed that phase current is not readable • Let:MCU send brake command and let motor get close to standstill state. Then start up the motor at standstill mode

2 • If:( (IB lead IC) AND (_btPresent_DIR=CCW) ) OR ( (IC lead IB) AND (_btPresent_DIR=CW) ) • Then:it indicate motor is in forward free running state • Let:AMC start the motor at forward free running mode (AMC_FORWARD_STARTUP)

3

• If:None of above AND (_wCalculateSpeed_CNT.U16 < LOWEST_DECEL_SPEED_120DT) • Then:it indicates motor is running at reverse direction and high speed • Let:AMC dir same as present motor direction and start the motor at forward mode, but decelerate the speed to low speed. Then start the motor again at forward startup

mode

4 • If:None of above • Then:it indicate motor is running at reverse direction and low speed • Let:AMC start the motor at reverse startup mode (AMC_BACKWARD_STARTUP)

13

Variable Description

_btMotor_StateCheck_Ena A flag. “1”indicates it needs to check motor states of standstill, forward running, or reverse running. “0”indicates motor state has been checked.

_btMotor_Brake_Ena A flag. “1”indicates it needs to do brake. “0”indicates it has been braked

_btMotor_IsStandstill A flag. “1”indicates motor is in standstill state, user should start the motor at standstill mode.

_btDIR_Change_Decelerating A flag. “1”indicates motor is running in a period of changing direction and decelerating.

_wCalculateSpeed_CNT.U16 Speed counter of forward / reverse running motor. Counter length spans time interval of 120º electrical degrees. Conversion formula is below :

RPM = ( 60 / ( _wCalculateSpeed_CNT.U16 × 3 / fPWM )) / ( P / 2 )

P : pole number of the motor fPWM : 15 kHz (frequency of PWM)

_wForwardRun_Duty.U16 Initial Duty value for motor forward startup. User should send _wCalculateSpeed_CNT.U16 to AMC and receive Omega in return. Then _wForwardRun_Duty.U16 = Omega * 35 / OMEGA_TO_DUTY_RATIO.

Main Loop & the Key Routines Key Variables of Key Routine: Motor_Status_Checking()

14

Main Loop & the Key Routines Operation of Key Routine: INTERRUPT(ISR_T0, VECTOR_ET0)

1 • Read VSP_PIN input voltage and CMD_PIN switch state, then set _btMotor_Run_Ena value.

2 • Read DIR_PIN switch state, then set _btPresent_DIR value.

3 • Check if fault occurs in AMC, and proceed error handling procedure.

4 • Read VSENSE_PIN voltage, judge if OVP or UVP, and proceed error handling procedure.

5 • Read RT_PIN voltage, judge if OTP, and proceed error handling procedure.

6 • Read IA/IB/IC voltage, judge if they are over OCP threshold, and proceed error handling

procedures.

v  Interrupt / 1 ms

15

Variable Description

_btPresent_CMD SW1 Run/Stop state. “1”is Run, “0”is Stop.

_btPresent_DIR SW2 CW/CCW state. “1”is CW, “0”is CCW.

_btAMC_Fault AMC Fault fault flag. “1”indicates fault occurs in AMC. When Speed-Integral’s integral value (Theta, θ) is larger than LOSS_STEP_VALUE, or Theta has no change in the time window of AMC_THETA_LOSS_COUNT. This flag will be set to“1”to indicate motor is losing step or blocked. AMC will wait until timeout of RECOVERY_WAIT_TIME , then AMC start up motor again with reties of RECOVERY_RETRY_TIMES.

_btVBUS_OVP_Occurring VBUS’s Over-Voltage Protection (OVP) fault flag. “1”indicates OVP occurs. When VSENSE_PIN‘s input voltage is larger or equal to VBUS_OVP_THRESHOLD, the flag is set to“1”and motor stops, while the flag is cleared to“0”when the voltage drops below VBUS_OVP_RELEASE and motor starts over.

Main Loop & the Key Routines Key Variables of Key Routine: INTERRUPT(ISR_T0, VECTOR_ET0)

16

Variable Description

_btVBUS_UVP_Occurring VBUS’s Under-Voltage Protection (UVP) fault flag.“1”indicates UVP occurs. When VSENSE_PIN’s input voltage is smaller than VBUS_UVP_THRESHOLD, the flag is set to“1”and motor stops. The flag is cleared to“0”when the voltage is larger than VBUS_UVP_RELEASE and motor starts over.

_btSPM_OTP_Occurring SPM(Smart Power Module)’s Over-Temperature Protection (OTP) fault flag. “1”indicates OTP occurs. When RT_PIN‘s input voltage is larger or equal to SPM_OTP_THRESHOLD, the flag is set to“1”and motor stops. When the voltage is smaller than SPM_OTP_RELEASE, the flag is cleared to“0”and motor start over.

_btCurrentLimit_Triggered “1”indicates Current Limit Level is triggered. When average peak voltage(current) of IA, IB, and IC is larger than CURRENT_LIMIT_THRESHOLD, the flag is set to “1”, _wSpeed_Reference.U16 pause increment counting. When the average peak voltage is smaller than CURRENT_LIMIT_THRESHOLD, this flag is set to“0”, _wSpeed_Reference.U16 resume increment counting.

_bVSP_Voltage VR1 (VSP_PIN)‘s input voltage. The data is updated every 8 ms.

Voltage = _bVSP_Voltage × 4 / 255

Main Loop & the Key Routines Key Variables of Key Routine: INTERRUPT(ISR_T0, VECTOR_ET0)

17

Variable Description

_wSpeed_Target.U16 Speed target, the data is updated every 8 ms.

In Open-loop (SPEED_CLOSE_LOOP_ENA = 0) mode, this variable denotes PWM Duty‘s target value. _wSpeed_Target.U16 = _bVSP_Voltage × 2

In Close-loop (SPEED_CLOSE_LOOP_ENA = 1) mode, this variable denotes frequency of electrical angle converted from target speed. _wSpeed_Target.U16 = ( _bVSP_Voltage × ( MAX_SPEED_FREQ -

MIN_SPEED_FREQ ) / 255 ) + MIN_SPEED_FREQ

Main Loop & the Key Routines Key Variables of Key Routine: INTERRUPT(ISR_T0, VECTOR_ET0)

18

Main Loop & the Key Routines Operation of Key Routine: INTERRUPT(ISR_T1, VECTOR_ET1)

ISR_T1

Is AMC Start-Up Complete?

•  Read current speed (Omega) from AMC

•  Update to _wSpeed_Buffer.U16

Yes

No

•  Adjust _wSpeed_Reference.U16 to meet _wSpeed_Target.U16

Updating Cycle Time = SPEED_REFERENCE_ACC_TIME

•  Convert Omega to Frequency à _wSpeed_FREQ.U16

•  Follow _wSpeed_Reference.U16 and _wSpeed_FREQ.U16 to Calculate _wDuty_Buffer.U16 use the PI control algorithm Updating Cycle Time = SPEED_LOOP_ACC_TIME

Is Close Loop?

END

•  _wDuty_Buffer.U16 = _wSpeed_Reference.U16

•  _btDuty_Updaut_Ena = 1

•  Read current duty from MSFR •  Initialize _wSpeed_Reference.U16

Yes

No

v  Interrupt / 1 ms

19

Variable Description

_btDuty_Update_Ena Flag to indicate a request to PWM Duty update. “1”denotes AMC’s PWM Duty needs update, “0”indicate the update is done. Every time period of SPEED_LOOP_ACC_TIME, T1 ISR will get a new PWM Duty value and set the flag to“1”. The new PWM Duty will be sent to AMC in main loop, and the flag is cleared to“0”.

_wSpeed_Buffer.U16 Omega (ω) of current speed. Read out from AMC every 1 ms.

_wSpeed_Reference.U16 Reference value (curve) during speed regulation. This variable is increased / decreased 1 at every interval of SPEED_REFERENCE_ACC_TIME until its value is equal to _wSpeed_Target.U16. In Open-loop (SPEED_CLOSE_LOOP_ENA = 0), this variable denotes PWM Duty. In Close-loop (SPEED_CLOSE_LOOP_ENA = 1), this variable denotes frequency of speed.

Conversion formula of speed and frequency : f = ( RPM x 10 x ( P / 2 )) / 60 P : pole number of the motor

Main Loop & the Key Routines Key Variables of Key Routine: INTERRUPT(ISR_T1, VECTOR_ET1)

20

Variable Description

_btDIR_Ready_For_Veering Flag to indicate readiness for direction change. When direction change is requested (SW2 is positioned to the other side), Motor speed will drop to the frequency of VEERING_SPEED_FREQ, and this flag will be set to“1”to indicate the speed is low enough for changing motor running direction.

_wSpeed_FREQ.U16 Current frequency of speed. It is obtained by converting _wSpeed_Buffer.U16 (Omega) as below,

_wSpeed_FREQ.U16 = _wSpeed_Buffer.U16 × 1000 / OMEGA_TO_FREQ_PARAMETER

OMEGA_TO_FREQ_PARAMETER = tS × 2(32 – RESOLUTION_VALUE) × 100

tS : 125 µs (sampling time of Speed-Integral)

_wDuty_Buffer.U16 Next setting value of PWM Duty. When _btDuty_Update_Ena is“1”, this value will be sent to AMC in main loop.

Main Loop & the Key Routines Key Variables of Key Routine: INTERRUPT(ISR_T1, VECTOR_ET1)

21

Something You Need to Know Before the Tuning a. Selection of Shunt Resistor

Appropriate Setting for OCH/OCL/SHORT

Resistance Range

Wattage

RSHUNT : Resistance of Shunt Resister PIN-MAX : Maximum Input Power VM-DRV : Driving Voltage of Motor

(VBUS)

PSHUNT : Rated Power of Shunt Resister

DRVM

MAXINSHUNT

DRVM

MAXIN

VP

vR

VP

v

≥≥3.06.0

OCL Setting Area

OCH Setting Area

SHORT Setting Area

0 V

1 V

2 V

3 V

4 V 2

2

××

−≥ ⎟⎟⎠

⎞⎜⎜⎝

⎛SHUNTSHUNT R

DRVM

MAXINPVP

22

PURPOSEØ  Tuning / Verification of reliable Sensor-less Start-Up , 100% successful rate based on our

robust methodology. Ø  Easy to track the failure angle. Ø  Easy to measure relationship between PWM Duty and magnetic force in the motor.

Something You Need to Know Before the Tuning b. Marking the Position of Electrical Angle for Motor Rotor

23

IMPLEMENTATION1.  Hold the motor ( stator ) by a stable platform, and install a index as shown in photo. 2.  Enable one and only one of following Conditional Compiling selections in

Parameter_SpeedIntegral.h, compile the codes and program it into FCM8531. #define ROTOR_POS_MARKING_0D 1 // 1= Enable, 0= Disable #define ROTOR_POS_MARKING_60D 0 // 1= Enable, 0= Disable #define ROTOR_POS_MARKING_120D 0 // 1= Enable, 0= Disable #define ROTOR_POS_MARKING_180D 0 // 1= Enable, 0= Disable #define ROTOR_POS_MARKING_240D 0 // 1= Enable, 0= Disable #define ROTOR_POS_MARKING_300D 0 // 1= Enable, 0= Disable

3.  Turn on RUN Switch, motor will be forced to the designated angle by the force defined by ALIGNMENT_DUTY. When motor come to a complete stop , mark a mark on where the index is pointing to.

4.  Repeat step 2 and 3 until all angles of 0° / 60° / 120° / 180° / 240° / 300° are all marked.

Something You Need to Know Before the Tuning b. Marking the Position of Electrical Angle for Motor Rotor

24

Parameters Tuning a. Motor Start Up at Standstill

OPERATIONAlignment Ramp-Up Speed-Integral

N

S

N S

N

S N

S Strongest Magnetism

Alignment Weakest Magnetism

Alignment Ramp-Up

Driving vector (ALIGNMENT_ANGLE)

25

Parameters Tuning a. Motor Start Up at Standstill

RELATED FUNCTIONsFunction Name Purpose Location

void Motor_Status_Checking() Check motor state and judge if standstill. Program.c

void Motor_Braking() Brake the motor to completely stop it Program.c

void Set_Motor_Run(SEG_BIT btDIR) Send start command to AMC to start up the motor

Program.c

26

Parameters Tuning a. Motor Start Up at Standstill

PARAMETERS DESCRIPTIONDuty

Time

ALIGNMENT_TIME

ALIGNMENT_DUTY

RAMPUP_START_DUTY

RAMPUP_END_DUTY

_wSpeed_Target.U16

ALIGNMENT_WAIT_TIME

RAMPUP_ACC_TIME

Alignment Period

Ramp-Up Period

Speed-Integral Working Period

27

Parameters Tuning a. Motor Start Up at Standstill

PARAMETERS DESCRIPTION – cont.Parameter Name Description

MOTOR_POLE« Number of poles.

ALIGNMENT_DUTY« Range: 0 ~ 255. Max value: 255, 255 = Duty 50%. The bigger the value is, the larger the magnetic force will be and larger vibration will occur when rotor is propelled to the designated position. Usually minimal Duty which is able to propel rotor from ALIGNMENT_ANGLE + 180º to ALIGNMENT_ANGLE is used for this parameter.

ALIGNMENT_TIME« Alignment working time. Range: 1 ~ 250. Unit: 20 ms. Max value = 250 x 20 ms = 5 seconds, Usually the time needed to propel rotor from ALIGNMENT_ANGLE + 180º to ALIGNMENT_ANGLE is used to for this parameter.

28

Parameters Tuning a. Motor Start Up at Standstill

PARAMETERS DESCRIPTION – cont.Parameter Name Description

ALIGNMENT_WAIT_TIME Range: 0 ~ 250, Unit: 20 ms. This is an optional parameter and is usually set to “0”, which means disabled. Other value will enable this option. After a period of ALIGNMENT_TIME, AMC will shut off output PWM for a period of ALIGNMENT_WAIT_TIME if it is non-zero, then transit to next step, Ramp-Up. The purpose is to give motor more time to rest and minimize vibration before entering next step, Ramp-Up. Unless mechanical load is big such as ceiling fan, this parameter is usually not necessary. * ALIGNMENT_TIME + ALIGNMENT_WAIT_TIME ≤ 5 seconds

ALIGNMENT_ANGLE The designated angle for alignment. Range: 0 ~ 255. Usually it is set 0º. Setting Value = Angle x 255 / 360

RAMPUP_START_DUTY« Initial Duty in Ramp-Up region. Range: 0 ~ 255, 255 = Duty 50%. The power outputting to motor is proportional to this value. KP_VALUE, RAMPUP_ID_ERR and RESOLUTION_VALUE, are used to determine acceleration slope of rotating vector. Output Duty force and slope shall work in harmony . Faster slope shall go with larger Duty.

29

Parameters Tuning a. Motor Start Up at Standstill

PARAMETERS DESCRIPTION – cont.Parameter Name Description

RAMPUP_END_DUTY« End Duty in Ramp-Up region. Range: 0 ~ 255, 255 = Duty 50%. This parameter must be equal or larger than RAMPUP_START_DUTY. Usually it is set same as RAMUP_START_DUTY.

RAMPUP_ACC_TIME« Ramp-Up acceleration period. Range: 1 ~ 65535. Unit: 1 ms. When RAMPUP_START_DUTY = RAMPUP_END_DUTY, Ramp-Up Period = RAMPUP_ACC_TIME

When RAMPUP_START_DUTY ≠ RAMPUP_END_DUTY, Ramp-Up Period = (RAMPUP_END_DUTY - RAMPUP_START_DUTY)

x RAMPUP_ACC_TIME

RAMPUP_ID_ERR Range: 1 or 2. This parameter will influence the slope of rotating vector in Ramp-Up. “2” will accelerate the ramp up.

MINIMUM_SPEED An optional parameter, please set 0.

30

Parameters Tuning a. Motor Start Up at Standstill

PARAMETERS DESCRIPTION – cont.Parameter Name Description

DFILTER_BIT Order of Digital Filter. Range: 1~10. This parameter will influence stability of angle estimation. System response will be slow if the order value is too big. Usually the value is 1 or 2.

RESOLUTION_VALUE« Resolution of Speed-Integral angle calculation. Range: 1~16. When speed is larger than 500 RPM, it shall set 16. Otherwise, it shall be 12 or 10 if max speed is less than 500 RPM. This parameter is interactively associated with KP_VALUE and KI_VALUE. In case this parameter is adjusted, in general KP_VALUE and KI_VALUE should be adjusted as well, especially KP_VALUE. The smaller this parameter is, the larger KP_VALUE should be.

KP_VALUE« Proportional parameter of PI controller of Speed-Integral. Range: 0~65535. System response will be faster and stability is poorer with larger KP. KP_VALUE and KI_VALUE should be adjusted together to get stable response and eliminate steady error. KP_VALUE will also influence slope of Ramp-Up. The larger the value is , the faster the slope. When RESOLUTION_VALUE = 16 , 200~500 are chosen for it.

31

Parameters Tuning a. Motor Start Up at Standstill

PARAMETERS DESCRIPTION – cont.Parameter Name Description

KI_VALUE« Integral parameter of PI controller of Speed-Integral. Range: 0~65535. The larger this value is, the larger steady error will be. Usually 256 is chosen for it.

LOSS_STEP_VALUE« Loss Step threshold. When integrator’s output value of Speed-Integral is larger than this threshold, AMC will recognize it as loss step and set up AMC_FAULT to signal MCU. Usually we recognize it for motor-stalled.

LOSS_STEP_VALUE = (( P × tS × 2(40-RESOLUTION_VALUE) × RPMMAX / 120) × K ) / 65536

P : pole number of the motor tS : 125 µs (sampling time of the algorithm) RPMMAX : the maximum speed of the motor K : 1.5 or 2 (multiple constant)

32

Parameters Tuning a. Motor Start Up at Standstill

TUNING PROCEDURE & HINT1.  Monitored Signals:AO, IA, IB, IC

Alignment Ramp-Up

AO

IA, IB, IC

5.  Link up the Speed-Integral.

4.  Start on the Ramp-Up phase.

3.  Turn run the motor & enter the Alignment phase.

2.  Use the brake to make sure the motor if it really is at the standstill.

1.  Check the motor status.

33

Parameters Tuning a. Motor Start Up at Standstill

TUNING PROCEDURE & HINT – cont.1.  Firstly turn off all protections.

#define CURRENT_LIMIT_ENA 0 #define OVP_UVP_FUNCTION_ENA 0 #define OTP_FUNCTION_ENA 0 #define OTP_LATCH_ENA 0

2.  Set ALIGNMENT_TIME to max – 250. (250 x 20 ms = 5 seconds) 3.  Manually turn rotor to 180º position, which was previously marked . Based on the ALIGNMENT_DUTY vs. physical force

that user experienced in the chapter of Marking the Position of Electrical Angle for Motor Rotor, a suitable ALIGNMENT_DUTY should be determined.

4.  Start up the motor and watch the move. Adjust ALIGNMENT_DUTY to ensure the force is tepid and spending time is not too much when rotor moves from 180º to 0º.

5.  Manually turn rotor to 90º and 270º. Restart the motor and check if the force is too strong or not when rotor moving to 0º, and make a fine tuning on ALIGNMENT_DUTY if necessary. But the fine tuning should ensure that rotor moves from 180º to 0º is still workable.

6.  Based on final value of ALIGNMENT_DUTY, time spent from 180º to 0º will be assigned to ALIGNMENT_TIME.7.  Select suitable RAMPUP_START_DUTY, RAMPUP_END_DUTY 和 RAMPUP_ACC_TIME.

34

Parameters Tuning a. Motor Start Up at Standstill

TUNING PROCEDURE & HINT – cont.9.  RAMPUP_START_DUTY and RAMPUP_END_DUTY must be larger than ALIGNMENT_DUTY.10.  Normally RAMPUP_START_DUTY are RAMPUP_START_DUTY set to be same, Ramp-Up can be successfully achieved. 11.  When phase current starts decreasing, it indicates the transition period of leaving Ramp-Up region and entering Speed-

Integral loop. 12.  Reading Theta information on AO pin and fine tuning KP_VALUE and KI_VALUE to watch Ramp-Up’s slope. 13.  Reading current information on IA, IB, IC pins, fine tuning RAMPUP_START_DUTY, RAMPUP_START_DUTY and

RAMPUP_ACC_TIME. 14.  The larger motor load inertia, the required ALIGNMENT_TIME and RAMPUP_ACC_TIME is larger, e.g. in ceiling fan

application in which load inertia is larger, ALIGNMENT_TIME is set to larger than 1 s and RAMPUP_ACC_TIME is 3 ~ 4 s. For pedestal fan in which load inertia is smaller. ALIGNMENT_TIME = 0.7 s and RAMPUP_ACC_TIME = 0.4 s are more or less met.

35

OPERATION

Parameters Tuning b. Open/Close-Loop Speed Control

Speed-Integral Working Period

Duty

Time

SPEED_REFERENCE_ACC_TIME

_wSpeed_Target.U16

_wSpeed_FEEQ.U16 @ bigger SPEED_LOOP_ACC_TIME

_wSpeed_Reference.U16

_wSpeed_FEEQ.U16 @ smaller SPEED_LOOP_ACC_TIME

36

RELATED FUNCTIONs

RELATED VARIABLESv  Please refer to the slides 19 and 20.

Parameters Tuning b. Open/Close-Loop Speed Control

Function Name Purpose Location

INTERRUPT(ISR_T1, VECTOR_ET1) Calculate PWM Duty value for speed close / open loop. MCS51.c

void Get_Motor_Speed() Read Speed Info(Omega) provided by AMC from MSFR_OMEGAH/L.

Program.c

void UpdateCurrentDuty() Read PWM Duty set by AMC from MSFR_DUTYA/L. Program.c

void OMEGA_To_Frequency(U16 wOMEGA_Value)

Convert unit of speed info in Omega to frequency. Program.c

Main Loop When _btDuty_Update_Ena is“1”, PWM Duty will be sent to AMC.

Main.c

37

RELATED PARAMETERS

Parameters Tuning b. Open/Close-Loop Speed Control

Parameter Name Description

SPEED_REFERENCE_ACC_TIME Time interval of updating _wSpeed_Reference.U16. Range: 0~65535. Unit: 1 ms. When motor load inertia is large, this parameter should be enlarged to increase the time interval, i.e. reduce the frequency of update.

SPEED_LOOP_ACC_TIME Time interval of updating PI in Close-loop speed control. Range: 0~65535. Unit: 1 ms. This parameter is valid only if SPEED_CLOSE_LOOP_ENA = 1. If the parameter is too small, Speed will run through Overshoot / Undershoot oscillation before reaching the target speed. Vice versa, it will take longer time to reach target speed.

OMEGA_TO_FREQ_PARAMETER Transitive parameter for rotating speed converted from Omega into Frequency.

OMEGA_TO_FREQ_PARAMETER = tS × 2(32-RESOLUTION_VALUE) × 100

tS : 125 µs (sampling time of Speed-Integral)

38

Parameters Tuning b. Open/Close-Loop Speed Control

TUNING PROCEDURE & HINT1.  Monitored Signals: AO, IA, IB, IC 2.  Set AO_SHOWS_SPEED_REFERENCE to “1”, Other AO_SHOWS_xxxx are ”0”. 3.  Adjust SPEED_REFERENCE_ACC_TIME and monitor AO pin to check _wSpeed_Reference.U16’s up-rising slope to get

a moderate one. 4.  Set AO_SHOWS_SPEED_FREQ to“1”and AO_SHOWS_SPEED_REFERENCE to“0”. 5.  Adjust SPEED_LOOP_ACC_TIME and monitor AO pin to check real speed change( _wSpeed_FREQ.U16 ) and get

satisfied speed curve. 6.  If motor lost step soon after entering Speed-Integral? Probably the ramp-up slope is too sharp, try to increase

SPEED_REFERENCE_ACC_TIME and SPEED_LOOP_ACC_TIME, and repeat the tuning.

39

RELATED FUNCTIONs

Parameters Tuning c. Angle Shift (AS) Correction

Function Name Purpose Location

SEG_CODE U8 As_Table[AS_TABLE_COUNT]

A matrix table to define shifted angle for every speed range

AsTable_SpeedIntegral.h

void OMEGA_To_Frequency(U16 wOMEGA_Value)

Get the corresponding index(_bASIndex) of AS table for the speed (Omega) value.

Program.c

void OMEGA_To_Frequency_Forward(U16 wOMEGA_Value_Forward)

Get the corresponding index(_bASIndex) of AS table for the speed (Omega) value. This function is only valid in forward startup mode.

Program.c

void Forward_StartUp_Initializing() Retrieve AS data indexed by _bASIndex from AS table and send it to AMC during the initializing phase of running motor forward startup.

Program.c

Main Loop When _btDuty_Update_Ena =“1”, retrieve AS data indexed by _bASIndex from AS table and send it to AMC.

Main.c

40

RELATED VARIABLEs

RELATED PARAMETERs

Parameters Tuning c. Angle Shift (AS) Correction

Variable Name Description

_bASIndex Index for AS Table _bASIndex = _wSpeed_FREQ.U16 / ( SPEED_INTERVAL × MOTOR_POLE / 12 )

Parameter Name Description

SPEED_INTERVAL Speed interval in AS Table. Unit: RPM

AS_TABLE_COUNT Length of AS Table. Unit: Byte

41

TUNING PROCEDURE & HINT1.  Monitored Signal: AO, IA, IB, IC 2.  AS Correction tuning must be executed at speed-close mode (SPEED_CLOSE_LOOP_ENA must be“1”), and load must

be coupled on to motor. 3.  Based on max speed in real application, decides suitable length of AS Table (AS_TABLE_COUNT) and the interval

(SPEED_INTERVAL). 4.  Set AO_SHOWS_SPEED_FREQ“1” to enable AO pin and monitor speed info on this pin. 5.  Set the target speed to the middle level. Record average value of IA, IB or IC when speed steadily reaches target value.

Fine tune AS repetitively and reach the lowest average value of IA, IB or IC. Then the optimal AS is found. 6.  Set the target speed to max, use above same method to find optimal AS 7.  Use AS values of middle level and max speed to interpolate other AS values in between based on the speed interval you

defined. 8.  Before tuning, user can set USING_UART_DEBUGGING and DUMP_AS_TO_UART“1” to monitor AS value through

UART port and HyperTerminal in Windows. 9.  Value of angle shift is proportional to speed. The higher the speed, the larger the value of angle shift!

Parameters Tuning c. Angle Shift (AS) Correction

42

OPERATION – Speed faster than LOWEST_LINKUP_SPEED_120DT

Parameters Tuning d. Motor Start Up at Forward Free Running

AO

IA, IB, IC

1.  If IA exists? Yes: wait until IA is near zero, move to next step. No: still no signal after LOWEST_LINKUP_SPEED_120DT, recognize motor at standstill.

2.  Await IB and IC, which one showing negative current?

3.  Determine motor direction, start time counting.

4.  Time is up, initialize start-up mode.

43

OPERATION – Speed slower than LOWEST_LINKUP_SPEED_120DT

Parameters Tuning d. Motor Start Up at Forward Free Running

AO

IA, IB, IC

2.  Brake 3.  Start up with Standstill Mode

1.  Check motor status

44

RELATED FUNCTIONs

RELATED VARIABLEsPlease refer to the slide 13.

Parameters Tuning d. Motor Start Up at Forward Free Running

Function Name Purpose Location

void Motor_Status_Checking() Check motor’s state and decide startup mode.

Program.c

void Forward_StartUp_Initializing() Initialization for state of forward free running motor

Program.c

45

RELATED PARAMETERs

Parameters Tuning d. Motor Start Up at Forward Free Running

Parameter Name Description

LOWEST_LINKUP_SPEED_120DT Time of 120º electrical angle, i.e., time between IB and IC, at the allowably lowest link-up speed entering Speed-Integral.

LOWEST_LINKUP_SPEED_120DT = tIB-IC × fPWM

tIB-IC : the time between IB and IC fPWM : the frequency of PWM, default is 15 kHz

OMEGA_TO_DUTY_RATIO The ratio of Omega (ω) to Duty

46

Parameters Tuning d. Motor Start Up at Forward Free Running

TUNING PROCEDURE & HINT1.  Monitored Signals: AO, IA, IB, IC2.  Set AO_SHOWS_THETA “1”, other

AO_SHOWS_xxxx are ”0”, Watch Theta change on AO pin.

3.  The first Theta duration, after linking up to Speed-Integral, divided by 3 is used for LOWEST_LINKUP_SPEED_120DT.tIB-IC = tTHETA / 3

Index of Link-up Speed-Integral

tTHETA

47

Parameters Tuning d. Motor Start Up at Forward Free Running

TUNING PROCEDURE & HINT4.  Set AO_SHOWS_DUTYA “1”, other

AO_SHOWS_xxxx are“0”. Watch Duty’s real time value on AO pin.

5.  Verify the Duty value linking up into Speed-Integral loop for low and high speed respectively. The value cannot be larger than the one prior to power off.

6.  Step-by-step increase LOWEST_LINKUP_SPEED_120DT and verify the link-up to Speed-Integral loop in forward free running mode at low and high speeds without any failures. Got the final LOWEST_LINKUP_SPEED_120DT

Final Duty prior to power off

Duty value linking up into Speed-Integral

48

OPERATION – Speed faster than LOWEST_DECEL_SPEED_120DT

Parameters Tuning e. Motor Start Up at Reverse Free Running

1.  Check motor status → Set AMC startup in“Forward Free Running”mode → Decelerate

2.  Speed lower than VEERING_SPEED_FREQ → Turn Off → Check motor status → Set AMC startup in “Reverse Free Running”mode

3.  Link up Speed-Integral

AO

IA, IB, IC

49

OPERATION – Speed slower than LOWEST_DECEL_SPEED_120DT

Parameters Tuning e. Motor Start Up at Reverse Free Running

1.  Check motor status → Set AMC startup in“Reverse Free Running”mode.

2.  Link up Speed-Integral VEER_RAMPUP_ACC_TIME VEER_RAMPUP_DUTY

AO

IA, IB, IC

50

Parameters Tuning d. Motor Start Up at Reverse Free Running

RELATED FUNCTIONs

RELATED VARIABLEsPlease refer to the slide 13, 19.

Function Name Purpose Location

void Motor_Status_Checking() Check motor’s state and decide startup mode. Program.c

void Backward_StartUp_Initializing() Initialization for state of reverse free running motor. Program.c

INTERRUPT(ISR_T1, VECTOR_ET1) If speed is lower than VEERING_SPEED_FREQ, set _btDIR_Ready_For_Veering “1”.

MCS51.c

Main Loop If_btDIR_Ready_For_Veering is“1”, turn off motor, set _btMotor_StateCheck_Ena“1”, toggle _btPresent_DIR.

Main.c

51

RELATED PARAMETERs

Parameters Tuning d. Motor Start Up at Reverse Free Running

Parameter Name Description

LOWEST_DECEL_SPEED_120DT Threshold speed to determine if deceleration is required or not prior to changing direction.

LOWEST_DECEL_SPEED_120DT = tIB-IC × fPWM

tIB-IC : the time between IB and IC fPWM : the frequency of PWM, default is 15 kHz

VEERING_SPEED_FREQ Threshold speed to start to force reverse direction.

Conversion between speed and frequency: f = ( RPM x 10 x ( P / 2 )) / 60 = RPM × P / 12 P : pole number of the motor

VEER_RAMPUP_DUTY Ramp-Up Duty in “Reverse Free Running Mode”. Range: 0 ~ 255, 255 = Duty 50%.

VEER_RAMPUP_ACC_TIME Ramp-Up period time in “Reverse Free Running Mode”. Unit: 1 ms, Range: 1 ~ 5000.

52

Parameters Tuning d. Motor Start Up at Reverse Free Running

TUNING PROCEDURE & HINT1.  Monitoring Signals: AO, IA, IB, IC 2.  Use previously obtained

LOWEST_LINKUP_SPEED_120DT as a reference, follow flow chart at right hand side to tune up other parameters.

Faster

LOWEST_DECEL_SPEED_120DT

VEERING_SPEED_FREQ

LOWEST_LINKUP_SPEED_120DT

Slower

53

Parameters Tuning f. Change Direction on Running Motor

OPERATION

AO

IA, IB, IC

1.  SW2 toggled → enter dir change procedures, decelerating

2.  Speed lower than VEERING_SPEED_FREQ → Turn Off → Check motor status → Set AMC startup in “Reverse Free Running Mode”

3.  Link up Speed-Integral → accelerate to original speed

54

Parameters Tuning f. Change Direction on Running Motor

RELATED FUNCTIONs

v  Other associated functions are same as “d. Motor Start Up at Reverse Free Running” .

RELATED VARIABLEsv  Same as “d. Motor Start Up at Reverse Free Running” .

TUNING PROCEDURE & HINTv  Sam as “d. Motor Start Up at Reverse Free Running”.

Function Name Purpose Location

INTERRUPT(ISR_T0, VECTOR_ET0) Every 1 ms , Check_DIR_Switch() is called to check SW2 (DIR_PIN) ‘s state

MCS51.c

void Check_DIR_Switch() Check SW2 (DIR_PIN)’s state. If state is changed, _btDIR_Change_Decelerating will be set“1”, original target speed is reserved and new target speed is set _wSpeed_Target.U16 = VEERING_SPEED_FREQ.

Program.c

55

Parameters Tuning g. Over/Under Voltage Protection

OPERATION

VBUS_OVP_RELEASE

VBUS_UVP_THRESHOLD

VBUS_UVP_RELEASE

VBUS_OVP_THRESHOLD

VSENSE_PIN

IA, IB, IC

56

Parameters Tuning g. Over/Under Voltage Protection

RELATED FUNCTIONs

RELATED VARIABLEs

Function Name Purpose Location

INTERRUPT(ISR_T0, VECTOR_ET0) Every 1 ms , Check_VBUS_OVP_UVP() is called MCS51.c

void Check_VBUS_OVP_UVP() Check VSENSE_PIN state, judge if OVP or UVP Program.c

Variable Name Description

_btVBUS_UVP_Occurring UVP fault flag. When VSENSE_PIN voltage is smaller than VBUS_UVP_THRESHOLD, this flag is set 1. When VSENSE_PIN is larger than VBUS_UVP_RELEASE, this flag is set ”0”.

_btVBUS_OVP_Occurring OVP fault flag. When VSENSE_PIN voltage is larger or equal to VBUS_OVP_THRESHOLD , this flag is set“1”. When VSENSE_PIN voltage is smaller than VBUS_OVP_RELEASE , this flag is set“0”.

_btNoneLatch_Fault_Occurring Please refer to the slide 11.

57

Parameters Tuning g. Over/Under Voltage Protection

RELATED PARAMETERs

TUNING PROCEDURE & HINT1.  Get the threshold and release voltage (VSENSE) by below formula, and convert it to ADC

Setting Value as well. VSENSE = VBUS × 8.45K / (( 330K × 3 ) + 8.45K )

ADC Setting Value = VSENSE x 255 / 4V 2.  Let OVP_UVP_FUNCTION_ENA be“1”to enable OVP and UVP. 3.  Verify protection functions. 4.  Fine tune the threshold / release voltage based on actual data from test.

Parameter Name Description

VBUS_OVP_THRESHOLD VBUS OVP Threshold voltage

VBUS_OVP_RELEASE VBUS OVP Release Threshold Voltage

VBUS_UVP_THRESHOLD VBUS UVP Threshold Voltage

VBUS_UVP_RELEASE VBUS UVP Release Threshold Voltage

VBUS

VSENSE

58

Parameters Tuning h. Over Temperature Protection

OPERATIONOTP without Error Latch OTP within Error Latch

RT_PIN

IA, IB, IC

SPM_OTP_THRESHOLD

SPM_OTP_RELEASE

SPM_OTP_THRESHOLD

SPM_OTP_RELEASE

59

Parameters Tuning h. Over Temperature Protection

RELATED FUNCTIONs

RELATED VARIABLEs

Function Name Purpose Location

INTERRUPT(ISR_T0, VECTOR_ET0) Every 1 ms, Check_SPM_OTP() is called. MCS51.c

void Check_SPM_OTP() Check RT_PIN state, judge if OTP occurs Program.c

Variable Name Description

__btSPM_OTP_Occurring OTP fault flag. When RT_PIN voltage is larger than SPM_OTP_THRESHOLD , this flag is set“1”. When RT_PIN voltage is smaller than SPM_OTP_RELEASE , this flag is cleared.

_btNoneLatch_Fault_Occurring Please refer to the slide 11.

60

Parameters Tuning h. Over Temperature Protection

RELATED PARAMETERs

TUNING PROCEDURE & HINT1.  Get VRT voltage by below formula, then convert it ADC Setting

Value as well. VRT = 5V × 6.49K / ( 6.49K + RTH )

ADC Setting Value = VRT × 255 / 4V 2.  Fine tune it based on actual triggering point from test.

Parameter Name Description

SPM_OTP_THRESHOLD SPM’s OTP threshold voltage

SPM_OTP_RELEASE SPM’s OTP release voltage

5V

VRT 6.49K

61

Parameters Tuning i. Current Limit Protection

OPERATION

_bAverage_Current

IA, IB, IC

CURRENT_LIMIT_THRESHOLD

Error Code

62

Parameters Tuning i. Current Limit Protection

RELATED FUNCTIONs

RELATED VARIABLEs

Function Name Purpose Location

INTERRUPT(ISR_T0, VECTOR_ET0) Every 1 ms, Check_Current_Limit() is called. MCS51.c

void Check_Current_Limit() Calculate average voltage of IA+IB+IC, judge if current limit threshold triggered.

Program.c

INTERRUPT(ISR_T1, VECTOR_ET1) When btCurrentLimit_Triggered is“1”, _wSpeed_Reference.U16 pause incremental counting

MCS51.c

Variable Name Description

_btCurrentLimit_Triggered Current Limit fault flag. When average voltage of IA+IB+IC is larger than CURRENT_LIMIT_THRESHOLD, this flag is set“1”. When the average voltage is smaller than CURRENT_LIMIT_THRESHOLD, this flag is cleared.

_bAverage_Current Current average voltage of IA+IB+IC.

63

Parameters Tuning i. Current Limit Protection

RELATED PARAMETERs

TUNING PROCEDURE & HINT1.  Let CURRENT_LIMIT_THRESHOLD be the max. value = 255. 2.  Let AO_SHOWS_AV_PEAK_CURRENT be“1”, Read _bAverage_Current ‘s content on AO pin. 3.  Let CURRENT_LIMIT_ENA be“1”to enable Current Limit Protection. 4.  Let target speed be the max rating value. Read voltage on AO pin when speed is stable. 5.  Convert voltage on AO pin into ADC value, and it is the value for CURRENT_LIMIT_THRESHOLD .

CURRENT_LIMIT_THRESHOLD = VAO × 255 / 4V

6.  Fine tune the parameter based on actual from test.

Parameter Name Description

CURRENT_LIMIT_THRESHOLD Current limit threshold

64

Parameters Tuning j. Motor Short Circuit Protection

OPERATION

Zoom In INITIL_SHORT

Error Code

IA, IB, IC

Theta

65

Parameters Tuning j. Motor Short Circuit Protection

RELATED FUNCTIONsFunction Name Purpose Location

INTERRUPT(ISR_Fault, VECTOR_EX8) Check MSFR_MSTAT‘s SHORT_A, SHORT_B, SHORT_C flags, Call Evt_ShortA(), Evt_ShortB(), Evt_ShortC() if corresponding flags are set.

MotorCtrl.c

void Evt_ShortA() void Evt_ShortB() void Evt_ShortC()

Counts the number of occurrence of (_bIA_ShortCircuit_Cnt, bIB_ShortCircuit_Cnt, bIC_ShortCircuit_Cnt). As long as either one of the 3 counters is larger than or equal to 3, set _btShortCircuit_Occurring and _btLatched_Fault_Occurring“1”and turn off PWM output immediately.

MotorCtrl.c

INTERRUPT(ISR_ADC, VECTOR_EX9) IA, IB, IC voltages are checked at every PWM cycle. If individual voltage is smaller than INITIAL_SHORT, corresponding counter ( _bIA_ShortCircuit_Cnt, bIB_ShortCircuit_Cnt, bIC_ShortCircuit_Cnt ) is cleared.

MotorCtrl.c

66

Parameters Tuning j. Motor Short Circuit Protection

RELATED VARIABLEs

RELATED PARAMETERs

Variable Name Description

_bIA_ShortCircuit_Cnt _bIB_ShortCircuit_Cnt _bIC_ShortCircuit_Cnt

Short Circuit Trigger Counters. When IA/ IB/ IC voltage is >= INITIAL_SHORT, the corresponding counter will increase 1. The counter will be cleared if the voltage is smaller than INITIAL_SHORT.

_btShortCircuit_Occurring Short Circuit Protection Fault Flag. When either phase’s counter reaches 3, _btShortCircuit_Occurring will be set“1”.

_btLatched_Fault_Occurring Please refer to the slide 11.

Parameter Name Location Description

INITIAL_SHORT MotorCtrl.c Motor Short Circuit Voltage Threshold

ISCP = (( INITIAL_SHORT × 4V / 255 ) – 2V ) / RSHUNT

ISCP : motor short circuit protected current RSHUNT : resistance of shunt resistor

67

Parameters Tuning j. Motor Short Circuit Protection

TUNING PROCEDURE & HINT1.  Assign a suitable INITIAL_SHORT based on the formula on previous slide. 2.  Let a DC Power Supply’s output voltage = INITIAL_SHORT + 0.2 V. 3.  Use the DC Power Supply’s output voltage to trigger either IA, IB, or IC and emulate the motor short circuit condition, watch

if output waveform responds correctly? Motor stops immediately? 4.  Afterwards short either two of the three U, V, W nodes and make sure SCP really takes action.

68

Parameters Tuning k. Lock Rotor Protection

OPERATIONRECOVERY_WAIT_TIME

IA, IB, IC

Error Code

1ST Start-Up 2ND Start-Up 3RD Start-Up RECOVERY_RETRY_TIMES = 3

69

Parameters Tuning k. Lock Rotor Protection

RELATED FUNCTIONsFunction Name Purpose Location

INTERRUPT(ISR_T0, VECTOR_ET0) Every 1 ms, Check_AMC_Fault() is called. MCS51.c

void Check_AMC_Fault() 1.  Check AMC’s AMC_FAULT flag “1”: motor lost step/blocked, based on setting of RECOVERY_WAIT_TIME and RECOVERY_RETRY_TIMES, restart motor

2.  Check AMC’s SAFET_WARNING flag “1”: proceed error handling procedure

3.  Check if Theta has no change (AMC_THETA_LOSS_COUNT) in for a while? If yes: motor is blocked. Based on setting of RECOVERY_WAIT_TIME and RECOVERY_RETRY_TIMES, restart motor

Program.c

70

Parameters Tuning k. Lock Rotor Protection

RELATED VARIABLEs

RELATED PARAMETERs

Variable Name Description

_btNoneLatch_Fault_Occurring Please refer to the slide 11.

_btLatched_Fault_Occurring Please refer to the slide 11.

Parameter Name Description

RECOVERY_RETRY_TIMES Retry Number of Restart. Range: 0 ~ 255, Counter increase 1 at every restart. When the retry number reaches this setting, btLatched_Fault_Occurring is set“1”, system halt, no more retry!

RECOVERY_WAIT_TIME Wait Time between Every Retry. Range: 0 ~ 65535: Unit: 1 ms. Blocked/Lost-Step motor will not restart until the time counter reaches RECOVERY_WAIT_TIME.

AMC_THETA_LOSS_COUNT Time of losing Theta. Range: 0 ~ 255. Unit: 1 ms. When Theta has no change during this time period, motor is recognized as block. _btNoneLatch_Fault_Occurring is set“1”. Restart motor.

71

OPERATION

ROTOR POSITION DETECTING METHODs

1. Back-EMF detects with Comparator2.  Back-EMF detects with Op-Amp3.  Back-EMF detects with Diodes

Advanced Start-Up Methods

Rotor Position Detection Ramp-Up Speed-Integral

72

CONCEPT

Advanced Start-Up Methods Rotor Position Detection – Method 1

1 • Firstly Motor is driven by a very short pulse (hypocorism: kick motor) and

invisibly moves. A patented Fairchild circuit will read the Back-EMF caused by the short movement, and determine three possible rotor positions: 0º/180º or 60º/240º or 120º/300º

2 • Secondly, another two strong pulses (hypocorism: shock motor) to further

distinguish the exact six positions : 0º or180º out of 0º/180º?60º or240º out of 60º/240º ?120º or 300º out of120º/300º?

73

DETECTION CIRCUIT

v  If the VIA/VIB/VIC < -2.5 mV then the output of comparator will transit from high to low!

Advanced Start-Up Methods Rotor Position Detection – Method 1

ON ON ON

74

BACK-EMF vs. COMPARATOR OUTPUT

Advanced Start-Up Methods Rotor Position Detection – Method 1

-1.5

-1

-0.5

0

0.5

1

1.5

1 9 17

25

33

41

49

57

65

73

81

89

97

105

113

121

129

137

145

153

161

169

177

185

193

201

209

217

225

233

241

249

257

265

273

281

289

297

305

313

321

329

337

345

353

361

0° 60° 120° 180° 240° 300° 0°

eA eB eC

1 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 1 0 0

75

BACK-EMF vs. ROTATING DIRECTION

Advanced Start-Up Methods Rotor Position Detection – Method 1

60° 120°

180°

240° 300°

1 0 0 0 1 1

eA eB eC

0 1 1 1 0 0

0 1 0 1 0 1

1 1 0 0 0 1

0 0 1 1 1 0

1 0 1 0 1 0

1ST Kick

2ND Kick

CCW CW

76

Advanced Start-Up Methods Rotor Position Detection – Method 1

OPERATION – Step 1

1.5 V : 120º/300º

1.0 V : 60º/240º

0.5 V : 0º/180º

KICK_TIME BEMF_DEBOUNCE_TIME

77

Advanced Start-Up Methods Rotor Position Detection – Method 1

OPERATION – Step 2

IA, IB, IC

iSHOCK_DISCHARGE_TIME

iSHOCK_CHARGE_TIME

1.0 V = 60º/240º

1ST Shock

Δ0.5V = 60º Δ1.0V = 240º

2ND Shock

78

Advanced Start-Up Methods Rotor Position Detection – Method 1

RELATED FUNCTIONsFunction Name Purpose Location

void Rotor_Position_Detecting() All the important and necessary routines are collected here.

RPD_HV.c

void Kick_Motor(U8 bKickAngle, U8 bKickDuty, U8 bKickTime)

To drive/kick motor shortly in order to get small Back-EMF signals

RPD_HV.c

U16 wBackEMF_Detecting() Use comparators to determine Back-EMF’s state. RPD_HV.c

U8 bPress_Current_Shock(U8 bShock_Angle, U8 bIShunt_Chan)

Shoot “Shocking Current”. RPD_HV.c

79

Advanced Start-Up Methods Rotor Position Detection – Method 1

RELATED PARAMETERsParameter Name Location Description

KICK_DUTY RPD_HV.h PWM Duty of Kick Drive. Range: 0 ~ 255, 255 = 50%

KICK_TIME RPD_HV.h Time of Kick Drive. Unit: 1 ms, Range: 0 ~ 255.

BEMF_DEBOUNCE_TIME RPD_HV.h Time Window of De-bouncing. Unit: 1 ms, Range: 0 ~ 65536.

iSHOCK_DUTY RPD_HV.h PWM Duty of Shocking Current. Range: 0 ~ 511, 511 = 100%.

iSHOCK_CHARGE_TIME RPD_HV.h Charge Time of Shocking Current. Unit: 1 ms, Range: 0 ~ 255.

iSHOCK_DISCHARGE_TIME RPD_HV.h Discharge Time Shocking Current. Unit: 1 ms, Range: 0 ~ 255.

80

Advanced Start-Up Methods Rotor Position Detection – Method 1

TUNING PROCEDURE & HINT1.  Set ROTOR_POS_DET_TUNING_1“1”, execute first step of Rotor Position Detection.

2.  Monitoring Signal: AO, eA, eB, eC

3.  Fine tune KICK_DUTY, KICK_TIME, BEMF_DEBOUNCE_TIME, and ensure the three rotor positions of 0º/ 180º, 60º/ 240º, 120º/300º are distinguishable.

4.  Set ROTOR_POS_DET_TUNING_1“0”and ROTOR_POS_DET_TUNING_2 “1”, execute the second step of Rotor Position Detection.

5.  Monitoring Signals: AO, IA, IB, IC, VBUS

6.  Fine tune iSHOCK_DUTY, iSHOCK_CHARGE_TIME, iSHOCK_DISCHARGE_TIME, and further identify correct polarity for each of the three positions.

7.  VBUS could drop for a short period when shooting Shocking Current. Thus second shoot should not start until VBUS recover to the stable level in order to ensure same energies at the two shots.

81

AO Pin Voltage System Status

0.5 V System is in the power-on/standby stage.

1.0 V System is checking the motor status.

1.5 V System is doing the motor brake.

2.0 V System is doing the rotor position detection.

2.5 V System is in the running stage.

Appendix 1. Status Code

82

AO Pin Voltage Situation

4.0 V ó 1.0 V Motor Short Circuit Protected

4.0 V ó 1.5 V Current Limit Protected

4.0 V ó 2.0 V Over Temperature Protected

4.0 V ó 2.5 V Over Voltage Protected

4.0 V ó 3.0 V Under Voltage Protected

4.0 V ó 3.5 V Motor Lock or Loss Step Protected

Appendix 2. System Error Code

AO

Time

Voltage

4 V

System Error Code

0 V

83

AO Pin Voltage Fail Condition

0 V ó 0.27 V SFR check failed

0 V ó 0.53 V Program Counter check failed

0 V ó 0.84 V Clock check failed

0 V ó 1.07 V RC Clock check failed

0 V ó 1.33 V RAM check failed

0 V ó 1.60 V ROM check failed

0 V ó 1.87 V PWM check failed

0 V ó 2.13 V ADC check failed

0 V ó 2.40 V Stack Pointer check failed

0 V ó 2.67 V Chip version check failed

0 V ó 2.93 V ADC pin short

0 V ó 3.20 V Over Current detected

0 V ó 3.47 V Lock Rotor detected

0 V ó 3.73 V Mailbox communication too frequent

0 V ó 4.00 V Shunt offset value inappropriate

Appendix 3. Safety Warning Code

AO

Time

Voltage

4 V

Safety Warning Code

0 V

THANK YOU