background image

 

                                                                             

 

RSBJEUM0001-0101    Rev. 1.01 

 

   

 

 

32 

4.11 PWM Duty Calculation Processing   

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

s_DltCnt  < 13?

s_DltCnt = 13

Yes

No

CalPWMDuty

g_DltCntRef =Tgt_Dlt_Conv[ g_TargetCnt/12]

g_SpeedAct > certain rotation speed?

Yes

CalCnt > 12 ?

CalCnt=0

Yes

No

g_DltCntArray[CalCnt] = s_DltCnt

1

g_AvrDltCnt=? g_DltCntArray[i] ( i= 0 to 
CalCnt)
g_AvrDltCnt / = 12
s_DltCnt = g_AvrDltCnt 

g_SpeedAct=Dlt_Act _Conv[s_DltCnt -13 ]

CalCnt > 12 ?

CalCnt=0

Yes

g_DltCntArray[CalCnt] = s_DltCnt

1

1

No

Summary of Contents for M16C/Tiny Series

Page 1: ...司名称 NEC电子公司与株式会社瑞萨科技于2010年4月1日进行业务整合 合并 整合后的 新公司暨 瑞萨电子公司 继承两家公司的所有业务 因此 本资料中虽还保留有旧公司 名称等标识 但是并不妨碍本资料的有效性 敬请谅解 瑞萨电子公司网址 http www renesas com 2010年4月1日 瑞萨电子公司 业务咨询 http www renesas com inquiry 发行 瑞萨电子公司 http www renesas com ...

Page 2: ...ct for an application categorized as Specific or for which the product is not intended where you have failed to obtain the prior written consent of Renesas Electronics The quality grade of each Renesas Electronics product is Standard unless otherwise expressly specified in a Renesas Electronics data sheets or data books etc Standard Computers office equipment communications equipment test and meas...

Page 3: ...arch 2008 Version 1 01 Document Number RSBJEUM0001 0101 Copyright C Renesas System Solutions Beijing Co Ltd Beijing Technical Center All rights reserved Trademarks a General All brand or product names used in this manual are trademarks or registered trademarks of their respective companies or organizations b Specific Microsoft Windows is registered trademarks of Microsoft Corporation Pentium is a ...

Page 4: ...icy Renesas System Solutions Beijing Co Ltd Beijing Technical Center hereafter collectively referred to as Renesas pursues a policy of continuing improvement in design performance and safety of this evaluation board Renesas reserves the right to change wholly or partially the specifications design user s manual and other documentation at any time without notice Target User of the Product Those who...

Page 5: ...roduct Any liability of Renesas is limited exclusively to the replacement of defective materials or workmanship DISCLAIMER RENESAS MAKES NO WARRANTIES EITHER EXPRESS OR IMPLIED ORAL OR WRITTEN EXCEPT AS PROVIDED HEREIN INCLUDING WITHOUT LIMITATION THEREOF WARRANTIES AS TO MARKETABILITY MECRCHANTABILITY FITNESS FOR ANY PARTICULAR PURPOSE OR USE OR AGAINST INFRINGEMENT OF ANY PATENT IN NO EVENT SHAL...

Page 6: ...he examples described herein 2 No license is granted by implication or otherwise under any patents or other rights of any third party or Renesas 3 MEDICAL APPLICATIONS Renesas Technology s products are not authorized for use in MEDICAL APPLICATIONS without the written consent of the appropriate officer of Renesas Technology Asia Sales company Such use includes but is not limited to use in life sup...

Page 7: ... trapezoidal wave commutation which is a method that makes use of the induced voltage of the motor This example applies to MCUs in the MC16C TinyGroup Section 1 About this platform Gives specification on hardware and software Section 2 Description of Software Describes software for motor control Section 3 Finite State Machine of Motor Control Describes state transition for motor control Section 4 ...

Page 8: ... 15 2 8 List of Macro definition 16 2 9 List of constant variable 16 3 Finite State Machine of Motor Control 17 3 1 State Discription 17 3 2 Condition Description 18 4 Control flow 19 4 1 Main processing for sensor less driving of an SPMSM by 120 degree trapezoidal wave commutation 19 4 2 Initialization Processing 20 4 3 Turn off Processing 21 4 4 PWM Interrupt Processing 22 4 5 Bootstrap Processi...

