background image

RL78/G1G          Sensorless  Speed  control  of  120-degree  conducting  controlled  permanent  magnetic  synchronous  motor  (Implementation) 

R01AN3582EJ0100    Rev.1.00 

 

Page  24  of 46 

Jan 13, 2017 

 

Table 3-11 

List of Functions “mtr_driver_access.c” 

File name 

Function name 

Process overview 

mtr_driver_access.c 

R_MTR_SetSpeed   

Input: (uint16) u2_ref_speed / speed command value 

Output: None 

Set the speed command value 

R_MTR_SetDir 

Input: (uint8) u1_dir / rotation direction 

Output: None 

Set the rotation direction 

R_MTR_GetSpeed 

Input: None 

Output: (uint16) u2_speed_rpm / rotational speed 

Obtain the calculated rotational speed 

R_MTR_GetDir 

Input: None 

Output: (uint8) g_u1_direction / rotation direction 

Obtain the rotation direction 

R_MTR_GetStatus   

Input: None 

Output: (uint8) g_u1_mode_system / motor status 

Obtain the motor status 

 

Table 3-12 

List of Functions “mtr_feedback.c” 

File name 

Function name 

Process overview 

mtr_feedback.c 

mtr_pi_ctrl 

Input: (MTR_PI_CTRL*) pi_ctrl / PI control structure 

Output: (int16) s2_ref / PI control output value 

PI control 

 

 

Summary of Contents for rl78/g1g

Page 1: ...ice Operations of the control programs have been checked by using the following device RL78 G1G R5F11EBAAFP Target control programs The target control programs of this application note are as follows...

Page 2: ...ontrol of 120 degree conducting controlled permanent magnetic synchronous motor Implementation R01AN3582EJ0100 Rev 1 00 Page 2 of 46 Jan 13 2017 Contents 1 Overview 3 2 System overview 7 3 Description...

Page 3: ...explained in this application note Table 1 1 Development Environment H W Microcontroller Evaluation board Motor RL78 G1G R5F11EBAAFP 24V inverter board Note 1 and RL78 G1G CPU Card Note 2 TSUKASA Note...

Page 4: ...and RL78 G1G CPU Card should be modified per below explanations 1 2 1 Modification of the VR1 input port 1 Remove R8 R15 C9 2 Connect CPU side of R7 and CPU side of R8 Figure 1 1 Modification of the C...

Page 5: ...e overcurrent detection method is changed to PGA CMP0 CMP1 from default INTP0 the 24V Inverter Board and RL78 G1G CPU Card should be modified per below explanations 1 Modification of the 24V Inverter...

Page 6: ...r circuit of comparator input 1 Mount 0 Ohms on R16 2 Change resister R10 from 100 Ohms to 1k Ohms 3 Change capacitor C11 from 100pF to 470pF Figure 1 5 Modification of the CPU Card Figure 1 6 Modific...

Page 7: ...ter circuit DC 24V input Up Vp Wp Un Vn Wn TRD output P15 TRDIOB0 Up P13 TRDIOA1 Vp P12 TRDIOB1 Wp P14 TRDIOD0 Un P11 TRDIOC1 Vn P10 TRDIOD1 Wn Vu Vv Vw Over current detection input P01 PGAI HV port H...

Page 8: ...troller of this system Table 2 2 Port Interface R5F11EBAAFP Port name Function P23 ANI3 Inverter bus voltage measurement P01 PGAI Shunt current input for over current detection use PGA CMP0 CMP1 Note1...

Page 9: ...d command value input U phase voltage Vu V phase voltage Vv W phase voltage Vw and inverter bus voltage Vdc are measured by using the 10 bit A D converter The operation mode is set as below The channe...

Page 10: ...nt magnetic synchronous motor Implementation R01AN3582EJ0100 Rev 1 00 Page 10 of 46 Jan 13 2017 6 Programmable Gain Amp PGA PGA is used to detect overcurrent with CMP0 CMP1 when selected 7 External in...

Page 11: ..._rl78g1g_mrssk h RL78 G1G and board dependent processing part header mtr_feedback h Feedback control processing part header mtr_gmc h General motor control function part header mtr_driver_access h Dri...

Page 12: ...name Application layer main c Motor control layer mtr_spm_less_120 c mtr_feedback c mtr_gmc c mtr_filter c mtr_driver_access c mtr_interrupt c Note H W control layer mtr_ctrl_rl78g1g_mrssk c mtr_ctrl...

Page 13: ...induced voltage with A D converters by 60 degrees Input voltage DC24 V Main clock frequency CPU clock fCLK 24 MHz TRD clock fHOCO 48 MHz Carrier frequency PWM 20 kHz Dead time 2 s Control cycle Speed...

Page 14: ...eed command value as shown below The maximum of the command value is set as the value from which maximum rotational speed is generated by the resolution of the A D converter Table 3 1 Conversion Ratio...

Page 15: ...ning Pattern created from U phase induced voltage 2p Timer counter Check Check Check Check Check Check Check Counter value difference Motor rotational speed rad s 2 frequency of timer difference of ti...

Page 16: ...0 Figure 3 2 PWM Control Modulation factor m is defined as follows E V m This modulation factor is reflected in the setting value of the register that determines the PWM duty In the target control pro...

Page 17: ...ss Speed control of 120 degree conducting controlled permanent magnetic synchronous motor Implementation R01AN3582EJ0100 Rev 1 00 Page 17 of 46 Jan 13 2017 U V W U V W Figure 3 4 Complimentary first 6...

Page 18: ...180 WIDE 120 INACTIVE ACTIVE ERROR RESET SYSTEM MODE INACTIVE ACTIVE ERROR INACTIVE INACTIVE INACTIVE ACTIVE ERROR ERROR ERROR ERROR ERROR INACTIVE ACTIVE ERROR MTR_V_PI_OUTPUT g_u2_state_voltage_ref...

Page 19: ...caught without enough speed Therefore as a start up method there is a method to lead the synchronous speed by generating a rotating magnetic field by forcibly switching conduction patterns regardless...

Page 20: ...e setting Channel PGA Gain CMP1 2 A CMP1 120 PGA out 4 is selected CMP0 2 A CMP0 83 Overvoltage error The inverter bus voltage is monitored at the overvoltage monitoring cycle When an over voltage is...

Page 21: ...stem Protection Function Error name Threshold Overcurrent error Note Overcurrent limit A 2 0 Overvoltage error Overvoltage limit V 28 Monitoring cycle ms 1 Low voltage error Under voltage limit V 15 M...

Page 22: ...n and event execution function call Main process User interface call Watchdog timer clear function call board_ui Input None Output None Motor status change Determination of rotational speed command va...

Page 23: ...0 1 and PGA clear_wdt Input None Output None Clear the watchdog timer WDT mtr_clear_oc_flag Input None Output None Clear the high impedance state mtr_clear_trd0_imfa Input None Output None Clear the C...

Page 24: ...Input uint8 u1_dir rotation direction Output None Set the rotation direction R_MTR_GetSpeed Input None Output uint16 u2_speed_rpm rotational speed Obtain the calculated rotational speed R_MTR_GetDir...

Page 25: ...or happens Check low voltage error mtr_check_over_speed_error Input uint16 u2_speed_rad rotational speed uint16 u2_speed_limit speed limit Output uint16 u2_temp0 over speed error flag when error happe...

Page 26: ...rror event Changing the motor status Set the flag of error about overcurrent mtr_oc_cmp1_interrupt Input None Output None Overcurrent detection process CMP1 interrupt Disable CMP0 CMP1 interrupt servi...

Page 27: ...state motor status Output uint8 u1_state motor status Global variables initialization mtr_act_error Input uint8 u1_state motor status Output uint8 u1_state motor status Call motor control stop functio...

Page 28: ...None Set the conduction pattern at draw in the rotor mtr_set_angle_shift Input None Output None Calculate the counts for phase shift based on the detection of zero cross mtr_check_pattern Input None O...

Page 29: ...minimum value for motor stop Mechanical angle rpm g_u2_ref_speed_rpm uint16 User setting rotational speed Mechanical angle rpm g_u1_rot_dir uint8 User setting rotation direction 0 CW 1 CCW g_u1_motor...

Page 30: ...tive mode 0x01 Active mode 0x02 Error mode g_u1_state_v_offset uint8 State management of voltage offset process 0x00 None 0x01 Measure with PWM off 0x02 Measure with PWM on 0x03 Finish measurement Ref...

Page 31: ...open loop Mechanical angle rpm g_s2_ol_mode1_change_rpm int16 Change speed of open loop mode1 Mechanical angle rpm g_s2_ol_mode2_change_rpm int16 Change speed of open loop mode2 Mechanical angle rpm g...

