Link Search Menu Expand Document

MCHP

PMSM FOC using Reduced Order Luenberger Observer

This application implements the sensorless field oriented control (FOC) of a permanent magnet synchronous motor (PMSM). It estimates rotor position from measured phase currents and a reduced order luenberger observer (ROLO). This algorithm is implemented on a SAMC21J18A MCU.

Description

Permanent Magnet Synchronous Motor (PMSM) is controlled using Field Oriented Control (FOC). Rotor position and speed is determined using Reduced Order Luenberger Observer. Motor start/stop operation is controlled by the switch and motor speed can be changed by the on-board potentiometer. Waveforms and variables can be monitored runtime using X2CScope.

Key features enabled in this project are:

  • Dual shunt current measurement
  • Speed control loop

MHC Project Configurations

MHC Project Graph

  • PMSM_FOC:

    • This component configures FOC algorithm parameters, motor parameters and motor control board parameters. It connects to underlying peripheral libraries ADC and TCC. This component auto configures ADC channels and PWM channels as per PMSM_FOC component configurations.
  • ADC0-ADC1 Peripheral:

    • ADC0 and ADC1 are setup to operate in Master - Slave mode with ADC0 acting as a Master.
    • Both ADCs convert single ended inputs. Phase U current is sampled and converted by ADC0 and Phase V current is sampled and converted by ADC1.
    • Both ADCs are hardware triggered simultaneously by an event generated from TCC0 at the end of each PWM cycle.
    • Conversion Ready interrupt is generated by ADC0. Since both ADCs are triggered simultaneously and have same resolution and sampling time, both ADCs complete conversion at the same time.
  • TCC0 Peripheral:

    Configured to generate three pairs of complimentary PWM signals at a frequency of 10 kHz in “Dual Slope PWM with interrupt/event when counter = ZERO” a.k.a. “Center Aligned Mode”.

    • Event output is enabled which is generated when the counter reaches ZERO.
    • Dead-time is enabled and set to
      • mchv3_sam_c21_pim.X. - 2uS
      • mclv2_sam_c21_pim.X. - 1uS
    • Non-recoverable Fault is enabled on EV0. When an event is detected on EV0, all PWM channels are held low.
  • EIC:
    • External Interrupt Controller detects a hardware over-current fault input and generates a non-recoverable fault event for TCC0, thereby shutting down the PWM in the event of an over-current fault.
  • EVSYS:
    • Event System acts as an intermediary between event generator and event users.
    • Event generated by the TCC0 when the counter reaches ZERO, is used by the ADC0 as a hardware trigger source via the Event System.
    • Event generated by the EIC upon over-current fault, is used by the TCC0 as a non-recoverable fault event via the Event System.
  • DIVAS:
    • This demo uses “Divide and Square Root Accelerator” to perform 32-bit signed and unsigned division and 32-bit unsigned square root operations.
    • DIVAS is set to overload “Divide - / “ operator i.e. c = a / b; would use DIVAS accelerator for division without using a special API. However, square root operation would still require a special API. Refer to the DIVAS help for more details.
  • SERCOM3 Peripheral:
    • SERCOM3 is configured in USART mode and is set to operate at 115200 bps.
    • This USART channel is used by the X2CScope plugin to plot or watch global variables in run-time. Refer to X2C Scope Plugin section for more details on how to install and use the X2CScope.

Control Algorithm

This section briefly explains the FOC control algorithm, software design and implementation. Refer to Application note AN2590 for the ROLO based estimator based sensor-less FOC technique in detail.

Field Oriented Control is the technique used to achieve the decoupled control of torque and flux. This is done by transforming the stator current quantities (phase currents) from stationary reference frame to torque and flux producing currents components in rotating reference frame using mathematical transformations. The Field Oriented Control is done as follows:

  1. Measure the motor phase currents.
  2. Transform them into the two phase system (a, b) using the Clarke transformation.
  3. Measure the rotor position angle.
  4. Transform stator currents into the d,q-coordinate system using the Park transformation.
  5. The stator current torque (iq) and flux (id) producing components are controlled separately by the controllers.
  6. The output stator voltage space vector is transformed back from the d,q-coordinate system into the two phase system fixed with the stator by the Inverse Park transformation.
  7. Using the space vector modulation, the three-phase output voltage is generated.

The following block diagram shows the software realization of the FOC algorithm.

Block Diagram

Software Design

Please refer to PMSM_FOC Library for state machine, flow charts and detailed software design.

Development Kits

MCLV2 with SAMC21 Family Motor Control PIM

Downloading and building the application

To clone or download this application from Github, go to the main page of this repository and then click Clone button to clone this repository or download as zip file. This content can also be downloaded using content manager by following these instructions.

Path of the application within the repository is apps/pmsm_foc_rolo_sam_c21 .

To build the application, refer to the following table and open the project using its IDE.

Project Name Description Demo User Guide
mclv2_sam_c21_pim.X MPLABX project for MCLV2 board with SAMC21 PIM MCLV2 with SAMC21 PIM
     

MCHV3 with SAMC21 Family Motor Control PIM

Downloading and building the application

To clone or download this application from Github, go to the main page of this repository and then click Clone button to clone this repository or download as zip file. This content can also be downloaded using content manager by following these instructions.

Path of the application within the repository is apps/pmsm_foc_rolo_sam_c21 .

To build the application, refer to the following table and open the project using its IDE.

Project Name Description Demo User Guide
mchv3_sam_c21_pim.X MPLABX project for MCHV3 board with SAMC21 PIM MCHV3 with SAMC21 PIM
     


Copyright © 2020 Microchip Technology.