Control
Control
com
Order the parts you need from our real-time inventory database.
Simply complete a request for quotation form with your part
information and a sales representative will respond to you with
price and availability.
Program Flash 8188 x 16-bit 32252 x 16-bit 32252 x 16-bit 61436 x 16-bit
                                      In addition to the fast Analog-to-Digital converter and the 16-bit Quadrature Timers, the most
                                      interesting peripheral, from the PM synchronous motor control point of view, is the Pulse Width
                                      Modulation (PWM) module. The PWM module offers a high degree of freedom in its configuration,
                                      allowing efficient control of the PM synchronous motor.
                                      The PM synchronous motor vector control application utilizes four channels of the Quadrature Timer
                                      module for position and speed sensing. A fifth channel of the Quadrature Timer module is set to
                                      generate a time base for speed sensing and a speed controller.
                                      The Quadrature Decoder is a module providing decoding of position signals from a Quadrature
                                      Encoder mounted on a motor shaft. It has the following features:
                                          •   Includes logic to decode quadrature signals
                                          •   Configurable digital filter for inputs
                                          •   32-bit position counter
                                          •   16-bit position difference counter
                                          •   Maximum count frequency equals the peripheral clock rate
                                          •   Position counter can be initialized by software or external events
                                          •   Preloadable 16-bit revolution counter
                                          •   Inputs can be connected to a general purpose timer to aid low speed velocity.
                                      The PM synchronous motor vector control application utilizes the Quadrature Decoder connected to Quad
                                      Timer module A. It uses the decoder’s digital input filter to filter the encoder’s signals, but does not make
                                      use of its decoding functions, freeing the decoder’s digital processing capabilities to be used by another
                                      application.
Stator
                                                                                                           Stator winding
                                                                                                           (in slots)
Shaft
Rotor
                                                                                                           Air gap
Freescale Semiconductor, Inc...
Permanent magnets
                                     In this respect, the PM synchronous motor is equivalent to an induction motor, where the air gap
                                     magnetic field is produced by a permanent magnet, so the rotor magnetic field is constant. PM
                                     synchronous motors offer a number of advantages in designing modern motion control systems. The
                                     use of a permanent magnet to generate substantial air gap magnetic flux makes it possible to design
                                     highly efficient PM motors.
                                                                     β
                                                        phase- b
                                                                    is β
Freescale Semiconductor, Inc...
                                      The space vector defined by (EQ 3-2.) can be expressed utilizing two-axis theory. The real part of the
                                      space vector is equal to the instantaneous value of the direct-axis stator current component, isα, and
                                      whose imaginary part is equal to the quadrature-axis stator current component, isβ. Thus, the stator
                                      current space vector, in the stationary reference frame attached to the stator can be expressed as:
i s = i sα + ji sβ (EQ 3-3.)
                                      In symmetrical three-phase machines, the direct and quadrature axis stator currents isα, isβ are fictitious
                                      quadrature-phase (two-phase) current components, which are related to the actual three-phase stator
                                      currents as follows:
                                                                                        3
                                                                           i sβ = k ------- ( i sb – i sc )                           (EQ 3-5.)
                                                                                      2
                                      where k=2/3 is a transformation constant.
                                      The space vectors of other motor quantities (voltages, currents, magnetic fluxes etc.) can be defined in
                                      the same way as the stator current space vector.
                                    For a description of the PM synchronous motor, the symmetrical three-phase smooth-air-gap machine
                                    with sinusoidally-distributed windings is considered. The voltage equations of stator in the
                                    instantaneous form can then be expressed as:
                                                                                         d
                                                                     u SA = R S i SA +      ψ                                     (EQ 3-6.)
                                                                                         d t SA
                                                                                         d
                                                                     u SB = R S i SB +      ψ                                     (EQ 3-7.)
                                                                                         d t SB
                                                                                         d
                                                                     u SC = R S i SC +      ψ                                     (EQ 3-8.)
                                                                                         d t SC
                                    where uSA, uSB and uSC are the instantaneous values of stator voltages, iSA, iSB and iSC are the
                                    instantaneous values of stator currents, and ψSA, ψSB, ψSC are instantaneous values of stator flux
Freescale Semiconductor, Inc...
                                                                                        d
                                                                    u Sβ = R S i Sβ +      Ψ                                     (EQ 3-10.)
                                                                                        d t Sβ
                                                           dω   p 3
                                                              = --- --- p ( Ψ Sα i Sβ – Ψ Sβ i Sα ) – T L                        (EQ 3-13.)
                                                           dt   J 2
                                    where: α,β              is the stator orthogonal coordinate system
                                            uSα,β           is the stator voltage
                                            iSα,β           is the stator current
                                            ΨSα,β           is the stator magnetic flux
                                            ΨM              is the rotor magnetic flux
                                            RS              is the stator phase resistance
                                            LS              is the stator phase inductance
                                            ω / ωF          is the electrical rotor speed / fields speed
                                            p               is the number of poles per phase
                                            J               is the inertia
                                            TL              is the load torque
                                            Θr              is the rotor position in α,β coordinate system
                                    The equations (EQ 3-9.) through (EQ 3-13.) represent the model of PM synchronous motor in the
                                    stationary frame α, β fixed to the stator.
                                      Besides the stationary reference frame attached to the stator, motor model voltage space vector
                                      equations can be formulated in a general reference frame, which rotates at a general speed ωg. If a
                                      general reference frame is used, with direct and quadrature axes x,y rotating at a general instantaneous
                                      speed ωg=dθg/dt, as shown in Figure 3-3, where θg is the angle between the direct axis of the
                                      stationary reference frame (α) attached to the stator and the real axis (x) of the general reference frame,
                                      then (EQ 3-14.) defines the stator current space vector in general reference frame:
                                                                                      – jθg
                                                                      i sg = i s e            = i sx + ji sy                         (EQ 3-14.)
                                                             y            β
Freescale Semiconductor, Inc...
                                      The stator voltage and flux-linkage space vectors can be similarly obtained in the general reference
                                      frame.
                                      Similar considerations hold for the space vectors of the rotor voltages, currents and flux linkages. The
                                      real axis (rα) of the reference frame attached to the rotor is displaced from the direct axis of the stator
                                      reference frame by the rotor angle θr. Since it can be seen that the angle between the real axis (x) of the
                                      general reference frame and the real axis of the reference frame rotating with the rotor (rα) is θg-θr, in
                                      the general reference frame, the space vector of the rotor currents can be expressed as:
                                                                                  –j ( θg – θr )
                                                                   i rg = i r e                    = i rx + ji ry                    (EQ 3-15.)
                                      where i r is the space vector of the rotor current in the rotor reference frame.
                                      The space vectors of the rotor voltages and rotor flux linkages in the general reference frame can be
                                      similarly expressed.
                                      The motor model voltage equations in the general reference frame can be expressed by utilizing
                                      introduced transformations of the motor quantities from one reference frame to the general reference
                                      frame. The PM synchronous motor model is often used in vector control algorithms. The aim of vector
                                      control is to implement control schemes which produce high dynamic performance and are similar to
                                      those used to control DC machines. To achieve this, the reference frames may be aligned with the
                                    stator flux-linkage space vector, the rotor flux-linkage space vector or the magnetizing space vector.
                                    The most popular reference frame is the reference frame attached to the rotor flux linkage space vector,
                                    with direct axis (d) and quadrature axis (q).
                                    After transformation into d-q coordinates, the motor model as follows:
                                                                                   d
                                                               u Sd = RS i Sd +       Ψ – ω F Ψ Sq                               (EQ 3-16.)
                                                                                   d t Sd
                                                                                   d
                                                               u Sq = R S i Sq +      Ψ + ω F Ψ Sd                               (EQ 3-17.)
                                                                                   d t Sq
Ψ Sd = L S i Sd + Ψ M (EQ 3-18.)
                                                                          Ψ Sq = L S i Sq                                        (EQ 3-19.)
Freescale Semiconductor, Inc...
                                                           dω   p 3
                                                              = --- --- p ( Ψ Sd i Sq – Ψ Sq i Sd ) – T L                        (EQ 3-20.)
                                                           dt   J 2
                                    By considering that below base speed isd=0, the equation (EQ 3-20.) can be reduced to the following
                                    form:
                                                                 dω   p 3
                                                                    = --- --- p ( Ψ M i Sq ) – T L                               (EQ 3-21.)
                                                                 dt   J 2
                                    From the equation (EQ 3-21.), it can be seen that the torque is dependent and can be directly controlled
                                    by the current isq only.
U DCB
Q1 Q3 Q5
C1
Q2 Q4 Q6
                                             GND
                                                                             Phase_A                    Phase_B          Phase_C
                                       The inverter consists of three half-bridge units where the upper and lower switches are controlled
                                       complementarily, meaning when the upper one is turned on, the lower one must be turned off, and vice
                                       versa. Because the power device’s turn off time is longer than its turn on time, some deadtime must be
                                       inserted between the turn off of one transistor of the half-bridge, and the turn on of its complementary
                                       device. The output voltage is mostly created by a pulse width modulation (PWM) technique, where an
                                       isosceles triangle carrier wave is compared with a fundamental-frequency sine modulating wave, and
                                       the natural points of intersection determine the switching points of the power devices of a half bridge
                                       inverter. This technique is shown in Figure 3-5. The 3-phase voltage waves are shifted 120o to each
                                       other and, thus, a 3-phase motor can be supplied.
                                                                                    Generated              P WM Carrier
                                                                                    S ine Wave                Wave
                                                                      1
Freescale Semiconductor, Inc...
                                                                      0
                                                                                                                    ωt
-1
                                                                               1
                                                        P WM Output T
                                                                       1   0
                                                        (U pper S witch)
                                                                                                                    ωt
                                                                           1
                                                        P WM Output T
                                                                       2       0
                                                        (L ower S witch)
                                                                                                                    ωt
                                       The most popular power devices for motor control applications are Power MOSFETs and IGBTs.
                                       A Power MOSFET is a voltage-controlled transistor. It is designed for high-frequency operation and
                                       has a low voltage drop; thus, it has low power losses. However, the saturation temperature sensitivity
                                       limits the MOSFET application in high-power applications.
                                       An insulated-gate bipolar transistor (IGBT) is a bipolar transistor controlled by a MOSFET on its base.
                                       The IGBT requires low drive current, has fast switching time, and is suitable for high switching
                                       frequencies. The disadvantage is the higher voltage drop of a bipolar transistor, causing higher
                                       conduction losses.
                                     In this method, we must break down the field-generating and torque-generating parts of the stator
                                     current to be able to separately control the magnetic flux and the torque. In order to do so, we need to
                                     set up the rotary coordinate system connected to the rotor magnetic field; this system is generally
                                     called a “d-q coordinate system”. Very high CPU performance is needed to perform the transformation
                                     from rotary to stationary coordinate systems. Therefore, the Motorola DSP56F80x is very well suited
                                     for use in a Vector Control algorithm. All transformations which are needed for Vector Control will be
                                     described in the next section.
                                           •   Calculate the rotor flux space vector magnitude and position angle
                                           •   Transform stator currents into the d-q coordinate system using Park transformation
                                           •   The stator current torque- (isq) and flux- (isd) producing components are controlled separately
                                               by the controllers
                                           •   The output stator voltage space vector is calculated using the decoupling block
                                           •   The stator voltage space vector is transformed back from the d-q coordinate system into the
                                               two-phase system and fixed with the stator by inverse Park transformation
                                           •   Using sinewave modulation, the output 3-phase voltage is generated
                                           -                      -                                      USd   USα
                                                                                            Decoupling
                                                                                                                         Sinewave
                                                                                                         USq
                                                                                                                         Generation
                                                                                                               USβ
USd_lin
                                                                                                                                      pwm a
                                                                                                                                      pwm b
                                                                                                                                                3-phase Power Stage
                                                                                                                                      pwm c
                                                USd     USq
                                                                            ISq
                                                                                                               ISα                        ISa
                                                                                                                                          ISb
                                                                                   Forward Park                      Forward Clarke
                                                                            ISd
                                                                                  Transformation               ISβ   Transformation       ISc
                                                                                                                                                                  PMSM
                                                                                                                                                                  motor
                                                Speed                                                                                            Position
                                                                                                                                                            Position/Speed
                                                                                                                                                                sensor
                                                                     β
                                                      phase- b
                                                                                         iS
                                                                  iSE
                                                    iSb - measured                   iSa - measured
                                                                                           iSD              α, phase-a
iSc - calculated
                                                        phase- c
                                                                     Figure 3-7. Clarke Transformation
                                                                                                1        1
                                                                                       1      – ---    – ---    a
                                                                         α = K                  2        2
                                                                                                                                                 (EQ 3-22.)
                                                                                                                b
                                                                         β                        3         3
                                                                                       0      ------- – ------- c
                                                                                                2         2
                                     In most cases, the 3-phase system is symmetrical, which means that the sum of the phase quantities is
                                     always zero.
                                     recommended. Then:
                                                                                           2
                                                                               α = a ⇒ K = ---                                                   (EQ 3-24.)
                                                                                           3
                                     We can fully define the Park-Clarke transformation:
                                                   2---           1       1
                                                              – --- – --- a                                          1      0       0 a
                                         α =        3             3       3
                                                                                b =     a+b+c = 0               =           1-       1 b         (EQ 3-25.)
                                         β         0
                                                                1         1
                                                              ------- – ------- c
                                                                                                                     0    ------ – -------
                                                                                                                              3        3 c
                                                                  3         3
ΨM = Ψ Mα + Ψ Mβ (EQ 3-26.)
                                                                                              Ψ Mβ
                                                                                sin ϑ Field = -----------
                                                                                              Ψ Md
                                                                                                                                                 (EQ 3-27.)
                                                                                                Ψ Mα
                                                                               cos ϑ Field    = -----------
                                                                                                Ψ Md
q β
ΨM d
                                                                      ΨMβ                                        ϑField
Freescale Semiconductor, Inc...
                                                                                                                      α
                                                                                                   ΨMα
                                           Figure 3-8. Establishing the d-q Coordinate System (Park Transformation)
                                       As demonstrated from PM synchronous motor equations, the maximum efficiency of the ideal PM
                                       synchronous motor is obtained when maintaining the current flux-producing component isd at zero.
                                       Therefore, in the drive from Figure 3-6, the Field-Weakening Controller sets isd = 0 in the normal
                                       operating range. The speed regulator controls the current torque-producing component isq.
                                       A real 3-phase power inverter has voltage and current rating limitations:
                                       1. The absolute value of stator voltage us is physically limited according to DCBus voltage to
                                          u_sdq_max limit
                                       2. The absolute value of the stator current is should be maintained below a limit of I_SDQ_MAX
                                          given by the maximum current rating
                                       In the normal operating range, the current torque-producing component isq can be set up to
                                       I_SDQ_MAX, since isd = 0.
                                       Due to the voltage limitation, the maximum speed in the normal motor operating range is limited for
Freescale Semiconductor, Inc...
isd = 0, to a nominal motor speed as shown in Figure 3-9 and (EQ 3-30.).
                                                                            nominal speed
                                           stator voltage us
                                                                                                                               u_sdq_max
stator current id
                                                                                       2    2
                                                               i Sq < I_SDQ_MAX – i Sd                                             (EQ 3-31.)
                                       One possibility to maintain the flux-producing current component isd for field weakening is to use a
                                       look-up table.
                                  4.       System Concept
                                  4.1 System Specification
                                       The motor control system is designed to drive a 3-phase PM synchronous motor in a speed
                                       closed-loop. The application meets the following performance specifications:
Freescale Semiconductor, Inc...
Optoisolation Required
SKDVH%/'&3RZHU6WDJH
8B'FEXV
                                                                                                             $&
                                                                                               &
                                                                                               $
                                                                                                                                                                                                        3060
                                                                                               
                                                                                               H
                                                                                               LQ                                                                                                             
                                                                                                /
                                                                                                                  '&                                                                                                               /2$'
                                        3&0DVWHU
                                                           83     '2:1         67$57
                                         6RIWZDUH
                                                                                 6723                                                                                                                             4XDGUDWXUH
                                                                                                                                                                                                                   (QFRGHU
                                                                                                                                                                           7HPSHUDWXUH
                                                                                                    )DXOWV                                                                                      ,VD ,VE ,VF
3:0
6&,
                                                                                                                             *3,2                                                                                         4XDG
                                            6&,                    *3,2                                                                                                                    $'&
                                                                                                    3:0                                                         3:0                                                       7LPHU
                                           'ULYHU                                                                       *3,2'ULYHU
                                                                 *3,2'ULYHU                                                                                                            $'&'ULYHU                       47'ULYHU
                                                                                               3:0'ULYHU                                                     3:0'ULYHU
                                                                                                                            %UHDN
                                                                 $SSOLFDWLRQ                                                &RQWURO            'XW\F\FOH D
                                                                                             )DXOW3URWHFWLRQ                                  'XW\F\FOH E                                                        ,VBD
                                                                  &RQWURO
                                                                                                                                               'XW\F\FOH F                                                        ,VBE
                                                                                                                       8BGFE                                                                                      ,VBF
                                        2PHJDB5HT
                                                                                                                                                                6LQXV
Freescale Semiconductor, Inc...
                                                                                                                                                                               6HFWRU
                                                                                                                                                              :DYHIRUP
                                                                                                                                                              0RGXODWLRQ
                                                                                  ,VBTB5HT
                                        2PHJDB5HT                                                                                          8VBDOSKDBFRPS
                                                                                                                                           8VBEHWDBFRPS                                                                  3RVLWLRQ
                                                                                               &XUUHQWT                G
                                                                                                                        U                                                                                                     
                                                                   6SHHG                            3,                 D
                                                                                                                                                                                                                          6SHHG
                                                                 &RQWUROOHU                    &RQWUROOHU           Z U                         8VBDOSKD
                                                                                                                   J R                                                                                                   6HQVLQJ
                                                                                                                       I
                                                                                                                   LQ
                                                                                                                    O G
                                               KF                                                         8VBT      S H
                                                                                                                    X IH
                                                                                                                                ,QYHUVH3DUN                   '&EXV               8BGFE
                                                H                                                                  R )
                                                                                                                               7UDQVIRUPDWLRQ                   5LSSOH
                                                P
                                                BOD                   J
                                                                      Q
                                                                          U
                                                                          H
                                                                                                          8VBG      F
                                                                                                                    H 0
                                                                                                                               GT!DOSKDEHWD               &RPSHQVDWLRQ
                                                                   L     OO                                           (
                                                  WXD                 Q                                             '                           8VBEHWD
                                                                  OG H     R                   &XUUHQWG                N
                                                                           U                                            F
                                                    DBJ
                                                                   LH N    W                        3,                  D
                                                                    ) D    Q
                                                                           R                                            %                    VLQ                  WKHWDBDWXDOBHO
                                                      H
                                                                      H                        &RQWUROOHU
                                                                           &
                                                      P
                                                      2
                                                                     :                                                                       FRV
2PHJDBDWXDOBPHFK
0RWRUROD'63)[
                                     If any of the previously-mentioned faults occur, the motor control PWM outputs are disabled in order
                                     to protect the drive, and the fault state of the system is displayed by the on-board LED.
                                     A hardware error is also detected if the wrong power stage is used. Each power stage contains a simple
                                     module generating a logic sequence unique for that type of power stage. During chip initialization, this
                                     sequence is read and evaluated according to the decoding table. If the correct power stage is identified,
                                     the program can continue. In the case of wrong hardware, the program stays in an infinite loop,
                                     displaying the fault condition.
                                     position counter counts up/down each edge of Phase A and Phase B signals according to their order.
                                     On each revolution, the position counter is cleared by an index pulse; see Figure 4-2.
                                     This means that the zero position is linked with the index pulse, but Vector Control requires the zero
                                     position, where the rotor is aligned to the d axis; see Section 4.3.1.3. Therefore, using a quadrature
                                     decoder to decode the encoder’s signal requires either the calculation of an offset which aligns the
                                     quadrature decoder position counter with the aligned rotor position (zero position), or the coupling of
                                     the zero rotor position with the index pulse of a quadrature encoder. To avoid the calculation of the
                                     rotor position offset, the quadrature decoder is not used in this application. The decoder’s digital
                                     processing capabilities are then free to be used by another application and the application presented can
                                     then run on the DSP56F801, which lacks a quadrature decoder.
                                     In addition to the quadrature decoder, the input signals (Phase A, Phase B and Index) are connected to
                                     quad timer module A. The quad timer module consists of four quadrature timers. Due to the wide
                                     variability of quad timer modules, it is possible to use this module to decode quadrature encoder
                                     signals, sense position, and speed. A configuration of the quad timer module is shown in Figure 4-3.
                                    The proposed algorithm combines both methods. The algorithm simultaneously measures the number
                                    of quadrature encoder pulses per constant period, and an accurate time interval between the first and
                                    last pulse is counted during that constant period. The speed can then be expressed as:
                                                                                k⋅N
                                                                        speed = -----------
                                                                                    T
                                                                                                                                  (EQ 4-1.)
                                    where:
                                             speed                   calculated speed
                                             k                       scaling constant
                                             N                       number of pulses per constant period
                                             T                       accurate period of N pulses
                                    The algorithm requires two timers for counting pulses and measuring their period, and a third timer as
Freescale Semiconductor, Inc...
                                    a time base; see Figure 4-3. Timer A2 counts the pulses of the quadrature encoder, and timer A3
                                    counts a system clock divided by 2. The values in both timers can be captured by each edge of the
                                    Phase A signal. The time base is provided by timer D0, which is set to call the speed processing
                                    algorithm every 900µs. An explanation of how the speed processing algorithm works follows.
                                    First, the new captured values of both timers are read. The difference in the number of pulses and their
                                    accurate time interval are calculated from actual and previous values. The new values are then saved
                                    for the next period, and the capture register is enabled. From that moment, the first edge of Phase A
                                    signal captures the values of both timers (A2, A3) and the capture register is disabled. This process is
                                    repeated on each call of the speed processing algorithm; see Figure 4-4.
                                                                                          60
                                                                           ω min = -------------------                                 (EQ 4-1.)
                                                                                   4NT calc
                                       where:
                                                ωmin                            Minimum obtainable speed [rpm]
                                                N                               Number of pulses per revolution [1/rev]
                                                Tcalc                           Period of speed measurement (calculation period) [s]
                                       In the application, the quadrature encoder has 1024 pulses per revolution and a calculation period of
                                       900µs was chosen on the basis of a motor mechanical constant. Thus, (EQ 4-1.) calculates the
Freescale Semiconductor, Inc...
                                                                                          60
                                                                          ω max = ----------------------
                                                                                  4NTclkT2                                             (EQ 4-2.)
                                       where:
                                                ωmax                            Maximum obtainable speed [rpm]
                                                N                               Number of pulses per revolution [1/rev]
                                                TclkT2                          Period of input clock to timer A2 [s]
                                       Substitution in (EQ 4-2.) for N and TclkT2 (timer A2 input clock = system clock 36 MHz/2) yields a
                                       maximum speed of 263672rpm. As demonstrated, the algorithm can measure speed across a wide
                                       range. Because such high speed is not practical, the maximum speed can be reduced to a required
                                       range by the constant k in (EQ 4-1.). The constant k can be calculated as:
                                                                                            60
                                                                         k = -----------------------------------
                                                                             4NT clkT2 ω max                                           (EQ 4-3.)
                                       where:
                                                k                               Scaling constant in (EQ 4-1.)
                                                ωmax                            Maximum of the speed range [rpm]
                                                N                               Number of pulses per revolution [1/rev]
                                                TclkT2                          Period of input clock to timer A2 [s]
                                       In this application, the maximum measurable speed is limited to 6000rpm.
                                  Note:         To ensure an accurate speed calculation, you must choose the input clock of timer A2 so that
                                                the calculation period of speed processing (in this case, 900µs) is represented in timer A2 as a
                                                value lower than 0x7FFFH (900.10-6/TclkT2<=0x7FFFH).
                                                           β
Freescale Semiconductor, Inc...
                                                                                                d                 α
                                                                      Figure 4-5. Rotor Alignment
$OLJQPHQW
6HWIL[HGSRVLWLRQ 5HVHWHQFRGHU
 SRVLWLRQ
                                                                          ,
                                                                           T                        ,
                                                                                                      T   
                                                                       ,
                                                                        G ,$OLJQPHQW                 ,
                                                                                                      G   
:DLWIRUURWRU 6HWSRVLWLRQIURP
VWDELOL]DWLRQ HQFRGHU
(QG
                                                                                     Q1                                 Q3                                    Q5
                                                                                     SKB04N60                           SKB04N60                              SKB04N60
                                                                                     Q2                                 Q4                                    Q6
                                                                                     SKB04N60                           SKB04N60                              SKB04N60
R318 75k-1%
                                                                                  R320 10k-1%
                                                                                                                            6                        1.65V +/- 1.65V   @ +/- Imax
                                        I_sense_C1                                                                              -
                                                                                                                                          7
                                                                                                                                                           I_sense_C
                                        I_sense_C2                                                                          5   +
                                                                                  R321 10k-1%
                                                                                                                       R322             U301B
                                                                     R323   390                                        75k-1%           MC33502D
                                                                                         1.65V ref
                                        +3.3V_A
                                                               +
                                                                                                     R324
                                                                                    8
                                                                            LM285M                   R325
                                                                            U304                     33k-1%
                                                   GNDA
                                                                                    4
GNDA
                                       As shown in Figure 4-7, the currents cannot be measured at any moment. For example, the current
                                       flows through Phase A (and shunt resistor R1) only if transistor Q2 is switched on. Likewise, the
                                       current in Phase B can be measured if transistor Q4 is switched on, and the current in Phase C can be
                                       measured if transistor Q6 is switched on. To get a moment of current sensing, a voltage shape analysis
                                       must be done.
                                       The voltage shapes of two different PWM periods are shown in Figure 4-11. The voltage shapes
                                       correspond to center-aligned PWM sinewave modulation. As shown, the best moment of current
                                       sampling is in the middle of the PWM period, where all bottom transistors are switched on.
                                       To set the exact moment of sampling, the DSP56F80x family offers the ability to synchronize ADC
                                       and PWM modules via the SYNC signal. This exceptional hardware feature, patented by Motorola, is
                                       used for current sensing. The PWM outputs a synchronization pulse, which is connected as an input to
                                     the synchronization module TC2 (Quad Timer C, counter/timer 2). A high-true pulse occurs for each
                                     reload of the PWM, regardless of the state of the LDOK bit. The intended purpose of TC2 is to provide
                                     a user-selectable delay between the PWM SYNC signal and the updating of the ADC values. A
                                     conversion process can be initiated by the SYNC input, which is an output of TC2. The time diagram
                                     of the automatic synchronization between PWM and ADC is shown in Figure 4-9.
                                   PWM COUNTER
Freescale Semiconductor, Inc...
PWM SYNC
                                   PWM
                                   GENERATOR
                                   OUTPUTS 0, 1
                                                           dead-time/2                                     dead-time/2
                                   PWM
                                   PINS 0, 1
                                   POWER
                                   STAGE                                 dead-time                                       dead-time
                                   VOLTAGE
                                   TC2
                                   COUNTER
                                                                          t1
                                   TC2
                                   OUTPUT
                                                                                     t2
                                   ADC
                                   CONVERSION
                                   ADC
                                   ISR
                                     However, all three currents cannot be measured from one voltage shape. The PWM period II in
                                     Figure 4-11 shows a moment when the bottom transistor of Phase A is switched on for a very short
                                     time. If the on-time is shorter than a critical time, the current can not be accurately measured. The
                                     critical time is given by hardware configuration (transistor commutation times, response delays of the
                                     processing electronics, etc.). Therefore, only two currents are measured and a third current is
                                     calculated from the following equation:
0 = i A + iB + iC (EQ 4-4.)
                                                                                               I.                                     II.
                                                                                       PWM PERIOD                       PWM RELOAD
PHASE_A
PHASE_B
PHASE_C
                                                                                       II.    I.
                                                                            
                                                                           
                                                       GXW\F\FOHUDWLRV
                                                                           
                                                                                                                                   3KDVH$
3KDVH%
3KDVH&
                                                                            
                                                                                                                          
                                                                                                                                        DQJOH
                                       A decision must now be made about which phase current should be calculated. The simplest technique
                                       is to calculate the current of the most positive voltage phase. For example, Phase A generates the most
                                       positive voltage within section 0 - 603KDVH%ZLWKLQVHFWLRQDQGVRRQVHHFigure 4-11.
                                       In this case, the output voltages are divided into six sectors, as shown in Figure 4-11. The current
                                       calculation is then made according to the actual sector value.
                                       Sectors 1 and 6:
i A = – iB – i C (EQ 4-5.)
Sectors 2 and 3:
i B = – iA – iC (EQ 4-6.)
Sectors 4 and 5:
i C = – iB – i A (EQ 4-7.)
                                  Note:         The sector value is used for current calculation only, and has no other meaning in the sinewave
                                                modulation. But if we use any type of space vector modulation, we can get the sector value as
                                                part of space vector calculation.
                                     The DCBus voltage sensor is represented by a simple voltage divider. The DCBus voltage does not
                                     change rapidly. It is nearly constant, with the ripple given by the power supply structure. If a bridge
                                     rectifier is used for rectification of the AC line voltage, the ripple frequency is twice the AC line
                                     frequency. If the power stage is designed correctly, the ripple amplitude should not exceed 10% of the
                                     nominal DCBus value.
                                     The measured DCBus voltage must be filtered to eliminate noise. One of the easiest and fastest
                                     techniques is the first order filter, which calculates the average filtered value recursively from the last
                                     two samples and coefficient C:
                                     To speed up the initialization of the voltage sensing (the filter has exponential dependency with
                                     constant of 1/N samples), the moving average filter, which calculates the average value from the last N
                                     samples, can be used for initialization:
                                                                                                –N
                                                                    u DCBusFilt =          ∑n = 1 uDCBus ( n )                          (EQ 4-9.)
+3.3V_A
                                                                                                R1
                                                                                                2.2k - 1%
                                                                                                            Temp_sense
                                                              D1          D2
                                                              BAV99LT1    BAV99LT1              C1
                                                                                                100nF
                                  5.       Hardware Implementation
                                  5.1 Hardware Set-up
                                       The application can run on Motorola’s motor control DSPs using the DSP56F803EVM,
                                       DSP56F805EVM, or DSP56F807EVM, Motorola’s 3-Phase AC/BLDC high voltage power stage and
                                       the BLDC high voltage motor with a quadrature encoder and integrated brake. All components are an
                                       integral part of Motorola’s embedded motion control development tools. Application hardware set-up
                                       is shown in Figure 5-1.
                                       The system hardware set-up for a particular DSP varies only by the EVM Board used. The application
                                       level of the software is identical for all DSPs. The EVM and chip differences are handled by the
                                       off-chip software drivers for the particular DSP EVM board.
                                       Detailed application hardware set-up can be found in the Targeting Motorola DSP5680x Platform
                                       manual.
81,&RQQHFWRUV7DEOH (QFRGHU&RQQHFWRUV7DEOH
'63) 3 '63) -
'63) - '63) -
                                                       8                                                                                 8
                                                                                                           ZIODWULEERQFDEOH
                                       /
                                                       -
                                       1               -      SK$&%/'&
                                                                  +LJK9ROWDJH                                                            -
                                       3(                                                            -                                  3       '63[(90
                                                                  3RZHU6WDJH                                                             -
                                   9$&
                                   +]                                                                                                     56      -7$*
                                                          ---
                                                               White
                                                               Black
                                                               Red
                                                                          -
                                                                                                              56&RQQHFWRUV7DEOH           -7$*&RQQHFWRUV7DEOH
'63) 3 '63) -
                                                                                                               '63)           3          '63)       -
                                                                          1RW&RQQHFWHG
                                  Note:        The application software is targeted for a PM synchronous motor with sinewave Back-EMF
                                               shape. In this demo application, a BLDC motor is used instead, due to the availability of the
                                               BLDC motor (MB1). Although the Back-EMF shape of this motor is not an ideal sinewave, it
                                               can be controlled by the application software. The drive parameters will be ideal with a PMSM
                                               motor with an exact sinewave Back-EMF shape.
                                       A detailed description of the individual board can be found in the appropriate DSP56F80x Evaluation
                                       Module User’s Manual, or on the Motorola web site, http://-www.motorola.com. The User’s
                                       Manual includes the schematic of the board, description of individual function blocks, and a bill of
                                       materials. The individual boards can be ordered from Motorola as standard products.
                                  6.
Freescale Semiconductor, Inc...
                                           Software Design
                                       This section describes the design of the drive’s software blocks. The software description comprises
                                       these topics:
                                           •   Main Software Flow Chart
                                           •   Data Flow
                                           •   State Diagram
                                       For more information on the system blocks used, refer to Section 4.3.
                                    Position and Speed Measurement processes are provided by hardware Timer modules and the
                                    functions giving the actual speed and position; see Figure 4.3.1.
                                    LED Indication Processing is called from Quadrature Timer D0 Interrupt, which provides the time
                                    base for LED flashing.
                                    The Fault Control process is split into Background and PWM Fault ISR. Background (see Figure 6-1)
                                    checks the Overheating, Undervoltage and Position Sensing Faults. The PWM Fault ISR part (see
                                    Figure 6-2) takes care of Overvoltage and Overcurrent Faults, which causes a PWM A Fault interrupt.
                                    The Brake Control process is dedicated to the brake transistor control, which maintains the DCBus
                                    voltage level. It is called from Main (see Figure 6-1).
                                    The Up/Down Button and Switch Control processes are subprocesses of Application Control and are
                                    described in Section 7.4.
                                    The Up/Down Button processes are split into Button Processing Interrupt, called from Quadrature
Freescale Semiconductor, Inc...
                                    Timer D0 Interrupt (see Figure 6-3); Button Processing BackGround (inside Analog Sensing);
                                    Interrupt Up Button; and Interrupt Down Button (see Figure 6-2).
Reset
DSP Initialization
                                                                  {set appFaultStatus
                                                                   trigger beginning of Fault State}
                                       The Switch process is split into Switch Filter Processing, called from Quadrature Timer D0 Interrupt
                                       (see Figure 6-3); and Switch Get State, called from Application Control processing, which handles
                                       manual switch control, and Switch Get State PC master software (in PC master application operating
                                       mode).
                                                 Interrupt
                                               ADC Complete                                              Interrupt
                                                                                                       Down Button
                                    PMSM Control
                                    -Current Processing:                                                Interrupt
                                    proceeds according to pmsmCtrlStatus                                Up Button
                                     Current Control:
                                     Currents Transformation (a,b,c to d-q)                              Return
                                     (Field-Weakening Controller)
                                     Current d Regulator
                                     Current q Regulator
                                     Voltages Transformation (d-q to α,β)                              Interrupt
                                     DCBus Ripple Compensation                                        PWM A Fault
                                     Space Vector Module sets pwmABC
                                                                                 Fault Control - PWM Fault ISR part:
                                                                                 if Overcurrent or Overvoltage:
                                      PWM:
                                                                                    {set appFaultStatus = Overvoltage /
                                      set duty cycles to pwmABC
                                                                                        Overcurrent
                                                                                     triggers beginning of Fault State (disable PWM...)}
Return
                                                                                    Interrupt
                                                                                   D0 QTimer
                                                                    PMSM Control
                                                                    Speed, Alignment Processing:
                                                                    proceeds according to its status
pmsmCtrlStatus?
                                                                    AlignFlag                        RunFlag
                                                                                         others
Return
                                                                                                                                   LED
Freescale Semiconductor, Inc...
                                                                                 Application
                                                                                                                                Indication
                                                                                  Control                brakeCtrlStatus
                                          faultCtrlStatus
                                     theta_align_el_C                                                                       i_Sd_Alignment
                                                                                   PMSM
                                                                                   Control
                                                                                                                             I_SDQ_MAX
                                    reloadSWtmrSpeedControl
                                                                                                                           SVM_INV_INDEX,
                                                      reloadSWtmrAlignment        pwmABC                                    u_Reserve_FW
                                                                                                                           SVM_INV_INDEX,
                                                                                                                             u_OverMax
                                                                              PWM Generation
                                                                                                                      coefBEMF, coefBEMFShift
PWM Outputs
                                                                                                                           PWM Faults
                                                             TEMPERATURE_MAX_F16                                      (Overvoltage/Overcurrent)
                                                                  temperature_filt
                                       u_dc_bus_min_fault_C                                        i_Sabc_comp
                                                                                                                            Check Index
                                                                                                                             Position
                                         u_dc_bus_filt
                                                                                                                           faultCtrlStatus
                                                                                                Fault Control
                                                          u_dc_bus_on_brake
Freescale Semiconductor, Inc...
                                                    brakeCtrlStatus
                                                                                           PWM Generation
                                                                                                                              PWM Outputs
IO_BRAKE
The data flows consist of the processes described in the following sections.
                                     The PMSM (PM Synchronous Motor) Control process provides most of the motor control
                                     functionality.
                                     Figure 6-6 shows the data flow inside the process PMSM Control. It shows essential subprocesses of
                                     the process: Sine; Cosine Transformations; Current Control; Speed; Alignment Control; and
                                     Field-Weakening.
                                     The Sine and Cosine Transformations generate sinCos_theta_el with the components sine, cosine
                                     according to electrical position theta_actual_el. It is provided in a look-up table.
omega_required_mech
                                                                   Speed Ramp
                                       reloadSWtmrAlignment          Control          reloadSWtmrSpeedControl
                                                                                           PIRegParams_omega_mech.
                                       theta_align_el_C                                          PositivePILimit
                                                                   Speed, Align
                                                                     Control                                          Field-Weakening
Freescale Semiconductor, Inc...
                                            theta_actual_el
                                                                                                           u_SDQ
                                                                 i_SDQ_desired    i_SDQ_desired
                                            Sin, Cos                 q_axis           d_axis
                                         Transformation
                                                                                                     pmsmCtrlStatus     u_dc_bus_filt
                                                          sinCos_theta_el
                                   coefBEMF, coefBEMFShift
                                                                                 Current                                    u_S_max_FWLimit
                                                                                 Control
                                                  i_Sabc_comp
                                                                                                            svmSector
i_Sabc_comp sinCos_theta_el
                                                                     Current Transformation
                                                                          a,b,c -> d-q
                                       u_LimitF16                                                                           I_SDQ_MAX_F16
                                                                   Current q                    Current d
                                                                   Regulator                    Regulator
Freescale Semiconductor, Inc...
                                    omega_actual_mech
                                                                  u_SDQ_lin.q_axis             u_SDQ_lin.d_axis
                                                                                                                             pmsmCtrlStatus
                                   coefBEMF, coefBEMFShift
                                                                                 Feed Forward
                                                      sinCos_theta_el                        u_SDQ
                                                                                                                    u_LimitF16
                                                               Voltage Transformation
                                                                  d-q -> alpha, beta
                                                                                                                    SVM_INV_INDEX/2*
                                                                                                                     *u_dc_bus_filt +
                                                                                                                       +u_OverMax
                                                                        u_SAlphaBeta
                                                                     Scaling
                                                                   DCBus Ripple
                                                                   Compensation
                                                                                                          u_dc_bus_filt     SVM_INV_INDEX,
                                                                                                                              u_OverMax
                                                                    u_Salpha_RipElim
                                                                    Space Vector
                                                                     Modulation
pwmABC svmSector
                                       The u_SDQ voltages are transformed into u_SAlphaBeta (see Section 3.3.3) by the Voltage
                                       Transformation process. The Scaling DCBus Ripple Compensation block scales u_SAlphaBeta
                                       (according u_dc_bus_filt) to u_Salpha_RipElim, described in the svmlimDcBusRip function in the
                                       Motor Control Library. The space vector modulation process generates duty cycle pwmABC and
                                       svmSector according to u_Salpha_RipElim.
                                       The u_LimitF16 is a voltage limit for current controllers. The u_OverMax constant is used to increase
                                       the limitation of u_SDQ voltages over maximum SVM_INV_INDEX/2*u_dc_bus_filt determined by
                                       the DCBus voltage and space vector modulation. Although the pwmABC will be limited by the space
                                       vector modulation process functions, the reserve is used for field-weakening controller dynamics. In
                                       the stable state, the u_SDQ voltages vector will not exceed u_S_max_FWLimit; see Section 6.2.5.4.
                                       with a linear ramp. The speed ramp is implemented so as not to saturate the speed regulator during
                                       acceleration.
SVM_INV_INDEX/2*u_dc_bus_filt-u_Reserve_FW
                                                                                                 0 -      I_SDQ_MAX_F16
                                                                            u_S_max_FWLimit
                                       u_SD.d_axis                                   +
                                                                                              max limit     min limit   i_SDQ_desired.d_axis
                                                                               -
                                                     (d_axis2+q_axis2)1/2
                                       u_SD.q_axis                                                PI regulator
Reset
                                                                                           DSP
                                                                                      Initialization
done
                                                                                Application Control:
                                    switchState = Stop &
                                    Fault Control: faults cleared                            Init
                                                                                Initializations proceeding
                                                                                  appState = APP_INIT
                                                                          Init Fault Control (pcb identification)
                                                                                      set appOpMode
Freescale Semiconductor, Inc...
                                                                                             switchState = Stop
                                    Fault Control: Begin Fault
                                    After reset, the DSP Initialization state is entered. The peripherals and variables are initialized in this
                                    state, and the application operating mode appOpMode is set to Manual Control.
                                    When the state is finished, the Application Control Init state follows. As shown in Figure 6-9,
                                    appState = APP_INIT; all subprocesses requiring initialization are proceeding; pcb identification is
                                    provided; the PWM is disabled; and so no voltage is applied on motor phases. If the
                                    appPcmCtrlStatus.RequestCtrl flag is set from PC master software, the application operating mode
                                    appOpMode is toggled and the application operating mode can only be changed in this state. If the
                                    switchState = Stop, the Application Control enters the Stop state.
                                    The switchState is set according to the manual switch on the EVM or PC master software register
                                    AppPcmCtrlStatus.StartStopCtrl, depending on the application operating mode.
                                    In the Stop state, appState = APP_STOP and the PWM is disabled, so no voltage is applied on motor
                                    phases. When switchState = Run, the Begin Run state is processed. If there is a request to change
                                    application operating mode, appPcmCtrlStatus.RequestCtrl = 1, the application Init is entered and the
                                    application operating mode request can only be accepted in the Init or Stop state by transition to the
                                    Init state.
                                    In the Begin Run state, all the processes provide settings to the Run state.
                                       In the Run state, the PWM is enabled, so voltage is applied on motor phases. The motor is running
                                       according to the state of all subprocesses. If switchState = Stop, the Stop state is entered.
                                       If and fault is detected during the Begin Fault state, which is a subprocess of Fault control, the Begin
                                       Fault state is entered. It sets appState = APP_FAULT; the PWM is disabled; and the subprocess
                                       PMSM Control is set to Stop. The Fault state can only move onto the Init state when switchState =
                                       Stop, and the Fault Control subprocess has successfully cleared all faults.
                                           PMSM Control:
                                             Initialization
                                        clear AlignInitDoneFlag
                                       When Application Control initializes, the PMSM Control subprocess initialization state is entered. The
                                       AlignInitDoneFlag is cleared, which means that alignment can proceed. The next PMSM Control state
                                       is Begin Stop or Fault. RunFlag and AlignFlag are cleared and the Stop or Fault state is entered. When
                                       Application Control: Begin Run, the PMSM Control subprocess enters the Begin Alignment or Begin
                                       Run state, depending on whether or not the alignment initialization has already proceeded (flagged by
                                       AlignInitDoneFlag). The alignment state is necessary for setting the zero position of position sensing;
                                       see Section 4.3.1.3. In the state Begin Alignment, the Alignment current and duration are set; the
                                       alignment is provided by setting desired current for d_axis to i_Sd_Alignment and q_axis to 0. The
                                     alignment state provides current control and timeout search. When alignment timeout occurs, End
                                     Alignment is entered. In that state, the Position Sensing Zero Position is set, so the position sensor is
                                     aligned with the real vector of the rotor flux. When the End Alignment state ends, the PMSM Control
                                     enters a regular Run state, where the motor is running at the required speed. If the Application Control
                                     state is set to Begin Stop or Begin Fault, the PMSM Control enters the Begin Stop or Fault, then the
                                     Stop or Fault.
Reset
                                                                                      Fault Control:
                                                                                    DSP Initialization
                                                                                     Fault Control:
                                                                                 Application Initialization
                                                                                  clear appFaultStatus
                                                                                    pcb identification
done
                                                                                     Fault Control:
                                                                                        No Fault
                                                                                     searching faults
                                                                                                              Fault:
                                                                                                              Undervoltage (filtered)
                                                                                                              Overheating (filtered)
                                                                                                              Overcurrent (fault pin)
                                                                                                              Overvoltage (fault pin)
                                                                                                              wrong PCB
                                                                                                              Position Sensing fault
                                                                                      Fault Control:
                                                                                        Begin Fault
                                                                              Application Control Begin Fault
                                                                                setting of appFaultStatus
                                                                                      PWMEN bit = 0
done
                                                                                     Fault Control:
                                                                                          Fault
                                                                                     clear/test faults
                                                                     Reset
Freescale Semiconductor, Inc...
                                                             Analog Sensing
                                                             DSP Initialization
                                                                                                     Analog Sensing
                                                             Analog Sensing
                                                                                                        Init Finished:
                                                                Init Done,
                                                                                                     samples average
                                                             normal operation:
                                                                                                     set current offsets
                                                                                   done
                                                                                                      set InitDoneFlag
                                  7.      Implementation Notes
                                  7.1 Scaling of Quantities
                                     The PM synchronous motor vector control application uses a fractional representation for all real
                                     quantities except time.
                                     The N-bit signed fractional format is represented using 1.[N-1] format (1 sign bit, N-1 fractional bits).
                                     Signed fractional numbers (SF) lie in the following range:
                                                                                             –[ N – 1 ]
                                                                      – 1.0 ≤ SF ≤ +1.0 -2                                            (EQ 7-1.)
                                     For words and long-word signed fractions, the most negative number that can be represented is -1.0,
                                     whose internal representation is $8000 and $80000000, respectively. The most positive word is $7FFF
                                     or 1.0 - 2-15, and the most positive long-word is $7FFFFFFF or 1.0 - 2-31.
                                     The following equation shows the relationship between the real and fractional representations:
                                                                                           Real Value
                                                      Fractional Value = --------------------------------------------------------------                                   (EQ 7-2.)
                                                                         Real Quantity Range Max
                                     where:
                                     Fractional Value is the fractional representation of the real value [Frac16]
                                     Real Value is the real value of the quantity [V, A, RPM, etc.]
                                     Real Quantity Range Max is the maximum of the quantity range, defined in the application [V, A,
                                     RPM, etc.]
                                     The C language standard does not have any fractional variable type defined. Therefore, fractional
                                     operations are provided by CodeWarrior intrinsics functions (e.g. mult_r() ). As a substitution for the
                                     fractional type variables, the application uses types Frac16 and Frac32. These are in fact defined as
Freescale Semiconductor, Inc...
                                     integer 16-bit signed variables and integer 32-bit signed variables. The difference between Frac16 and
                                     pure integer variables is that Frac16 and Frac32 declared variables should only be used with fractional
                                     operations (intrinsics functions).
                                     A recalculation from real to a fractional form and Frac16, Frac32 value is made with the following
                                     equations:
                                                                                             Real Value
                                                    Frac16 Value = 32768 ⋅ --------------------------------------------------------------                                 (EQ 7-3.)
                                                                           Real Quantity Range Max
                                                                                       31                       Real Value
                                                     Frac32 Value = 2                       ⋅ --------------------------------------------------------------              (EQ 7-4.)
                                                                                              Real Quantity Range Max
                                                                                           Real Value
                                                      Fractional Value = --------------------------------------------------------------                                   (EQ 7-5.)
                                                                         Real Quantity Range Max
                                     Fractional form, a conversion from Fraction Value to Frac16 and Frac32 Value can be provided by the
                                     C language macro.
                                       where:
                                       uFrac                     Fractional representation of voltage quantities                        [-]
                                       uReal                     Real voltage quantities in physical units                              [V]
                                       VOLT_RANGE_MAX Defined voltage range maximum used for scaling in physical units[V]
                                       In the application, the VOLT_RANGE_MAX value is the maximum measurable DCBus voltage:
                                               VOLT_RANGE_MAX = 407 V
                                       All application voltage variables are scaled in the same way (u_dc_bus, u_dc_bus_filt, u_SAlphaBeta,
                                       u_SDQ, u_SAlphaBeta, and so on).
                                       Current scaling also results from the sensing circuits of the hardware used; for details see 3-Phase
                                       AC/BLDC High-Voltage Power Stage User’s Manual.
                                       The relationship between real and fractional representation of current quantities is:
                                                                                                   i Real
                                                                   i Frac = --------------------------------------------------------
                                                                                                                                   -      (EQ 7-7.)
                                                                            CURR_RANGE_MAX
                                       where:
                                       iFrac                      Fractional representation of current quantities                       [-]
                                       iReal                      Real current quantities in physical units                             [A]
                                       CURR_RANGE_MAX Defined current range maximum used for scaling in physical units[A]
                                       In the application, the CURR_RANGE_MAX value is the maximum measurable current:
                                               CURR_RANGE_MAX = 5.86 A
                                       All application current variables are scaled in the same way (components of i_Sabc_comp,
                                       i_SAlphaBeta, i_SDQ, i_SDQ_desired, i_Sd_Alignment and so forth).
                                  Note:          As shown in 3-Phase AC/BLDC High-Voltage Power Stage User’s Manual, the current
                                                 sensing circuit provides measurement of the current in the range from CURR_MIN = -2.93A
                                                 to CURR_MAX = +2.93A, giving the voltage for the ADC input ranges from 0 to 3.3V with
                                                 1.65V offset. The DSP5680x’s ADC converter is able to automatically cancel (subtract) the
                                                 offset. The fractional representation of the measured current is then in the range <-0.5, 0.5),
                                                 while the possible representation of a fractional value is <-1,1), as shown in (EQ 7-3.).
                                                 Therefore, CURR_RANGE_MAX is calculated according to the following equation:
                                     where:
                                     ωFrac                       Fractional representation of speed quantities                                  [-]
                                     ωReal                       Real speed quantities in physical units                                        [rpm]
                                     OMEGA_RANGE_MAX Defined speed range maximum used for scaling in physical units[rpm]
Freescale Semiconductor, Inc...
                                       DSP56F805, and DSP56F807 EVMs. Since the DSP56F803 has no free GPIO pins for user buttons,
                                       the application uses buttons connected to IRQA/B pins. The EVM boards do not resolve the button
                                       contact bouncing, which may occur while pushing and releasing the button, so this issue must be
                                       resolved by software.
                                       The IRQA and IRQB interrupts are maskable interrupts connected directly to the DSP’s core. The
                                       IRQA and IRQB lines are internally synchronized with the processor’s internal clock and can be
                                       programmed as level-sensitive or edge-sensitive. The IRQA and IRQB interrupts have no interrupt
                                       flag, so this flag is replaced by a software flag. The following algorithm is used to check the state of
                                       the IRQ line and is described for one interrupt.
                                       The IRQ interrupt is set to be negative-level-sensitive. When the button is pressed, the logical level 0 is
                                       applied on the IRQ line and the interrupt occurs; see Figure 7-1. To avoid multiple calls of ISR due to
                                       contact bounces, the ISR disables the IRQ interrupt, sets the debounce counter to a predefined value
                                       and sets the variable buttonStatus to 1. The variable buttonStatus represents the interrupt flag. Using
                                       the DSP56F80x’s software timer, the ButtonProcessing function is periodically called, as shown in
                                       Figure 7-1. The function ButtonProcessing decrements the debounce counter and if the counter is 0,
                                       the IRQ interrupt is again enabled. The button press is checked by the ButtonEdge function; see
                                       Figure 7-2. When the variable buttonStatus is set, the ButtonEdge function returns “1” and clears
                                       buttonStatus. When the variable buttonStatus is not set, the ButtonEdge function returns “0”.
                                       According to the ButtonProcessing calling period, the value of the debounce counter should be set
                                       close to 180ms. This value is sufficient to prevent multiple IRQ ISR calls due to contact bounces.
,54,65 %XWWRQ3URFHVVLQJ
                                                                                         'HFUHPHQWGHERXQFH
                                             'LVDEOH,54LQWHUUXSW                             FRXQWHU
                                               6HWEXWWRQ6WDWXV                     1R
                                                                                         'HERXQFHFRXQWHU 
Freescale Semiconductor, Inc...
                                                                                                      <HV
                                             6HWGHERXQFHFRXQWHU
                                                                                         (QDEOH,54LQWHUUXSW
5HWXUQ
5HWXUQ
%XWWRQ(GJH
                                                                               1R
                                                            EXWWRQ6WDWXV 
<HV
&OHDUEXWWRQ6WDWXV
5HWXUQ 5HWXUQ
                                  8.       SDK Implementation
                                       The Motorola Embedded SDK is a collection of APIs, libraries, services, rules and guidelines. This
                                       software infrastructure is designed to let DSP5680x software developers create high-level, efficient,
                                       portable code. The application code is available in the SDK. This chapter describes how the PM
                                       synchronous motor vector control application is written under the SDK.
                                           •   PWM driver
                                           •   LED driver
                                           •   SCI driver
                                           •   PC master software driver
                                           •   Switch driver (only for DSP56F805EVM and DSP56F807EVM)
                                           •   Brake driver
                                       All drivers are included in bsp.lib library.
                                       The PM synchronous motor vector control application uses the following library functions:
                                           •   cptrfmClarke (Clarke transformation, mcfunc.lib library)
                                           •   cptrfmPark (Park transformation, mcfunc.lib library)
                                           •   cptrfmParkInv (Inverse Park transformation, mcfunc.lib library)
                                           •   mcElimDcBusRip (DC bus ripple elimination, mcfunc.lib library)
                                           •   mcPwmIct (3-ph sinewave modulation, mcfunc.lib library)
                                           •   rampGetValue (ramp generation, mcfunc.lib library)
                                           •   switchcontrol (switch control, mcfunc.lib library)
                                           •   boardId (board identification, bsp.lib library)
                                    The appconfig.h file can be divided into two sections. The first section defines which components of
                                    SDK libraries are included in the application; the second part overwrites components’ standard setting
                                    during their initialization.
                                        •   Initialize the configuration setting in appconfig.h for specific drivers, which depends on driver
                                            type
                                        •   Call the open (create) function
                                    Access to individual driver functions is provided by the ioctl function call.
                                  8.4 Interrupts
                                    The SDK serves the interrupt routine calls and automatically clears interrupt flags. The user defines the
                                    callback functions called during interrupts. The callback functions are assigned during driver
                                    initialization--open(). The callback function assignment is defined as one item of the initialization
                                    structure, which is used as a parameter of the open()function. Some drivers define the callback
                                    function in the appconfig.h file.
                                       The 3-Phase PM Synchronous Motor Vector Control utilizes PC master software for remote control
                                       from a PC. It enables the user to:
                                           •   Control the PC master software
                                           •   Start/stop control
                                           •   Set the motor speed
                                       Variables read by the PC master software as a default and displayed to the user are:
                                           •   Required Speed of the motor
                                           •   Actual Speed of the motor
                                           •   Application status
                                               — Init
                                               — Stop
Freescale Semiconductor, Inc...
                                               — Run
                                               — Fault
                                           •   DCBus voltage level
                                           •   Identified line voltage
                                           •   Fault Status
                                               — No_Fault
                                               — Overvoltage
                                               — Overcurrent
                                               — Undervoltage
                                               — Overheating
                                           •   Identified Power Stage
                                       The profiles of required and actual speeds, together with the desired Id and Iq currents can be seen in
                                       the Speed Scope window.
                                       The course of quickly-changing variables can be observed in the Recorder windows, displayed by the
                                       PC master’s Speed Scope. The Recorder can only be used when the application is running from
                                       External RAM, due to the limited on-chip memory. The length of the recorded window may be set in
                                       Recorder Properties => bookmark Main => Recorded Samples. The dedicated memory space is
                                       defined in the appconfig.h file of the ExtRAM target. The recorder samples are taken every 125µsec.
                                       The following records can be captured:
                                           •   Required speed
                                           •   Actual speed
                                           •   Desired Id current
                                           •   Desired Iq current
                                       The PC master software Control Page is illustrated in Figure 8-1. The profiles of the required and
                                       actual speeds can be seen in the Speed Scope window.
                                                   Table 9-1. RAM and FLASH Memory Use by SDK2.4 and CW4.1
                                         Memory          Available for     Available for    Application Used +   Application Used
                                    (in 16-bit Words)    DSP56F803         DSP56F807              Stack          without PC Master
                                                         DSP56F805                                                 Software, SCI
                                  MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their
                                  respective owners. © Motorola, Inc. 2003.
ASIA/PACIFIC: Motorola Semiconductors H.K. Ltd.; Silicon Harbour Centre, 2 Dai King Street, Tai Po Industrial Estate, Tai Po, N.T., Hong Kong. 852–26668334
                                                                                                                                                                             AN1931/D
                                                                               For More Information On This Product,
                                                                                      Go to: www.freescale.com