Page 9: ...wave cycle control P102 AN2 Bus current sample P103 AN3 Bus voltage sample P72 V V phase voltage P73 V V phase voltage P74 W W phase voltage P75 W W phase voltage P80 U U phase voltage P81 U U phase voltage Comparator Vin Uin Win P102 AN2 IBUS VBUS P15 INT3 P16 INT4 P17 INT5 VBEMF WBEMF UBEMF P85 nNMI nSD SD P72 TA1OUT V P74 TA2OUT W P75 TA2IN W P81 TA4IN U P80 TA4OUT U VP VN WN WP UN UP Three pha...

Page 10: ...sition Detection Detected by three phase induced voltage of motor Carrier Frequency 5kHz Range of Rotation Speed Command Single Direction 1000rpm to 7200 rpm Error detection The Fo signal forced shut down signal of the IPM is input to the NMI pin of the MCU Thus if the Fo signal goes low the three phase output is forcibly stopped and the three phase output pins are placed in the high impedance sta...

Page 11: ...tern 5 Pattern 0 Pattern 1 Pattern 2 Pattern 3 Pattern 4 Pattern 5 Zero crossing Switch the output pattern 30 degree after the zero crossing of the induced voltage 0 1 3 2 4 5 Calcultation the actual rotation speed from intervals between zero crossings of the induced voltages U BEMF V BEMF W BEMF Up Un Vp Vn Wp Wn ...

Page 12: ... can control each bit in the PFCi i 0 to 5 to enable each one of three phase PWM output pins When setting the PFCi i 0 to 5 to 0 three phase PWM output pin functions act as I O port and can output H level state and L level state In order to outputting PWM wave when motor rotor angles 360 electrical degrees PFCR register should be set based the following table Table 3 1 1 PFCR correspond to differe...

Page 13: ...f induced voltages The voltages output by the inverter are compared with half the bus voltage and the results are fed to the MCU The following table shows the connection between MCU pins and induced voltage signals Input pin BEMF signal 3 INT P15 V_BEMF 4 INT P16 W_BEMF 5 INT P17 U_BEMF Table 3 1 3 the connection of input pin and induce voltage Induced voltage Comparator Output Signal U V W U V W ...

Page 14: ...tion of Actual Rotation Speed The actual rotation speed is calculated by interval between two zero crossings of induced voltages The interval comprises certain carrier wave cycle pulses In the PWM mode 6 intervals are passed every 360 electrical degree So if counting the carrier wave pulses every a rotate the actual rotation speed can be calculated by the following formula Actual rotation speed 6 ...

Page 15: ... cycle pulses can be acquired by target rotation speed every time Every result is saved a 1dimension array including 12 data units Then 12 elements are added to calculate average value a current carrier wave pulses between zero crossings can be gotten According to formula 3 3 1 the current actual rotation speed will be gotten Consequently the PWM duty cycle is changed according to the conditions g...

Page 16: ...PWM Performs startup operation and check run mode switch Bootstrap processing BootstrapPWM Charging for 3 phase IGBT circuit TB1 int processing TB1Int Performs 50us timer inquiry and detect induced voltage Run Processing RunPWM Normal PWM operation processing Run calculation processing Cal PwmRun Performs sensor less control and Output pattern switching PWM duty calculation processing CalPWMDuty C...

Page 17: ... used to provide a time period from a pattern switching until detection of induced voltage zero crossings is enabled Counter clock period is the carrier period output pattern g_Stage UINT_16 2 0 Current output pattern Next output Pattern s_ReloadStg UINT_16 2 0 Next pattern that is determined based on the induced voltage zero crossing detection PWM duty clcye g_PwmDuty UINT_16 2 13 Bootstrap charg...

Page 18: ...Carrier wave cycle is 5k M_TURNOFF 0 2 0 Turnoff work mode M_BOOTSTRAP 1 2 0 Bootstrap work mode M_TURNON 2 2 0 Turnon work mode M_RUN 3 2 0 Run work mode M_INI_DUTY_120 1600 2 15 Initial PWM duty 0 08 2 15 M_MIN_DUTY_120 328 2 15 Min PWM duty 0 01 2 15 M_MAX_DUTY_120 29488 2 15 Max PWM duty 0 9 2 15 M_BOOT_DUTY_120 3276 2 15 Bootstrap PWM duty 0 1 2 15 M_Sft_DUTY_120_TIME 15 2 0 M_BOOTSTRAPSTEP 3...

Page 19: ...e IGBT circuit bootstrap mode is finished the motor work mode changes into turnon mode otherwise the bootstrap mode is continue When no rotation speed command is detected or three phase motor output control timer is disabled the motor work mode come back turnoff mode 3 Turnon mode points motor starts to run while MCU outputs initial duty PWM wave Output pattern switching is forcibly implemented by...

