Application Note AN 2013-09 V1.0 September 2013 300W Motor Control Application Kit Mitja Rebec, IFAT IPC APS AE Ralf Walter, IFAT PMM APS SE DC Evaluation Board Application Note 300W Motor Control Application Kit Application Note AN 2013-09 V1.1 September 2013 Edition 2011-02-02 Published by Infineon Technologies Austria AG 9500 Villach, Austria © Infineon Technologies Austria AG 2011. All Rights Reserved. Attention please! THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE IMPLEMENTATION OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE REGARDED AS ANY DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR QUALITY OF THE INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION NOTE MUST VERIFY ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON TECHNOLOGIES HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND (INCLUDING WITHOUT LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN IN THIS APPLICATION NOTE. Information For further information on technology, delivery terms and conditions and prices please contact your nearest Infineon Technologies Office (www.infineon.com). Warnings Due to technical requirements components may contain dangerous substances. For information on the types in question please contact your nearest Infineon Technologies Office. Infineon Technologies Components may only be used in life-support devices or systems with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system, or to affect the safety or effectiveness of that device or system. Life support devices or systems are intended to be implanted in the human body, or to support and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may be endangered. AN-LV-09-2013-V1.1-EN-049 Revision History: 13-09-01, V1.1 Previous Version: 05/2013, V1.0 Subjects: 300W Motor Control Application Kit Authors: Mitja Rebec, IFAT IPC APS AE Ralf Walter, IFAT PMM APS SE DC We Listen to Your Comments Any information within this document that you feel is wrong, unclear or missing at all? Your feedback will help us to continuously improve the quality of this document. Please send your proposal (including a reference to this document) to: [[email protected]] 2 Evaluation Board Application Note 300W Motor Control Application Kit Application Note AN 2013-09 V1.1 September 2013 Table of contents 1 Overview ....................................................................................................................................................... 5 1.1 Key Features ...................................................................................................................................... 5 2 300W Motor Control Application Kit .......................................................................................................... 6 2.1 PCB .................................................................................................................................................... 6 2.2 Communication Interface ................................................................................................................... 7 2.3 Dedicated Software for the Onboard 8-bit Microcontroller ................................................................ 7 2.4 Infineon Board Control Graphical User Interface (IBC-GUI).............................................................. 8 2.5 BLDC Motor (BLDCM) ....................................................................................................................... 8 3 Running the 300W Motor Control Application Kit .................................................................................... 9 3.1 Connecting the board to a BLDC Motor, Power Supply and PC ....................................................... 9 3.2 IBC-GUI installation .........................................................................................................................10 3.3 First Running of IBC-GUI .................................................................................................................10 3.4 Using PC GUI...................................................................................................................................10 3.4.1 Establishing communication with USB adapter ........................................................................... 10 3.4.2 Selecting operational modes ........................................................................................................ 11 3.4.3 Setting reference and reading actual board and motor values .................................................... 13 3.4.4 Commands and Statuses ............................................................................................................. 14 3.4.5 Parameters ................................................................................................................................... 15 4 Hardware Description ...............................................................................................................................16 4.1 Power Supply ...................................................................................................................................16 4.2 Two Level Three Phase Inverter ......................................................................................................17 4.2.1 Current Measurement .................................................................................................................. 18 4.3 XC836M and MOSFETs Driver 6ED003L02 ...................................................................................19 4.3.1 Driver 6ED003L02 ........................................................................................................................ 20 4.3.2 Microcontroller XC836M ............................................................................................................... 21 4.4 Digital Outputs .................................................................................................................................22 4.5 Hall Sensors Digital Inputs ...............................................................................................................23 4.6 Communication Port ........................................................................................................................23 5 PCB .............................................................................................................................................................24 5.1 Schematic ........................................................................................................................................24 3 Evaluation Board Application Note 300W Motor Control Application Kit Application Note AN 2013-09 V1.1 September 2013 5.2 Placement ........................................................................................................................................25 5.3 Bill of Material...................................................................................................................................26 6 Microprocessor Software Description ....................................................................................................27 6.1 Overview ..........................................................................................................................................27 6.2 Motor Control Algorithm ...................................................................................................................29 6.2.1 Unipolar Block Commutation........................................................................................................ 29 6.3 Scheduler .........................................................................................................................................35 6.4 Serial Communication Protocol........................................................................................................36 6.5 Parameters.......................................................................................................................................38 4 Evaluation Board Application Note 300W Motor Control Application Kit 1 Application Note AN 2013-09 V1.1 September 2013 Overview Brushless motors are taking over the cordless power-tool industry, with just about every manufacturer either already selling brushless tools or preparing to do so. Manufacturers claim brushless motors give more power, require less maintenance and extend the life of cordless tools. Brushless motors differ from brushed motors in three main ways: computer circuitry replaces the commutator, the electromagnets are stationary and conventional magnets can move freely. Relatively new to the power-tool industry, these motors are generating interest among customers and manufacturers. Complete lines of cordless tools are being developed, and because brushless motors can generate more power than brushed motors, some tasks previously thought too tough for a cordless tool are no longer off limits. In a traditional cordless power tool motor, the power supply (battery) uses carbon brushes to conduct electricity to the commutator, which acts as an electric switch. The commutator changes the polarity of the electromagnets, which are attached to a free-spinning shaft and surrounded by fixed magnets, creating the magnetic field for pushing and pulling against. Brushless motors eliminate the wasted energy created by the physical connection of carbon brushes in a brushed motor. Computer circuitry replaces the commutator. Since the electromagnets are stationary, brushes aren’t needed to deliver power. Conventional magnets spin freely within a ring of electromagnets because they don’t require an electrical connection, thereby generating power to the tool. Infineon´s Power Tool Kit is addressing cordless power-tool industry by using simple plug-and-play system. Customers can easily run a BLDC motor and test the efficiency of Infineon devices mounted on a PCB. Figure 1.1: Power Tool Demo Board 1.1 Key Features High efficiency Infineon MOSFETs and MCU Easy plug and play software for fast testing of the board Suitable for BLDC motors with hall sensors Voltage, Current (Torque) and Speed control possible 5 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 2 V1.1 September 2013 300W Motor Control Application Kit Within the 300W Motor Control Application Kit you can find: Power Tool PCB USB/Serial communication adapter USB memory stick including documentation PC and MCU software The PCB functionality is controlled by using Infineon 8-bit microprocessor (XC863M2FRI), which is already programmed with dedicated motor control software. 2.1 PCB The PC board has different functional parts in order to control BLDC motor: DC/DC converter transforming battery voltage into 5V (MCU supply) and 12V (driver supply). Two level three phase inverter using six Infineon OptiMOS Power-MOSFETs BSC016N06NS (100A, RDS(on)=1.6mΩ). The inverter is equipped with shunt resistor on DC link return path for current measurement. Three phase inverter driver IC (6ED003L02) with over-current protection and fault signalization. 8-bit microprocessor (XC836M2FRI). Hall signal circuitry for running BLDC motors. Serial communication for programming and controlling the MCU software. Inputs: Motor Temperature Measurement, Potentiometer, 3 digital inputs. Outputs: 2 digital outputs. TM Two Level Three Phase Converter VBATT VDC Linear Regulator Q1 Q3 Q5 U V W +12V +5V Q2 Q4 UART communication Q6 Temperature Protection Potentiometer Digital Inputs 2 Digital Outputs +5V Microprocessor XC836M current protection drive signals ENABLE +12V Three Phase Driver 6ED003L02_F2 Q1-Q6 Figure 2.1: PCB Functional Blocks 6 Hall Signals Evaluation Board Application Note 300W Motor Control Application Kit 2.2 Application Note AN 2013-09 V1.1 September 2013 Communication Interface The Communication interface is a link between PC user interface and the board. It was realized with a commercially available cable from FTDI TTL-232R-5V. Figure 2.2: FTDI Communication Adapter 2.3 Dedicated Software for the Onboard 8-bit Microcontroller The 8-bit MCU is already programmed with dedicated software. The software is implementing different functions: Block commutation for running BLDC motor with voltage, current or speed control. Hall auto-tuning in order indentify hall sequence using different motor. Unlocking the processor for programming using serial communication with user´s software. Changing and saving parameters to MCU flash permanently. Enabling/Disabling inputs for controlling motor. 7 Evaluation Board Application Note 300W Motor Control Application Kit 2.4 Application Note AN 2013-09 V1.1 September 2013 Infineon Board Control Graphical User Interface (IBC-GUI) The KIT comes with a GUI used to control MCU software execution using serial communication. IBC-GUI is a general program used to control Infineon demo or reference boards. In order to control the 300W Motor Control Application Kit, IBC-GUI must be opened with project file “PowerTool.iproj”. The project file defines parameter, commands, states, scaling factors and displayed values. IBC-GUI can perform different tasks: Displaying and selecting motor operational modes. Reading and writing (set or clear) microprocessor different statuses. Real time values reading (current, voltage, frequency, etc.). Changing and saving parameters (switching frequency, dead time, etc.) to a project file or MCU permanent memory (FLASH). Selecting two different microprocessor operational modes: normal and program mode. Figure 2.3: Infineon Board Control Graphical User Interface (IBC-GUI) 2.5 BLDC Motor (BLDCM) The 300W Motor Control Application Kit can run every BLDC motor equipped with Hall Sensors. 8 Evaluation Board Application Note 300W Motor Control Application Kit 3 Application Note AN 2013-09 V1.1 September 2013 Running the 300W Motor Control Application Kit The 300W Motor Control Application Kit contains: Demo board, FTDI cable and USB memory stick. Running the KIT can be done in three steps: 1. The demo board must be connected properly to a BLDC motor, power supply and PC. 2. IBC-GUI (provided on USB memory stick) must be installed on the PC. 3. Tuning and running the motor. 3.1 Connecting the board to a BLDC Motor, Power Supply and PC In order to run the board, connect the DC power supply (+18V, GND), 3 BLDC motor phases (U, V, W), BLDC motor hall sensors (+5V, GND, H1, H2, H3) and serial communication (GND, T x, Rx). Additionally connect 2 digital inputs to control power ON/OFF and motor direction by using switches instead of GUI. When DC power supply is switched ON, the microprocessor starts to send messages using serial communication, therefore the UART/USB adapter hast to be connected to the PC and the dedicated GUÍ has to be installed for interpreting received messages. 9 Evaluation Board Application Note 300W Motor Control Application Kit Application Note AN 2013-09 V1.1 September 2013 Figure 3.1: Board Wirings 3.2 IBC-GUI installation To install the IBC-GUI, you must run the installation program “Setup.exe”, which is provided on USB memory stick. The setup program will install USB/UART adapter driver and create a desktop shortcut “Infineon Demo Board Control”. 3.3 First Running of IBC-GUI If you run the PC software for the first time, you must select the correct project file. Project files have the extension “*.iproj”. The project file for Power Tool KIT can be found in application folder C:\Program Files\Infineon Technologies\Infineon Board Control\Projects\PowerTool.iproj. Double click it or run “Infineon Demo Board” program and select “File => Open”. When selected, the project file path is written in the application header. 3.4 Using PC GUI 3.4.1 Establishing communication with USB adapter If the USB adapter is plugged into PC port, the application will automatically establish communication with it. If communication is not established automatically you can force the adapter to connect by selecting menu “Comm => Open Communication” or clicking F5. If the other part of the adapter is connected to functional 10 Evaluation Board Application Note 300W Motor Control Application Kit Application Note AN 2013-09 V1.1 September 2013 Power Tool PCB, you will see some activity in the PC GUI. Connection status is visible in GUI footer (left bottom corner of the GUI). 3.4.2 Selecting operational modes There are three different operational modes that can be selected in order to control the motor. First of all the hall sequence has to be tuned according to the phase connection sequence. This operation will create the right commutation table. If the motor phases or hall signals connections change again, this operation must be repeated. The procedure is the following: (1) Select Mode => Hall Sensor Tuning. (2) Click button S (Set) for Power Enable command (this will run the selected operational mode). Power Enable will be colored in red (active). (3) Increase the voltage [%] (duty cycle) till the motor rotor start to sweep and angle is changing (this mode is positioning the rotor in six different angles and hall sensor sequence is saved for each of those angles). When all angles are fired you can stop the power by clicking the button R (Reset) for Power Enable. (4) (5) After doing that commutation table is formed in RAM (temporary memory). In order to save the commutation table to FLASH (permanent memory) you must select menu Flash => Save to Flash. Figure 3.2: Hall Sensor Tuning 11 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 When the sensors are tuned, the motor can be run by selecting two remaining operational modes: “Voltage Control” and “Speed Control”. Operational mode will be started and stopped by clicking buttons “S” or “R” for “Power Enable” command like for hall tuning. “Voltage Control” is used to control the duty cycle or voltage [%] that is exciting motor stator. By increasing the voltage the motor start to rotate. “Speed Control” is used to control the frequency of the rotor using the speed feedback obtains from reading hall sensors. Duty cycle is regulated in order to keep this frequency stable to the selected one. Modes and its statuses are shown in a banner bellow the GUI menus as followed: Mode (Status). Mode: Speed Control, Status: Stopped Mode: Speed Control, Status: Running Figure 3.3: Operational Mode in Mode/Status Banner Name Remark Operational Modes Hall Sensor Tuning Creating commutation table Voltage Control Setting duty cycle Speed Control Setting rotor speed Possible Statuses Stopped Motor is stopped, driver is disabled, control algorithm is blocked Boot Start Boot sequence; Bootstrap capacitor is charging before the motor starts running All the main motor control variables are initialized Running Motor control algorithm is running, block commutation is active Driver Error MOSFETs driver current protection is active Temperature Protection Motor temperature is too high Table 3.1: GUI Operational Mode and its Status banner 12 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 3.4.3 Setting reference and reading actual board and motor values Some important values are sent from microprocessor periodically. Those values are displayed in orange GUI boxes. There are two values that can be set in microprocessor depending on operational modes: Voltage (duty cycle) and frequency. Figure 3.4: Values which can be read or written in real time Name Remark Monitored values f_ref [Hz] Ramped reference frequency used as an input to speed PI controller Angle Hall sensor combination f_act [Hz] Actual frequency calculated from hall signals I_act [A] Actual current read from shunt on negative DC link path Voltage [%] Duty cycle Temp Motor temperature Poti [%] Potentiometer Volt [V] DC link voltage Values that can be set f_ref [Hz] Reference frequency used in Speed Control operational mode Voltage [%] Duty Cycle used in Voltage Control operational mode Table 3.2: MCU Command and Status Flags 13 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 3.4.4 Commands and Statuses Behavior of MCU software can be controlled using a set of commands. Using status flags, we can easily monitor some main errors, warnings or messages that are happening when the MCU software is active. Figure 3.5: MCU Command and Status Flags Name Remark Command [0] Power Enable Enabling/Disabling operational mode (driver, algorithm) [1] Power Enable by Input Enabling/Disabling operational mode by external input [2] Direction by Input Selecting rotor direction by external input [3] Speed by Potentiometer Controlling speed or voltage using potentiometer [4] Driver Protection En. Enabling/Disabling driver protection (switching power off when it occurs) [5] OverTemp. Protection En. Motor over-temperature protection (switching power off when it occurs) [6] Output M1 Output M1 ON/OFF [7] Output M2 Output M2 ON/OFF Status flags Input Power External input for power is ON/OFF Input Direction External input for rotor direction is ON/OFF Input Driver Driver error output is ON/OFF (this output is normally ON) Speed Direction Direction of motor Motor Stall Motor is stand still or not Driver Error Status of driver error Table 3.3: MCU Command and Status Flags 14 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 3.4.5 Parameters MCU parameters are values that can be saved in FLASH and copied to working memory whenever the PCB start is operational. Those values can be changed and saved to FLASH in order to modify the PCB behavior. By clicking Read/Write, the GUI will read or write all parameters into MCU working memory. By clicking Save/Load, the GUI will save or load all parameter in project file. To save this parameters to FLASH (permanent memory) select menu “Flash => Save To Flash”. Figure 3.6: MCU Parameters Name Remark Pwm.SwitchDelay [x21ns] Setting the exact moment when current is sensed from shunt Pwm.Freq [kHz] PWM switching frequency Pwm.DeadTime [x21ns] Dead time between high side and low side I.Kp (NOT USED) Current controller proportional parameter I.Ki (NOT USED) Current controller integral parameter I.KiLimit [%] (NOT USED) Current controller integral limit parameter Freq.Max [Hz] Maximum motor frequency Freq.Slew [Hz/s] Frequency ramp Freq.I_Kp (NOT USED) Frequency current controller proportional parameter Freq.I_Ki (NOT USED) Frequency current controller integral parameter Freq.I_KiLimit [%] (NOT USED) Frequency current controller integral limit parameter Freq.V_Kp Frequency voltage controller proportional parameter Freq.V_Ki Frequency voltage controller integral parameter Freq.V_KiLimit [%] Frequency voltage controller integral limit parameter Adc.Offset Setting the zero for sensed current Adc.TmotorMax Maximum motor temperature (after this error is signalized) Sys.Commands Start up command when PCB start working Sys.Modes Start up operational mode Table 3.4: MCU Parameters 15 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 4 Hardware Description 4.1 Power Supply V1.1 September 2013 Figure 4.1: Auxiliary Power The nominal input voltage is 18-24V. This voltage is used to supply the two level three phase inverter. Supplied voltage is converted to 12V and 5V by using voltage regulators LM7812. 12V is used to supply the MOSFET drivers and 5V is used to supply MCU and hall sensors. Name Remark Elements Voltage regulator LM7812 Transforming 18V into 12V Voltage regulator LM7805CT Transforming 12V into 5V Bulk capacitor 1000uF / 35V Input Signals Mains power supply 18-24V supplied from battery Ground Output Signals DC link voltage 18V supplying 2 level three phase inverter DC link voltage sense (U1-1) 5V on MCU is 30.5V on DC link 12V voltage line Supplying MOSFETs driver 5V voltage line Supplying MCU, hall sensors, potentiometer, … Ground (GND) 0V Table 4.1: Auxiliary Power 16 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 4.2 V1.1 September 2013 Two Level Three Phase Inverter Figure 4.2: Schematic Two Level Three Phase Inverter This inverter stage is designed to drive BLDC motors up to 300W continuously without additional heatsinks or fans using two MOSFETs in parallel. Higher motor power ratings are possible using an optimized thermal management (heatsink, fan etc.). There is a shunt on negative DC link path used for current measurement and driver current protection signal too. Name Remark Parameters MOSFETs current rating (BSC016N06NS) 100A (package limited) MOSFETs RDS(ON) 1,6mΩ MOSFETs VDS 60V Input Signals DC Link Voltage 18V Ground GND Gate drive signals for high side MOSFET x 3 (UT, VT, WT) Applied voltage 12V to U, V, W Gate drive signals for low side MOSFET x 3 (UB,VB,WB) Applied voltage 12V to COM Output Signals Positive shunt voltage (COM) 499mV / 1A supplying operational amplifier Current protection (ITRIP) 248mV / 1A supplying driver protection input Phases U, V, W Table 4.2: Description of the Two Level Three Phase Inverter Circuitry 17 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 4.2.1 Current Measurement Figure 4.3: Current Measurements Operational amplifier is adapting and shifting the current signal in a range of MCU analog to digital channel. The signal´s offset is increased in order to measure negative current as well. The offset is corrected in MCU by subtracting the transformed value for . This is done using parameter “Adc.Offset”. Name Remark Parameters Operational amplifier (MPC6002) Input Signals Positive shunt voltage (COM) 499mV / 1A supplying operational amplifier Ground GND 5V power supply Output Signals Output voltage (U_I) This voltage is supplied to ADC MCU input Table 4.3: Shunt Current Measurements 18 Evaluation Board Application Note 300W Motor Control Application Kit 4.3 XC836M and MOSFETs Driver 6ED003L02 Figure 4.4: XC836 and MOSFET Driver 6ED003L02 19 Application Note AN 2013-09 V1.1 September 2013 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 4.3.1 Driver 6ED003L02 The gate driver (6ED003L02-F) is a two level three phase inverter driver to control power devices such as MOSFETs. The main features of this device are: Thin-film-SOI-technology Insensitivity of the bridge output to negative voltages up to -50V given by SOI-technology Maximum blocking voltage +180V Power supply of the high side drivers via boot strap CMOS and LSTTL compatible input (negative logic) Signal interlocking of every phase to prevent cross-conduction Detection of over-current and under-voltage supply 'Shut down' of all switches during error conditions Externally programmable delay for fault clear after over current detection Name Remark Parameters ITRIP shut down threshold 0.46V ITRIP input low pass corner frequency fc 3.386 MHz Input Signals Power supply logic VCC 12V supplying driver and MOSFETs gate Ground GND Driver enable (active high) 5V/0V supplied by MCU 6 control signals for low and high side switch 5V/0V supplied by MCU Current protection (ITRIP) 248mV / 1A supplied by two level three phase inverter Output Signals Gate drive signals for high side MOSFETs x 3 (UT, WT, VT) 12V to U, V, W Gate drive signals for low side MOSFETs x 3 (UB, WB, VB) 12V to COM Inverter fault output (/CTRAP) (active low) 5V / 0V Table 4.4: Description of Driver Section 20 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 4.3.2 Microcontroller XC836M The Demoboard is controlled by 8-bit Infineon microcontroller XC836M. The XC83x-Series makes the entry level for Infineon’s 8-bit microcontroller family XC800 with real-time-control capabilities. The vector computer co-processor (MDU + CORDIC) boosts up standard 8-bit processing performance and supports field oriented motor control at 8-bit cost. This enables more efficient and intelligent designs for motor control (e.g. sensorless motors). Name Remark Parameters XC836M system clock frequency (fSYS) Internal oscillator runs with 48 MHz important for instruction execution time. Typical instruction is 2/f SYS = 20,8ns. Input Signals Voltage supply 5V 5V DC Ground (GND) 0V MOSFETs driver error signal (/CTRAP) Digital input 0V or 5V supplied by MOSFETs driver circuitry DC link voltage cense (U1-1) Analog input from 0V to 5V supplied by power supply circuitry DC link current cense (U_I) Analog input from 0V to 5V supplied by 2 level 3 phase inverter circuitry Analog input from 0V to 5V supplied by temperature protection circuitry Temperature sense (Temp) Potentiometer input (SPIN) Analog input from 0V to 5V supplied by speed control circuitry Digital input (BMI3) Digital input 0V or 5V supplied by digital inputs circuitry Digital input (BMI2) Digital input 0V or 5V supplied by digital inputs circuitry Hall sensor signals inputs (HALL A,B,C) Digital inputs 0V or 5V supplied by hall circuitry Output Signals Driver Enable Signal (active high) Enabling/disabling MOSFET driver Driver control signals (COUT6x and CC6x) Inputs to MOSFET driver Digital outputs (Mout1,2) To digital output circuitry LED digital output (LED) Communication Receive Input (RXD) From Communication Port Transmit Output (TXD) To Communication Port Table 4.5: Description of XC836 Circuitry 21 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 4.4 V1.1 September 2013 Digital Outputs Figure 4.5: Digital Outputs Name Remark Input Signals Digital outputs (Mout1,2) 0V/5V supplied from MCU Ground (GND) Output Signals Digital outputs (OUT1,2) Optional Output (like LED Control Light) Ground (GND) Table 4.6: Digital Outputs 22 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 4.5 V1.1 September 2013 Hall Sensors Digital Inputs Figure 4.6: Hall Sensor Inputs Name Remark Input Signals Hall sensor inputs (PIN 1,2,3) 0V/5V 5V power supply Ground (GND) Output Signals Hall sensor outputs (HALL A,B,C) 0V/5V supplied to MCU Table 4.7: Hall Sensor Inputs 4.6 Communication Port Figure 4.7: Communication Port Pin Num. Name 4 Transmit Output (RTS) 3 Receive Input (RXD) 1 Ground (GND) Table 4.8: Description of Communication Port 23 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 5 PCB 5.1 Schematic 1 2 3 V1.1 September 2013 4 5 6 7 8 2 +18V LM7812 U2 CD1 100UF/35V C1 100nF U1 LM7805CT +12V 3 Out 1 +5V Vin 3 +5V UT R1 R4 Q1 Q2 BSC016N06NS BSC016N06NS 1 C2 CD2 100nF 220uF/25V A C3 + 100nF CD3 470UF/16V VT 10 R7 10K Q3 Q4 BSC016N06NS BSC016N06NS R2 R5 Q5 Q6 BSC016N06NS BSC016N06NS R3 WT R6 10 3 10 GND + Vin 2 1 GND 2 M7 + CD5 1000UF/35V 2 D1 1 +18V 10 10 R8 10K 10 R9 10K U V A W C4 22nF/630V GND 18V->12V->5V UB R10 R11 +18V 51K Q7 Q8 BSC016N06NS BSC016N06NS R13 R16 10 R19 U1-1 VB R17 10K +18V 10K R23 5mR GND GND 2 1 C6 10nF Power Stage 10K Q13 W V U R24 ITRIP Battery Voltage Tset V V Q15 10K U U 10K Q14 120R W W GND OUT1 R63 1 1K R75 R69 Mout1 1K C29 100nF Temp B Q16 28050 Temp 10K 3 R74 10K P1 10 COM R22 120R B R18 10 R21 10K C5 100nF R12 10K GND +5V Q11 Q12 BSC016N06NS BSC016N06NS R15 WB 10 1K +18V Power IN Q9 Q10 BSC016N06NS BSC016N06NS R14 10 R20 10 R72 10K 10UF/50V OUT1 OUT2 3 2 1 GND U3 DATA-OUT OUT2 R64 R39 1K MI 10K 1 R37 10K 2 1 C10 100nF R70 Mout2 1K 3 Header 2 Q17 28050 C +5V R73 10K Program Control GND U1-1 1 Temp 2 U_I 3 SPIN 4 CTRAP 5 BM3 6 BM2 7 BM1 8 DR_EN9 MI 10 CLK 11 C11 100nF Output Control 12 13 14 AN7/P2.7 AN6/P2.6 AN5/P2.5 AN4/P2.4 AN3/P2.3 AN2/P2.2/CCPOS2_1 AN1/P2.1/CCPOS1_1 AN0/P2.0/CCPOS0_1 P0.6 P0.5 P0.4 VDDP P1.3/CC61 P1.2/COUT61 P0.7/TXD P3.2/SPD_0/RXD P3.0 P3.1 P0.3 P0.2/CCPOS0_2 P0.1/CCPOS0_1 P0.0/CCPOS0_0 P1.5/CC62 P1.4/COUT62 VDDC VSSP P1.0/COUT60 P1.1/CC60 28 27 26 25 24 23 22 21 20 19 18 17 16 15 RXD TXD Mout1 Mout2 LED R34 HALL-C HALL-B HALL-A C7 100nF 1K LED LED1 R28 10K R29 10K R30 10K R31 10K R32 10K 470R !VT R36 2 3 4 5 6 7 470R !WT R38 C8 470R !UB R40 100nF +5V R41 470R XC836-2FRI GND JP2 100nF R52 3 2 1 5 4 3 2 1 SPIN 20K C16 10nF SP_IN HALL_IN GND Speed Control D JP3 TXD R68 RXD R71 4 3 2 1 +5V 1K 1K 470R R60 10K C12 BM3 BM2 BM1 1 2 9 100nF 1OUT 1IN1IN+ GND Current Measurement C23 100nF VCC 2OUT 2IN2IN+ R48 MCP6002 8 7 6 5 U_I 100 R54 R55 22K 10K R58 R59 200K C19 100pF +12V 4 10 HO2 VS2 ITRIP 23 22 VT R50 V RCIN C18 10uF/50V HO3 VS3 LO1 COM 13 C25 100nF 20 EN C24 100nF VSS LO2 COM LO3 19 18 WT 16 UB 15 VB 14 WB R62 W 5R1 D Infineon Technologies Austria AG Siemensstr. 2 9500 Villach Austria Power Tool Kit Sheet: Date: File: Figure 5.1: Schematic C 24 Mosfet Driver COM +5V 5 24 U 10K GND 3 FLT VB3 C17 100nF R61 220K +5V U5 1 2 3 4 DATA-IN X-IN R42 5R1 EN ITRIP +12V 12 C28 C26 C27 100nF100nF100nF C9 10uF/50V 27 26 1K R57 DR_EN GND Program 8 11 GND R65 R66 1K R67 1K 1K +5V HO1 VS1 C13 10uF/50V R49 CTRAP HALL-A HALL-B HALL-C P3 5 4 3 2 1 28 R44 10K 10nF 10nF 10nF C20 C21 C22 HALL Input VB1 VB2 MCU R51 R53 1K R56 1K 1K HIN1 HIN2 HIN3 LIN1 LIN2 LIN3 5R1 R45 R46 R47 1K1K1K 100nF VCC +5V C14 JP1 27R R27 !VB !WB R43 +5V HALL C15 27R R26 D4 RS1M 27R RS1M U4 6ED003L02-F 1 470R !UT R35 470R +5V R33 10K R25 D3 RS1M +5V +5V P2 D2 +12V + P4 Temperature Protection UT CD4 GND 6 1 of 1 Drawn By: RW 5/23/2013 Revision: 1.1 300W_Demo_IFX_1.SchDoc 7 8 Evaluation Board Application Note 300W Motor Control Application Kit 5.2 Placement Figure 5.2: Placement 25 Application Note AN 2013-09 V1.1 September 2013 Evaluation Board Application Note 300W Motor Control Application Kit 5.3 Bill of Material Table 5.1: Bill of Material 26 Application Note AN 2013-09 V1.1 September 2013 Evaluation Board Application Note 300W Motor Control Application Kit 6 Microprocessor Software Description 6.1 Overview Application Note AN 2013-09 V1.1 September 2013 Motor control software task is to get information or commands from user and control the motor according to them. The core of the software is motor control algorithm calculating duty cycle according to different control schemes. Fast motor control respond is obtained by reading analogue values like DC link current, voltage, etc. using A/D converter and calculating duty cycle calculation every second PWM period. Before running motor control algorithm, there is a sequence of operations that ensure safe motor start/stop (control parameters initialization, charging bootstrap capacitors, switching patterns configuration …). This sequence is controlled by the scheduler. User can control software behavior using serial communication. Above described software function are distributed among different MCU events and main loop according to their priority of execution: Main function is the start up function initializing all the peripheral, activating other units and jumping into never endless loop with the lowest priority (Can be overrun by any other unit). Scheduler is split between main loop and timer T1 event because there are some parts of it that require higher priority. This event is triggered every 1ms. Serial communication has its own event which is triggered when the message is received. Sending messages is done in main loop periodically. Motor control algorithm is linked to timer T12 event (part of CCU6) executing it periodically every second PWM period. 27 Evaluation Board Application Note 300W Motor Control Application Kit Figure 6.1: MCU Software Flow Chart 28 Application Note AN 2013-09 V1.1 September 2013 Evaluation Board Application Note 300W Motor Control Application Kit Application Note AN 2013-09 V1.1 September 2013 Table 6.1 represents a description of events and its priority starting from 1 as the highest priority. High priority tasks can interrupt low priority tasks. Tasks with the same priority have to wait for the first one started to be finished. Priority MCU unit, event, trigger Description Capture/Compare Unit 6 - Timer nd T12, Period Match Event, every 2 PWM period 1 2 Timer T1, Period Match Event, every 1ms 2 UART, Message received event Lowest Main function, Main Loop The CCU6 unit is made up of a Timer T12 Block with three compare channels and a Timer T13 Block. The T12 channels can jointly generate control signal patterns to drive AC-motors or inverters. T13 is used for current measurement synchronized with T12, its duty cycle and A/D converter in order to sense the current in the right moment. T12 event is executed every two PWM periods and is used to execute motor control algorithm and consequently to obtain and set T12 duty cycles for each compare channel. This timer is set to trigger event every 1 ms. Within this event high priority scheduler part of algorithm is executed. This event is triggered by a received message from PC using serial communication. Main loop is a never endless loop that is running only when the other events are not running. Within this loop several tasks are executed: Sending messages to PC using serial communication. Low priority scheduler. Write parameters to MCU permanent memory (FLASH). Other Table 6.1: MCU Software Events Priority Description 6.2 Motor Control Algorithm The 300W Motor Control Application Kit was designed to run Brushless DC Motors (BLDCM). When rotating, BLDCM induces trapezoidal voltage waveform. Therefore a modulation is needed, which creates a square voltage waveform. This is called Block Commutation Control. 6.2.1 Unipolar Block Commutation The trapezoidal commutation method is the simplest way to control BLDC motors and easy to implement the control aspects of it. For proper commutation and for motor rotation, the rotor position information is very crucial. Only with the help of rotor position information, the electronic switches in the inverter bridge will be switched correctly to ensure proper direction of current flow in respective coils. Three hall sensors are used in general as position sensor. Each hall sensor is typically placed 120° apart and senses the position of the rotor field. Position information is needed to keep the angle between the rotor and stator magnetic field between 60° and 120° in order to get the maximum torque. 29 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 [+Vv,-Vw] HC HC 2 [+Vu,-Vw] Ro to rF ie ld Vv [-Vu,+Vv] 1 is Vu Ls HC0 HC3 α Rs E VDC/2 St ato rF iel d [+Vu,-Vv] Vw [-Vu,+Vw] HC HC 4 5 [-Vv.+Vw] Figure 6.2: BLDC Motor Vector Diagram and phase circuit The Inverter can switch among six different voltage vectors. Stator magnetic field is proportional to stator current. The current is the consequence of the difference between DC and BEMF voltage (1). (1) (2) Rotor field is produced by permanent magnets. Stator field is attracting rotor field with torque defined by stator field magnitude and the angle between them (3), therefore the rotor will move toward stator field. (3) Hall combination (HC1) is triggering the right voltage vector (+Vu,-Vu) in order to achieve maximum torque possible. When angle between rotor and stator field is reduced to 60° and hall combination change to (HC0), the successive stator voltage vector (-Vv,+Vw) is activated and the angle is again 120°. This is called commutation because the current is commutating from one phase to another. 30 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit +Vu , -Vv T1 T3 D3 T5 D5 VDC Ru T2 Rv + T4 D4 T6 Ru Lw D6 Rv Lu Lv D3 T5 D5 T2 D2 T4 D4 T6 D6 Rw Lw - - Lv D2 Rw + - Lu D6 Ru Lu - T6 T3 Rv Lv - D4 + T4 + D2 D1 VDC + Rw Lw + + + + + + + + + Eu Ev Ew Eu Ev Ew Eu Ev Ew - - - - - - - - Figure 6.3: BLDC motor current commutation Commutation table defines the right relationship between hall combinations (HCx) and voltage vectors (V1, V2) for both rotation directions. Hall Combination HC0 Voltage vector for different rotation direction CCW CW +Vv , -Vw -Vv , +Vw HC1 +Vv , -Vu -Vv , +Vu HC2 +Vw , -Vu -Vw , +Vu HC3 +Vw , -Vv -Vw , +Vv HC4 +Vu , -Vv -Vu , +Vv HC5 +Vu , -Vw -Vu , +Vw Table 6.2: BLDC motor commutation table 31 - T2 T1 + VDC D1 - D5 - T5 - D3 + T3 +Vu , -Vw + D1 Commutation + T1 V1.1 September 2013 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 0° 60° 120° V1.1 September 2013 180° 240° 330° 360° IGBTs status Q1 Q2 Q3 Q4 Q5 Q6 Phase currents Phase voltages VU U EU VV V EV VW EW W IU IV IW HC0 HC1 HC2 HC3 HC4 HC5 Figure 6.4: BLDC motor switching pattern BLDC motor static characteristic is obtained combining equations (1), (2) and (3). Current transient (di/dt) and torque fluctuation sin ∝ are neglected. (4) Motor speed is a function of phase voltage and load torque. By increasing the voltage also speed will increase. Voltage control is done using PWM technique by changing duty cycle. PWM is applied only on one high side switch per time for 120°. Low side switch is switched ON for 120° too but without using PWM. This is calling unipolar switching. 32 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit High Side Switch ON T1 D1 T3 D3 T5 V1.1 September 2013 High Side Switch OFF D5 D1 T3 D3 T5 D5 T2 D2 T4 D4 T6 D6 VDC D4 T6 Ru Rv Rw Ru - + Lw Lu Lv + Ew Eu Ev - + Ev + Eu Rw Lw - Lv Rv - Lu D6 + T4 + D2 + T2 - VDC T1 Ew + - Figure 6.5: BLDC motor unipolar switching As mentioned before the main control parameter is the duty cycle. This can be calculated selecting from three available motor control techniques (Figure 6.7). 1. Voltage control – phase voltage can be changed from 0% to 100% (VDC/2). 2. Speed regulation – phase voltage is regulated using PI controller. Input parameter is reference speed. 3. Current (Torque) regulation – phase voltage is regulated using PI controller. Input parameter is reference current. The single shunt current measurement must be done when high side switch is OFF (Figure 6.5). This is the moment when the current is flowing through the shunt back into the power source. Therefore A/D converter must be synchronized with PWM and its duty cycle as visible on (Figure 6.6). T13 duty cycle is equal PWM period value (T12PER) and T13 period value is three times PWM period. Those values will assure that the current is sensed on right moment. 33 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 1st current sensing OFF ON 2nd current sensing T12 and duty cycle Period Match Event V1.1 September 2013 ON T13 and duty cycle OFF T12PER 3*T12PER Figure 6.6: BLDC motor current measurement using a single shunt 34 OFF Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit V1.1 September 2013 1. Voltage Control VREF Control Techniques Selector VREF PI Controler 2. Speed Regulation fREF εf + - VREF_I KI VREF + + KI_LIMIT Z-1 KP fACT VREF_P PI Controler 3. Current Regulation εI IREF + - VREF_I KI VREF + + KI_LIMIT Z-1 KP VREF_P Duty Cycle IACT fACT Current Calcul. Duty Cycle BLDCM Commutation Table 3 phase inverter Speed Calculation Hall Combination Figure 6.7: BLDC motor block commutation control techniques 35 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 6.3 V1.1 September 2013 Scheduler There are some procedures that must be run before the main motor control algorithm is started. Those procedures ensure safe motor start up conditions. Scheduler is controlling procedures to be executed one after another sequentially. The Scheduler is split in two parts: high and low priority. High priority scheduler is linked to a timer executing every 1ms. Low priority scheduler is linked to main loop executing when no other task is running. High priority scheduler is taking care of parameters and MCU register initialization, bootstrap capacitor charging and speed ramp generation. Low priority scheduler is controlling start/stop of the motor. 6.4 Serial Communication Protocol UART settings are: 192000 Baud rate 8-bit data 1 start bit 1 stop bi Communication protocol is a set of communication rules applied to serial communication messages. Each message is made out of 9 bytes. The last byte is a check sum of first 8 bytes. There are two different message types: Message with fixed parameters: Certain parameters are mapped to byte 1 - 7. This mapping is fixed and depends on byte 0 value. This message is sent both directions. MCU sent it periodically every 10ms. It can be also sent by user to MCU in order to control the motor real time. Byte 0 Byte 1 <b7-b4> <b3-b0> <b7-b0> 2 0xE Byte 2 Byte 3 Byte 4 Byte 5 Byte 6 Byte 7 Byte 8 <b7-b0> <b15-b8> <b7-b0> <b15-b8> <b7-b0> <b15-b8> <b7-b0> ACM Software VDC 4 Mode fREF fACT SVM Angle 6 State IREF IACT VACT 8 Control Bits 10 Status Bits PWM period Check Sum BLDCM Software 2 0xE Temperature Potentiometer VDC 4 Mode fREF fACT Hall Combination 6 State IREF IACT VACT 8 Control Bits Hall Index 10 Status Bits Table 6.3: Serial message with fixed parameters, MCU to PC 36 Check Sum Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit Byte 0 Byte 1 <b7-b4> <b3-b0> <b7-b0> 0 Mode 2 0xE Byte 2 Byte 3 V1.1 September 2013 Byte 4 Byte 5 Byte 6 Byte 7 <b7-b0> <b15-b8> <b7-b0> <b15-b8> Control Bits Set fREF 4 IREF 6 VREF Byte 8 <b7-b0> Control Bits Clear Check Sum Table 6.4: Serial message with fixed parameters, PC to MCU Message with indexed parameters: Parameters that can be saved into FLASH are indexed and are reachable by setting the correct index in bytes 2-3. Value can be read/write by setting or reading byte 4-5. Byte 0 Byte 1 <b7-b4> <b3> <b2> <b1-b0> 0 = byte 1 = word 1 0 = read 1 = write 0xF Byte 2 Byte 3 Byte 4 Byte 5 <b7-b0> <b15-b8> <b7-b0> <b15-b8> Index (if byte) Value Table 6.5: Serial message with indexed parameters, PC to MCU 37 (if word) Value Byte 6 Byte 7 Byte 8 <b7-b0> Check Sum Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit 6.5 V1.1 September 2013 Parameters Parameters are values that influence motor and its control behavior. There are two types of parameters: permanent and variable parameters. Permanent parameters are saved in a permanent MCU memory (FLASH). Each of them is identified and reachable by its index using communication message (Error! Reference source not found.). Variable parameters reflect the current state of the motor control or it can be controlled by them using communication message (Table 6.3). MCU receives recalculated parameter by Infineon PC user interface according to coefficient K in Table 6.7 and equation (5). (5) Length Min Max K Byte Mode Name [Unit] 0 4 1 Operational mode Description Byte Status 0 255 1 Status of the operational mode Byte Command Bits 0 255 1 Commands sent to MCU in order to activate some functionality Byte Status Bits 0 255 1 Statuses of the program that is running Word fREF [Hz] -300 300 10 Reference current frequency Word fACT [Hz] -300 300 10 Actual current frequency Word IACT [A] 0 2 Actual DC link current Word IREF [A] 0 2 Reference DC link current Word VREF [%] 0 100 Word Hall Sensors 0 5 Word VDC [V] 0 420 327.67 Reference DC phase voltage or duty cycle 1 Hall sensors combination DC link voltage Table 6.6: Variable parameters 38 Application Note AN 2013-09 Evaluation Board Application Note 300W Motor Control Application Kit Index Length Group.Name [Unit] Def. Min V1.1 September 2013 Max K Description Fine tuning of shunt current sensing moment. Switching frequency 0 Byte Pwm.SwitchDelay [x21ns] 63 -128 127 1 1 Byte Pwm.Frequency [kHz] 15 5 25 1 2 Byte Pwm.DeadTime [x21ns] 20 10 255 1 Dead time between half bridge devices 3 Word I.Kp 0 0 32767 1 Proportional part of PI controller for current control loop 4 Word I.Ki 10 0 32767 1 7 Byte I.Ki_Limit [%] 100 0 100 1.27 8 Word Freq.Max [Hz] 300 0 300 10 10 Word Freq.Slew [Hz/s] 4 0.1 100 10 12 Word FreqI.Kp 0 0 32767 1 14 Word FreqI.Ki 5 0 32767 1 16 Byte FreqI.Ki_Limit [%] 100 0 100 1.27 17 Word FreqV.Kp 0 0 32767 1 19 Word FreqV.Ki 5 0 32767 1 21 Byte FreqV.Ki_Limit [%] 100 0 100 1.27 22 Byte Adc.Offset [x 21ns] 62 -128 127 1 Tuning the zero of current sensing 23 Word Adc.TmotorMax 32767 0 65535 1 Maximum motor temperature before the motor switch off 25 26 Byte Byte Sys.Commands Sys.Modes 0 2 0 0 255 4 1 1 Startup values of the commands Startup mode Table 6.7: Permanent parameters saved or can be saved to Flash 39 Integral part of PI controller for current control loop Integral part limit of PI controller for current control loop Absolute aloud maximum frequency Ramp for the frequency when increasing or decreasing Proportional part of PI controller for speed control loop which output is reference current Integral part of PI controller for speed control loop which output is reference current Integral part limit of PI controller for speed control loop which output is reference current Proportional part of PI controller for speed control loop which output is duty cycle Integral part of PI controller for speed control loop which output is duty cycle Integral part limit of PI controller for speed control loop which output is duty cycle