| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x
Top Searches for this datasheetAN3002 Rev. 10/2005 Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x Covers MCF523x eTPU-equipped Devices Milan Brejl Michal Princ System Application Engineers Roznov Czech System Center This application note describes design 3-phase permanent magnet synchronous motor (PMSM) speed torque vector control drive based Freescale's ColdFire MCF523x microprocessor. application design takes advantage enhanced time processing unit (eTPU) module, which used motor control co-processor. eTPU handles motor control processing, eliminating microprocessor overhead other duties. PMSMs very popular wide array applications. Compared motor, PMSM misses commutator, therefore more reliable than motor. PMSM also advantages when compared induction motor. PMSM generates rotor magnetic flux with rotor magnets, achieving higher efficiency. Therefore, PMSM used high-end white goods (refrigerators, washing machines, dishwashers, etc.), high-end pumps, fans, other appliances that require high reliability efficiency. concept application create vector control PMSM driver with optional speed closed-loop, using quadrature encoder. serves example PMSM vector control system design using Freescale Table Contents ColdFire MCF523x eTPU Advantages Features Target Motor Theory System Concept Software Design Implementation Notes Microprocessor Usage Summary Conclusions References Freescale Semiconductor, Inc., 2005. rights reserved. ColdFire MCF523x eTPU Advantages Features microprocessor with eTPU. also illustrates usage dedicated motor control eTPU functions that included motor control eTPU function set. This application note also includes basic motor theory, system design concept, hardware implementation, microprocessor eTPU software design, including FreeMASTER visualization tool. Figure Using M523xEVB, 33395 Evaluation Motor Board, BLDC Motor ColdFire MCF523x eTPU Advantages Features ColdFire MCF523x Microprocessor MCF523x family composed highly-integrated, 32-bit microprocessors based ColdFire core. features 32-channel eTPU, Kbytes internal SRAM, 2-bank SDRAM controller, four 32-bit timers with request capability, 4-channel controller, modules, three UARTs, queued SPI. MCF523x family been designed general purpose industrial control applications. also high-performance upgrade users MC68332. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor ColdFire MCF523x eTPU Advantages Features This 32-bit device based version ColdFire reduced instruction computer (RISC) core, operating core frequency frequency MHz. On-chip modules include following: ColdFire core with enhanced multiply-accumulate unit (EMAC) providing Dhrystone 2.1MIPS eTPU with channels, Kbytes code memory, Kbytes data memory with eTPU debug support Kbytes internal SRAM External speed half operating frequency (75-MHz 150-MHz core) 10/100 Mbps bus-mastering Ethernet controller Kbytes configurable instruction/data cache Three universal asynchronous receiver/transmitters (UARTs) with support Controller area network 2.0B (FlexCAN module) Optional second FlexCAN module multiplexed with third UART Inter-integrated circuit (I2C) controller Queued serial peripheral interface (QSPI) module Hardware cryptography accelerator (optional) Random number generator DES/3DES/AES block cipher engine MD5/SHA-1/HMAC accelerator 4-channel, 32-bit direct memory access (DMA) controller 4-channel, 32-bit input capture/output compare timers with optional support 4-channel, 16-bit periodic interrupt timers (PITs) Programmable software watchdog timer Interrupt controller capable handling interrupt sources Clock module with phase locked loop (PLL) External interface module including 2-bank synchronous DRAM controller 32-bit, non-multiplexed with chip select signals that support page-mode Flash memories more information, refer Reference eTPU Module eTPU intelligent, semi-autonomous co-processor designed timing control, handling, serial communications, motor control, engine control applications. operates parallel with host CPU. eTPU processes instructions real-time input events, performs output waveform generation, accesses shared data without host CPU's intervention. Consequently, host setup service times each timer event minimized eliminated. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Target Motor Theory eTPU timer channels, addition having Kbytes code memory Kbytes data memory that store software modules downloaded boot time, mixed matched needed application. eTPU provides more specialized timer processing than host achieve. This partially eTPU implementation, which includes specific instructions handling processing time events. addition, channel conditions available eTPU processor, thus eliminating many branches. eTPU creates host overhead servicing timing events. more information, refer Reference Target Motor Theory Stator Stator winding slots) Shaft Rotor Permanent magnets Figure Permanent Magnet Machine Cross Section Permanent magnet (PMAC) machines provide automotive actuator designers with unique features capabilities. There principal classes permanent magnet machines: sinusoidally excited machines permanent magnet synchronous motors (PMSM), trapezoidaly excited machines brushless (BLDC) motors. difference that while stator windings trapezoidal PMAC machines concentrated into narrow-phase pole, windings sinusoidal machine typically distributed over multiple slots order approximate sinusoidal distribution. These differences construction reflected their corresponding motion characteristics well: first type PMAC provides sinusoidal back-electromotive force (back-EMF) generation, while second type provides trapezoidal back-EMF. PMSM machines have unique advantages unsurpassed efficiency power density characteristics, which primarily responsible their wide appeal. other hand, PMSM machines synchronous, which certainly requires accompanying power electronics, they also provide basis achieving high-quality actuator control. torque ripple associated with sinusoidal PMAC (PMSM) machines generally less than that developed trapezoidal machines, reason sinusoidal motors Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Target Motor Theory preferred high-performance motion control applications, such electro-mechanical braking. This application note targets PMSM only. Digital Control PMSM common 3-phase PMSM motor, standard 3-phase power stage used (see Figure power stage utilizes power transistors that operate complementary mode. PWM_Q1 PWM_Q3 PWM_Q5 PWM_Q2 PWM_Q4 PWM_Q6 Phase_A Phase_B Phase_C Figure 3-Phase BLDC Power Stage inverter consists three half-bridge units where upper lower switches controlled complimentarily, meaning when upper turned lower must turned off, vice versa. Because power device's turn-off time longer than turn-on time, some dead time must inserted between turning transistor half-bridge turning complementary device. output voltage mostly created pulse width modulation (PWM) technique. 3-phase voltage waves shifted 120o another; thus 3-phase motor supplied. Vector Control PMSM Vector control elegant method controlling permanent magnet synchronous motor (PMSM), where field-oriented theory used control space vectors magnetic flux, current, voltage. possible co-ordinate system decompose vectors into electro-magnetic field generating part torque generating part. Then structure motor controller (vector control controller) almost same separately excited motor, which simplifies control PMSM. This vector control technique developed achieve same excellent, dynamic performance PMSM. explained Figure choice been made widely used current control with inner position closed loop. this method, decomposition field generating part torque generating part stator current allows separate control magnetic flux torque. order need Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Target Motor Theory rotary co-ordinate system connected rotor magnetic field. This co-ordinate system generally called `d-q reference co-ordinate system.' more information, refer Reference PMSMVC i_d_required u_dc_bus Inverse Park Transform u_q_lin u_d_lin DC-Bus Ripple Elimination i_q_required u_alpha alpha beta Decoupling Feed Forward u_beta cos_theta sin_theta theta scaling position_counter omega_actual Park Transform Clarke Transform i_alpha i_beta Figure PMSM Vector Control Current Loop Block Diagram Quadrature Encoder PMSM motor application uses quadrature encoder rotor position sensing. quadrature encoder output consists three signals. phases, represent rotor position, index pulse defines zero position. quadrature encoder signals depicted Figure 1998 1999 position counter values Phase Phase Index revolution Figure Quadrature Encoder Output Signals 2.3.1 Position Alignment Since quadrature encoder does give absolute position, need know exact rotor position before motor started. possible very easily implemented method rotor alignment Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor 1998 1999 System Concept predefined position. motor powered defined static voltage pattern rotor aligns predefined position. This alignment done during motor start System Concept System Outline system designed drive 3-phase PMSM. application meets following performance specifications: Voltage control PMSM using quadrature encoder HEDS-5640 Targeted ColdFire MCF523x evaluation board (M523xEVB), 33395 evaluation motor board (power stage), PMSM (IB23810) Control technique incorporates: PMSM vector control with optional speed-closed loop Both directions rotation 4-quadrant operation Rotor alignment start position Minimum speed Maximum speed 1000 (limited power supply) Manual interface (start/stop switch, up/down push button control, indication) FreeMASTER control interface (speed set-up, speed control/torque control choice) FreeMASTER monitor FreeMASTER graphical control page (required speed, required torque, actual motor speed, actual torque, start/stop status, fault status) FreeMASTER control scope (observes required actual speeds torques, applied voltage) Detail description eTPU functions used application (monitoring channel registers function parameters real time) over-current fault protection Application Description standard system concept chosen motor control function (see Figure system incorporates following hardware: Evaluation board M523xEVB 33395 evaluation motor board PMSM (IB23810) Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor System Concept Quadrature encoder (HEDS-5640 A06) Power supply 2.7Amps eTPU module runs main control algorithm. 3-phase output signals 3-phase inverter generated, using vector control algorithm according feedback signals from quadrature encoder, actual values phase currents, input variable values provided microprocessor CPU. phase currents sampled external analog-to-digital converter connected QSPI peripheral. transfer phase current samples from QSPI eTPU DATA provided CPU, because transfer applicable here. over-current interrupt ON/OFF switch status eTPU GPIO Fault Signal Trigger Hardware 9÷12V ON/OFF DOWN GPIO Application State Machine enable/disable signals Converter Power Stage PMSM Motor Drive UART FreeMASTER Remote Control Signals PMSM motor Shaft Encoder Signals Figure System Concept system processing distributed between eTPU, which both parallel. performs following tasks: Periodically scans user interface (ON/OFF switch, down buttons, FreeMASTER). Based user input, handles application state machine calculates required speed torque, which passed eTPU. Periodically reads application data from eTPU DATA order monitor application variables. event over-current fault, immediately outputs temporarily disabled eTPU hardware. Then, after interrupt latency, disables outputs permanently displays fault state. Periodically, with period 50us, transfers converter result queue received QSPI into eTPU DATA RAM. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor System Concept eTPU performs following tasks: eTPU channels (PWMF) used generate output signals. Three eTPU channels (QD) used process quadrature encoder signals. eTPU channel (BC) used controlling DC-bus break. eTPU channel (ASAC) used trigger external converter preprocess sampled values. eTPU channel (GPIO) used generate interrupt when over-current fault signal activates. eTPU channel (PWMMAC) internally used synchronize outputs calculate space vector modulation, based applied motor voltage vector Alpha-Beta coordinates. eTPU channel (SC) internally used calculate actual motor speed control speed-closed loop case speed vector control. actual motor speed calculated based position counter last edge time. required speed provided passed through ramp. speed control algorithm processes error between required actual speed. controller output passed PMSMVC eTPU function newly corrected value required motor torque. eTPU channel (PMSMVC) internally used calculate current vector control closed loop. takes values actual phase currents from ASDC, actual rotor position from actual motor speed from phase currents transferred Alpha-Beta coordinate system, using Clark Park transformations. control algorithm processes error between required actual D-current, another processes error between required actual Q-current. required value D-current, which flux controlling current, zero. required value Q-current, which torque controlling current, either directly (torque vector control) provided output (speed vector control). controller outputs create motor applied voltage vector coordinate system. transformed back Alpha-Beta coordinate system passed generator. 3.2.1 User Interface application interfaced following: ON/OFF switch M523xEVB Up/down buttons M523xEVB FreeMASTER running connected M523xEVB RS232 serial cable ON/OFF switch affects application state enables disables phases. When switch position, voltage applied motor windings. When ON/OFF switch position, motor speed controlled either down buttons M523xEVB, FreeMASTER FreeMASTER also displays control page, real-time values application variables, their time behavior using scopes. FreeMASTER software designed provide application-debugging, diagnostic, demonstration tool development algorithms applications. runs connected M523xEVB Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor System Concept RS232 serial cable. small program resident microprocessor communicates with FreeMASTER software return status information process control information from FreeMASTER software executing uses part Microsoft Internet Explorer user interface. Note that FreeMASTER version 1.2.31.1 higher required. FreeMASTER application downloaded from http://www.freescale.com. more information about FreeMASTER, refer Reference Hardware Implementation Application Setup Figure Connection Application Parts previously stated, application runs MCF523x family ColdFire microprocessors using following: M523xEVB 33395 evaluation motor board 3-phase PMSM (IB23810) Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor System Concept Quadrature encoder (HEDS-5640 A06) Power supply, 9-12V minimum 2.7Amps Figure shows connection these parts. system parts documented according references. 3.3.1 ColdFire MCF523x Evaluation Board (M523xEVB) intended provide mechanism customers easily evaluate MCF523x family ColdFire microprocessors. heart evaluation board MCF5235; other M523x family members have subset MCF5235 features therefore fully emulated using MCF5235 device. M523xEVB fitted with single 512K page-mode Flash memory (U19), giving total memory space Mbytes. Alternatively, footprint available upgrading flash 512K page-mode Flash memory (U35), doubling memory size Mbytes. more information, refer Reference Table lists M523xEVB jumper settings used application. Table M523xEVB Jumper Settings Jumper JP10 JP11 JP12 JP13 JP14 JP15 JP16 JP17 JP18 JP19 Setting Jumper JP20 JP21 JP22 JP23 JP24 JP25 JP26 JP27 JP28 JP29 JP30 JP31 JP32 JP33 JP34 JP35 JP36 JP37 JP38 JP39 Setting Jumper JP40 JP41 JP42 JP43 JP44 JP45 JP46 JP47 JP48 JP49 JP50 JP51 JP52 JP53 JP54 JP55 JP56 JP57 JP58 JP59 Setting Jumper JP60 JP61 JP62 JP63 JP64 DIP1 DIP2 DIP3 DIP4 DIP5 DIP6 DIP7 DIP8 DIP9 DIP10 DIP11 DIP12 Setting Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor System Concept 3.3.2 Flashing M523xEVB CFFlasher utility used programming code into Flash memory MCF523xEVB. Check correct setting switches jumpers: SW7-6 SW7-7 off, JP64 2-3, (JP31 2-3). flashing procedure follows: Metrowerks CodeWarrior ColdFire open project. Choose simple_eflash target compile application. file simple_eflash.elf.S19, which will loaded into Flash memory, created project directory bin. CFFlasher application, click "Target Config" button. Target Configuration window, select type board M523xEVB Communication PE_LPT (see Figure Click close window. Program section clicking "Program" button. Select simple_eflash.elf.S19 file check "Verify after Program" option (see Figure Finally, press "Program" button bottom window start loading code into Flash memory. code been programmed correctly, remove interface push RESET button M523xEVB. application should from Flash. CFFlasher application downloaded from Figure CFFlasher Target Configuration Window Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor System Concept Figure CFFlasher Program Window 3.3.3 Setting Over-current Level over-current fault signal connected eTPU output disable (LETPUODIS) that handles eTPU hardware faults, along with proper eTPU configuration. This connection part M523xEVB1. order enable handling fault software, fault signal, available LETPUODIS pin, must connected eTPU channel which runs GPIO function generates interrupt request case fault. This connection must done manually. Connect (LETPUODIS) with (ETPUCH4) eTPU header (see Figure 10). over-current level trimmer M523xEVB (see Figure 11). Reference describes what voltage trimmer defines over-current comparator. Follow steps below over-current level properly without measuring voltage: Connect system parts according Figure connect with eTPU header. over-current interrupt disabled. over-current fault handled hardware only. Download start application. Turn ON/OFF switch Using Down buttons, required speed maximum. Adjust trimmer. find level from which starts light motor speed starts limited. trimmer level somewhat higher, that motor maximum speed. Turn ON/OFF switch OFF. When eTPU configured 32-channels, LTPUODIS applicable channels 0-15. When ethernet enabled (SW11 on), function LTPUODIS then changes channels UTPUODIS thus controls channels 8-15. Therefore UTPUODIS must tied LTPUODIS enable application work when ethernet enabled. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor System Concept Connect with eTPU header. This enables over-current interrupt. Both hardware software handle over-current fault. Turn ON/OFF switch Using Down buttons, required speed maximum. application goes fault state during acceleration, adjust trimmer level somewhat higher, that motor maximum speed. Figure Connection Between LETPUODIS ETPUCH4 eTPU Header Figure Over-current Level Trimmer M523xEVB (R41) 3.3.4 33395 Evaluation Motor Board 33395 evaluation motor board 12-volt, 8-amp power stage, which supplied with 40-pin ribbon cable. combination with M523xEVB, provides out-of-the-box software development platform Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor System Concept small brushless motors. power stage enables sensing variety feedback signals suitable different motor control techniques. measures three-phase currents, DC-bus voltage, back-EMF voltages with zero cross sensing. DC-bus current also reconstructed from three-phase currents. analog signals adapted directly sampled converter. This single-board power stage contains analog bridge gate driver circuitry, sensing control circuitry, power N-MOSFET transistors, DC-bus break chopper, well various interface connectors supply motor. Figure 33395 Evaluation Motor Board more information, refer Reference 3.3.5 PMSM with Quadrature Encoder used motor low-voltage PMSM (IB23810). motor characteristics Table apply operation 25°C. Table PMSM (IB23810) Characteristics Characteristic Max. operating speed Continuous torque Peak torque Continuous current Peak current Torque sensitivity Tolerance MAX. MAX. MAX. MAX. MAX. ±10% Units R.P.M. LC/A Value 5000 11.4 Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design Table PMSM (IB23810) Characteristics (continued) Characteristic Back constant D.C. resistance Inductance Rotor inertia Weight Tolerance ±10% ±10% ±15% NOM. NOM. Units R.P.M. Value 3.35 6.32 0.0011 1.18 more motor specifications, refer Reference Quadrature encoder HEDS-5640 attached motor order scan encode shaft movement. basic encoder features follows: Three channel quadrature output with index pulse Resolution counts revolution External mounting ears Quick easy assembly signal adjustment required Small size -40°C 100°C operating temperature compatible Single supply more quadrature encoder specifications, refer Reference 3.3.6 Power Supply power supply supplied with M523xEVB, 9.0V/2.7A, also used power 33395 evaluation motor board. application scaled this power supply. case power supply used instead, application should rescaled wider voltage speed range. Software Design This section describes software design PMSM vector control drive application. system processing distributed between eTPU, which parallel. eTPU tasks described terms following: Software flowchart Application state diagram eTPU application Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design eTPU eTPU block diagram eTPU timing Software Level User Application Run-Time Methods Source Code Files main.c Run-Time Methods Initialization Methods: my_system_etpu_init(); my_system_etpu_start(); Origin only code written user generated eTPU AN30003002SW AN29422945SW AN29702973SW AN2864SW AN2968SW User eTPU Initialization Code eTPU Application eTPU Function Standard eTPU Utilities <user_app>_etpu_gct.c/.h etpu_app_<app_name>.c/.h etpu_<func>.c/.h etpu_util.c/.h etpu_struct.h Code Generated etpu_<func>_auto.h Etpu_set4.h eTPU Compiler eTPU Function etpuc_<func>.c Etpuc_set4.c Source Code, compiled ByteCraft etpuc.h etpuc_common.h ETPU_C Code eTPU Code User written code Freescale supplied code Generated code ByteCraft supplied code Figure eTPU Project Structure Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design software uses several ready-to-use Freescale software drivers. communication between microprocessor FreeMASTER handled software included fmaster.c/.h files. eTPU module uses general eTPU utilities, eTPU function interface routines (eTPU function API), eTPU application interface routines (eTPU application API). general utilities, included etpu_util.c/.h files, used initialization global eTPU module engine settings. eTPU function routines used initialization eTPU channels interfacing each eTPU function during run-time. eTPU application encapsulates several eTPU function APIs. eTPU application eliminates need initialize each eTPU function separately handle eTPU function initialization settings, ensuring correct cooperation eTPU functions. Software Flowchart RESET Initialize interrupts pins FreeMaster Timer Interrupt FreeMaster Dispatcher wait Timer Interrupt eTPU Channel Interrupt FreeMaster Recorder Read ON/OFF switch status Handle application state machine Service Up/Down buttons Status Read application data structure Fault Interrupt Handle overcurrent fault QSPI Interrupt eTPU Global Exception Interrupt Transfer external converter result queue, received QSPI, from QSPI eTPU DATA Handle eTPU global exception Figure Software Flowchart After reset, software initializes interrupts pins. following processing incorporated periodical timer interrupts, periodical eTPU channel interrupt, periodical QSPI interrupt, fault interrupts. 4.1.1 Initialization Interrupts Pins initialization timer eTPU channel interrupts, QSPI interrupt, eTPU global exception interrupt, together with initialization GPIO LETPUODIS pins, done InitInterruptsAndPins function. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design 4.1.2 Timer Interrupt Service Routine timer interrupt handled timer3_isr function. following actions performed periodical, timer3_isr: Read ON/OFF switch status. Handle application state machine. application state diagram described detail below. Service Down buttons status ApplicationButtonsAndStatusLed function. Read data structure through eTPU application routine. fs_etpu_app_pmsmesvc1_get_data (see 4.3). 4.1.3 QSPI Interrupt Service Routine QSPI interrupt handled qspi_isr function. queue data received QSPI from external converter copied eTPU DATA RAM. Then, QSPI reinitialized transfer command external converter. This transfer executed from eTPU. 4.1.4 FreeMASTER Interrupt Service Routine FreeMASTER interrupt service routine called fmasterDispatcher. This function implemented fmaster.c. 4.1.5 eTPU Channel Interrupt Service Routine This interrupt, which raised every period PWMMAC eTPU function running eTPU channel handled etpu_ch7_isr function. This function calls fmasterRecorder, implemented fmaster.c, enabling recording application variable time courses with PWM-period time resolution. 4.1.6 Fault Interrupt Service Routine over-current fault interrupt, which raised GPIO eTPU function running eTPU channel handled etpu_ch4_isr function. following actions performed order switch motor off: Reset required speed/torque. Disable generation signals. Switch Fault Enter APP_STATE_MOTOR_FAULT. FAULT_OVERCURRENT. 4.1.7 eTPU Global Exception Interrupt Service Routine global exception interrupt handled etpu_globalexception_isr function. following situations cause this interrupt assertion: Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design Microcode global exception asserted. Illegal instruction flag asserted. MISC flag asserted. following actions performed order switch motor off: Reset required speed. Disable generation signals. Enter APP_STATE_GLOBAL_FAULT. Based eTPU global exception source, FAULT_MICROCODE_GE, FAULT_ILLEGAL_INSTR, FAULT_MISC. Application State Diagram reset ON/OFF switch moved APP_STATE_INIT APP_STATE_ MOTOR_FAULT APP_STATE_ GENERAL_FAULT ON/OFF switch moved APP_STATE_STOP ON/OFF switch moved APP_STATE_ENABLE APP_STATE_DISABLE ON/OFF switch moved APP_STATE_RUN over-current fault interrupt Figure Application State Diagram application state diagram consists seven states (see Figure 15). After reset, application goes first APP_STATE_INIT. Where ON/OFF switch position, APP_STATE_STOP follows, otherwise APP_STATE_MOTOR_FAULT entered ON/OFF switch must turned from APP_STATE_MOTOR_FAULT APP_STATE_STOP. Then cycle between APP_STATE_STOP, APP_STATE_ENABLE, APP_STATE_RUN, APP_STATE_DISABLE repeated, depending ON/OFF switch position. APP_STATE_ENABLE APP_STATE_DISABLE states introduced order ensure safe transitions between APP_STATE_STOP APP_STATE_RUN states. Where over-current fault interrupt raised (see Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design line Figure 15), APP_STATE_MOTOR_FAULT entered. This fault cleared moving ON/OFF switch position thus entering APP_STATE_STOP. Where eTPU global exception interrupt raised (see gray line Figure 15), APP_STATE_GLOBAL_FAULT entered. global fault cleared moving ON/OFF switch position thus entering APP_STATE_INIT. following paragraphs describe processing each application states. 4.2.1 APP_STATE_INIT This state passed through only. entered either after reset, after APP_STATE_GLOBAL_FAULT. Perform following actions initialize (re-initialize) application: Call my_system_etpu_init routine eTPU module initialization. eTPU functions DATA addresses FreeMASTER. addresses channel configuration registers FreeMASTER. Initialize QSPI ADC. ASAC polarity pulse high. Initialize DMA3. Initialize UART FreeMASTER. Initialize FreeMASTER. Call my_system_etpu_start routine eTPU Start. this point, eTPU parallel. Depending ON/OFF switch position, enter APP_STATE_STOP APP_STATE_MOTOR_FAULT. 4.2.1.1 Initialization Start eTPU Module eTPU module initialized using my_system_etpu_init function. Later, after initialization other peripherals, eTPU started my_system_etpu_start. These functions general eTPU utilities eTPU function routines. Both my_system_etpu_init my_system_etpu_start functions, included pmsmesvc1_etpu_gct.c file, generated eTPU graphical configuration tool. eTPU graphical configuration tool downloaded from http://www.freescale.com/etpu. more information, refer Reference my_system_etpu_init function first configures eTPU module motor settings. Some these settings include following: Channel filter mode two-sample mode Channel filter clock etpuclk input signals (from quadrature encoder) filtered channel filters. filter settings guarantee minimum delay input transition recognition. TCR1 source etpuclk Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design TCR1 prescaler TCR1 internal eTPU clock maximum rate 37.5 150-MHz system clock), corresponding 27ns resolution generated signals. After configuring module engine settings, my_system_etpu_init function initializes eTPU channels. Channel quadrature decoder (QD) phase channel Channel quadrature decoder (QD) phase channel Channel quadrature decoder (QD) index channel Channel general purpose (GPIO) Channel speed controller (SC) Channel PMSM vector control (PMSMVC) Channel master motors (PWMMAC) Channel full range (PWMF) phase base channel Channel full range (PWMF) phase complementary channel Channel full range (PWMF) phase base channel Channel full range (PWMF) phase complementary channel Channel full range (PWMF) phase base channel Channel full range (PWMF) phase complementary channel Channel analog sensing motors (ASAC) Channel break controller (BC). These eTPU channels initialized fs_etpu_app_pmsmesvc1_init eTPU application function (see 4.3). application settings follows: phases-type full range complementary pairs frequency dead-time 500ns Motor speed range Motor speed minimum DC-bus voltage Number motor pole pairs Speed controller update frequency Speed controller parameters: Controller gain Integral time constant 1ms. controller parameters were experimentally tuned. Ramp parameters: 300ms ramp from zero maximum speed. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design D-current controller parameters: Controller gain Integral time constant 500µs. controller parameters were experimentally tuned. Q-current controller parameters: Controller gain Integral time constant 500µs. controller parameters were experimentally tuned. Motor electrical constant 8.4V/kRPM Motor induction 6.32mH Number quadrature encoder position counter increments revolution 2000. Range converter sampling phase currents corresponds 1.947A. Break controller mode PWM-based breaking signal generated case over-voltage. Break control signal polarity active high. DC-bus voltage level, which break control signal 130% nominal DC-bus voltage. DC-bus voltage level, which break control signal OFF, 110% nominal DC-bus voltage. ASAC function triggers converter high-low edge (applies only during converter initialization, then this option changed). Phase currents DC-bus voltage measurement time, including conversion time transfer time, 15µs. p_ASAC_result_queue pointer contains address eTPU DATA RAM, where result queue transferred. samples result queue shifted left bits achieve alignment corresponding 24-bit fractional format, which used eTPU functions. Phase current sample offset within ASAC_result_queue Phase current sample offset within ASAC_result_queue Phase current sample offset within ASAC_result_queue DC-bus voltage sample offset within ASAC_result_queue ASAC EWMA filter time constant 200µs phase currents. ASAC EWMA filter time constant DC-bus voltage. Channel general purpose (GPIO) This eTPU channel initialized fs_etpu_gpio_init function. setting Channel priority: high my_system_etpu_start function first applies settings channel interrupt enable channel output disable options, then enables eTPU timers, thus starting eTPU. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design Figure eTPU Configuration Using eTPU Graphical Configuration Tool 4.2.1.2 Initialization FreeMASTER Communication Prior FreeMASTER initialization, necessary pointers eTPU functions' DATA bases configuration register bases. Based these pointers, which read FreeMASTER during initialization, locations eTPU function parameters configuration registers defined. This essential correct FreeMASTER operation. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design FreeMASTER consists software running microprocessor, connected RS-232 serial port. small program resident microprocessor communicates with FreeMASTER order return status information processes control information from microprocessor part FreeMASTER initialized functions: iniFmasterUart fmasterInit. Both functions included fmaster.c, which automatically initializes UART driver installs necessary services. 4.2.2 APP_STATE_STOP this state, signals disabled motor off. motor shaft rotated hand, which enables user explore functionality quadrature decoder (QD) eTPU function, watch variables produced signals FreeMASTER. When ON/OFF switch turned application goes through APP_STATE_ENABLE APP_STATE_RUN. 4.2.3 APP_STATE_ENABLE This state passed through only. following actions performed order switch motor drive Reset required speed. Enable generation signals calling fs_etpu_app_pmsmesvc1_enable application routine. This routine also performs motor alignment. phases successfully enabled, GPIO eTPU function configured input interrupt rising edge, enters APP_STATE_RUN mode. phases successfully enabled, application state does change. 4.2.4 APP_STATE_RUN this state, signals enabled motor required motor speed torque using Down buttons M523xEVB using FreeMASTER. latest value periodically written eTPU. When ON/OFF switch turned off, application goes through APP_STATE_DISABLE APP_STATE_STOP. 4.2.5 APP_STATE_DISABLE This state passed through only. following actions performed order switch motor drive off: Reset required speed/torque. Disable generation signals. phases were successfully disabled, APP_STATE_STOP entered. phases successfully disabled, application state remains same. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design 4.2.6 APP_STATE_MOTOR_FAULT This state entered after over-current fault interrupt service routine. application waits until ON/OFF switch turned off. This clears fault application enters APP_STATE_STOP. 4.2.7 APP_STATE_GLOBAL_FAULT This state entered after eTPU global exception interrupt service routine. application waits until ON/OFF switch turned off. This clears fault application enters APP_STATE_INIT. eTPU Application eTPU application encapsulates several eTPU function APIs. eTPU application includes methods which enable initialization, control, monitoring eTPU application. eTPU application functions eliminates need initialize each eTPU function separately, ensures correct cooperation eTPU functions. eTPU application device-independent handles only eTPU tasks. Abbreviated application names shorten eTPU application names: Motor type (DCM motor, BLDCM brushless motor, PMSM permanent magnet synchronous motor, ACIM induction motor, switched reluctance motor, stepper motor) Sensor type Hall sensors, shaft encoder, resolver, sincos, sensorless) Control type open loop, position loop, speed loop, current loop, speed vector control, torque vector control) Based these definitions, PMSMESVC1 abbreviation `PMSM with quadrature encoder speed vector control' eTPU motor-control application. there several applications like this, number denotes first such application order. PMSMESVC1 eTPU application described following paragraphs. There five basic functions added PMSMESVC1 application API. routines found etpu_app_pmsmesvc1.c/.h files. PMSMESVC1 application routines will described order listed below: Initialization function: int32_t fs_etpu_app_pmsmesvc1_init( pmsmesvc1_instance_t pmsmesvc1_instance, uint8_t uint8_t uint8_t uint8_t uint8_t uint8_t uint8_t uint8_t PWM_master_channel, PWM_phaseA_channel, PWM_phaseB_channel, PWM_phaseC_channel, QD_phaseA_channel, QD_index_channel, SC_channel, BC_channel, Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design uint8_t uint8_t uint8_t uint32_t uint32_t int32_t int32_t int32_t uint8_t uint32_t int32_t int32_t uint32_t int32_t int32_t int32_t int32_t int32_t int32_t uint32_t int32_t uint8_t uint8_t uint8_t uint8_t uint8_t uint24_t uint8_t uint8_t uint8_t uint8_t uint8_t uint32_t uint32_t PMSMVC_channel, ASAC_channel, PWM_phases_type, PWM_freq_hz, PWM_dead_time_ns, speed_range_rpm, speed_min_rpm, dc_bus_voltage_mv, pole_pairs, SC_freq_hz, SC_PID_gain_permil, SC_I_time_const_us, SC_ramp_time_ms, PMSMVC_D_PID_gain_permil, PMSMVC_D_I_time_const_us, PMSMVC_Q_PID_gain_permil, PMSMVC_Q_I_time_const_us, PMSM_Ke_mv_per_krpm, PMSM_L_uH, QD_pc_per_rev, phase_current_range_ma, BC_mode, BC_polarity, BC_u_dc_bus_ON_perc, BC_u_dc_bus_OFF_perc, ASAC_polarity, ASAC_measure_time_us, ASAC_bit_shift, ASAC_ia_queue_offset, ASAC_ib_queue_offset, ASAC_ic_queue_offset, ASAC_u_dcbus_queue_offset, ASAC_filter_time_constant_i_us, uint32_t *ASAC_result_queue, Change operation functions: int32_t fs_etpu_app_pmsmesvc1_enable( pmsmesvc1_instance_t pmsmesvc1_instance, uint8_t sc_configuration) int32_t fs_etpu_app_pmsmesvc1_disable( Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design pmsmesvc1_instance_t pmsmesvc1_instance) void pmsmesvc1_instance_t pmsmesvc1_instance, int32_t speed_required_rpm) Value return function: void fs_etpu_app_pmsmesvc1_get_data( pmsmesvc1_instance_t pmsmesvc1_instance, pmsmesvc1_data_t pmsmesvc1_data) 4.3.1 int32_t fs_etpu_app_pmsmesvc1_init(.) This routine used initialize eTPU channels PMSM with quadrature encoder torque vector control application. This function following parameters: pmsmesvc1_instance (pmsmesvc1_instance_t*) pointer pmsmesvc1_instance_t structure, which filled fs_etpu_app_pmsmesvc1_init. This structure must declared user application. When there more instances application running simultaneously, there must separate pmsmesvc1_instance_t structure each one. PWM_master_channel (uint8_t) master channel number; 0-31 ETPU_A, 64-95 ETPU_B. PWM_phaseA_channel (uint8_t) phase channel number; 0-31 ETPU_A, 64-95 ETPU_B. case complementary signal generation complementary channel channel higher. PWM_phaseB_channel (uint8_t) phase channel number; 0-31 ETPU_A, 64-95 ETPU_B. case complementary signal generation complementary channel channel higher. PWM_phaseC_channel (uint8_t) phase channel number; 0-31 ETPU_A, 64-95 ETPU_B. case complementary signal generation complementary channel channel higher. QD_phaseA_channel (uint8_t) quadrature decoder phase channel number; 0-30 ETPU_A, 64-94 ETPU_B. quadrature decoder phase channel channel higher. QD_index_channel (uint8_t) quadrature decoder index channel number; 0-31 ETPU_A, 64-95 ETPU_B. SC_channel (uint8_t) speed controller channel number; 0-31 ETPU_A, 64-95 ETPU_B. BC_channel (uint8_t) break controller channel number; 0-31 ETPU_A, 64-95 ETPU_B. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design PMSMVC_channel (uint8_t) PMSM vector control function channel number; 0-31 ETPU_A, 64-95 ETPU_B. ASAC_channel (uint8_t) analog sensing motors (ASAC) channel number; 0-31 ETPU_A, 64-95 ETPU_B. PWM_phases_type (uint8_t) Determines type phases; should assigned value PWM_freq_hz (uint32_t) frequency PWM_dead_time_ns (uint32_t) dead-time speed_range_rpm (int32_t) maximum motor speed rpm. speed_min_rpm (int32_t) minimum (measurable) motor speed rpm. dc_bus_voltage_mv (int32_t) DC-bus voltage pole_pairs (uint8_t) number motor pole-pairs. SC_freq_hz (uint32_t) speed controller update frequency assigned value must equal PWM_freq_hz divided SC_PID_gain_permil (int32_t) speed controller gain millesimals. SC_I_time_constant_us (int32_t) speed controller integral time constant SC_ramp_time_ms (uint32_t) Defines required speed ramp time step change required speed from speed_range_rpm slowed down ramp take defined time. PMSMVC_D_PID_gain_permil (int32_t) D-current (flux controlling current) controller gain millesimals. PMSMVC_D_I_time_constant_us (int32_t) D-current (flux controlling current) controller integral time constant PMSMVC_Q_PID_gain_permil (int32_t) Q-current (torque controlling current) controller gain millesimals. PMSMVC_Q_I_time_constant_us (int32_t) Q-current (torque controlling current) controller integral time constant PMSM_Ke_mv_per_krpm (int32_t) motor electrical constant mV/1000RPM. PMSM_L_uH (int32_t) motor induction QD_qd_pc_per_rev (uint32_t) number position counter increments revolution. phase current_range_ma (int32_t) maximum measurable phase current BC_mode (uint8_t) function mode; should assigned value BC_polarity (uint8_t) output polarity.; should assigned value Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design BC_u_dc_bus_ON_perc (uint8_t) proportion between U_DC_BUS (above which output nominal U_DC_BUS, expressed percentage (usually about 130%). BC_u_dc_bus_OFF_perc (uint8_t) proportion between U_DC_BUS (below which output OFF) nominal U_DC_BUS, expressed percentage (usually about 110%). ASAC_polarity (uint8_t) polarity assign ASAC function; should assigned value ASAC_measure_time_us (uint24_t) Time from first (triggering) edge second edge, which result queue supposed ready DATA_RAM us). This value depends conversion time transfer time. ASAC_result_queue (uint32_t Pointer result queue eTPU DATA RAM. Result queue array 16-bit words that contains measured values. ASAC_bit_shift (uint8_t) Defines align data from result queue into fract24 int24). This parameter should assigned value ASAC_ia_queue_offset (uint8_t) Position phase current sample result queue. Offset defined bytes. ASAC_ib_queue_offset (uint8_t) Position phase current sample result queue. Offset defined bytes. ASAC_ic_queue_offset (uint8_t) Position phase current sample result queue. Offset defined bytes. ASAC_u_dcbus_queue_offset (uint8_t) Position DC-bus voltage sample result queue. Offset defined bytes. ASAC_filter_time_constant_i_us (uint32_t) time constant exponentially-weighted moving average (EWMA) filter that applies when processing phase current samples, ASAC_filter_time_constant_i_us (uint32_t) time constant EWMA filter that applies when processing DC-bus voltage samples, 4.3.2 int32_t fs_etpu_app_pmsmesvc1_enable(.) This routine used enable generation signals, align motor start position reset position counter, initialize measurement analog values, start vector control loop speed controller. This function following parameters: pmsmesvc1_instance (pmsmesvc1_instance_t*) pointer pmsmesvc1_instance_t structure, which filled fs_etpu_app_pmsmesvc1_init. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design sc_configuration (uint8_t) required configuration should assigned value speed loop opened, motor controlled torque; closed, motor controlled speed. 4.3.3 int32_t fs_etpu_app_pmsmesvc1_disable (pmsmesvcl1_instance_t pmsmesvc1_instance) This routine used disable generation signals stop vector control loop speed controller. This function following parameter: pmsmesvc1_instance (pmsmesvc1_instance_t*) pointer pmsmesvc1_instance_t structure, which filled fs_etpu_app_pmsmesvc1_init. 4.3.4 void This routine used required motor speed. This function following parameters: pmsmesvc1_instance (pmsmesvc1_instance_t*) pointer pmsmesvc1_instance_t structure, which filled fs_etpu_app_pmsmesvc1_init. speed_required_rpm (int32_t) required motor speed rpm. speed loop opened (sc_configuration been fs_etpu_pmsmesvc1_enable(.)), required speed value passed directly speed controller output, which required motor torque. this case, required motor speed RPM, fraction speed range RPM, corresponds required motor torque, fraction maximum motor torque. 4.3.5 void This routine used application state data. This function following parameters: pmsmesvc1_instance (pmsmesvc1_instance_t*) pointer pmsmesvc1_instance_t structure, which filled fs_etpu_app_pmsmesvc1_init. pmsmesvc1_data (pmsmesvc1_data_t*) pointer pmsmesvc1_data_t structure application state data, which updated. eTPU Block Diagram eTPU functions used PMSM vector control drive located motor-control eTPU functions (set4 motors). eTPU functions within serve building blocks various motor-control applications. following paragraphs describe functionality each block. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design eTPU fault interrupt Hardware GPIO DC-bus voltage DC-bus voltage phase_a_current phase_b_current phase_c_current Fault DC-Bus Break Trigger ASAC required torque duty-cycles alpha PWMF PMSMVC beta PWMMAC required actual torque speed Motor Inverter required speed position counter position difference time difference QD_Index Shaft Encoder Figure Block Diagram eTPU Processing size motor control eTPU function (set4) binary image higher then eTPU CODE available MCF523x. This limited version eTPU set4, which fits into 6kB, used this application. This version, set4 0.2, includes only eTPU functions necessary PMSM vector control application. Some them even modified smaller code size. following paragraph lists limitations modified eTPU functions: Speed controller (SC)-HD mode implemented master motors (PWMMAC)-only types modulation implemented (PWM_ICT SVM_STD) full range (PWMF)-half cycle reload implemented 4.4.1 Generator (PWMMAC+PWMF) generation signals motor-control applications with eTPU provided eTPU functions: PWM-master motors (PWMMAC) PWM-full range (PWMF) master motors (PWMMAC) function calculates sine wave space vector modulation resulting duty cycles, updates three phases. phases driven full range (PWMF) function, which enables full 100%) duty-cycle range. PWMF function generates signals. PWMMAC function controls three PWMF functions three phases, does generate drive signal. PWMMAC even executed eTPU channel connected output (channels 32). Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design input values alpha angle input values beta amplitude PWMMAC update update update update update polarity: active-high active-low center-aligned edge-aligned single channel complementary pair variable periods PWMF PWMF PWMF Figure Functionality PWMMAC+PWMF more details about PWMMAC PWMF eTPU functions, refer Reference 4.4.2 Quadrature Decoder (QD) quadrature decoder eTPU function intended process signals generated shaft encoder motion control system. uses channels decode pair out-of-phase encoder signals produce 24-bit bi-directional position counter, together with direction information, CPU. additional input channel also processed. index channel receives pulse each revolution. Based Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design actual direction, revolution counter incremented decremented index pulse. further additional input channel indicate home position, used this application. position_counter direction last_edge_tcr revolution_counter QD_INDEX QD_HOME Figure Functionality more details about eTPU function, refer Reference 4.4.3 Analog Sensing Motors (ASAC) analog sensing motors eTPU function (ASAC) useful preprocessing analog values that measured converter transferred eTPU data memory transfer. ASAC function also useful triggering converter synchronizing other eTPU functions. above mentioned ASAC features utilized application. ASAC initialized synchronized mode, e.g. first ASAC edge synchronized with beginning period. Simultaneously, ASAC manages synchronize function generating link channel every fourth ASAC period. ASAC function preprocesses phase currents DC-bus voltage analog values passes adjusted values input PMSMVC functions. Processing DC-bus voltage sample includes shifting, dc-offset removing, filtering. Processing phase current samples includes also computation third phase current from other two, based actual motor position sectors computation dead-time compensation parameters. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design result queue shift offset shift offset transfer converter shift offset sector shift offset trigger trigger filter dtc_a dtc_b dtc_c filter filter filter ASAC Pre-processed analog values link outer link inner loop controller loop controller link inner loop controller Figure Functionality ASDC more details about ASAC eTPU function, refer Reference order ensure periodic sampling quick transfer measured data from converter ETPU DATA RAM, several peripheral modules used: external analog digital converter (AD7928BRA) used sampling analog values. queued serial peripheral interface (QSPI) module used interface converter. enables initialization converter control registers, triggering converter, receiving measured samples phase currents DC-bus voltage. QSPI module generates interrupt each time receives data from converter. Dedicated interrupt service routine qspi_isr ensures that external converter result queue transferred from QSPI eTPU DATA RAM. Direct memory access (DMA channel used transfer auxiliary byte (0x80) from eTPU DATA QDLYR register QSPI module. This operation triggers QSPI transfer consequent converter sampling. channel transfer initiated request generated ASAC eTPU function. transfer decrements BCR3 register one. Re-initializing this register must done regularly enable continuous operation channel this way. 4.4.4 PMSM Vector Control (PMSMVC) PMSM vector control eTPU function intended process input output signals, control another eTPU function's input parameter. PMSMVC function even executed eTPU channel connected output pin. purpose PMSMVC function perform current control loop field-oriented (vector control) drive permanent magnet synchronous motor (PMSM). sequence PMSMVC calculations consists following steps: Forward Clarke transformation Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design Inverse Park transformation (establishing coordinate system) current controllers calculation Decoupling back-EMF feed forward DC-bus ripple elimination Inverse Park transformation PMSMVC calculates applied voltage vector components alpha beta based measured phase currents required values phase currents 2-phase, orthogonal rotating reference frame (D-Q). PMSMVC function optionally enables perform DC-bus ripple elimination based actual measured value DC-bus voltage. PMSMVC u_dc_bus u_d_lin Decoupling i_d_required Inverse Park Transform u_q_lin DC-Bus Ripple Elimination i_q_required u_alpha alpha beta u_beta cos_theta sin_theta theta position_counter omega_actual Park Transform Clarke Transform i_alpha i_beta Figure Functionality PMSMVC more details about PMSMVC eTPU function, refer Reference 4.4.5 Speed Controller (SC) speed controller eTPU function intended process input output signals. purpose control another eTPU function's input parameter. function executed even eTPU channel connected output pin. function includes general controller algorithm. controller calculates output based inputs: measured value required value. measured value (the actual motor speed) calculated based inputs provided function. required value output speed ramp, whose input function parameter, provided Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design another eTPU function. motor-control eTPU function set, this function mostly provides speed outer-loop. applied_voltage controller ramp scaling_factor position_difference time_difference position_counter last_edge_time requested_value time Figure Functionality more details about eTPU function, refer Reference 4.4.6 Break Controller (BC) purpose break controller (BC) eTPU function eliminate DC-bus over-voltage when motor driven generating mode. function generates DC-bus break control signal (see Figure based actual DC-bus voltage. AC/DC DC-bus H-BRIDGE DC-bus break control signal Figure Functionality described application uses mode function. this mode, function switches softly using signal. u_dc_bus_ON u_dc_bus_OFF thresholds define ramp (see Figure 24). When DC-bus voltage lower than u_dc_bus_OFF, control signal turned off. Between u_dc_bus_OFF u_dc_bus_ON thresholds, signal with duty-cycle linearly increasing from 100% generated. Above u_dc_bus_ON threshold, control signal turned Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design functionality shown Figure Figure Figure Signal (dark blue line) represents DC-bus voltage, signal (light blue line) reflects DC-bus break control signal generated Duty_cycle 100% U_dc_bus_OFF U_dc_bus_ON U_dc_bus Figure Mode Break Controller Function Figure Oscilloscope Screen-shot Showing DC-bus Voltage Course when Motor Reaches Generating Mode (Without Action Break Controller) Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design Figure Oscilloscope Screen-shot Showing Functionality Break Controller Figure Oscilloscope Screen-shot showing Functionality Break Controller Detail (Zoom DC-bus Break Control Signal) more details about eTPU function, refer Reference Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design 4.4.7 General Purpose (GPIO) This function originates from general eTPU function (set1) included motor control eTPU function well. allows user configure eTPU channel general purpose input output. There supported function: Input mode-update periodically Input mode-update transition-either edge Input mode-update transition-falling edge Input mode-update transition-rising edge Input mode-update request/disable transition match updates Output mode-output Output mode-output high GPIO function configured generate interrupt case over-current fault. fault signal, which usually connected eTPU output disable input, also connected eTPU channel assigned GPIO function. When fault signal turns active, selected output channels immediately disabled eTPU hardware. same time, GPIO function generates interrupt notify about fault occurrence. more details about GPIO eTPU function, refer Reference eTPU Timing eTPU processing event-driven. Once event service begins, execution cannot interrupted another event service. other event services have wait, which causes service request latency. maximum service request latency, worst case latency (WCL), differs each eTPU channel. affected channel priority activity other channels. each channel must kept below required limit. example, PWMF channels must lower than period. theoretical calculation WCLs, given eTPU configuration, trivial task. motor control eTPU functions introduce debugging feature that enables user check channel latencies using oscilloscope, eliminates necessity theoretical calculations. mentioned earlier, some eTPU functions intended process input output signals driving motor. These functions turn output high low, that high-time identifies period time which function execution active. oscilloscope used determine much channel activity pulse varies time, which indicates channel service latency range. example, when oscilloscope time base synchronized with periods, behavior tested channel activity pulse described following cases: pulse asynchronous with periods. This means that tested channel activity synchronized with periods. pulse synchronous with periods stable. This means that tested channel activity synchronous with periods delayed service latency. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Software Design pulse synchronous with periods, position varies time. This means that tested channel activity synchronous with periods service latency varies this time range. Figure Logic Analyzer Screen-shot eTPU Timing Figure explains application eTPU timing. logic analyzer screen-shot depicts typical situation described below: Figure shows input output eTPU signals. signals numbered according eTPU channels. time scale adjusted that dark green grid lines correspond period frames. whole picture shows time section periods. Signals coming from shaft encoder processed quadrature decoder (QD) eTPU function. During this time, motor speed 1000 RPM. Signal generated speed controller (SC) eTPU function. pulses determine activity pulse width determines time necessary calculate motor speed from position counter last edge time, calculate required speed ramp, apply controller algorithm. This calculation performed periodically 5-kHz rate, which every fourth period. Signal generated PMSM vector control (PMSMVC) eTPU function. pairs pulses show that update PMSMVC divided consecutive threads. PMSM update performed every period. Signal generated master motors (PWMMAC) eTPU function. pulses determine activity PWMMAC. Immediately after PMSMVC update finished, narrow PWMMAC pulse occurs. These pulses determine service time PMSMVC request update applied motor Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Implementation Notes voltage vector. This service also includes calculation space vector modulation. Apart from these pulses, wider pulses signal actual update next period. Signals three phases signals-three center-aligned complementary pairs. base channels active-high polarity, while complementary channels active-low. period 50µs, which corresponds frequency kHz. Signal generated analog sensing motors (ASAC) eTPU function. ASAC function triggers converter generating request first (low-high) edge. ASAC pulse width determines time necessary sample phase currents DC-bus voltage transfer sampled values eTPU data memory. ASAC starts measured samples preprocessing time second edge when samples supposed ready eTPU data memory. Signal generated break controller (BC) eTPU function. When break controller channel receives link, actual value DC-bus voltage compared with defined over-voltage thresholds, according this comparison, generates PWM-based break control signal. ASAC thread executed first ASAC edge requests update every fourth period sending link channel. Consequently, requests update. Both updates finished prior ASAC second edge. ASAC thread executed second edge requests PMSMVC update every period, order apply values phase currents. PMSMVC requests PWMMAC update applied motor voltage vector. these ASAC, PMSMVC activities have finished prior start PWMMAC update. they finished, PWMMAC update postponed next period. update starts update_time prior end-of-the-period frame, that update finished end-of-the-period frame, even worst case latency case. Reference describes update_time value. Implementation Notes Scaling Quantities PMSM vector control algorithm running eTPU uses 24-bit fractional representation real quantities except time. 24-bit signed fractional format mostly represented using 1.23 format sign bit, fractional bits). most negative number that represented -1.0, whose internal representation 0x800000. most positive number 0x7FFFFF 2-23. following equation shows relationship between real fractional representations: Real Value Fractional Value -Real Quatity Range where: Fractional value fractional representation real value [fract24]. Real value real value quantity RPM, etc.]. Real quantity range maximal range quantity, defined application RPM, etc.]. Some quantities represented using 3.21 format signed integer bits, fractional bits) order eliminate need saturation range (-1, most negative number that represented -4.0, Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Microprocessor Usage whose internal representation 0x800000. most positive number 0x7FFFFF 2-21. this format components applied motor voltage vector passed from PMSMVC PWMMAC. Speed Calculation position_difference omega_actual scaling_factor time_difference speed controller (SC) eTPU function calculates angular motor speed using pc_sc last_edge parameters eTPU function. following equation applies: where: omega_actual [fract24] actual angular speed fraction maximum speed range. position_difference [int24] difference between updated value position counter previous value, which captured previous period. fact position_difference readable from pc_sc parameter function. After reads updated value, resets this pc_sc parameters, ensuring that position_difference available pc_sc parameter next time reads time_difference [int24] difference between updated value last_edge previous value, which captured previous period. scaling_factor pre-calculated using following equation: etpu_tcr_freq scaling_factor -omega_max pc_per_rev where: etpu_tcr_freq [Hz] frequency internal eTPU timer (TCR1 TCR2) used. omega_max [RPM] maximal speed range. pc_per_rev number position counter increments revolution. internal eTPU timer (TCR1 TCR2) frequency must that calculation omega_actual both fits into 24-bits arithmetic resolution sufficient. Microprocessor Usage Table Memory Usage Bytes Memory Flash (external) eTPU code eTPU data Available 1.5K Used 34,800 5,832 6,088 1,024 Table shows much memory needed application. Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Microprocessor Usage eTPU module usage terms time load easily determined based following facts: According Reference maximum eTPU load produced generation 1364 eTPU cycles period. frequency kHz, thus period 3750 eTPU cycles (eTPU module clock MHz, half clock). According Reference contribution function overall eTPU time load calculated. depends number shaft encoder pulses (500) motor speed (maximum 1000rpm). maximum eTPU busy time encoder pulse eTPU cycles. According Reference PMSM vector control calculation takes eTPU cycles. calculation performed every period. According Reference speed controller calculation takes eTPU cycles. calculation performed every fourth period. According Reference maximum eTPU load update slave switching mode eTPU cycles, maximum eTPU load edge eTPU cycles. update performed every four periods. frequency DC-bus break control signal kHz, which means that BC-PWM update performed every periods. According Reference ASAC maximum eTPU load takes eTPU cycles (both first then second edge processing performed). ASAC function processing executed every period. GPIO function processing does affect eTPU time load. values eTPU load each functions influenced compiler efficiency. above numbers given guidance only subject change. up-to-date information, refer information provided latest release available from Freescale. peak eTPU time load occurs within period when speed controller break controller calculations executed. This peak value must kept below 100%, which ensures that processing fits into period, service latency longer than period, thus generated signals affected. Table shows eTPU module time load several typical situations. more information, refer Reference Table eTPU Time Load Situation Motor Speed (20.8 pulses second) Motor Speed 1000 (2083 pulses second) Average Time Load 68.7 76.8 Peak Time Load Within Period 84.8 84.8 Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Summary Conclusions Summary Conclusions This application note provides user with description demo application PMSM vector control. application also demonstrates usage eTPU module ColdFire MCF523x, which results independent motor drive. demo application targeted MCF523x family devices, could easily reused with device that eTPU. References Table References MCF5235 Reference Manual, MCF5235RM M523xEVB User's Manual, M5235EVBUM 33395 Evaluation Motor Board Designer Reference Manual DRM33395/D MCG's Motors web: http://www.mcg-net.com Quadrature Encoder HEDS-5640 distributor's web: FreeMASTER page, http://www.freescale.com, search keyword "FreeMASTER" Enhanced Time Processing Unit Reference Manual, ETPURM "Using Quadrature Decoder (QD) eTPU Function," AN2842 "Using Speed Controller (SC) eTPU Function," AN2843 "Using Motor Control eTPU Functions," AN2969 "Using General Purpose eTPU functions (GPIO)," AN2850 "Using Analog Sensing Motors (ASAC) eTPU Function," AN2970 "Using PMSM Vector Control (PMSMVC) eTPU Function," AN2972 "Using Break Controller (BC) eTPU Function," AN2845 "Using Motor Control eTPU Function (set4)," AN2968 eTPU Graphical Configuration Tool, http://www.freescale.com, search keyword "ETPUGCT" Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor THIS PAGE INTENTIONALLY LEFT BLANK Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor THIS PAGE INTENTIONALLY LEFT BLANK Permanent Magnet Synchronous Motor Vector Control, Driven eTPU MCF523x, Rev. Freescale Semiconductor Reach Home Page: www.freescale.com E-mail: support@freescale.com USA/Europe Locations Listed: Freescale Semiconductor Technical Information Center, CH370 1300 Alma School Road Chandler, Arizona 85224 +1-800-521-6274 +1-480-768-2130 support@freescale.com Europe, Middle East, Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 81829 Muenchen, Germany 1296 (English) 52200080 (English) 92103 (German) (French) support@freescale.com Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064, Japan 0120 191014 5437 9125 support.japan@freescale.com Asia/Pacific: Freescale Semiconductor Hong Kong Ltd. Technical Information Center King Street Industrial Estate N.T., Hong Kong +800 2666 8080 support.asia@freescale.com Literature Requests Only: Freescale Semiconductor Literature Distribution Center P.O. 5405 Denver, Colorado 80217 1-800-441-2447 303-675-2140 Fax: 303-675-2150 Information this document provided solely enable system software implementers Freescale Semiconductor products. There express implied copyright licenses granted hereunder design fabricate integrated circuits integrated circuits based information this document. Freescale Semiconductor reserves right make changes without further notice products herein. Freescale Semiconductor makes warranty, representation guarantee regarding suitability products particular purpose, does Freescale Semiconductor assume liability arising application product circuit, specifically disclaims liability, including without limitation consequential incidental damages. "Typical" parameters that provided Freescale Semiconductor data sheets and/or specifications vary different applications actual performance vary over time. operating parameters, including "Typicals", must validated each customer application customer's technical experts. Freescale Semiconductor does convey license under patent rights rights others. Freescale Semiconductor products designed, intended, authorized components systems intended surgical implant into body, other applications intended support sustain life, other application which failure Freescale Semiconductor product could create situation where personal injury death occur. Should Buyer purchase Freescale Semiconductor products such unintended unauthorized application, Buyer shall indemnify hold Freescale Semiconductor officers, employees, subsidiaries, affiliates, distributors harmless against claims, costs, damages, expenses, reasonable attorney fees arising directly indirectly, claim personal injury death associated with such unintended unauthorized use, even such claim alleges that Freescale Semiconductor negligent regarding design manufacture part. Freescaleand Freescale logo trademarks Freescale Semiconductor, Inc. other product service names property their respective owners.© Freescale Semiconductor, Inc. 2004. rights reserved. AN3002 Rev. 10/2005 Other recent searchesMT90221 - MT90221 MT90221 Datasheet BSDB-4000-1B - BSDB-4000-1B BSDB-4000-1B Datasheet B45010W107 - B45010W107 B45010W107 Datasheet AZ100ELT20N - AZ100ELT20N AZ100ELT20N Datasheet AZ100ELT20D - AZ100ELT20D AZ100ELT20D Datasheet AZ100ELT20T - AZ100ELT20T AZ100ELT20T Datasheet AN3624 - AN3624 AN3624 Datasheet AN2565 - AN2565 AN2565 Datasheet
Privacy Policy | Disclaimer |