background image

• The available APIs for the PWM are:

mcdrv_pwma_pwm3ph_t

—MCDRV PWM structure data type.

void M1_MCDRV_PWM_PERIPH_INIT

—this function is by default called during the PWM periphery initialization

procedure invoked by the 

MCDRV_Init_M1()

 function.

void M1_MCDRV_PWM3PH_SET(mcdrv_pwma_pwm3ph_t*)

—this function updates the PWM phase duty cycles.

void M1_MCDRV_PWM3PH_EN(mcdrv_pwma_pwm3ph_t*)

—this function enables all PWM channels.

void M1_MCDRV_PWM3PH_DIS (mcdrv_pwma_pwm3ph_t*)

—this function disables all PWM channels.

bool_t M1_MCDRV_PWM3PH_FLT_GET(mcdrv_pwma_pwm3ph_t*)

—this function returns the state of the over-

current fault flags and automatically clears the flags (if set). This function returns true when an over-current event occurs.
Otherwise, it returns false.

• The available APIs for the quadrature encoder are:

mcdrv_qd_enc_t

—MCDRV QD structure data type.

void M1_MCDRV_QD_PERIPH_INIT()

—this function is by default called during the QD periphery initialization

procedure invoked by the 

MCDRV_Init_M1()

 function.

void M1_MCDRV_QD_GET(mcdrv_qd_enc_t*)

—this function returns the actual position and speed.

void M1_MCDRV_QD_SET_DIRECTION(mcdrv_qd_enc_t*)

—this function sets the direction of the

quadrature encoder.

void M1_MCDRV_QD_CLEAR(mcdrv_qd_enc_t*)

—this function clears the internal variables and decoder counter.

NXP Semiconductors

Motor-control peripheral initialization

MCUXpresso SDK Field-Oriented Control (FOC) of 3-Phase PMSM and BLDC motors, Rev. 0, 01/2022

User Guide

19 / 50

Summary of Contents for MCUXpresso

Page 1: ...MCUXpresso SDK Field Oriented Control FOC of 3 Phase PMSM and BLDC motors NXP Semiconductors Document identifier PMSMRT1170 User Guide Rev 0 01 2022...

Page 2: ...17 Chapter 6 Motor control peripheral initialization 18 Chapter 7 User interface 20 Chapter 8 Remote control using FreeMASTER 21 Chapter 9 Conclusion 45 Chapter 10 Acronyms and abbreviations 46 Chapt...

Page 3: ...These tools provide a simple and user friendly way for the motor parameter identification algorithm tuning software control debugging and diagnostics This document describes how to run and control th...

Page 4: ...in layout The FRDM MC LVPMSM low voltage 3 phase Permanent Magnet Synchronous Motor PMSM Freedom development platform board has the power supply input voltage of 24 48 VDC with a reverse polarity prot...

Page 5: ...sensors hall and encoder For information on the wiring of feedback sensors see the datasheet on the manufacturer web page The motor parameters are listed in Table 2 Table 2 Teknic M 2310P motor param...

Page 6: ...y the power input wires If used with the hall or encoder sensors connect also the sensor wires to the NXP Freedom power stage Figure 4 Teknic motor connector type 1 NXP Semiconductors Hardware setup M...

Page 7: ...i MX RT1170 runs on the Cortex M7 core at 1 GHz and Arm Cortex M4 at 400 MHz while providing best in class security Table 3 MIMXRT1160 EVK and MIMXRT1170 EVK jumper settings Jumper Setting Jumper Set...

Page 8: ...and solder some resistors Please solder resistor R1841 and R1842 for encoder and remove resistors R188 and R193 for right ADC measuring These resistors are located on the top of the EVK board For more...

Page 9: ...TE 2 Connect the 3 phase motor wires to the screw terminals J7 on the Freedom PMSM power stage 3 On the top of FRDM MC PMSM shield connect by wires following pins Table 4 MIMXRT1170 EVK pin assignment...

Page 10: ...Figure 8 Assembled Freedome system NXP Semiconductors Hardware setup MCUXpresso SDK Field Oriented Control FOC of 3 Phase PMSM and BLDC motors Rev 0 01 2022 User Guide 10 50...

Page 11: ...ipherals take care of the timing and synchronization on the hardware layer In addition you can set the PWM frequency as a multiple of the ADC interrupt ADC ISR frequency where the FOC algorithm is cal...

Page 12: ...trigger control ADC_ETC The ADC_ETC module enables multiple users to share the ADC modules in the Time Division Multiplexing TDM way The external triggers can be brought from the Cross BAR XBAR or oth...

Page 13: ...map linker file including the 4 KB FreeMASTER recorder buffer allocated in RAM The CPU load is measured using the SysTick timer The CPU load is dependent on the fast loop FOC calculation and slow loo...

Page 14: ...mum CPU load is depending on executing functions from RAM or FLASH memory Executing functions can be speeding up in RTCESL_cfg h header file by using macros RAM_OPTIM_HIGH RAM_OPTIM_MEDIUM or RAM_OPTI...

Page 15: ...ue to the possibility to add or remove files and directories The pack_motor_board project includes all the available functions and routines MID functions scalar and vector control of the motor FOC con...

Page 16: ...ntaining the FreeMASTER communication and features setup pin_mux and h port configuration files It is recommended to generate these files in the pin tool peripherals c and h MCUXpresso Config Tool con...

Page 17: ...tial runtime logic and performance errors In some cases warnings can be suspended and these warnings do not show during the compiling process One of such special cases is the unused function warning w...

Page 18: ...easurable on both ADC converters and the two remaining phase currents must be measurable on different ADC converters The reason for this is that the selection of the phase current pair to measure depe...

Page 19: ...atically clears the flags if set This function returns true when an over current event occurs Otherwise it returns false The available APIs for the quadrature encoder are mcdrv_qd_enc_t MCDRV QD struc...

Page 20: ...n and the set of software drivers running in the embedded application Data is transferred between the PC and the embedded application via the serial interface This interface is provided by the CMSIS D...

Page 21: ...g steps to control a PMSM motor using FreeMASTER 1 Download the project from your chosen IDE to the MCU and run it 2 Open the FreeMASTER file pmsm_x pmp The PMSM project uses the TSA by default so it...

Page 22: ...ents one sub module which enables you to tune or control different aspects of the application Besides the MCAT page for PMSM several scopes recorders and variables in the project tree are predefined i...

Page 23: ...le to generate the m1_pmsm_appconfig h file which is then used to preset all application parameters permanently at the project rebuild Online update this tab shows actual values of variables on target...

Page 24: ...endent on the motor speed Both the d axis and q axis stator voltages can be specified in the M1 MCAT Ud Required and M1 MCAT Uq Required fields This control method is useful for the BEMF observer func...

Page 25: ...l devices The position control using the P controller can be tuned in the Speed loop menu tab An encoder sensor is required for the feedback Without the sensor the position control does not work A bra...

Page 26: ...is not STOP 8 4 Identifying parameters of user motor Because the model based control methods of the PMSM drives provide high performance e g dynamic response efficiency obtaining an accurate model of...

Page 27: ...Figure 20 MID FreeMASTER control NXP Semiconductors Remote control using FreeMASTER MCUXpresso SDK Field Oriented Control FOC of 3 Phase PMSM and BLDC motors Rev 0 01 2022 User Guide 27 50...

Page 28: ...utomatically starting a new measurement If a MID fault appears the measurement process immeadiatelly stops and brings the MID state machine safely to the STOP state If a MID warning appears the measur...

Page 29: ...de is automatic Rotor is not fixed In this mode will be performed automatic measurement of the inductances for a definied number NUM_MEAS of different DC current levels using positive values of the DC...

Page 30: ...of pp is correct The required speed for the Ke measurement is also calculated from pp Therefore inaccuracy in pp causes inaccuracy in the resulting Ke Increase Id meas to produce higher torque when sp...

Page 31: ...s freely with no generated torque only by friction This enables you to simply measure the mechanical time constant m J B as the time in which the rotor decelerates from its original value by 63 The fi...

Page 32: ...verall system inertia and can be obtained using a mechanical measurement The J parameter is used to calculate the speed controller constant However the manual controller tuning can also be used to cal...

Page 33: ...tion scales Parameter Units Description Typical range N max rpm Speed scale 1 1 N nom E block V BEMF scale ke Nmax kt Nm A Motor torque constant 7 Check the alignment parameters these fields are calcu...

Page 34: ...ition difference depends on the motor load The higher the load the bigger the difference between the positions due to the load angle Figure 23 Generated and estimated positions 7 If an opposite speed...

Page 35: ...determined as follows 1 Navigate to the Scalar Voltage Control tab in the project tree and select SCALAR_CONTROL in the M1 MCAT Control variable 2 Turn the application switch on The application state...

Page 36: ...loop parameters do not correspond to the required response the bandwidth and attenuation parameters can be tuned 1 Lock the motor shaft 2 Set the required loop bandwidth and attenuation and click the...

Page 37: ...e 27 Figure 27 Optimal step response of the Id current controller The loop bandwidth is high 700 Hz and the response time of the Id current is very fast but with oscillation and overshoot see Figure 2...

Page 38: ...shape equals the Speed Ramp profile 2 The increments are common for the scalar and speed control The increment fields are in the Speed loop tab and accessible in both tuning modes Clicking the Update...

Page 39: ...electrical revolution The higher the value the faster the merge Values close to 1 are set for the drives where a high start up torque and smooth transitions between the open loop and the closed loop a...

Page 40: ...e proportional gain Set the SL_Ki integral gain to 0 Set the speed ramp to 1000 rpm sec or higher Run the motor at a convenient speed about 30 of the nominal speed Set a step in the required speed to...

Page 41: ...ure 32 Speed controller response SL_Kp value is low Speed Actual Filtered greatly overshoots The speed loop response has a small overshoot and the Speed Actual Filtered settling time is sufficient Suc...

Page 42: ...de an example of how to set the position P controller for a PM synchronous motor 1 Select the Position Controller scope in Position Control tab in the FreeMASTER project tree 2 Tune the proportional g...

Page 43: ...n overshoots the required position Figure 35 Position controller response PL_Kp value is too high and the actual position overshoots The PL_Kp value and the actual position response are optimal NXP Se...

Page 44: ...on controller response the actual position response is good NXP Semiconductors Remote control using FreeMASTER MCUXpresso SDK Field Oriented Control FOC of 3 Phase PMSM and BLDC motors Rev 0 01 2022 U...

Page 45: ...r control application timing is described in RT crossover processors features and peripheral settings and the peripheral initialization is described in Motor control peripheral initialization The moto...

Page 46: ...e Input Output LPIT Low power Periodic Interrupt Timer LPUART Low power Universal Asynchronous Receiver Transmitter MCAT Motor Control Application Tuning tool MCDRV Motor Control Peripheral Drivers MC...

Page 47: ...l Application Tuning MCAT Tool for 3 Phase PMSM document AN4642 3 PMSM Field Oriented Control on MIMXRT10xx EVK User s Guide document PMSMFOCRT10xxUG 4 PMSM Field Oriented Control on MIMXRT10xx EVK do...

Page 48: ...d 6 i MX RT1170 EVK board 7 i MX RT Crossover MCUs 8 FRDM MC PMSM Freedome Development Platform 9 MCUXpresso IDE Importing MCUXpresso SDK 10 MCUXpresso Config Tool 11 MCUXpresso SDK Builder SDK exampl...

Page 49: ...ne to the document since the initial release Table 13 Revision history Revision number Date Substantive changes 0 01 2022 Initial release NXP Semiconductors MCUXpresso SDK Field Oriented Control FOC o...

Page 50: ...ate design and operating safeguards to minimize the risks associated with their applications and products NXP the NXP logo NXP SECURE CONNECTIONS FOR A SMARTER WORLD COOLFLUX EMBRACE GREENCHIP HITAG I...

Reviews: