Microchip logo
  • All
  • Products
  • Documents
  • Applications Notes

Motor Control Library Overview

This library is a collection of optimized functions designed to be used in developing 3-phase motor control applications on dsPIC® Digital Signal Controllers (DSCs).

For customers looking for our 32-bit motor control software solutions:

  • For the PIC32MK series of microcontrollers (MCUs), please refer to MPLAB Harmony for the latest code examples
  • For Arm® Cortex® based SAM devices (SAM C/D/E families), please refer to Atmel START

Description

The Motor Control Library contains function blocks that are optimized for the dsPIC33C, E and F families of DSCs. All functions in this Motor Control Library have input(s) and output(s), but do not access any of the DSC peripherals. The library functions are designed to be used within an application framework to provide an efficient and flexible solution for implementing a FOC motor control application.

The block diagram to the right shows a typical usage scenario. The user-developed motor control application interfaces to the DSC peripherals while using function calls into this library to perform most of the time-critical operations.

The Motor Control Library hosts functions in two implementation variants:

  1. C - functions are declared with static and inline keywords.
  2. Assembly - functions are defined in a C-callable archive file with function interfaces defined in the motor_control.h file.

Library users may choose to use one or both or a mixture of these two implementation variants. Unused implementation variants of the library will not consume data or program memory on the target device.

Motor-Control-Library

Elements of the Library

Interface Header File: motor_control.h

The interfaces to the Motor Control library are defined in the " motor_control.h " header file. Any C language source (.c) file that uses the Motor Control library should include the " motor_control.h ".

Library Files: libmotor_control_dspic33e-elf.a & libmotor_control_dspic33f-elf.a

The Motor Control library archive (.a) files installed with the library release. The prototypes for library functions hosted by the archive files are described in the motor_control.h file. Both of these archive files released with the library are built using the ELF-type of Object Module Format (OMF).

Inline C Definitions Header File: motor_control_inline_dspic.h

This header file hosts the C language definitions of the library functions. The " motor_control_inline_dspic.h " is automatically included when a C language source (.c) file includes the " motor_control.h " file.

Mapping Header File: motor_control_mapping.h

This header file defines a short function name for each of the library functions and maps it, by default, to the prototype of one of the implementation variants. The " motor_control_mapping.h " is automatically included when a C language source (.c) file includes the " motor_control.h " file.

Installation
In order to start using the Motor Control library, download a copy of the library from this webpage using the link below. Then, extract the library files from the downloaded archive file into your application source files folder. For more details on the Usage Model, refer to Help document that is included in the Motor Control library.

Motor Control Library Function list

NameDescription
MC_CalculateSineCosine_Assembly_RamThis function calculates the Sine and Cosine values for a specified angle input.
MC_CalculateSineCosine_InlineC_RamThis function calculates the Sine and Cosine values for a specified angle input.
MC_CalculateSpaceVectorPhaseShifted_AssemblyThis function calculates the duty cycle values based on the three scaled reference vectors in the a-b-c reference frame and the PWM period value.
MC_CalculateSpaceVectorPhaseShifted_InlineCThis function calculates the duty cycle values based on the three scaled reference vectors in the a-b-c reference frame and the PWM period value.
MC_ControllerPIUpdate_AssemblyThis function calculates the PI correction.
MC_ControllerPIUpdate_InlineCThis function calculates the PI correction.
MC_TransformClarke_AssemblyThis function calculates the Clarke transformation.
MC_TransformClarke_InlineCThis function calculates the Clarke transformation.
MC_TransformClarkeInverseSwappedInput_AssemblyThis function calculates the scaled reference vectors using inputs in an alpha-beta reference frame.
MC_TransformClarkeInverseSwappedInput_InlineCThis function calculates the scaled reference vectors using inputs in an alpha-beta reference frame.
MC_TransformPark_AssemblyThis function calculates the Park transformation.
MC_TransformPark_InlineCThis function calculates the Park transformation.
MC_TransformParkInverse_AssemblyThis function calculates the inverse Park transformation.
MC_TransformParkInverse_InlineCThis function calculates the inverse Park transformation.