Renesas M16C/Tiny User Manual
Hide thumbs Also See for M16C/Tiny:

Advertisement

Quick Links

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

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the M16C/Tiny and is the answer not in the manual?

Questions and answers

Summary of Contents for Renesas M16C/Tiny

  • Page 1 致尊敬的顾客 关于产品目录等资料中的旧公司名称 NEC电子公司与株式会社瑞萨科技于2010年4月1日进行业务整合(合并),整合后的 新公司暨“瑞萨电子公司”继承两家公司的所有业务。因此,本资料中虽还保留有旧公司 名称等标识,但是并不妨碍本资料的有效性,敬请谅解。 瑞萨电子公司网址:http://www.renesas.com 2010年4月1日 瑞萨电子公司 【发行】瑞萨电子公司( http:// www.renesas.com) 【业务咨询】http://www.renesas.com/inquiry...
  • Page 2 Renesas Electronics. Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as “Specific”...
  • Page 3 RSBJ Published by: Renesas System Solutions (Beijing) Co., Ltd. Beijing Technical Center. Date: March 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.
  • Page 4 Do not attempt to use the platform board until you fully understand its layout concept. MCU: Throughout this document, the term “Platform” shall be defined as the Renesas M16C/Tiny Sensor-less PMSM Driving Platform by 120-Degree Trapezoidal Wave Commutation, which is for washing machine demo and prototype design reference.
  • Page 5 No warranty of fitness for a particular purpose is offered. The user assumes the entire risk of using the product. Any liability of Renesas is limited exclusively to the replacement of defective materials or workmanship.
  • Page 6 All Right Reserved: This user’s manual and product are copyrighted and all rights are reserved by Renesas. No part of this user’s manual, all or part, any be reproduced or duplicated in any form, in hardcopy or machine-readable form, by any means available without Renesas‘s prior written consent.
  • Page 7 PREFACE About this manual This user’s manual discusses how to use three-phase motor control timer function, and a sample application of how to implement position-sensor-less driving of an SPMSM by 120-degree trapezoidal wave commutation, which is a method that makes use of the induced voltage of the motor.
  • Page 8: Table Of Contents

    Contents 1. About This Platform ..........................7 1.1 The hardware block diagram ......................7 1.2 The hardware resource assignment table..................7 1.3 software specifications ........................8 2 Description of Software..........................9 2.1 Output Pattern Switching ........................9 2.2 Detection of Induced Voltages.......................11 2.3 Calculation of Actual Rotation Speed ...................12 2.4 Calculation of Target Rotation Speed....................12 2.5 Calculation of PWM Duty Cycle ....................13 2.6 List of function modules........................14...
  • Page 9: About This Platform

    1. About This Platform 1.1 The hardware block diagram M16C/Tiny (SD) /nNMI/nSD Three-phase motor control /TA1 POWER /TA1 /TA2 220V AC circuit circuit /TA2 /TA4 /TA4 PVcc Motor Potentionmeter Speed Command /AN0 A/D Conversion /INT5 BEMF Vin Uin Win PVcc...
  • Page 10: Software Specifications

    1.3 software specifications Motor type permanent magnet synchronous motor(PMSM) Numbers of pole pairs Control method 120-degree commutation using trapezoidal waves Motor Position Detection Detected by three phase induced voltage of motor Carrier Frequency 5kHz Range of Rotation Single Direction Speed Command 1000rpm to 7200 rpm Error detection The Fo signal (forced shut-down signal) of the IPM is input...
  • Page 11: Description Of Software

    2 Description of Software 2.1 Output Pattern Switching Pattern 5 Pattern 0 Pattern 1 Pattern 2 Pattern 3 Pattern 4 Pattern 5 U-BEMF V-BEMF Zero-crossing W-BEMF Switch the output pattern 30 Calcultation the actual rotation speed degree after the zero-crossing from intervals between zero-crossings of the induced voltage of the induced voltages...
  • Page 12 Figure 3.1.2 Three-phase IGBT inverter circuit In the 120 degree trapezoidal communication mode, three phase IGBT circuit turn-on sequence is UpWn→WnVp→VpUn→UnWp→WpVn→VnUp, two IGBT are conducted every 60 electrical degrees. Accordingly, PWM wave have 6 output pattern switching. It is shown as the figure 3.1.1 and figure 3.1.2 Output pattern is switched when motor rotor angles 60 electrical degree every time.
  • Page 13: Detection Of Induced Voltages

    PFCi Output “L” “H” Table 3.1.2 three states of output pin 2.2 Detection of Induced Voltages Induced voltage Vbus /2 Vbus/2 Vbus /2 30 dgr 30 dgr Comparator Switching output pattern Output Signal Zero-crossing of induced voltage Figure 3.1.3 Detection of zero-crossing of induced voltage and comparator output The output pattern of the MCU depends on position information of induced voltages.
  • Page 14: Calculation Of Actual Rotation Speed

    In our program, when motor mode changes into turnon mode, TB1 interrupt is enabled, after the next carrier wave cycle interrupt, motor woke mode become run mode. Every 50us, TB1 interrupts. If the TB1 interrupt request bit is set to 1, after another 50us, the TB1 interrupt request bit is still set to 1, the zero-crossing of induced voltages is detected, and it is at the mid-point (30 electrical degrees) of each output pattern.
  • Page 15: Calculation Of Pwm Duty Cycle

    2.5 Calculation of PWM Duty Cycle Sawtooth Wave modulation Slow Fast Output Figure 3.1.4 Relationship between PWM Duty Cycle and Rotation Speed Command PWM duty cycle depends on counting values of TAi. The actual rotation speed is proportion to PWM duty cycle, the bigger is PWM duty cycle, the faster is the actual rotation speed. In the course of approaching rotation speed command, the carrier wave cycle pulses can be acquired by target rotation speed every time.
  • Page 16: List Of Function Modules

    2.6 List of function modules Module name Label name Input Output Description —— Motor control main Main_PWM_120slc20_PFCR( ) Main processing processing —— Initialization PWMInitial( ) Set initial values for AD processing conversion, zero-crossing detection ,and three phase —— PWM interrupt PWMInt( ) Call the turnoff, bootstrap, processing...
  • Page 17: List Of Vrialbles

    2.7 List of vrialbles Item Label Data Type Resolution Description Stop state s_StopMode UINT_16 Output state g_OutputMode UINT_8 Operation mode Output angle g_MotTheta UINT_16 2^11 Startup control s_StartCnt UINT_16 counter Target rotation Counter used to provide the period s_TargetCnt UINT_16 speed calculation (2ms) target...
  • Page 18: List Of Macro Definition

    interval pulse AD sample interval g_swtime UINT_16 Sample once every 16 carrier wave interrupt Induced voltage g_ChkOnCnt UINT_16 Counter used to provide a time delay detection disable detect induced voltage time counter zero-crossing. 2.8 List of Macro definition Macro name Macro value Resolution Description...
  • Page 19: Finite State Machine Of Motor Control

    3 Finite State Machine of Motor Control The state of motor control can be shown by finite state machine (FSM). The following figure is the FSM of BLDC in this software. It concludes four states, the states can be switched to other states under the certain conditions.
  • Page 20: Condition Description

    disabled, the motor work mode come back turnoff mode. No intervals of zero-crossing of induced voltages are detected when counter of zero-crossing interval exceeds certain values, the motor work mode change into turnon mode. 3.2 Condition Description Condition number Description ①...
  • Page 21: Control Flow

    4 Control flow 4.1 Main processing for sensor-less driving of an SPMSM by 120-degree trapezoidal wave commutation. Main Set local variable ad_input=0x0000 Set local variable Ad_speed PWMInitial processing ad_input = 0x03ff&AD1 CalSpeedCnd processing Ad_speed is current calculate rotation speed Ad_speed< M_Start_Hz? Rotation speed command = 0 Rotation speed command = Ad_speed RSBJEUM0001-0101 Rev.
  • Page 22: Initialization Processing

    4.2 Initialization Processing PWMInitial g_OutputMode =Turnoff mode g_Mottheta=0 s_StopMode =1 g_SpeedCnd=0 Set initial values for induced voltage inputs INT4 interrupt control register = 0x00; INT3 interrupt control register = 0x00; INT5 interrupt control register = 0x00; Interrupt request cause select register = 0xF8; // disable external interrupt, set both edge trigger Set three-pahse PWM initial values.
  • Page 23: Turn-Off Processing

    4.3 Turn-off Processing TurnoffPWM Stop TB1 TA4= TA1=TA2 = M_CARR_CNT -((M_MIN_DUTY_120 * (SINT_32)M_CARR_CNT) >> 2^15 // Set time value IDB0 = 0x3f IDB1 = 0x00 // generate 3-phase PWM Protect register = 0x02 INVC0 |= 0x08 // output enable Protect register = 0x00 p8_0 = INACTIVE_LVL,pd8_0 = 1 p8_1 = INACTIVE_LVL,pd8_1 = 1 p7_2 = INACTIVE_LVL,pd7_2 = 1...
  • Page 24: Pwm Interrupt Processing

    4.4 PWM Interrupt Processing PWMINT g_OutputMode = M_TURNOFF ? TurnoffPWM processing g_OutputMode = M_BOOTSTRAP? BootstrapPWM processing g_OutputMode =M_TURNON ? TurnonPWM processing g_OutputMode=M_RUN RunPWM processing RSBJEUM0001-0101 Rev. 1.01...
  • Page 25: Bootstrap Processing

    4.5 Bootstrap Processing BootstrapPWM 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_BootstpStep <...
  • Page 26: Turn-On Processing

    4.6Turn-on Processing TurnonPWM g_PWMDuty=M_INI_PWM_DUTY g_PWMDuty> M_Max_PWM _duty g_PWMDuty= M_Max_PWM_duty g_PWMDuty< M_Min_PWM_duty g_PWMDuty= M_Min_PWM_duty 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) Set timer values Timer A4 register = timer value Timer A1 register = timer value Timer A2 register = timer value...
  • Page 27 g_MotTheta > 360 degree g_MotTheta -= 360 degree s_StartCnt+1 Exceed Pre-setting start time g_Stage!=s_ReloadStg? g_OutputMode = 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 s_DltCnt+1 Timer_tb1 processing Clear INTi (i=3 to 5) interrup request bit StopCheck processing Stop Requested ? g_OutputMode = M_TURNOFF RSBJEUM0001-0101 Rev.
  • Page 28: Tb1 Interrupt Processing

    4.7 TB1 Interrupt Processing TB1INT PWM duty calculation processing in Run mode 4.8 Stop Check Processing StopCheck Rotation speed command=0? Stop requested Three phase motor control timer disable ? Stop requested No stop requested RSBJEUM0001-0101 Rev. 1.01...
  • Page 29: Run Processing

    4.9 Run Processing RunPWM g_SpeedTgt > set value? SpdDlyCnt = 300 SpdDlyCnt = 600 IDB0=0x3f IDB1=0x00 Timer value =M_CARR_CNT – ((g_PWMDuty*(SINT_32)M_CAR R_CNT) >>15) Set timer values Timer A4 register = timer value Timer A1 register = timer value Timer A2 register = timer value s_TargetCnt+1 s_TargetCnt>=s_DlyCnt s_TargetCnt=0...
  • Page 30: Pwm Run Calculation Processing

    4.10 PWM Run Calculation Processing CalPWMRun s_DltCnt < preset value? g_OutputMode=M_TURNON g_MotTheta=0 s_DltCnt +1 idb0 = 0x3f g_Stage = s_ReloadStg? idb1 = 0x3f // stop PWM output pfcr = 0x3f // enable PWM output pins int4ic &= 0x00 int3ic &= 0x00 int5ic &= 0x00// clear interrupt request g_Stage =0? (Int3ic!=0)
  • Page 31 g_Stage = 2 ? (Int4ic!=0) Int_counter+1 Int_counter=2 ? CalPWMDuty Processing s_ReloadStg= 3 Int_counter=0 Int4ic=0 Int3ic=0 Int5ic=0 g_Stage =3 ? (Int3ic!=0) Int_counter+1 Int_counter=2? CalPWMDuty Processing s_ReloadStg= 3 Int_counter=0 Int3ic=0 Int4ic=0 Int5ic=0 RSBJEUM0001-0101 Rev. 1.01...
  • Page 32 g_Stage = 4 ? (Int5ic!=0) Int_counter+1 Int_counter=2 ? CalPWMDuty Processing s_ReloadStg= 5 Int_counter=0 Int5ic=0 Int3ic=0 Int4ic=0 g_Stage = 5 ? (Int4ic!=0) Int_counter+1 Int_counter=2 ? CalPWMDuty Processing s_ReloadStg= 0 Int_counter= 0 Int4ic=0 Int3ic=0 Int5ic=0 s_ReloadCnt >0? s_ReloadCnt -1 RSBJEUM0001-0101 Rev. 1.01...
  • Page 33 s_ReloadCnt =0? g_Stage= s_ReloadStg g_Stage = 0 ? Output Wn phase PWM wave g_Stage = 1 ? Output Vp phase PWM wave g_Stage = 2 ? Output Un phase PWM wave g_Stage = 3 ? Output Wp phase PWM wave g_Stage = 4 ? Output Vn phase PWM wave g_Stage = 5 ?
  • Page 34: Pwm Duty Calculation Processing

    4.11 PWM Duty Calculation Processing CalPWMDuty g_DltCntRef =Tgt_Dlt_Conv[ g_TargetCnt/12] s_DltCnt < 13? s_DltCnt = 13 g_SpeedAct > certain rotation speed? CalCnt > 12 ? CalCnt > 12 ? CalCnt=0 CalCnt=0 g_DltCntArray[CalCnt] = s_DltCnt g_DltCntArray[CalCnt] = s_DltCnt CalCnt+1 CalCnt+1 g_AvrDltCnt=? g_DltCntArray[i] ( i= 0 to CalCnt) g_AvrDltCnt / = 12 s_DltCnt = g_AvrDltCnt...
  • Page 35 g_PreDltCnt = s_DltCnt g_ReloadCnt = s_DltCnt >> 1 s_DltCnt = 0 g_SpeedTgt > 0&&g_DltCntRef< g_PreDltCnt g_PWMDuty + 1 g_SpeedTgt > 0&&g_DltCntRef> g_PreDltCnt g_PWMDuty - 1 g_PWMDuty >M_Max_PWM _duty? g_PWMDuty =M_Max_PWM _duty g_PWMDuty <M_Min_PWM _duty? g_PWMDuty =M_Min_PWM _duty Save current PWM duty and actual rotation speed RSBJEUM0001-0101 Rev.
  • Page 36: Calculate Rotation Speed Command Processing

    4.12 Calculate Rotation Speed Command Processing CalSpeedCnd Rotation speed command input value = AD vaule*M_K_SPEED_AD_REF/2^11 s_ADSum+=Rotation speed command input Average calculation counter+1 Average calculation counter>=16 ? s_ADSpeed=s_ADSum/16 s_ADSum=0 Average calculation counter=0 Return value=s_ADSpeed RSBJEUM0001-0101 Rev. 1.01...
  • Page 37 Please be sure to implement safety measures to guard against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a Renesas product, such as safety design for hardware and software including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other applicable measures.

This manual is also suitable for:

Rsbj

Table of Contents