Page 32: ...interruption counter value g_u1_v_pattern_num uint8 Control number for forced conduction pattern at open loop g_u1_v_pattern_open 2 7 uint8 Array of forced conduction patterns at open loop g_u2_offse...

Page 33: ...less 120 degree conducting control software structure Lists of structure used in this control program are given below Table 3 21 List of structure Structure Member Type Scale Content Remarks MTR_PI_CT...

Page 34: ...oltage at draw in ms CP_MAX_SPEED_RPM 2650 Maximum of rotational speed command Mechanical angle rpm CP_MIN_SPEED_RPM 1200 Minimum of rotational speed command Mechanical angle rpm CP_LIMIT_SPEED_CHANGE...

Page 35: ...PM Speed to change open loop mode1 Mechanical angle rpm OL_MODE2_CHANGE_RPM CP_OL_MODE2_CHANGE_RPM Speed to change open loop mode2 Mechanical angle rpm OL_START_REFV int16 CP_OL_START_REFV Voltage ref...

Page 36: ...setting value MTR_HALF_CARRIER_SET MTR_CARRIER_SET 2 Half of MTR_CARRIER_SET MTR_NDT_CARRIER_SET MTR_CARRIER_SET MTR_DEADTIME_SET MTR_PORT_UP CA P1 5 CC RL P1_bit no5 U phase positive phase output por...

Page 37: ..._ADCCH_VR1 0 A D Converter channel of VR1 MTR_ADCCH_VDC 3 A D Converter channel of inverter bus voltage MTR_ADCCH_VU 17 A D Converter channel of U phase voltage MTR_ADCCH_VV 18 A D Converter channel o...

Page 38: ...s scale Q3 MTR_CNT_START_CALC 30 Wait speed measurement still zero cross is detected become this counts MTR_SPEED_LPF_K int16 CP_SPEED_LPF_K Speed LPF parameter MTR_LIMIT_SPEED_CHANGE CP_LIMIT_SPEED_...

Page 39: ..._OL_MODE1_CHANGE_RPM Frequency to change open loop mode1 Hz MTR_OL_MODE2_CHANGE_FREQ int16 MTR_OL_FREQ_CALC MTR_POLE_PAI RS MTR_OL_MODE2_CHANGE_RPM Frequency to change open loop mode2 Hz MTR_PATTERN_C...

Page 40: ...LG_CLR 0 Constant for flag management MTR_FLG_SET 1 MTR_MODE_INACTIVE 0x00 Inactive mode MTR_MODE_ACTIVE 0x01 Active mode MTR_MODE_ERROR 0x02 Error mode MTR_SIZE_STATE 3 State size MTR_EVENT_INACTIVE...

Page 41: ...r MTR_ERROR_UNKNOWN 0xff Unknown error MTR_DRAW_IN_NONE 0 initial state not work MTR_DRAW_IN_1ST 1 draw in the 1st initial position MTR_DRAW_IN_2ND 2 draw in the 2nd initial position MTR_DRAW_IN_FINIS...

Page 42: ...Figure 3 7 Main Process Flowchart Main process Initialization of peripheral functions Initialization of user interface Initialization of variables used in the main process Initialization of sequence p...

Page 43: ...t Get inverter bus voltage value Measure the voltage of three phase Cancel voltage offset SYSTEM MODE speed reference PI control Commutation with pseudo Hall pattern Detect zero cross End INACTIVE ACT...

Page 44: ...ing DRIVE MODE BOOT MODE Calculate speed reference Calculate voltage reference Set PWM duty Set conduction pattern to draw in the rotor Finish draw in Go to DRIVE MODE Go to BOOT MODE Finish offset pr...

Page 45: ...ure 3 10 Overcurrent detection process Hardware detection Figure 3 11 Overcurrent detection process PGA CMP0 1 interrupt Overcurrent detection interrupt Hardware End Generate error event Disable INTP0...

Page 46: ...netic synchronous motor Implementation R01AN3582EJ0100 Rev 1 00 Page 46 of 46 Jan 13 2017 Website and Support Renesas Electronics Website http www renesas com Inquiries http www renesas com contact Al...

Page 47: ...Revision History Rev Date Description Page Summary 1 00 Jan 13 2017 First edition issued...

Page 48: ...p power on reset function are not guaranteed from the moment when power is supplied until the power reaches the level at which resetting has been specified 3 Prohibition of Access to Reserved Addresse...

Page 49: ...any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or systems manufactured by you 8 Please contac...

Reviews: