S32M276 Motor Control Quick Start Guide

Contents of this document

  • 1

    Out of the Box
  • 2

    Get Software
  • 3

    Plug It In
  • 4

    Build Application Project
  • 5

    Application Control

1. Out of the Box

1.1 Get to Know the S32M276SFFRD Board

This Getting Started template describes first steps and SW installation setup for S32M276SFFRD-SW version 2.x. Target location is S32M276SFFRD Getting Started web page.

The Getting Satrted for older S32M276SFFRD-SW package version 1.x is distribuded inside S32M276SFFRD-SW.exe package in pdf format.

Get to Know the XS32M276SFFRD Board

Get to Know the S32M276SFFRD Board

Get to Know the S32M276SFFRD Board

2. Get Software

Sign in at NXP with your credentials

2.1 Select SW packages from Automotive Software Package Manager

Open Automotive Software Package Manager and select S32K3 device.

S32DS3.5 Download 1

Unfold the FRDM Automotive Board Installation Package bundle and check S32 Design Studio, Real-Time Drivers and FreeMASTER software. Other SW packages are optional.

S32DS3.5 Download 2

Click on the Generate Bundle Installer button at the end of the page.

GS-MCSPTR2AK396-IMG51.1.

Follow the wizard instructions for Export Control and SW License Agreement (need to scroll whole text down before accepting). After that, you may close the window. Installer and Installer User Manual download will start automatically in a few moments.

GS-MCSPTR2AK396-IMG51.2

The FRDM Automotive Board Installation Package bundle allows to enable automatic installation and configuration sw without any interaction. That simplifies the installation procedure.

GS-MCSPTR2AK396-IMG51.3

2.2 Add GCC Toolchain Version 10.2

Latest version of the S32 Design Studio contains GCC toolchain only in version 11.4. For full compatibility with RTD, you need to install GCC also in version 10.2.

In S32 Design Studio, go to Help → S32DS Extensions and Updates from the top menu to open the S32DS Extensions and Updates dialogue where you may install it.

S32K3 RTD Download 1 S32K3 RTD Download 2

2.3 Add FreeMASTER Communication Driver for S32M27x

Download updatesite file with FreeMASTER Communication Driver for S32M2.

Download the RTD Drivers Download the RTD Drivers

In S32 Design Studio, go to Help → S32DS Extensions and Updates from the top menu to open the S32DS Extensions and Updates dialogue where you click on Add Update Sites and install it.

Download the RTD Drivers Download the RTD Drivers

2.4 Get FreeMASTER Application Tool for Real-Time Debugging

Download and install FreeMASTER application tool for real-time debugging

Download the Patch for RTD Drivers

2.5 Get Automotive Math and Motor Control Library (AMMCLib) Set

Download and install AMMCLib for S32M27x.

Add the RTD Drivers to S32DS GS-MCSPTR2AK396-IMG59N.1.

2.6 Download the Development Kit Application Software

Download and install S32M276SFFRD motor control application software package.

Download and Install the Draft of S32M276 Add the RTD Patch 20 to S32DS

3. Plug It In

The recommended accessory kit for S32M276SFFRD board is BLDC_KIT (software developed and tuned for given motor), however you may use any suitable 3 ph motor and 12 V power supply instead.

BLDC Motor Control Accessory Kit with Cables Top View

BLDC Motor Control Accessory Kit with Cables Top View

BLDC_KIT Content:

  • 95 W BLDC motor with HALL sensors Sunrise 42BLY3A78-24110
  • Plexiglass
  • 12 V, 5 A power supply Meanwell GST60A12-P1J
  • Power supply cable with set of universal plugs
  • Four self-adhesive standoffs for any EVB Takachi AST3-10B
  • Micro-USB cable

In addition to BLDC_KIT, you will also need:

  • Standard 6.3 mm FASTON connectors (3 pcs for motor, 2 pcs for power supply)
  • Wire conversion from 2.1 mm barrel connector (male) to FASTON
  • UART-USB serial interface for run-time debugging
  • JTAG debug interface like PEmicro USB Multilink or Segger J-Link

3.1 Plug the Motor and Power Supply

Plug In the Motor

Plug In the Motor

3.2 Optionally Plug the Encoder/Hall Sensors (Only for Sensor-Based SW Application)

Optionally Plug In the Encoder/HALL Sensors

Optionally Plug In the Encoder/HALL Sensors

3.3 Plug In the JTAG Debug Interface

Plug In the JTAG Debug Interface

Plug In the JTAG Debug Interface

3.4 Plug In the UART to USB Interface

For run-time debugging is recommended serial interface.

Plug In the UART to USB Interface

Plug In the UART to USB Interface

4. Build Application Project

Let's take your S32M276SFFRD motor control kit for a test drive.

4.1 Select Application and MCU Programming

Select the appropriate PMSM or BLDC motor control application from the installed directory NXP\MC_DevKits\S32M276SFFRD\sw.

To import the installed application software project in the S32 Design Studio IDE for S32 Platform:

  1. Launch S32DS for S32 Platform
  2. Go to File > Import, then select General > Existing Projects into Workspace
  3. Import Project
  4. Navigate to the installed application directory: NXP\MC_DevKits\S32M276SFFRD\sw and choose appropriate project and click OK. Then, click Finish.
  5. Import MCSPTR2AK396 Project

4.2 Use Configuration Tool

  1. Unfold structure of the project with low-level drivers and double-click on *.mex file to open the project configuration in S32 Configuration Tool Use Configuration Tool
  2. Please ensure that you configure appropriate project and click on "Update Code" button for generating configuration files Use Configuration Tool

4.3 Upload Software and Debug

In S32DS, return back to the C/C++ perspective.

Upload Software and Debug

Use the Debug Configuration menu and select the predefined debug configuration for building and uploading software into MCU.

Upload Software and Debug

Upload Software and Debug

Upload Software and Debug

The S32DS will switch into debug perspective where you may let the code run by clicking on Resume (or press F8), and use Disconnect to avoid interference between the S32DS IDE debugger and the FreeMASTER tool.

Upload Software and Debug Upload Software and Debug

4.4 Set Up the Debugging Tool

Launch the FreeMASTER application.

To open the *.pmpx FreeMASTER project <selected project>\FreeMASTER_control, click File → Open Project .

Set Up the Debugging Tool

To enable communication, in the FreeMASTER tool bar, click Go (or press Ctrl + G).

Successful communication displays in the status bar at the bottom as: RS-232 UART Communication;COMn;speed = 115200

Set Up the Debugging Tool

5. Application Control

5.1 Application Setup (Optional Step)

If you run S32M276SFFRD sw on modified or own hardware platform, you may need to edit hardware scales and fault triggers. In the Motor Control Application Tuning (MCAT) Tool switch to Application Setup page and edit values on left side.

Motor Parameters (optional step)

Once you finish, click on Save config to generate static configuration file. You may check file content at Output file page.

Now repeat step from Upload Software and Debug section to build the project and upload the code into MCU.

5.2 Motor Parametrization and Control Loops Autotuning (Optional Step)

In a case of motor change, you may benefit from new MCAT 2.0 motor parametrization and control loops autotuning features.

At Motor Parameters page fill four basic motor parameters that canot be detected automatically:

  • Number of pole pairs
  • Nominal Current
  • Nominal Speed
  • Maximum Speed

Click on Update target buton and start the motor parameters estimation and automating tuning for control loops.

Parameters are automatically updated typically in less than a minute.

Motor Parameters (optional step)

For more information about the automatic motor parametrization and control loops autotuning please read AN15061 Application Note in S32M276SFFRD\doc folder. Default path: c:\NXP\MC_DevKits\S32M276 SFFRD\doc\ApplicationNotes\AN15061 MCAT 2.0 - Motor Control Application Tuning Tool for PMSM FOC.pdf

5.3 Spin the Motor

Switch for example to Speed Loop page. Under Speed control tab, configure Required speed and turn on the motor drive.

Spin the Motor

Select one of predefined Scopes or Recorders in Project Tree to watch the application variables real-time.

For comfortable run-time debugging you may create or modify any of scopes or recorders.

Spin the Motor
  • Check pending faults
  • In case of pending faults, click the CLEAR button at MCAT control tab.

    Spin the Motor
  • Start application
  • Click On/Off on the control bar to initiate clockwise/counterclockwise spinning of the rotor.

  • Set Speed
  • Modify Required speed field on the Speed control bar or change Speed Required in Variable Watch window.

    Spin the Motor
  • Stop Application
  • Stop the motor by clicking On/Off button on the MCAT control page or by clear On/Off variable.

Application Control

Motor Parameters (Optional Step)

If you do not use BLDC_KIT (motor Sunrise 42BLY3A78-24110), you may need to edit the motor parameters according to used BLDC/PMSM motor. In the Motor Control Application Tuning (MCAT) Tool switch to Parameters tab and edit values on left side.

Motor Parameters (optional step)

Once you finish, click on Store Data, switch to Output File tab and Generate static configuration file.

Motor Parameters (optional step)

Now repeat step 4.3 to build the project and upload the code into MCU.

Spin the Motor

Click the App Control tab on the Motor Control Application Tuning (MCAT) Tool menu to display the application control page.

Configure the motor rpms and turn on the motor drive.

Spin the Motor

Check Pending Faults

In case of pending faults, click the Clear FAULT on the FreeMASTER MCAT control page.

Start Application

Click On/Off on the control page to initiate clockwise/counterclockwise spinning of the rotor.

Set Speed

Change the speed required variable to set the speed. Go to the Variable Watch window and modify Speed Required variable or click on the speed gauge.

Stop application

Stop the application by clicking On/Off button on the FreeMASTER MCAT control page.

RTD Examples

Kickstart your RTD journey with these handy examples. We've rounded up some of the most common use cases to get you inspired and moving forward.

Users can copy the path directly into their window once the RTD is downloaded.

RTD Examples

AE HANDLER FAULTS

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Ae_TS_T40D34M30I0R0\examples\S32DS\S32M276\Ae_Handler_Faults_Example_DS_001_S32M276

AE SPI

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Ae_TS_T40D34M30I0R0\examples\S32DS\S32M276\Ae_Spi_Example_DS_001_S32M276

AEC SPI

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Ae_TS_T40D34M30I0R0\examples\S32DS\S32M276\Aec_Ip_Spi_Example_DS_001_S32M276

CAN TRCV

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\CanTrcv_43_AE_TS_T40D34M30I0R0\examples\S32DS\S32M276\CanTrcv_Example_S32M276

DPGA

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Dpga_TS_T40D34M30I0R0\examples\S32DS\S32M276\Dpga_example_S32M276

DPGA IP

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Dpga_TS_T40D34M30I0R0\examples\S32DS\S32M276\Dpga_Ip_example_S32M276

GDU

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Gdu_TS_T40D34M30I0R0\examples\S32DS\S32M276\Gdu_Example_DS_S32M276

LIN TRCV

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Lin_43_LPUART_FLEXIO_TS_T40D34M30I0R0\examples\S32DS\S32M276\Lin_LinTrcv_Flexio_MasterFrameTransfer_S32M276

LIN TRCV LPUART

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Lin_43_LPUART_FLEXIO_TS_T40D34M30I0R0\examples\S32DS\S32M276\Lin_LinTrcv_Lpuart_MasterFrameTransfer_S32M276

CLOCK IP

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Mcu_TS_T40D34M30I0R0\examples\S32DS\S32M276\Clock_Ip_Example_S32M276

MCU

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Mcu_TS_T40D34M30I0R0\examples\S32DS\S32M276\Mcu_Example_S32M276

POWER IP

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Mcu_TS_T40D34M30I0R0\examples\S32DS\S32M276\Power_Ip_Example_S32M276

MEM OTP IP

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Ocotp_TS_T40D34M30I0R0\examples\S32DS\S32M276\Mem_Otp_Ip_Example_S32M276

OCOTP

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Ocotp_TS_T40D34M30I0R0\examples\S32DS\S32M276\Ocotp_Example_S32M276

PLATFORM MPU HLD

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Platform_TS_T40D34M30I0R0\examples\S32DS\S32M276\Platform_MPU_HLD_Example_S32M276

MPU IP

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Platform_TS_T40D34M30I0R0\examples\S32DS\S32M276\Platform_MPU_IP_Example_S32M276

PORT

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Port_TS_T40D34M30I0R0\examples\S32DS\S32M276\Port_Example_S32M276

SIUL2 PORT IP

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Port_TS_T40D34M30I0R0\examples\S32DS\S32M276\Siul2_Port_Ip_Example_S32M276

WDOG

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Wdg_TS_T40D34M30I0R0\examples\S32DS\S32M276\Wdg_Example_S32M276

WDOG IP

C:\NXP\S32DS.3.6.1\S32DS\software\PlatformSDK_S32K3\RTD\Wdg_TS_T40D34M30I0R0\examples\S32DS\S32M276\Wdg_Ip_Example_S32M276

Support

Forums

Connect with other engineers and get expert advice on designing with the S32M276SFFRD Reference Design Board using our community sites.