Page 20: ...d command is not equal to zero The three phase IGBT charging process is over Motor rotation speed is synchronous to rotate magnetic field frequency after passing some carrier wave cycle interrupts No rotation speed command Rotation speed command is equal to zero or three phase motor output control timer disable No intervals of zero crossing of induced voltages are detected The three phase IGBT cha...

Page 21: ...120 degree trapezoidal wave commutation Rotation speed command 0 Yes No Rotation speed command Ad_speed Main PWMInitial processing CalSpeedCnd processing Ad_speed M_Start_Hz RTS Set local variable ad_input 0x0000 Set local variable Ad_speed Ad_speed is current calculate rotation speed ad_input 0x03ff AD1 ...

Page 22: ...ister TB2 trigger TB2 M_CARR_CNT TA4 TA1 TA2 M_CARR_CNT M_INI_DUTY_120 SINT_32 M_CARR_CNT 2 15 Timer B2 interrupt vector setting Timer B2 interrupt control register 0x04 Count start flag 0x96 timer count start Protect register 0x02 INVC0 0x08 output enable Protect register 0x00 PWMInitial RTS Set initial values for induced voltage inputs INT4 interrupt control register 0x00 INT3 interrupt control ...

Page 23: ..._StopMode 0 Yes No TurnoffPWM g_OutputMode Turnoff mode RTS g_SpeedCnd 0 Yes g_OutputMode Bootstrap mode g_MotTheta 0 s_StopMode 1 Startup control counter 0 Actual rotation speed M_Start_Hz Target rotation speed M_Start_Hz 2 Yes No No p8_0 INACTIVE_LVL pd8_0 1 p8_1 INACTIVE_LVL pd8_1 1 p7_2 INACTIVE_LVL pd7_2 1 p7_3 INACTIVE_LVL pd7_3 1 p7_4 INACTIVE_LVL pd7_4 1 p7_5 INACTIVE_LVL pd7_5 1 TPRC 1 PF...

Page 24: ...WM Interrupt Processing g_OutputMode M_TURNOFF BootstrapPWM processing g_OutputMode M_RUN g_OutputMode M_TURNON Yes No No No Yes No PWMINT RTI g_OutputMode M_BOOTSTRAP TurnoffPWM processing Yes TurnonPWM processing RunPWM processing Yes ...

Page 25: ... No RTS BootstrapPWM StopCheck processing Stop Requested g_OutputMode M_TURNOFF Yes No IDB0 0x3f IDB1 0x00 generate 3 phase PWM p8_0 INACTIVE_LVL pd8_0 1 p8_1 INACTIVE_LVL pd8_1 1 p7_2 INACTIVE_LVL pd7_2 1 p7_3 INACTIVE_LVL pd7_3 1 p7_4 INACTIVE_LVL pd7_4 1 p7_5 INACTIVE_LVL pd7_5 1 s_BootstpCnt 1 Set timer values Timer A4 register timer value Timer A1 register timer value Timer A2 register timer ...

Page 26: ...gister timer value TurnonPWM g_PWMDuty M_Max_PWM _duty g_PWMDuty M_Max_PWM_duty g_PWMDuty M_Min_PWM_duty g_PWMDuty M_Min_PWM_duty No No Yes Yes g_Stage g_MotTheta 60 degree IDB0 0x3f IDB1 0x00 generate 3 phase PWM PFCR PFCRTbl g_Stage Timer value M_CARR_CNT g_PWMDuty SINT_32 M_CARR_CNT 15 Rotation speed command 0 g_MotTheta M_Start_Hz M_Start_Hz M_CNTL_TS No Yes 1 ...

Page 27: ...Mode M_Run g_SpeedAct M_Start_Hz s_ReloadStg g_Stage s_DltCnt Tgt_Dlt_Conv M_Start_Hz 12 s_DltCnt 1 s_ReloadCnt 0 No No Yes Yes Clear INTi i 3 to 5 interrup request bit Stop Requested g_OutputMode M_TURNOFF Yes No RTS g_MotTheta 360 degree g_MotTheta 360 degree No Yes 1 StopCheck processing Timer_tb1 processing ...

Page 28: ...rrupt Processing 4 8 Stop Check Processing Rotation speed command 0 Stop requested Three phase motor control timer disable No stop requested Yes No Yes StopCheck RTS RTS Stop requested No TB1INT PWM duty calculation processing in Run mode RTI ...

Page 29: ...edCnd g_SpeedTgt g_SpeedTgt 1 g_SpeedTgt 1 Stop Requested g_OutputMode M_TURNOFF Yes No RTS Yes No Set timer values Timer A4 register timer value Timer A1 register timer value Timer A2 register timer value IDB0 0x3f IDB1 0x00 Timer value M_CARR_CNT g_PWMDuty SINT_32 M_CAR R_CNT 15 Stop Check processing s_TargetCnt 0 s_TargetCnt 1 RunPWM ...

Page 30: ...ssing s_ReloadStg 1 Int_counter 0 Int3ic 0 Yes Yes No s_DltCnt 1 No Int_counter 1 Int_counter 2 g_Stage 1 Yes Int5ic 0 CalPWMDuty Processing s_ReloadStg 2 Int_counter 0 Int5ic 0 Yes No Int_counter 1 Int_counter 2 1 No Yes No No Int4ic 0 Int5ic 0 Yes Int4ic 0 Int3ic 0 2 idb0 0x3f idb1 0x3f stop PWM output pfcr 0x3f enable PWM output pins int4ic 0x00 int3ic 0x00 int5ic 0x00 clear interrupt request R...

Page 31: ...lPWMDuty Processing s_ReloadStg 3 Int_counter 0 Int4ic 0 Yes No Int_counter 1 Int_counter 2 Yes No No g_Stage 3 Yes Int3ic 0 CalPWMDuty Processing s_ReloadStg 3 Int_counter 0 Int3ic 0 Yes No Int_counter 1 Int_counter 2 Yes No No Int3ic 0 Int5ic 0 Int4ic 0 Int5ic 0 ...

Page 32: ...es Int5ic 0 CalPWMDuty Processing s_ReloadStg 5 Int_counter 0 Int5ic 0 Yes No Int_counter 1 Int_counter 2 Yes No No Int3ic 0 Int4ic 0 g_Stage 5 Yes Int4ic 0 CalPWMDuty Processing s_ReloadStg 0 Int_counter 0 Int4ic 0 Yes No Int_counter 1 Int_counter 2 Yes No No Int3ic 0 Int5ic 0 4 ...

Page 33: ...tage RTS Yes No g_Stage s_ReloadStg s_ReloadCnt 0 Yes g_Stage 0 Output Wn phase PWM wave g_Stage 1 Output Vp phase PWM wave Yes No Yes No No 4 g_Stage 3 Output Wp phase PWM wave Yes No g_Stage 4 g_Stage 5 Output Vn phase PWM wave Output Up phase PWM wave int4ic 0x00 int3ic 0x00 int5ic 0x00 ...

Page 34: ...tRef Tgt_Dlt_Conv g_TargetCnt 12 g_SpeedAct certain rotation speed Yes CalCnt 12 CalCnt 0 Yes No g_DltCntArray CalCnt s_DltCnt CalCnt 1 g_AvrDltCnt g_DltCntArray i i 0 to CalCnt g_AvrDltCnt 12 s_DltCnt g_AvrDltCnt g_SpeedAct Dlt_Act _Conv s_DltCnt 13 CalCnt 12 CalCnt 0 Yes g_DltCntArray CalCnt s_DltCnt CalCnt 1 1 No ...

Page 35: ...Cnt No g_PWMDuty 1 RTS Yes No No 1 g_ReloadCnt s_DltCnt 1 s_DltCnt 0 Yes g_SpeedTgt 0 g_DltCntRef g_PreDltCnt g_PWMDuty 1 g_PWMDuty M_Max_PWM _duty g_PWMDuty M_Max_PWM _duty Yes g_PWMDuty M_Min_PWM _duty g_PWMDuty M_Min_PWM _duty Yes No Save current PWM duty and actual rotation speed ...

Page 36: ...sing s_ADSum Rotation speed command input CalSpeedCnd Average calculation counter 16 No Yes s_ADSpeed s_ADSum 16 s_ADSum 0 Average calculation counter 0 Return value s_ADSpeed Rotation speed command input value AD vaule M_K_SPEED_AD_REF 2 11 Average calculation counter 1 RTS ...

Page 37: ...nd reliability such as safety systems or equipment or systems for transportation and traffic healthcare combustion control aerospace and aeronautics nuclear power or undersea communication transmission If you are considering the use of our products for such purposes please contact a Renesas sales office beforehand Renesas shall have no liability for damages arising out of the uses set forth above ...

Reviews: