This user's guide describes the General Motor Control Library (GMCLIB) for the family
of DSP56800E core-based digital signal controllers. This library contains optimized
functions.
1.1.2
Data types
GMCLIB supports several data types: (un)signed integer, fractional, and accumulator.
The integer data types are useful for general-purpose computation; they are familiar to
the MPU and MCU programmers. The fractional data types enable powerful numeric and
digital-signal-processing algorithms to be implemented. The accumulator data type is a
combination of both; that means it has the integer and fractional portions.
The following list shows the integer types defined in the libraries:
• Unsigned 16-bit integer —<0 ; 65535> with the minimum resolution of 1
• Signed 16-bit integer —<-32768 ; 32767> with the minimum resolution of 1
• Unsigned 32-bit integer —<0 ; 4294967295> with the minimum resolution of 1
• Signed 32-bit integer —<-2147483648 ; 2147483647> with the minimum resolution
of 1
The following list shows the fractional types defined in the libraries:
• Fixed-point 16-bit fractional —<-1 ; 1 - 2
• Fixed-point 32-bit fractional —<-1 ; 1 - 2
-15
> with the minimum resolution of 2
-31
> with the minimum resolution of 2
-15
-31
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.5
Introduction
The following list shows the accumulator types defined in the libraries:
• Fixed-point 16-bit accumulator —<-256.0 ; 256.0 - 2-7> with the minimum
resolution of 2
GMCLIB uses the types mentioned in the previous section. To enable simple usage of the
algorithms, their names use set prefixes and postfixes to distinguish the functions'
versions. See the following example:
• lss—the types of the function inputs; if all the inputs have the same type as the
output, the inputs are not marked
The input and output types are described in the following table:
Table 1-1. Input/output types
TypeOutputInput
frac16_tF16s
frac32_tF32l
acc32_tA32a
1.1.4Supported compilers
GMCLIB for the DSP56800E core is written in assembly language with C-callable
interface. The library is built and tested using the following compilers:
• CodeWarrior™ Development Studio
For the CodeWarrior™ Development Studio, the library is delivered in the gmclib.lib
file.
GMCLIB User's Guide, Rev. 2, 10/2015
6Freescale Semiconductor, Inc.
Chapter 1 Library
The interfaces to the algorithms included in this library are combined into a single public
interface include file, gmclib.h. This is done to lower the number of files required to be
included in your application.
1.1.5Special issues
1. The equations describing the algorithms are symbolic. If there is positive 1, the
number is the closest number to 1 that the resolution of the used fractional type
allows. If there are maximum or minimum values mentioned, check the range
allowed by the type of the particular function version.
2. The library functions require the core saturation mode to be turned off, otherwise the
results can be incorrect. Several specific library functions are immune to the setting
of the saturation mode.
3. The library functions round the result (the API contains Rnd) to the nearest (two's
complement rounding) or to the nearest even number (convergent round). The mode
used depends on the core option mode register (OMR) setting. See the core manual
for details.
4. All non-inline functions are implemented without storing any of the volatile registers
(refer to the compiler manual) used by the respective routine. Only the non-volatile
registers (C10, D10, R5) are saved by pushing the registers on the stack. Therefore, if
the particular registers initialized before the library function call are to be used after
the function call, it is necessary to save them manually.
1.2
Library integration into project (CodeWarrior™
Development Studio)
This section provides a step-by-step guide to quickly and easily integrate the GMCLIB
into an empty project using CodeWarrior™ Development Studio. This example uses the
MC56F8257 part, and the default installation path (C:\Freescale\FSLESL
\DSP56800E_FSLESL_4.2) is supposed. If you have a different installation path, you
must use that path instead.
1.2.1
To start working on an application, create a new project. If the project already exists and
is open, skip to the next section. Follow the steps given below to create a new project.
1. Launch CodeWarrior™ Development Studio.
Freescale Semiconductor, Inc.7
New project
GMCLIB User's Guide, Rev. 2, 10/2015
Library integration into project (CodeWarrior™ Development Studio)
2. Choose File > New > Bareboard Project, so that the "New Bareboard Project" dialog
appears.
3. Type a name of the project, for example, MyProject01.
4. If you don't use the default location, untick the “Use default location” checkbox, and
type the path where you want to create the project folder; for example, C:
\CWProjects\MyProject01, and click Next. See Figure 1-1.
Figure 1-1. Project name and location
5. Expand the tree by clicking the 56800/E (DSC) and MC56F8257. Select the
Application option and click Next. See Figure 1-2.
Figure 1-2. Processor selection
6. Now select the connection that will be used to download and debug the application.
In this case, select the option P&E USB MultiLink Universal[FX] / USB MultiLink
and Freescale USB TAP, and click Next. See Figure 1-3.
GMCLIB User's Guide, Rev. 2, 10/2015
8Freescale Semiconductor, Inc.
Chapter 1 Library
Figure 1-3. Connection selection
7. From the options given, select the Simple Mixed Assembly and C language, and
click Finish. See Figure 1-4.
Figure 1-4. Language choice
The new project is now visible in the left-hand part of CodeWarrior™ Development
Studio. See Figure 1-5.
Figure 1-5. Project folder
1.2.2
Library path variable
To make the library integration easier, create a variable that will hold the information
about the library path.
1. Right-click the MyProject01 node in the left-hand part and click Properties, or select
Project > Properties from the menu. The project properties dialog appears.
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.9
Library integration into project (CodeWarrior™ Development Studio)
2. Expand the Resource node and click Linked Resources. See Figure 1-6.
Figure 1-6. Project properties
3. Click the 'New…' button on the right-hand side.
4. In the dialog that appears (see Figure 1-7), type this variable name into the Name
box: FSLESL_LOC
5. Select the library parent folder by clicking 'Folder…' or just typing the following
path into the Location box: C:\Freescale\FSLESL\DSP56800E_FSLESL_4.2_CW
and click OK.
6. Click OK in the previous dialog.
GMCLIB User's Guide, Rev. 2, 10/2015
10Freescale Semiconductor, Inc.
Figure 1-7. New variable
Chapter 1 Library
1.2.3
Library folder addition
To use the library, add it into the CodeWarrior Project tree dialog.
1. Right-click the MyProject01 node in the left-hand part and click New > Folder, or
select File > New > Folder from the menu. A dialog appears.
2. Click Advanced to show the advanced options.
3. To link the library source, select the third option—Link to alternate location (Linked
Folder).
4. Click Variables…, and select the FSLESL_LOC variable in the dialog that appears,
click OK, and/or type the variable name into the box. See Figure 1-8.
5. Click Finish, and you will see the library folder linked in the project. See Figure 1-9
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.11
Library integration into project (CodeWarrior™ Development Studio)
Figure 1-8. Folder link
Figure 1-9. Projects libraries paths
1.2.4
Library path setup
GMCLIB requires MLIB and GFLIB to be included too. Therefore, the following steps
show the inclusion of all dependent modules.
1. Right-click the MyProject01 node in the left-hand part and click Properties, or select
Project > Properties from the menu. A dialog with the project properties appears.
GMCLIB User's Guide, Rev. 2, 10/2015
12Freescale Semiconductor, Inc.
Chapter 1 Library
2. Expand the C/C++ Build node, and click Settings.
3. In the right-hand tree, expand the DSC Linker node, and click Input. See Figure 1-11.
4. In the third dialog Additional Libraries, click the 'Add…' icon, and a dialog appears.
5. Look for the FSLESL_LOC variable by clicking Variables…, and then finish the
path in the box by adding one of the following:
• ${FSLESL_LOC}\MLIB\mlib_SDM.lib—for small data model projects
• ${FSLESL_LOC}\MLIB\mlib_LDM.lib—for large data model projects
6. Tick the box Relative To, and select FSLESL_LOC next to the box. See Figure 1-9.
Click OK.
7. Click the 'Add…' icon in the third dialog Additional Libraries.
8. Look for the FSLESL_LOC variable by clicking Variables…, and then finish the
path in the box by adding one of the following:
• ${FSLESL_LOC}\GFLIB\gflib_SDM.lib—for small data model projects
• ${FSLESL_LOC}\GFLIB\gflib_LDM.lib—for large data model projects
9. Tick the box Relative To, and select FSLESL_LOC next to the box. Click OK.
10. Click the 'Add…' icon in the Additional Libraries dialog.
11. Look for the FSLESL_LOC variable by clicking Variables…, and then finish the
path in the box by adding one of the following:
• ${FSLESL_LOC}\GMCLIB\gmclib_SDM.lib—for small data model projects
• ${FSLESL_LOC}\GMCLIB\gmclib_LDM.lib—for large data model projects
12. Tick the box Relative To, and select FSLESL_LOC next to the box. Click OK.
13. Now, you will see the libraries added in the box. See Figure 1-11.
Figure 1-10. Library file inclusion
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.13
Library integration into project (CodeWarrior™ Development Studio)
Figure 1-11. Linker setting
14. In the tree under the DSC Compiler node, click Access Paths.
15. In the Search User Paths dialog (#include “…”), click the 'Add…' icon, and a dialog
will appear.
16. Look for the FSLESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${FSLESL_LOC}\MLIB\include.
17. Tick the box Relative To, and select FSLESL_LOC next to the box. See Figure 1-12.
Click OK.
18. Click the 'Add…' icon in the Search User Paths dialog (#include “…”).
19. Look for the FSLESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${FSLESL_LOC}\GFLIB\include.
20. Tick the box Relative To, and select FSLESL_LOC next to the box. Click OK.
21. Click the 'Add…' icon in the Search User Paths dialog (#include “…”).
22. Look for the FSLESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${FSLESL_LOC}\GMCLIB\include.
23. Tick the box Relative To, and select FSLESL_LOC next to the box. Click OK.
24. Now you will see the paths added in the box. See Figure 1-13. Click OK.
GMCLIB User's Guide, Rev. 2, 10/2015
14Freescale Semiconductor, Inc.
Figure 1-12. Library include path addition
Chapter 1 Library
Figure 1-13. Compiler setting
The final step is typing the #include syntax into the code. Include the library into the
main.c file. In the left-hand dialog, open the Sources folder of the project, and doubleclick the main.c file. After the main.c file opens up, include the following lines into the
#include section:
When you click the Build icon (hammer), the project will be compiled without errors.
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.15
Library integration into project (CodeWarrior™ Development Studio)
GMCLIB User's Guide, Rev. 2, 10/2015
16Freescale Semiconductor, Inc.
Chapter 2
Algorithms in detail
2.1GMCLIB_Clark
The
GMCLIB_Clark function calculates the Clarke transformation, which is used to
transform values (flux, voltage, current) from the three-phase coordinate system to the
two-phase (α-β) orthogonal coordinate system, according to the following equations:
Equation 1
Equation 2
2.1.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the GMCLIB_Clark function are shown in the following table:
Clarke transformation of a 16-bit fractional three-phase system input to a 16-bit fractional twophase system. The input and output are within the fractional range <-1 ; 1).
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.17
GMCLIB_ClarkInv
2.1.2Declaration
The available GMCLIB_Clark functions have the following declarations:
/* Periodical function or interrupt */
void Isr(void)
{
/* Clarke Transformation calculation */
GMCLIB_Clark_F16(&sAbc, &sAlphaBeta);
}
2.2
GMCLIB_ClarkInv
The GMCLIB_ClarkInv function calculates the Clarke transformation, which is used to
transform values (flux, voltage, current) from the two-phase (α-β) orthogonal coordinate
system to the three-phase coordinate system, according to the following equations:
Equation 3
Equation 4
Equation 5
GMCLIB User's Guide, Rev. 2, 10/2015
18Freescale Semiconductor, Inc.
Chapter 2 Algorithms in detail
2.2.1Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the GMCLIB_ClarkInv function are shown in the following
table:
Inverse Clarke transformation with a 16-bit fractional two-phase system input and a 16-bit
fractional three-phase output. The input and output are within the fractional range <-1 ; 1).
2.2.2Declaration
The available GMCLIB_ClarkInv functions have the following declarations:
/* Periodical function or interrupt */
void Isr(void)
{
/* Inverse Clarke Transformation calculation */
GMCLIB_ClarkInv_F16(&sAlphaBeta, &sAbc);
}
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.19
GMCLIB_Park
2.3GMCLIB_Park
The GMCLIB_Park function calculates the Park transformation, which transforms values
(flux, voltage, current) from the stationary two-phase (α-β) orthogonal coordinate system
to the rotating two-phase (d-q) orthogonal coordinate system, according to the following
equations:
Equation 6
Equation 7
where:
• θ is the position (angle)
2.3.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the GMCLIB_Park function are shown in the following table:
The Park transformation of a 16-bit fractional two-phase stationary system input to a 16-bit
fractional two-phase rotating system, using a 16-bit fractional angle two-component (sin / cos)
position information. The inputs and the output are within the fractional range <-1 ; 1).
2.3.2Declaration
The available GMCLIB_Park functions have the following declarations:
/* Periodical function or interrupt */
void Isr(void)
{
/* Park Transformation calculation */
GMCLIB_Park_F16(&sAlphaBeta, &sAngle, &sDQ);
}
2.4
GMCLIB_ParkInv
The GMCLIB_ParkInv function calculates the Park transformation, which transforms
values (flux, voltage, current) from the rotating two-phase (d-q) orthogonal coordinate
system to the stationary two-phase (α-β) coordinate system, according to the following
equations:
Equation 8
Equation 9
where:
• θ is the position (angle)
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.21
GMCLIB_ParkInv
2.4.1Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the GMCLIB_ParkInv function are shown in the following
table:
Inverse Park transformation of a 16-bit fractional two-phase rotating system input to a 16-bit
fractional two-phase stationary system, using a 16-bit fractional angle two-component (sin / cos)
position information. The inputs and the output are within the fractional range <-1 ; 1).
2.4.2Declaration
The available GMCLIB_ParkInv functions have the following declarations:
The GMCLIB_DecouplingPMSM function calculates the cross-coupling voltages to
eliminate the d-q axis coupling that causes nonlinearity of the control.
The d-q model of the motor contains cross-coupling voltage that causes nonlinearity of
the control. Figure 2-1 represents the d-q model of the motor that can be described using
the following equations, where the underlined portion is the cross-coupling voltage:
Equation 10
where:
• ud, uq are the d and q voltages
• id, iq are the d and q currents
• Rs is the stator winding resistance
• Ld, Lq are the stator winding d and q inductances
• ωel is the electrical angular speed
• ψr is the rotor flux constant
GMCLIB User's Guide, Rev. 2, 10/2015
Freescale Semiconductor, Inc.23
GMCLIB_DecouplingPMSM
Figure 2-1. The d-q PMSM model
To eliminate the nonlinearity, the cross-coupling voltage is calculated using the
GMCLIB_DecouplingPMSM algorithm, and feedforwarded to the d and q voltages. The
decoupling algorithm is calculated using the following equations:
Equation 11
where:
• ud, uq are the d and q voltages; inputs to the algorithm
• u
ddec
, u
are the d and q decoupled voltages; outputs from the algorithm
qdec
The fractional representation of the d-component equation is as follows:
Equation 12
The fractional representation of the q-component equation is as follows:
GMCLIB User's Guide, Rev. 2, 10/2015
24Freescale Semiconductor, Inc.
Loading...
+ 55 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.