Home

FM3 family inverter reference Firmware USER MANUAL

image

Contents

1. RETURN Valid value is TRUE FALSE ii BOOL ReadDTIF INT8U WhichMFT 40 Ge AAN7O6 00043 1v0 E Driver for A D converter FUNCTION Enable or disable output convert ADC start signal when O detected INT comes PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFTRCh Which FRT channel to configure Valid value is ERT CHO ERT CH0 ERT CHO WhichADC Start signal send to which ADC unit Valid value is ADC_UNITO ADC_UNITI ADC_UNIT2 En Enable or not valid value is TRUE FALSE RETURN none void ConfADCTriggerFromFRTx INT8U WhichMFT INT8U WhichFTRCh INT8U WhichADC INT8U En iif FUNCTION Allocate channel to each ADC unit PARAMETERS ChSet Which channels will allocate to ADC unit Every set bit in pChSet means to allocate a channel to ADC unit For example bit0 1 means allocate channel 0 to ADC unit bit3 1 means allocate channel 3 to ADC unit bit0 15 means allocate channel5 0 to ADC unit WhichADC Allocate channel to which ADC unit Valid value is ADC_UNITO ADC UNTTI1 ADC_UNIT2 RETURN none void ConfADCChToUnit INT32U ChSet INT8U WhichADC e e FUNCTION Check scan conversion is finished or not PARAMETERS WhichADC Which ADC unit to
2. es FUNCTION To start ADC PARAMETERS none RETURN none void StartMacro ADC void e if FUNCTION To stop ADC PARAMETERS none RETURN none void StopMacro ADC void FUNCTION To start macros include 1 ADC 2 OC 3 FRT 4 DualTimer 56 AN706 00043 1v0 E AN706 00043 1v0 E PARAMETERS WhichMFT The motor controlled by this MFT will be stopped Valid value is MFTO MEI RETURN none void StartMacros MCL INT8U WhichMFT L FUNCTION To stop macros include ADC OC FRT DualTimer PARAMETERS WhichMFT The motor controlled by this MFT will be stopped Valid value is MFTO MEI RETURN none void StopMacros MCL INT8U WhichMFT 57 AAN7O6 00043 1v0 E 5 4 2 Functions in MotorCtrl Folder These functions are in the folder of MCL source Application MotorCtrl FUNCTION Initialization Do the following jobs 1 initialize some global parameters 2 initialize NVIC 3 initialize clock 4 initialize WDT 5 initialize MFT 6 initialize ADC 7 initialize other global variables according to the user given value PARAMETERS none RETURN 1
3. 3 MCL Architecture Introduction MCL includes 2 root folders MCL head and MCL source Each of the root folders is divided into 4 parts _Global Driver Algorithm and Application as shown in Figure 1 In head folder there is a header file named HeadInOne_MCL h It includes all MCL header files If users want to call functions in MCL this file should be included in main c isis lArminverterPlatform Debug E Global E Algorithm Gm Code Application L MCL gt head Driver gt source L F HeadinOne_MCL h AO Source LoG Application La G MotorCtrl IO Paralnterface_MCL c E User C Output Figure 1 file structure in head and source folder User Source folder is used to hold all source files c files and head folder is used to hold all header files h files Source files are a place to hold functions and header files are a place to do the following jobs e macros definition e data types definition e global variables definition e function declaration The Qn n 15 format is wildly used In MCL Many data are shown as Q15 format in the debug window The relationship between Q15 value and real value is as follows Q15 value real value x 32768 AAN7O6 00043 1v0 E 4 Data Structure Introduction All data structure in MCL is not included here only some important ones are listed Name Description _stWarningCode Save warning messag
4. FUJITSU AN706 00043 1v0 E E NIS 32 BIT MICROCONTROLLER MB9B100A MB9B300A MB9B400A MB9B500A Series FM3 family inverter reference Firmware USER MANUAL TM ARI ARM and Cortex M3 are the trademarks of ARM Limited in the EU and other countries AAN7O6 00043 1V0 E All Rights Reserved The contents of this document are subject to change without notice Customers are advised to consult with FUJITSU sales representatives before ordering The information such as descriptions of function and application circuit examples in this document are presented solely for the purpose of reference to show examples of operations and uses of Fujitsu semiconductor device Fujitsu does not warrant proper operation of the device with respect to use based on such information When you develop equipment incorporating the device based on such information you must assume any responsibility arising out of such use of the information Fujitsu assumes no liability for any damages whatsoever arising out of the use of the information Any information in this document including descriptions of function and schematic diagrams shall not be construed as license of the use or exercise of any intellectual property right such as patent right or copyright or any other right of Fujitsu or any third party or does Fujitsu warrant non infringement of any third party s intellectual property right or other right by using such information Fujitsu assumes no liab
5. the place to hold basic inverter control functions Application layer the place to hold application functions e MCL offers 2 ways to access on chip registers One is macro definitions which can access registers in a high speed The other is function which can make the coding easy to maintain The user can choose one of them according to the requirement In addition you also can use these two ways at the same time to access registers e MCL includes a user interface to facilitate user s initialization to on chip macros and configuration of system parameters e MCL includes exception checking function to judge automatically whether the user parameters and function parameters are suitable or not e Other editor supporting For example Eclipse Netbeans Codeblocks etc MCL can eliminate these editor errors and warning prompting 2 3 Peripheral Occupation MCL occupies some peripherals Please refer Table 1 as follows Table 1 MCL peripherals occupation Peripheral Amount Details Dual Timer MCL always uses Dual Timer ch2 MFT 1 User can select and configure among FRTs on the chip User can select and configure among ADC channels on the chip 4 channels ane This is In the case of without PFC function User can select and configure among ADC channels on the chip 8 channels SC This is In the case of with PFC function UART 1 MCL always uses UART ch6 AAN7O6 00043 1v0 E
6. WhichWFGxx Which WFGxx to configure Valid value is WFG_CH10 WFG CHS4 Mode Division value Valid value range is MODE THROUGH MODE RT DEADTIMER amp MODE PPG DEADTIMER GateOutput What signal output from gate Valid value is GATE OUTPUTO GATE _OUTPUT3 DESCRIPTION This function configure WFG channel by pairs 36 AN706 00043 1v0 E WEG CHO WFG CH1 WFG CH2 WFG CH3 WFG CHA WFG CH54 Mode description EE EE MODE THROUGH O Initial value MODE RT PPG 1 MODE TIME PPG 2 MODE RT DEAD TIMER MODE PPG DEAD TIMER RETURN none void ConfWorkModeForWFGxx INT8U WhichMFT INT8U WhichWFGxx INT8U Mode INT8U GateOutput FUNCTION Configure non overlapped output signal polarity for WFGxx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichWFGxx Which WFGxx to configure Valid value is WFG_CH10 WEG CHS4 Polarity Non overlapped output signal polarity Valid value is POLARITY HIGH POLARITY LOW DESCRIPTION This function configure WFG channel by pairs EG CHO WEG CH1 WEG CH2 WEG CH3 WEG CH4 WEG CH54 RETURN none void ConfPolarityForWFGxx INT8U WhichMFT INT8U WhichWFGxx INT8U Polarity
7. b i De HG al emale WYSE RS e i Messages Paralnterface_MCL c main c startup c Linking ArminverterPlatform out Total number of errors 0 Total number of warnings 0 s fi Si Build Debug Log z x Errors 0 Warnings 0 Figure 11 MCL is correctly compiled 81 AAN7O6 00043 1v0 E 6 If you meet some errors or warnings when rebuilding please assure the following configuration in EWARM Options for node AralnverterPlatform Category General Options C C Compiler Assembler Output Converter Target Output Library Configuration Library Options MI Custom Build Build Actions Linker O Core Cortex M3 r O Devic KI Angel GDB Server IAR ROM monitor Endian mode JLinkf3 Trace Little TI Stellaris FTDI Macraigor PE micro RDI ST LINK Third Party Driver Processor variant Figure 12 Target device selection MB9BF506x Options for node ArmlInverterPlatform General Options C Multi file Compilation CiC Compiler Discard Unused Publics Assembler S EE EEN Output Converter Language 1 Language 2 Code Optimizations Qutput Lis P S Level Enabled Fins cones FlConnon subexpression eliminati Debugger CH Low E Loop unrolling Simulator O Medium Function inlining Angel O High Eco de motion GDB Server P ElTspe b d alias analysis IAR ROM monitor Est atic clustering J Link J Trace
8. 44 AN706 00043 1v0 E PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC UNTTI1 ADC_UNIT2 RETURN none void StartScanConv INT8U WhichADC L FUNCTION Configure FIFO stage When A D conversion data for the FIFO stage count set is written the interrupt request flag SCIF is set to 1 PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC UNTTI1 ADC_UNIT2 Stage Valid range is ADC SCAN CONV_STAGE1 ADC SCAN CONV_STAGE16 RETURN none void ConfFIFOStageForScanConv INT8U WhichADC INT8U Stage FUNCTION Configure FIFO stage When A D conversion data for the FIFO stage count set is written the interrupt request flag SCIF is set to 1 PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC UNTTI1 ADC_UNIT2 RETURN 31 means no valid data can be read out from ADC FIFO else means a valid data read out from ADC FIFO INT32U ReadSingleData_ScanConv INT8U WhichADC e FUNCTION Select sampling time for an ADC channel PARAMETERS WhichADC Which ADC unit to be configured Valid value is ADC_UNITO ADC UNTTI1 ADC_UNIT2 WhichADCCh Which ADC channel to be configured Valid value is ADC_UNI
9. PI PI regulator quantities can be seen as follows Name Description Pl_W2lqref PI regulator for speed loop PI Idref2Vd PI regulator for d axis current Pl Igref2Vq PI regulator for q axis current Expand gstMotorRunCtrl Output some output can be seen as follows Name Description CurrentReflnRotAxis The current reference value in rotational coordinate VoltagelnRotAxis The voltage value in rotational coordinate VoltagelnFixAxis The voltage value in fixed coordinate 92 AAN7O6 00043 1v0 E Expand gstMotorRunCtrl gt ObsForPLL some result come from motor control algorithm can be seen as follows Name Description InfoOfSmplCurr Information relative to current sampling CurrentinRotAxis Current information in rotational coordinate VoltagelnFixAxis Voltage information in fixed coordinate BEMFInFixAxis BEMF information in fixed coordinate Wm_Q15 Mechanical speed unit is Hz Q15 format Theta_Q15 Rotor position unit is degree Q15 format 9 2 5 Debug with GUI GUI can get data from MCU and it can show data as waveforms r values on PC The advantage of using GUI the users can see some of data which cannot measure directly by oscilloscope For example motor speed BEMF etc These data may do help for users to debug system We have supported many quantities in MCL please refer to the software user manua
10. TI Stellaris FTDI Macraigor PE micro RDI ST LINK Third Party Driver ET OK Cancel Figure 13 Optimization level None 82 AAN7O6 00043 1v0 E Options for node AralnverterPlatfora Category Factory Settings General Options C Multi file Compilation Discard Unused Publics Assembler Output Converter Optimizations l Output List Preprocessor Diagnostics T Custom Build l l Build Actions Cl Ignore standard include direc Linker Additional include directories one per line Simulator Angel GDB Server IAR ROM monitor Preinclude Linkf3 Trace TI Stellaris FTDI Defined symbols one per Macraigor PE micro EDITOR T R EWARM Fi Preprocessor output to RDI re ve comments ST LINK rate line directive Third Party Driver Figure 14 Preprocessor above path and symbol should be set Options for node AralnverterPlatforn Category Factory Settings General Options C Multi file Compilation Compiler Discard Unused Publics Assembler i po Output Converter Output List Preprocessor Diagnostics MISRA C 2004 h es C Enable remarks Build Actions S l Linker Suppress these diagnostics Debugger Pa082 Pe009 Simulator Treat these as remarks Angel GDB Server Treat these as warnings TAR ROM monitor J Link J Trace TI Stellaris FTDI
11. Which OC channel to configure Valid value range is OC CH0 OC_CH5 RETURN TRUE matching detected FALSE matching not detected 31 AAN7O6 00043 1v0 E INT8U ReadIntFlag OCCPMatchFRT INT8U WhichMFT INT8U WhichOCCh FUNCTION Clear match flag for OCx of OCCP matches FRT count PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichoCCh Which OC channel to configure Valid value range is 0C_CH0 OC_CH5 RETURN none void ClrIntFlag OCCPMatchFRT INT8U WhichMFT INT8U WhichOCCh FUNCTION Configure the initial output level for RTx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichoCCh Which OC channel to configure Valid value range is OC CH0 OC_CH5 Level initial output level valid value is LEVEL HIGH LEVEL LOW RETURN none void ConfInitOutputLevelForOCx INT8U WhichMFT INT8U WhichOCCh INT8U Level e e e FUNCTION Configure the timing when data in OCCP buffer send to OCCP for RTx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichOCCh Which OC channel to configure Valid value range is OC_CHO OC_CH5 When Timing of send buffer valid value is CNT TOP CNT
12. successful 1 failed INT8S AutoConfByMCL void FUNCTION To configure INT priority for NVIC PARAMETERS none RETURN none if void ConfNVIC void Ti FUNCTION To configure PLL clock and bus clock PARAMETERS none iif RETURN none void ConfClock void L FUNCTION To configure GPIO port PARAMETERS none 58 RETURN none void ConfGPIO void FUNCTION To configure WDT PARAMETERS none RETURN none FUNCTION To configure dual timer2 PARAMETERS none RETURN none FUNCTION To configure MCU parameters PARAMETERS none RETURN none FUNCTION To configure motor parameters PARAMETERS WhichMFT Which MFT valid value is MFTO RETURN none void ConfMotorPara INT8U WhichMFT 59 MFT1 AN706 00043 1v0 E FUNCTION To configure system parameters PARAMETERS WhichMFT Which MFT valid value is MFTO RETURN none void ConfSysPara INT8U WhichMFT FUNCTION To configure control parameters PARAMETERS WhichMFT Which MFT valid value is MFTO RETURN none void ConfCtrlPara INT8U WhichMFT e FUNC
13. AAN7O6 00043 1v0 E Options for node AralnverterPlatforn Category General Options C C Compiler Assembler Output Converter Custom Build Build Actions Linker o Simulator Angel GDB Server IAR ROM monitor J Link J Trace TI Stellaris FTDI Macraigor PE micro RDI ST LINK Third Party Driver Factory Settings Setup Download Images l Extra Options Plugins Driver J Link J Trace Setup macros Use macro file s PROJ DIR A 4 config FlashMB9BF50x mac IZ Run to d Ces k main evice description file VJOverride default PROJ DIR A 4 confighiomb9bf506 ddf Cancel Figure 18 macro file and device description file Flashmb9BF50x mac and iomb9bf506 ddf Options for node AralnverterPlatforn Category C C Compiler Assembler Output Converter Custom Build Build Actions Linker Simulator Angel GDB Server IAR ROM monitor J Link J Trace TI Stellaris FTDI Macraigor PE micro RDI ST LINK Third Party Driver General Options Factory Settings Setup Download Images Extra Options Plugins Cl attach to progr Verify download CI Suppress download Ml Use flash loader M Override default board file SPROJ_DIRS A confi g MB9BF506 board Figure 19 Flash download description file some switch and Mb9BF506 board 85 9 2 AAN7O6 00043
14. Check scan conversion FIFO is full or not PARAMETERS 43 AAN7O6 00043 1v0 E WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC_UNIT1 ADC UNIT2 if RETURN TRUE Scan conversion FIFO is full FALSE Scan conversion FIFO is not full Li BOOL CheckFIFOFullForScanConv INT8U WhichADC GI FUNCTION Check scan conversion FIFO is Overrun or not L PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC_UNIT1 ADC UNIT2 4 RETURN TRUE Scan conversion FIFO is Overrun FALSE Scan conversion FIFO is not Overrun L BOOL CheckFIFOOverrunForScanConv INT8U WhichADC FUNCTION Clear FIFO for scan conversion PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC_UNIT1 ADC UNIT2 RETURN none dele void ClrFIFOForScanConv INT8U WhichADC FUNCTION Enable or disable repeat when scan conversion is over run PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC _ UNITO ADC UNTTI1 ADC UNTT2 En Enable or disable if Valid value is TRUE FALSE RETURN none void ConfRepeatForScanConv INT8U WhichADC BOOL En FUNCTION Start or restart during conversion ADC scan conversion
15. I5R DefaultHandler dd External Interrupt Request ch 3 tc 15R DualTimer vd Dual Timer Quadrature Decoder Ur ISR DefaultHandler ff Reception Interrupt Request of MFE Figure 21 ISR in startup c If users want to use motor control algorithm in MCL please do not modify the entry name Users that do not use motor control algorithm in MCL should modify this entry to meet your require User interface functions are embedded in MCL ISR to meet some users who want to do something in MCL ISR The interface functions are in ISR_User c The user interface functions name are void DualTimer_User void void MFT_FRT_User void void ADC_Sampling_User INT8U WhichADC void MFT_WFG_User void 87 AAN7O6 00043 1v0 E Debug Files DG o ArminverterPlatform Debug lt EI MCL E ForExhibition h F HeadinOne User h ISR User h Ha G Source ic main c E startup c Figure 22 files of holding user interface in MCL ISR main c Paralnterface_MCL c include User Head HeadInOne_ User Hr ff Dual timer interrupt service for user C void DualTimer_User void d dd f f ERT interrupt service for user dd void MFT_FRT_User void dd FUNCTION vd ADC interrupt service for user ff vi PARAMETERS dd WhichADC Which ADC unit interrupt tf Valid value is ADC UNITO ADC UNITI ADC UNIT2 L vi RETURN ff none tf void ADC Sampling User INT8
16. INT8U WhichDualTimer FP32 ms 24 Ti AN706 00043 1v0 E Driver for free run timer in MFT FUNCTION Configure count mode for FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT_CHO ERT CH1 ERT CH2 Mode Count mode valid value is CNT MODE UP CNT MODE UPDOWN RETURN none void ConfCountModeForFRTx INT8U WhichMFT INT8U WhichFRTCh INT8U Mode FUNCTION Configure count cycle for FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT_CHO FRT_CH1 FRT CH2 ms count cycle ms valid range is from 0 001 to upper limit RETURN none void ConfCntCycleForFRTx INT8U WhichMFT INT8U WhichFRTCh FP32 ms e e FUNCTION Configure count cycle for FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is ERT CHO FRT CHI ERT CH2 RETURN CNT MODE UP or CNT MODE UPDOWN T T INT8U CheckCntModeForFRTx INT8U WhichMFT INT8U WhichFRTCh es FUNCTI
17. ee FUNCTION Configure WFG overflow period ms for WFGxx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichWFGxx Which WFGxx to configure Valid value is WFG_CH10 WFG CHS4 ms WFG overflow period ms valid range is from 0 001 to upper limit L DESCRIPTION This function configure WFG channel by pairs WEG CHO MG CH1 WFG CH2 WEG CH3 WFG CH4 WFG CH54 fit RETURN 37 AN706 00043 1v0 E none void ConfCntValForWFGxx INT8U WhichMFT INT8U WhichWFGxx FP32 ms Ti Ly Ge FUNCTION Configure non overlapped output signal polarity for WFGxx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 En Enable or not valid value is TRUE FALSE NoiseTime How long noise signal can be bear on DTTIX pin Valid value is DTTI_ NOISE TIMEO DTTI NOISE TIME4 DESCRIPTION DTTI NOISE TIMEO 0 PCLK APB1 bus clock DTTI NOISE TIME1 4 PCLK DTTI NOISE TIME2 8 PCLK DTTI NOISE TIME3 16 PCLK DTTI NOISE TIME4 32 PCLK RETURN none T void ConfIntForWFG DTTI INT8U WhichMFT BOOL En INT8U NoiseTime e e e FUNCTION Trigger a DTTI interrupt by software PARAMETERS WhichMFT Which MFT will be
18. 54 61 and Oxffff Oxffff means disable all IRQs RETURN none void DisIRQ INT32U NVIC_No FUNCTION Enable exception PARAMETERS Exception Which Exception to be controlled Valid value include 1 EXCEPTION USAGEFAULT 2 EXCEPTION BUSFAULT 3 EXCEPTION MEMFAULT LE RETURN none void EnException INT8U Exception FUNCTION Disable exception 11 Tf AN706 00043 1v0 E PARAMETERS Exception Which Exception to be controlled Valid value include 1 EXCEPTION USAGEFAULT 2 EXCEPTION BUSFAULT 3 EXCEPTION MEMFAULT RETURN none void DisException INT8U Exception LE FUNCTION Set IRQ PARAMETERS NVIC_No NVIC serial No corresponding to IRQ The valid value range is 16 51 54 61 RETURN none void SetIRQ INT32U NVIC_No FUNCTION Clear IRQ PARAMETERS NVIC_No NVIC serial No corresponding to IRQ The valid value range is NVIC_FCS NVIC_USB 2 NVIC_DMA CHO NVIC_DMA CH7 0xffff means clear all IRQs RETURN none void ClrIRQ INT32U NVIC_No FUNCTION Configure IRQ priority
19. BOTTOM CNT TOP Performs buffer transfer of the OCCP register upon Peak value detection by FRT CNT BOTTOM Performs buffer transfer of the OCCP register upon Peak value detection by FRT RETURN none void ConfTimingOfSendBufForOCx INT8U WhichMFT INT8U WhichOCCh INT8U When FUNCTION 32 void ConfWorkModeForOCChx INT8U WhichMFT INT8U WhichOCCh INT8U CMOD AN706 00043 1v0 E Configure work mode for RTx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichoCCh Which OC channel to configure Valid value range is LOC CH0 OC_CH5 CMODE S table below MOD see table below RETURN none D INT8U MOD Lik es e FUNCTION Configure OCCP value for RTx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichoCCh Which OC channel to configure Valid value range is OC CH0 OC CH5 ms Elapsed time from 0x0000 to the OCCP value which will be configured in this function unit is millisecond DESCRIPTION Below is the illustration TCCP OCCP ps Z 3 i ll RETURN none void ConfOccpValForOCChxA INT8U WhichMFT INT8U WhichOCCh FP32 ms if FUNCTION Configure OCCP value for RTx corres
20. In some cases FRT s Ld counter value is not initialized to 0x0000 even after FRT stops depending on the state of FRT s count clock Always write 0x0000 E TCDT afterwards to clear FRT s counter value to 0x0000 ez RETURN none void StopFRTx INT8U WhichMFT INT8U WhichFRTCh LE FUNCTION Enable or disable TCCP buffer for FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure valid value is CHO CH1 CH2 En Enable buffer or not valid value is TRUE FALSE RETURN 26 AAN7O6 00043 1v0 E none void ConfBufForFRTx INT8U WhichMFT INT8U WhichFRTCh BOOL En ff FUNCTION Configure division value for FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is ERT CHO ERT CHI ERT CH2 Div Division value Valid value range is FRT_DIVO FRT_DIV8 DESCRIPTION FRTs count clock APB1 bus clock 2 Div Div description L ERT DIVO 1 1 Initial value ERT DIVI 1 2 ERT DIV2 1 4 ERT DIV3 1 8 FRT_DIV4 1 16 FRT_DIVS 1 32 ERT DIV6 1 64 ERT DIV7 1 128 ERT DIV8 1 256 ATTENTION Only valid in 16 b
21. Motor Driving interface CtrlMotor is the motor driving interface After configuring the user parameters as shown in section 7 2 2 Call this function in main loop and it can trigger the motor control algorithm in MCL void main void 77 ff Initialize all in chip resources d F AutoConfByYMCL 1 if ff short the relay ay ShortRelay PORTZ PIN_1 TRUE 1500 ff main loop start from here FF FR KKK K TATA XXX X XXX XXX while TRUE FeedDog TRUE FALSE CtrlMotor MFTO Figure 4 Calling CtrlMotor to trigger motor control algorithm in MCL 74 AAN7O6 00043 1v0 E 8 User Interface II Users maybe want to control motors by themselves algorithm This section introduces how to use component in MCL 8 1 Macros on Chip Drive Interface Please refer 7 1 8 2 User Parameters configuration Interface Please refer 7 2 8 3 Macros on chip Startup Interface After configuring the user parameters as shown in section 7 2 2 the following functions can be called to startup macros Function Description void StartMacro_DT INT8U Startup dual timer WhichDualTimer void StartMacro_FRT INT8U Startup FRT WhichMFT void StartMacro_OC INT8U Startup OCCP WhichMFT void StartMacro ADC void Startup ADC 8 4 Macros In chip Stop Interface The following functions can be called to stop macros Function Description void StopMacro_DT INT8U Stop du
22. PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 30 AAN7O6 00043 1v0 E WhichOCCh Which OC channel to configure Valid value range is OC CHO OC_CH5 En Enable or disable valid value is TRUE FALSE RETURN none void ConfBufForOCChx INT8U WhichMFT INT8U WhichOCCh INT8U En FUNCTION Enable or disable interrupt for each OC channel when OCCP matches FRT count value id PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichOCCh Which OC channel to configure Valid value range is OC CHO OC_CH5 En Enable or disable valid value is TRUE FALSE ii RETURN none void ConfIntForOCChx MatchFRT INT8U WhichMFT INT8U WhichOCCh INT8U En L FUNCTION Check interrupt is enabled or disabled for each OC channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichOCCh Which OC channel to configure e Valid value range is 0C CH0 OC_CH5 RETURN TRUE enabled FALSE disabled BOOL ReadIntEnFlagWhenOCCPMatchFRT INT8U WhichMFT INT8U WhichOCCh FUNCTION Check match flag for OCx of OCCP matches FRT count PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichOCCh
23. Treat these as errors Macraigor PE micro RDI C Treat all warnings as errors ST LINK Third Party Driver OK l Cancel Figure 15 Diagnostics Pa050 Pa082 Pa009 83 AAN7O6 00043 1v0 E Options for node ralnverterPlatforn EEE Factory Settings General Options C C Compiler Assembler Output Converter Config Library Input Optimizations Output l List 4 Custom Build Linker configuration file Build Actions V Override default SPROJ_DIR confi g MB9BF506_Flash icf ka Debugger Angel GDB Server Configuration file symbol definitions one per line TAR ROM monitor J Linkf3 Trace TI Stellaris FTDI Macraigor PE micro RDI ST LINK Third Party Driver Figure 16 Linker configuration file MB9BF506_Flash icf Options for node AralnverterPlatform Category Factory Settings General Options C C Compiler Assembler Output Converter Config Library Input Optimizations Output List act Custom Build i s 3 Build Actions F Automatic runtime library s Additional libraries one Debugger PROJ_DIR Code lib aArmInv_Debugz a Simulator Angel GDB Server TAR ROM monitor J Link J Trace c TI Stellaris FTDI sd by application Macraigor PE micro RDI ST LINK Third Party Driver OK Cancel Figure 17 Library Arminv Debug a 84
24. be checked Valid value is ADC UNITO ADC UNTTI1 ADC UNTT2 RETURN TRUE Scan conversion is finished FALSE Scan conversion is not finished BOOL CheckFinishForScanConv INT8U WhichADC 41 Ef AN706 00043 1v0 E FUNCTION Clear finish flag for scan conversion PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC UNITO ADC UNITI ADC_UNIT2 RETURN none void ClrintFlagForScanConv INT8U WhichADC Ty ii FUNCTION Enable or disable interrupt when scan conversion is finished When conversion values are written up to the stage count specified in SFNS this bit is set to 1 PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC UNTTI1 ADC_UNIT2 En Enable or disable Valid value is TRUE FALSE RETURN none void ConfConvFinishIntForScanConv INT8U WhichADC BOOL En 77 FUNCTION Enable or disable interrupt when scan conversion is over run PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC UNIT1 ADC_UNIT2 En Enable or disable Valid value is TRUE FALSE RETURN none void ConfOverRunIntForScanConv INT8U WhichADC BOOL En FUNCTION Stop ADC
25. both scan and priority conversion PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC_UNITI ADC_UNIT2 42 AN706 00043 1v0 E RETURN none void StopADCConv INT8U WhichADC FUNCTION Check scan conversion is stopped or not PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC UNTTI1 ADC_UNIT2 RETURN TRUE Scan conversion is stopped FALSE Scan conversion is not stopped BOOL CheckStopForScanConv INT8U WhichADC FUNCTION Check data storage format for scan conversion PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC UNITO ADC UNIT1 ADC_UNIT2 RETURN ADC DATA FORMAT NORMAL Converting result is stored at bit6 bit15 in SCFD ADC DATA FORMAT CHANGED Converting result is stored at bitO0 bit9 in SCFD BOOL CheckDataFormatForScanConv INT8U WhichADC KA FUNCTION Check scan conversion FIFO is empty or not PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC _ UNITO ADC UNTTI1 ADC UNTT2 RETURN TRUE Scan conversion FIFO is empty FALSE Scan conversion FIFO is not empty BOOL CheckFIFOEmptyForScanConv INT8U WhichADC E FUNCTION
26. configured valid value is MFTO MFT1 DESCRIPTION This interrupt caused irrespective with bit NZCL DTIE I RETURN none void TriggerDTTIBySoftware INT8U WhichMFT if FUNCTION Stop causing a DTTI interrupt by software PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 DESCRIPTION This function will clear WFIR DTIF and clear the DTIF interrupt flag RETURN 38 AAN7O6 00043 1v0 E none void StopDTTIBySoftware INT8U WhichMFT ff FUNCTION Clear DTTI interrupt flag DTIF PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 L RETURN none void ClrDTIF INT8U WhichMFT if FUNCTION Judge WFGxx interrupt is generated or not PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichWFGxx Which WFGxx to configure L Valid value is WFG_CH10 WEG _CH54 RETURN FALSE This interrupt is not generated TRUE This interrupt is generated BOOL CheckIntForWFGxx INT8U WhichMFT INT8U WhichWFGxx Le FUNCTION Clear WFGxx interrupt PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichWFGxx Which WFGxx to configure Valid value is WFG_CH10 WEG CHS4 RETURN no
27. group register PRIGROUP PARAMETERS BitCnt How many bits will be used to denote preempt priority So the left bits in Priority Level Register is used to denote sub priority The valid value range is PREEMPT BIT CNTO PREEMPT BIT CNT7 Example If BitCnt 2 means bit7 bit6 are used to denote preempt priority and bit5 bit0O are used to denote sub priority T RETURN 12 void ConfPreemptPriority INT8U if e none FUNCTION Configure IRQ priority PARAMETERS PRI L Priority IRQ priority EV EL RETURN none AAN7O6 00043 1v0 E BitCnt NVIC No NVIC serial No corresponding to IRQ The valid value range is NVIC_DMA CHO NVIC_DMA CH7 PreemptFieldLen how many bits are used as preempt priority bit the valid value range is PRI_LEVELO NVIC_FCS NVIC_USB 2 void ConfPriorityForIRQ INT32U NVIC_No INT8U PreemptFieldLen INTSU Priority void ConfPriorityForl FUNCTION Configure Exception priority PARAMETERS Priority Excep PRI_LEVEL7 RETURN none INT8U Priority L 77 to id f L FUNCTION Restore interrupt enable regist PARAMETERS RegNo serial
28. 043 1v0 E 4 Right click on the project and choose rebuild all Pa IAR Embedded Workbench IDE File Edit View Project Tools Window Help ps Debug define DEFINE_GLOBAL_VARS A include User Head HeadInOne_ User h v Files B fe jJArminverterPli ae mann La MGL Iptions Ha O hHead Source void nain void 70 v i Initialize all in chip resources da AutoConfByNCL 1 ff ff short the relay 77 Add gt LS a Source Pmainc Renove ShortRelay PORT2 PIN 1 TRUE 1500 IO startup c Sines E Output JE EB EEEEELEEEELELEEEEREREEEERELELEBEES Source Code Control gt ff 3 ff main lann start Fram here AminverterPlatform File Properties OO lt D Si De E so ce kets VW Y RED Build Debug Log x Clean and make the selected project Errors 0 Warnings O Ln 14 Col 38 Figure 10 rebuild project 5 If no any error and warning message in the build box it means the MCL is compiled correctly Z IAR Embedded Workbench IDE File Edit View Project Tools Window Hel Workspace Debug define DEFINE GLOBAL VARS Files E include User Head HeadInOne_User h Tn Deb La Head l o Source vd Initialize all in chip resources A Application e La O MotorCtrl AutoConfBYMCL 1 E Paralnterface_M LS User ei ArminverterPlatform 77 short the rei ay
29. 1v0 E Usage This section introduces how to use MCL include 1 The structure of function main and how to modify this function 2 How to configure peripherals to meet user hardware 3 How to add user routine into ISR of MCL 4 How to debug in EWARM 5 How to debug via GUI 9 2 1 main The coding of function main is as follows Also below figure introduces the code Mielke Paralnterface MCL c ISR_User c define DEFINE GLOBAL VARS include User Head HeadIn0ne User h void main void Include this head file to enable user access functions in MCL ff ff Initialize all in chip resources PF T utoConfByMCL lt Initialize in chip macros according to user parameters to meet user hardware Introduce alobal variable from MCL L i dd short the relay 5 e Short relay if not use a relay ShortRelay PORT2 PIN 1 TRUE 1500 remove this line Pf FFREFFERE ELE ELE ELE RK ELF ELE ELEEKEFKERFELFELEELEFKELLELFE ELE ELE LKELLELFELFELS Ct d main loop start from here 77 bel EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE E EE EN Users maybe need to modify this code 8 ForExhibitionl according to your WDT configuration while TRUE i Enable UART ch6 to communicate with 4 FeedDog TRUE eae PC so users can debug system by GUI eg ForExhibition2 CtelMotor MFTO 4 Enable motor control algorithm in MCL If user do not u
30. 3 5 4 Application folder T 55 5 4 1 Functions in Init as le DIE 55 5 4 2 Functions in MotorCtrl Folder eccccceececeeeeeeeceeceeeeeeeeeeeeseeeeaeeeeeeeeeeeeenees 58 5 4 3 Functions in Others Folder ccccccceceeeeeceeeeeeeeeeeeeneaeeeeeeeeeeeeeueaeeeeeeeesseees 63 6 EE 64 G s rt Rr Eer Dee 68 7 4 Macros on Chip Drive Interface 68 7 1 1 Interface of Definition Type esse eee 68 7 1 2 Interface of Function Type sese eee 69 7 2 User Parameters configuration Interface 70 7 2 1 Introduction NEE 70 7 2 2 Flow to DIS so cael cea a as at ae ca es 12 7 3 Motor Driving interface sese see ee eee ee eee 74 8 User tA 1 ccinsed veer Heres Need end nian i en deal 75 8 1 Macros on Chip Drive Interface 75 AAN7O6 00043 1v0 E 8 2 User Parameters configuration Interface 75 8 3 Macros on chip Startup Interface 75 8 4 Macros In chip Stop Interface 75 8 5 Log Warning Interface sirsiran are e aaea I aaa TEE N AES aaia aaka 76 8 67 Math interface sienien a a eee Se Ae 76 8 7 Transfer function Interface 76 8 8 Transformation function interface sse eee eee eee e TT 8 9 Motor Control Algorithm Interface sese eee eee 77 EI L Be LEE TT 8 11 Definition Interface ee eee eee eee 78 Installation and Usage for MCL 79 9 1 l stallai DEE 79 G A O 15 0 E 86 9 2 1 M N Askar a a a a aa ER A RE pa 86 9 2 2 Configuring Peripherals err 87 9 2 3 ISRelnterfaceIniMCL eene sad beten frs a aga asni skala
31. 3 1v0 E 6 Global Variables Name gstWarningCode Type struct _stWarningCode ee To record warning code the warning amount of this variable can hold Description MAX_WARNING_CODE_CNT Name gstErrInfo Type struct _stErrlnfo To record error information System will stop running the motor Description when some errors are occurred This variable is available when DEBUG_MODE is TRUE Name gADCSampleTime Type FP32 Description To save ADC sampling time the unit is us micro second Name gADCCmpTime Type FP32 Description To save ADC compare time the unit is us micro second Name gFreqOfPLL Type FP32 Description To save PLL output frequency the unit is MHz Name gFreqOfBaseClk Type FP32 Description To save base clock frequency theunit is MHz Name gFreqOfAPBOCIk Type FP32 Description To save APBO clock frequency the unit is MHz 64 AAN7O6 00043 1v0 E Name gFreqOfAPB1Clk Type FP32 Description To save APB1 clock frequency the unit is MHz Name gFreqOfAPB2Clk Type FP32 Description To save APB2 clock frequency the unit is MHz Name gCntTopValOfFRT Type INT32S Description To save the count top value for FRT that is TCCP value Name gPeriodOfFRT_Q15 Type Q15 V
32. AL32 Description To save the count top value for FRT that is TCCP value Name gFreqOfFRT Type FP32 Description To save the FRT frequency unit is MHZ Name gFreqOfWFGCounter Type FP32 Description To save the WFG counter frequency the unit is MHZ Name gFreqOfWDTCIk Type FP32 Description To save the WDT frequency the unit is MHZ Name gstSapmle Type _stSapmle Description ADC properties and sampling results are stored Name _stVectorA Type FP32 Description To save the WDT frequency the unit is MHz 65 AAN7O6 00043 1v0 E Name gstMcuPara Type _stMcuPara Description To save the MCU parameters given by user Name gstMotorPara Type _stMotorPara Description To save the motor parameters given by user Name gstLPFPara Type _stLPFPara Description To save the LPF parameters given by user Name gstDCBusParal Type _stDCBusPara Description To save the DC Bus parameters given by user Name gstPIDParal Type _stPIDPara Description To save the PID parameters given by user Name gstTrgSrcForAlgo Type _stTrgSrcForAlgo Description MFT uses a FRT channel to trigger running of motor control algorithm Name guniStartFlagForMFT Type _uniStartFlagForMFT Description A flag to define a FRT channel to count selected MFT Name guniStartFlagForADC Type _uniStartFlagForADC Desc
33. FRTch 0 to ch 2 as selected ADC trigger source PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFTRCh Which FRT channel to configure fe Valid value is FRT_CHO FRT_CHO FRT_CHO WhichADC Start signal send to which ADC unit Valid value is ADC_UNITO ADC_UNIT1 ADC UNIT2 RETURN 47 AAN7O6 00043 1v0 E none void ConfADCTriggerBy0Detect LogicOR INT8U WhichMFT INT8U WhichFRTCh INT8U WhichADC FUNCTION Configure a pin act as ADC analog input pin ii PARAMETERS WhichPort Which port to be configured Valid value is PROTO PROT7 WhichADCCh Which ADC channel to be configured Valid value is ADC CH 0 ADC CH 15 RETURN none if void ConfPinUsedForADC INT8U WhichPort INT8S WhichADCCh 48 AAN7O6 00043 1v0 E 5 3 Algorithm folder 5 3 1 Functions in Control Folder These functions are in the folder of MCL source Algorithm Control FUNCTION According to the destination vector in fixed 2 axis system program will void send SV PWM waveform out PARAMET ERS WhichMF pstVolt RETURN none T Which MFT valid value is MFTO MFT1 ageInFixAxis the destination voltage vector in fixed axis SendSVPWM B INT8U WhichMFT volatile _stDataInFixAxis pstVoltageInF
34. No of interrupt 0 SETENAO 1 SETENA1 Val32 use this value to restor RegNo RETURN none E NVIC_No NVIC serial No corresponding to Exception The valid value range is PreemptFieldLen how many bits are used as preempt priority bit tion priority the valid value range is PRI_LEVELO 4 6 11 12 14 15 Exception INT32U NVIC No INT8U PreemptFieldLen nable registers interrupt enable register according 13 void RestoreIRQ INT8U RegNo INT32U Val32 FUNCTION Enable exception PARAMETERS Exception Which Exception to be controlled Valid value include 1 EXCEPTION USAGEFAULT 2 EXCEPTION BUSFAULT 3 EXCEPTION MEMFAULT RETURN none void EnException INT8U Exception 14 AN706 00043 1v0 E AAN7O6 00043 1v0 E 5 2 2 Functions in PeripheralCtrl folder All functions in this folder are designed to drive in chip macros As mentioned above there are 2 sets of ways to access in chip registers 1 2 Function Way access registers by functions Definition Way access registers by definitions Here only to introduce the Function Way users can check the Definition Way in h files in the folder of MCL head driver PeripheralCtrl These functions are in the file of MCL source driver PeripheralC
35. ON Start FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 25 AAN7O6 00043 1v0 E WhichFRTCh Which FRT channel to configure Valid value is ERT CHO FRT_CH1 FRT_CH2 L RETURN none void StartFRTx INT8U WhichMFT INT8U WhichFRTCh If FUNCTION Stop FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT_CHO FRT_CH1 FRT CH2 I ATTENTION There are two ways to use this register as described below 1 When starting FRT s counter operation When 0 is written to TCSA STOP and TCSA SCLR while FRT s count operation is stopped FRT starts counting 2 When clearing the count value of FRT s counter to 0x0000 through synchronization in Up count mode If If 0 is written to TCSA STOP and 1 is written to TCSA SCLR during FRT s count operation in Up count mode FRT s count value is cleared to 0x0000 in FRT s next count clock If O is written to TCSA SCLR if before the counter is cleared the counter clear request is cancelled If and the counter value is not cleared This operation cannot be performed in Up Down count mode 3 When stopping the operation of FRT s counter If 1 is written to TCSA STOP and TCSA SCLR during FRT s count ff operation FRT stops the count operation
36. Port FUNCTION Write bit data from port PARAMETERS WhichPort Which port to be configured Valid value is PORTO PORT7 WhichPin Which pin to be configured Valid value is PINO PIN15 bVal Bit value valid value is HIGH LEVEL LOW LEVEL RETURN none void WriteBitToPort INT8U WhichPort INT8U WhichPin BOOL bVal FUNCTION Write byte data from port PARAMETERS WhichPort Which port to be configured Valid value is PORTO PORT7 Val Value RETURN none void WriteByteToPort INT8U WhichPort INT32U Val 20 AAN7O6 00043 1v0 E s Driver for Dual Timer FUNCTION To enable dual timer PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMER1 DUAL TIMER2 RETURN none void EnDualTimer INT8U WhichDualTimer if FUNCTION To disable dual timer PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMER1 DUAL TIMER2 RETURN none void DisDualTimer INT8U WhichDualTimer FUNCTION To configure dual timer work mode PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMER1 DUAL TIMER2 Mode work mod
37. Skaga Ek Aha nikk abs 87 9 2 4 Debug with EWARM neee aannrnrrr rr 90 9 2 9 Debug With GUD rre aienea iyaa arada aa E aena EE S e AEE A s 93 AAN7O6 00043 1v0 E Introduction This user manual describes how to use the Motor Control Library to develop your firmware in MB9B500 Series In this document Motor Control Library is abbreviated to MCL 2 AN706 00043 1v0 E MCL Specification Introduction of MCL structure 2 1 Overview MCL is a motor control library which is used to help users developing firmware for motor control By calling functions in MCL user can develop motor control firmware easily USER modules Firmware in application layer Transform Transfer function USB driver UART Driver interface circuits interface Peripherals j EEPROM AAN7O6 00043 1v0 E 2 2 Features e Only need to include one header file to access all MCL functions MCL consists of two root folders head and source All the h files is placed in the head folder and all the c files is placed in the source folder In the head folder there is a root header file named Head inOne_MCL h By including this file in source file the source file is able to access any function in MCL e MCL functions are divided into 3 layers Driver layer the place to hold functions which directly operate hardware registers Algorithm layer
38. T RstEn Reset by WDT is enabled or not Valid value is TRUE or FALSE IntEn Interrupt by WDT is enabled or not Valid value is TRUE or FALSE DESCRIPTION Software WDT begins to run when set IntEn to TRUE Gl 17 AN706 00043 1v0 E RETURN none void ConfWDTCtrlReg INT8U WhichWDT BOOL RstEn BOOL IntEn Ti FUNCTION Feed DESC Call RETU none watch dog clear WDT counter PARAMETERS WhichWDT Which WDT to configure valid value is HWDT or SWDT RIPTION this function will reload WDT load register RN void FeedWDT INT8U WhichWDT if FUNCTION DESC Call RETU none Unlock registers relative to WDT PARAMETERS WhichWDT Which WDT to configure valid value is HWDT or SWDT RIPTION this function will reload WDT load register RN void INNER FUNCTION UnlockWDT INT8U WhichWDT 18 AAN7O6 00043 1v0 E e Driver for GPIO FUNCTION Configure a pin act as peripheral function or not PARAMETERS WhichPort Which port to be configured Valid value is PORTO PORT7 WhichPin Which pin to be configured Valid value is PINO PIN15 En Peripheral function enable or not RETURN none void ConfPinPeripheralF
39. T Matchzero INT8U WhichMFT INT8U WhichFRTCh INT8U FUNCTION Enable or disable interrupt for FRTx when FRT count value reaches 0 PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT_CHO FRT_CH1 FRT CH2 En Enable or not valid value is TRUE FALSE RETURN none El D H FUNCTION Clear interrupt flag for FRTx of FRT count value reaches 0 PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT_CHO FRI CH1 FRI CH2 RETURN 28 AN706 00043 1v0 E none void ClrIntOfFRTx MatchZero INT8U WhichMFT INT8U WhichFRTCh FUNCTION Initialize FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is ERT CH0 FRT CH1 ERT CH2 En Enable or not valid value is TRUE FALSE ATTENTION There are two ways to use this register as described below 1 When stopping FRT counter Write 1 to issue an initialization request for FRT s operation state when stopping FRT counter 2 When clearing FRT counter through clock synchronization Wr
40. TION To configure FRT PARAMETERS WhichMFT Which MFT valid value is MFTO RETURN none void ConfFRT INT8S WhichMFT FUNCTION To configure OCCP PARAMETERS WhichMFT Which MFT valid value is MFTO RETURN none void ConfOCCP INT8S WhichMFT e FUNCTION To configure WFG PARAMETERS WhichMFT Which MFT valid value is MFTO 60 MFT1 MFT1 MFT1 MFT1 MFT1 AN706 00043 1v0 E AAN7O6 00043 1v0 E RETURN none void ConfWFG INT8S WhichMFT FUNCTION To configure ADC i PARAMETERS none RETURN none void ConfADC void FUNCTION To configure DTTI L PARAMETERS WhichMFT Which MFT valid value is MFTO MFT1 RETURN none void ConfDTTI INT8S WhichMFT bf FUNCTION Check flag to run or stop motor PARAMETERS WhichMFT The motor controlled by this MFT will be operated Valid value is MFTO MFT1 RETURN none void CtrlMotor INT8U WhichMFT FUNCTION To orient rotor to a given position PARAMETERS WhichMFT The motor controlled by this MFT will be stopped Z Valid value is MFTO MFT1 VecAmp_Q15 vector amplitude RotorDir Q15 position which rotor will orient to SendPeriod
41. TO ADC _UNIT2 SampleTimeSel Select sampling time Valid value is ADC_SAMPLE TIMEO ADC SAMPLE TIME1 T L RETURN none 45 AAN7O6 00043 1v0 E If void SelectSampleTime INT8U WhichADC INT8U WhichADCCh INT8U SampleTimeSel FUNCTION Configure sampling time PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC UNIT1 ADC_UNIT2 WhichSampleTimeReg Which sampling time register to be configured Valid value is ADC_STO ADC STI1 ST Value ST value in ADSTx register valid value is ADC ST VALUEO ADC_ST_VALUE63 STX Value STX value in ADSTx register valid value is ADC STXO ADC_STX3 RETURN none Tf void ConfSampleTime INT8U WhichADC INT8U WhichSampleTimeReg INT8U ST Value INT8U STX Value if FUNCTION Configure sampling time PARAMETERS WhichADC Which ADC unit to be checked Valid value is ADC_UNITO ADC_UNIT1 ADC UNIT2 CmpTime Compare time valid value is ADC CMP TIMEO ADC CMP TIME7 RETURN none void ConfCmpTime INT8U WhichADC INT8U CmpTime FUNCTION ADC is triggered when ACCPx matches FRTy or disable triggered by ACCPx and ACCPDNx ACSA SELx always equals 00 and other value is not supported temporarily ACCPx buffer is not allowed PARAMETERS WhichMFT Which MFT will b
42. U WhichaDC dd va WFG interrupt service in MCL dd void MFT_WFG_User void L Figure 23 interface functions in MCL ISR 88 AAN7O6 00043 1v0 E For example if users want to do something in dual timer ch2 interruption user code can be added into the function void DualTimer User void User code will be called after MCL ISR is executed 89 AAN7O6 00043 1v0 E 9 2 4 Debug with EWARM This section introduces how to debug motor control algorithm in MCL When coding is finished select download and debug command to start debugging FF IAR Embedded Workbench IDE File Edit View JOGA Tools Window Help Add Files ma Add Group Edit Configurations S CH Arminv l a User Create New Project Ha He Add Existing Project It Ei Options Alt F7 a Source Code Control gt 150 I Make F7 Eli Compile Ctrl F7 sta Rebuild All Le IC Outpu Clean L By Arr Batch build F8 Download and Debug Ctrl D Download D Figure 24 start debug window In the debug window please open live watch window and add global variable gstMotorRunCtrl into live watch window 90 AAN7O6 00043 1v0 E J IAR Embedded Workbench IDE File Edit ES Project Debug Disassembly J Link Tools Window Help Ei Messages gt Workspace eem IES Paralnterf Source Browser RM Bon defin ire cl Expression Val
43. al timer WhichDualTimer void StopMacro_FRT INT8U Stop FRT WhichMFT void StopMacro_OC INT8U Stop OCCP WhichMFT void StopMacro ADC void Stop ADC 75 AAN7O6 00043 1v0 E 8 5 Log Warning Interface Function Description void LogWarningCode const Record WarningCode into structure of _stWarningCode INT16U WarningCode 8 6 Math interface Function Description Q15 VAL32 Cos Q15 VAL32 theta_Q15 Calculating for cos Q15 VAL32 Sin Q15 VAL32 theta Q15 Calculating for sin 8 7 Transfer function interface Function Description Q15 VAL32 DiffDirect Q15 VAL32 Calculating for differential DeltaVal Q15 Q15 VAL32 DeltaT Q15 Q15 VAL32 IntegralByDirect Q15 VAL32 Calculating for integral x_Q15 Q15_VAL32 t_Q15 Q15_VAL32 UpperLimit Q15 VAL32 LowerLimit Q15 VAL32 FirstOrderBylnertia volatile Fist order LPF _stInfoOfLPF pinfoOfLPF Q15 VAL32 PI Weakenl volatile _stPIDPara PI regulator pPI_Q15 76 AAN7O6 00043 1v0 E 8 8 Transformation function interface Function Description void ClarkAmplitude volatile stDataln ThreeAxis Clark transformation ostDatalnThreeAxis volatile _stDatalnFixAxis pstDatalnFixAxis void Park volatile _stDatalnFixAxis pstDatalnFixAxis Park transformation volatile _stDatalnRotAxis pstDatalnRotAxis void InvPark volatile _stDatalnRotAxis Inverting park transformation stDatalnRotAxis
44. alue is MFTO MFT1 RETURN none SE void Start3PhaseWFG INT8U WhichMFT FUNCTION Judge WFG is running or not e PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichWFGxx Which WFGxx to configure Valid value is WFG_CH10 WEG CH54 ee RETURN 35 AAN7O6 00043 1v0 E FALSE stopped TRUE running BOOL ReadWFGxxStatus INT8U WhichMFT INT8U WhichWFGxx FUNCTION Configure division value for WFGxx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichWFGxx Which WFGxx to configure Valid value is WFG_CH10 WFG CHS4 Div Division value Valid value range is FRT_ DIVO FRT_DIV8 DESCRIPTION This function configure WFG channel by pairs WEG CHO WFG CH1 WFG CH2 WFG CH3 WFG_CH4 WFG CH54 WFGs count clock APB1 bus clock 2 Div f en SSS ese E Div description a a a WEG_DIVO 1 1 Initial value WEG DIV1 1 2 WEG DIV2 1 4 WEG DIV3 1 8 WEG DIV4 1 16 WEG DIV5 1 32 WEG DIV6 1 64 Pe a aa aa RETURN none void ConfDivFreqForWFGxx INT8U WhichMFT INT8U WhichWFGxx INT8U Div FUNCTION Configure work mode for WFGxx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1
45. ameters given by user _stMotorRunCtrl Save motor control parameters given by user and save motor running status given by user AAN7O6 00043 1v0 E 5 NCL Functions All data structure in MCL is not included here only some important ones are listed 5 1 Global folder These functions are in the folder of MCL source Global Debug FUNCTION To log the warning code when detect warning This function will record WarningCode into the member of a global structure named gstWarningCode The maximum warning information amount of this function can record is MAX WARNING CODE CNT PARAMETERS WarningCode warning code warning code Ox0lxx warnings relating to calculating 0x02xx Warnings relating to MFT RETURN none void LogWarningCode const INT16U WarningCode T 10 AAN7O6 00043 1v0 E 5 2 Driver folder 5 2 1 Functions in CoreCtrl folder These functions are in the folder of MCL source driver CoreCtrl FUNCTION Enable IRQ PARAMETERS NVIC No NVIC serial No corresponding to IRQ Ti The valid value range is 16 51 54 61 and Oxffff Oxffff means enable all IRQs RETURN none if void EnIRQ INT32U NVIC_No Te FUNCTION Disable IRQ PARAMETERS NVIC_No NVIC serial No corresponding to IRQ The valid value range is 16 51
46. e _stErrinfo Save error message _stSapmle Relative properties to ADC sampling is stored here _stDatalnThreeAxis Save data in symmetrical 3 phase coordinate _stDatalnFixAxis Save data in alpha beta coordinate _stDatalnRotAxis Save data in d q coordinate _stParaForMcu MCU parameters given by user is placed at here _stParaForClock Clock parameters given by user is placed at here _stParaForMotor Motor parameters given by user is placed at here _stParaForDualTimer2 Dual timer ch2 parameters given by user is placed at here _stParaForLPF LPF parameters given by user is placed at here _stParaForDCBus DC bus parameters given by user is placed at here _stParaForPID PID parameters given by user is placed at here _stParaForMotorRunCtrl Motor control parameters given by user is placed at here _stInitFRT FRT parameters given by user is placed at here _stInitOCCP OCCP parameters given by user is placed at here _stInitWFG WFG parameters given by user is placed at here _stInitADC ADC parameters given by user is placed at here _stInitDTT DTTI parameters given by user is placed at here _stMcuPara Save MCU parameters given by user _stDCBusPara Save DC bus parameters given by user _stMotorPara Save motor parameters given by user _stDualTimer2 Save dual timer ch2 parameters given by user _stLPFPara Save LPF parameters given by user _stPIDPara Save PID par
47. e Valid value is DT MODE FREERUN DT MODE PERIOD lZ DT MODE ONESHOT RETURN none void ConfDualTimerWorkMode INT8U WhichDualTimer INT8U Mode FUNCTION To enable dual timer interrupt PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMER1 DUAL TIMER2 RETURN none 77 21 AAN7O6 00043 1v0 E void EnDualTimerINT INT8U WhichDualTimer FUNCTION To disable dual timer interrupt PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMER1 DUAL TIMER2 RETURN none de void DisDualTimerINT INT8U WhichDualTimer FUNCTION To clear dual timer interrupt PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL _TIMER1 DUAL TIMER2 RETURN none void ClrDualTimerINT INT8U WhichDualTimer FUNCTION To read dual timer interrupt status PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL_TIMERI DUAL TIMER2 RETURN FALSE No interrupt generated TRUE Interrupt is generated BOOL ReadIntStatusOfDualTimer INT8U WhichDualTimer FUNCTION To prescale for dual
48. e configured valid value is MFTO MFT1 WhichFTRCh Which FRT channel to configure Valid value is FRT_CHO FRT_CH1 PRT CH2 FRT NONE WhichADC Start signal send to which ADC unit Valid value is ADC_UNITO ADC_UNIT1 ADC UNIT2 ACCP Value ACCP value 46 AAN7O6 00043 1v0 E RETURN none void ConfTriggerByACCP INT8U WhichMFT INT8S WhichFRTCh INT8U WhichADC INT16U ACCP Value a FUNCTION Configure trigger source for ADC when using scan conversion PARAMETERS WhichADC Start signal send to which ADC unit Valid value is ADC_UNITO ADC_UNIT1 ADC_UNIT2 TrigSrc trigger source L Valid value is TRG_SRC_NONE TRG_SRC_FRT TRG_SRC_BTCO TRG_SRC_BTC7 RETURN none e void ConfTrigSrcForScanConv INT8U WhichADC INT8U TrigSrc FUNCTION configure ADCMP channel connects to which FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFTRCh Which FRT channel to configure Valid value is ERT CHO FRT_CH1 FRT CH2 WhichADCMP Which ADCMP channel to be configured valid value is ADCMP CHO ADCMP CHL ADCMP CH2 RETURN none Ge void ConfADCMPConnectToFRT INT8U WhichMFT INT8U WhichFRTCh INT8U WhichADCMP FUNCTION ADC is triggered when O detect occurs on FRTs This function use the logic OR signal of
49. er of ConfFRT stInitFRT stConfFRT WhichFRTCh FRT_CHO To meet the demanding 1 stInitFRT stConfFRT Cycle 0 2 To meet the demanding 2 stInitFRT stConfF RT CntMode CNT_MODE_UPDOWN To meet the demanding 3 stInitFRT stConfFRT EnBuf FALSE To meet the demanding 4 stInitFRT stConfFRT EnINT_MatchTop FALSE To meet the demanding 5 stInitFRT stConfFRT EnINT_MatchZero TRUE To meet the demanding 6 stInitFRT stConfFRT TrgSrcForAlgo TRUE To meet the demanding 7 72 Step 2 AN706 00043 1v0 E Locating to the function of AutoConfByMCL input parameters in ConfFRT should be given to determine which MFT is to be configured As shown in the following figure Step 3 INTSS AutoConfByMCL void H ConfNVIC 1 ConfMCUPara ConflotorPara MFTO ConfSysPara MFTO ConfClock ConfWDT ConftGPIO ConfDualTimer2 1 2 ConfCtrlPara MFTO ConfFRT MFTO ConfOccP MFTO ConfUFG MFTO ConfADC ADC UNITO ConfDTTI MFTO return 1 Figure 2 Setting input parameters for ConfFRT Repeat step 1 and step 2 until completed all the configurations Then call AutoConfByMCL in main to start configuration progress user configuration will be set L define DEFINE GLOBAL VARS include User Head HeadInOne User h void main void 77 Initialize all in chip resources 7 7 Figure 3 Calling AutoConfByMCL in main 73 AN7O6 00043 1v0 E 7 3
50. ese functions are in the folder of MCL source Application Init e FUNCTION To start dual timer WhichMFT which dual timer will be operated Valid value is DUAL TIMER1 DUAL TIMER2 T RETURN none void StartMacro_DT INT8U WhichDualTimer ld e FUNCTION To stop dual timer WhichMFT which dual timer will be operated T Valid value is DUAL TIMER1 DUAL TIMER2 RETURN none void StopMacro DT INT8U WhichDualTimer FUNCTION To start FRT WhichMFT The FRT in which MFT will be operated Valid value is MFTO MEI RETURN none void StartMacro FRT INT8U WhichMFT ie FUNCTION To stop FRT WhichMFT The FRT in which MFT will be operated Valid value is MFTO MEI RETURN none void StopMacro FRT INT8U WhichMFT 55 AN706 00043 1v0 E FUNCTION To start OC PARAMETERS WhichMFT The OCU in which MFT will be operated Valid value is MFTO MEI RETURN none void StartMacro OC INT8U WhichMFT FUNCTION To stop OC PARAMETERS WhichMFT The OCU in which MFT will be operated Valid value is MFTO MFT1 RETURN none void StopMacro OC INT8U WhichMFT
51. face of Definition Type This interface offers approaching to access bits in registers To be easy that users contrast definitions with chip user manual every definition is named by the bit name For example to access MODE bit of TCSAy in MFTx MCL uses the following definition define SET MFTx TCSAy MODE WhichMFT WhichFRTCh Mode do ASSERT CNT_MODE UP Mode CNT MODE UPDOWN Mode JOIN5 MFT WhichMFT _TCSA WhichFRTCh _bit MODE Mode a while FALSE DH To be easy using for user every definition also has an alias to denote its function For example to configure the counter mode for FRT MCL uses the following definition define ConfCountModeOfFRTx Def WhichMFT WhichFRTCh Mode SET MFTx TCSAy MODE WhichMFT WhichFRTCh Mode If users want to set the counter mode of FRTO in MFTO to up down counter mode the following coding can be used ConfCountModeOfFRTx Def MFTO FRTO CNT MODE UPDOWN or SET METS TCSAy MODE MFTO FRTO CNT MODE UPDOWN To see more definition type interface please refer to the files of MCL head drive h 68 AAN7O6 00043 1v0 E 7 1 2 Interface of Function Type There is an example to explain this interface The interface is designed as follows FUNCTION Configure count mode for FRT channel Ld PARAMETERS WhichMFT Which MFT will be configured valid value i
52. hase 0 91f 2 stMotorPara Ld 0 0107f stMotorPara Lq 0 0119f stMotorPara K phi 36 2f Vrms Krpm InitMotorPara_MCL stMotorPara s amp gstMotorPara WhichMFT H Figure 1 example for configure motor parameters Referring the figure 3 the users will feel that it is easy to set the motor parameters into _stParaForMotor and then call InitMotorPara_MCL to deliver parameters into MCL 71 AAN7O6 00043 1v0 E 7 2 2 How to Use Users should modify the given data in the structure to suit for the hardware or system For example if the following configuration is one of user s demanding configurations 1 Configure for FRTO in MFTO 2 Trigger period of MCL motor control algorithm is 200us 3 FRT counter mode is up down count 4 Disable FRT buffer 5 Disable interruption when FRT counter becomes top value in the up down count 6 Enable interruption when FRT counter becomes zero 7 FRT acts as trigger source for MCL motor control algorithm e Step 1 Referring Table 2 you can see that _stInitFRT and ConfFRT should be used At first open the file of MCL head application MotorCtrl Userlnterface_MCL c and then locate to the function of ConfFRT _stlInitFRT should be configured as follows Table 2 mainly configuration contents Configuration Description stInitFRT stConfFRT WhichMFT WhichMFT To meet the demanding 1 WhichMFT is determined by the input paramet
53. how long the vector will be last ms RETURN none 61 AAN7O6 00043 1v0 E Lf void RotorOrienting INT8S WhichMFT Q15 VAL32 VecAmp 015 Q15 VAL32 RotorDir Q15 INT16U SendPeriod 62 AAN7O6 00043 1v0 E 5 4 3 Functions in Others Folder These functions are in the folder of MCL source Application Others id void FeedDog BOOL EnHWDT es e FUNCTIO Feed wa N tch dog PARAMET ERS EnHWDT EnSWDT RETURN none Wheth r feed r feed Wheth FUNCTION Delay by software PARAMET ERS hardware watch dog or not software watch dog or not BOOL EnSWDT DelayTime how long is to delay ms RETURN none void DelaySoft FP32 DelayTime ii e FUNCTION After system powered on the relay will be shorted PARAMET ERS WhichPort which port is to control the relay WhichPin which pin is to control the relay ActiveLevel The active levle for driving relay valid value is LOW L EV EL HIGH LEVEL DelayTime how long is to delay after power on after the delay relay will be shorted ms RETURN none void ShortRelay INT8U WhichPort INT8U WhichPin INT8U ActiveLevel FP32 DelayTime 63 AAN7O6 0004
54. ility for any infringement of the intellectual property rights or other rights of third parties which would result from the use of information contained herein The products described in this document are designed developed and manufactured as contemplated for general use including without limitation ordinary industrial use general office use personal use and household use but are not designed developed and manufactured as contemplated 1 for use accompanying fatal risks or dangers that unless extremely high safety is secured could have a serious effect to the public and could lead directly to death personal injury severe physical damage or other loss i e nuclear reaction control in nuclear facility aircraft flight control air traffic control mass transport control medical life support system missile launch control in weapon system or 2 for use requiring extremely high reliability i e submersible repeater and artificial satellite Please note that Fujitsu will not be liable against you and or any third party for any claims or damages arising in connection with above mentioned uses of the products Any semiconductor devices have an inherent chance of failure You must protect against injury damage or loss from such failures by incorporating safety design measures into your facility and equipment such as redundancy fire protection and prevention of over current levels and other abnormal operating conditions If any products de
55. is Valid range is DESCRIPTION Each macro in chip uses which APB bus clock is listed below Clock and Reset Control Hardware Watch dog Timer APBO APB2 Div Factor of frequency division APBx CLK DIVO APBx CLK DIV3 Software Watch dog Timer Dual Timer APB1 Multi function Timer unit0 Multi function Timer unitl PPG Base Timer Multi function Serial Watch Counter USB Clock Generation Circuit CAN Pre scaler RETURN none void ConfAPBxClock INT8U APBx INT8U Div 16 AN706 00043 1v0 E Driver for watchdog FUNCTION Configure software WDT clock PARAMETERS Div Factor of frequency division Valid range is WDT CLK DIVO WDT_CLK_DIV3 DESCRIPTION WDT CLK DIVO 1 1 Initial value WDT_CLK_DIV1 1 2 WDT_CLK_DIV2 1 4 WDT_CLK_DIV3 1 8 RETURN none void ConfWDTClock INT8U Div if FUNCTION configure WDT load register PARAMETERS WhichWDT Which WDT to configure valid value is HWDT or SWDT ms WDT overflow period ms valid range is from 0 001 to upper limit RETURN none void ConfWDTLoadReg INT8U WhichWDT FP32 ms e e e bb FUNCTION configure software WDT control register PARAMETERS WhichWDT Which WDT to configure valid value is HWDT or SWD
56. it up down counter RETURN none void ConfDivFreqForFRTx INT8U WhichMFT INT8U WhichFRTCh INT8U Div FUNCTION Configure division value for FRT channel L PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT_CHO FRT_CH1 FRT CH2 if RETURN ERT DIVO FRT_DIV8 INT8U ReadDivFreqForFRTx INT8U WhichMFT INT8U WhichFRTCh 27 AN706 00043 1v0 E FUNCTION Enable or disable interrupt for FRTx when TCCP matches FRT count value PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT_CHO ERT CH1 ERT CH2 En Enable or not valid value is TRUE FALSE RETURN none void ConfIntForFRT_MatchTop INT8U WhichMFT INT8U WhichFRTCh INT8U En St FUNCTION Clear interrupt flag for FRTx Event TCCP matches FRT count value PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is ERT CHO FRT_CH1 FRIT CH2 RETURN none void ClrIntOfFRTx MatchTop INT8U WhichMFT INT8U WhichFRTCh e es void ConfIntForFR
57. ite 1 to issue a request to clear FRT s count value to 0x0000 through synchronization when operating FRT in Up count mode RETURN none void InitFRTx INT8U WhichMFT INT8U WhichFRTCh BOOL En 29 AAN7O6 00043 1v0 E e Driver for output compare in MFT Lf FUNCTION Configure each OC channel connect to which FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichOCCh Which OC channel to configure Valid value range is LOC CHO OC_CH5 WhichFRTCh Which FRT channel to configure Valid value is FTR_CHO FTR CHL FTR CH2 RETURN none void ConfFRTforOCChx INT8U WhichMFT INT8U WhichFRTCh INT8U WhichOCCh ff FUNCTION Start OC channel to operate PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichOCCh Which OC channel to configure Valid value range is OC CHO OC_CH5 RETURN none void StartOCChx INT8U WhichMFT INT8U WhichOCCh FUNCTION Stop OC channel to operate PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichOCCh Which OC channel to configure e Valid value range is OC CHO OC CH5 RETURN none void StopOCChx INT8U WhichMFT INT8U WhichOCCh FUNCTION Enable or disable buffer for each OC channel Tf
58. ixAxis 49 AAN7O6 00043 1v0 E 5 3 2 Functions in Math Folder These functions are in the folder of MCL source Algorithm Math FUNCTION calculate sin theta i PARAMETERS theta 015 angle with Q15 32bit format Input any angle is enabled because this function will If correct angle into a 0 360 degree RETURN value of sin theta with Q15 32bit format ff Q15 VAL32 Sin Q15 VAL32 theta 015 Ce FUNCTION calculate cos theta if PARAMETERS theta_Q15 angle with Q15 32bit format Input any angle is enabled because this function will id correct angle into a 0 360 degree RETURN value of cos theta with Q15 32bit format Q15_ VAL32 Cos Q15 VAL32 theta_Q15 50 AAN7O6 00043 1v0 E 5 3 3 Functions in Transfer Folder These functions are in the folder of MCL source Algorithm Transfer FUNCTION Differential calculation by mathematical definition PARAMETERS DeltaVal Q15 Increment quantity of value DeltaT Q15 Increment quantity of time RETURN Differential result Q15 VAL32 DiffDirect Q15 VAL32 DeltaVal_Q15 Q15 VAL32 DeltaT_Q15 FUNCTION Calculate the integral directly If the calculation result exceed th maximum value UpperLimit or minimum
59. l End 93
60. meters interface is used to accept parameters derived from hardware design The interface has 2 parts data structure interface and function interface Users can modify the file of MCL head application MotorCtrl Userlnterface_MCL c to set new parameters Below table describes the details Table 2 User Parameters Interface Data Structure Function Description _stParaForNVIC ConfNVIC Configure exception and INT priority _stParaForMotor ConfMotorPara Configure motor parameters _stParaForDCBus ConfSysPara Configure system parameters _stParaForMcu ConfMCUPara Configure MCU parameters _stParaForClock ConfClock Configure PLL and bus clock ConfWDT Configure WDT _stPortPinForGPIO ConfGPIO Configure GPIO _stParaForDualTimer2 ConfDualTimer2 Configure dual timer ch2 _stParaForMotorRunCtrl ConfCtriPara Configure motor control parameters _stParaForPID Configure PID regulator parameters _stParaForLPF InitLPF_MCL Configure LPF _stInitFRT ConfFRT Configure FRT _stInitOCCP ConfOCCP Configure OCCP _stlnitWFG ConfWFG Configure WFG _stInitADC ConfADC Configure ADC _stInitDTTI ConfDTTI Configure DTTI There is just an example to show the interface 70 AAN7O6 00043 1v0 E Configure motor parameters void ConfMotorPara INTSU WhichMFT StParaForMotor stMotorPara stMotorPara PolePairs 2 stMotorPara RsP
61. ne void ClrWFGIntStatusForWFGxx INT8U WhichMFT INT8U WhichWFGxx FUNCTION Select RTO pin for WFG and determine U V W is driven by which pin if PARAMETERS WhichMFT WFG is in Which MFT valid value is MFTO MFT1 WhichPort WhichPin Which pin in which port will connect to RTO P WhichPort s valid value is PORTO PORT7 WhichPin s valid value is PIN_0 PIN 15 39 AAN7O6 00043 1v0 E if RETURN ChPairs The pin described by WhichPort and WhichPin is in which WFG channel pairs valid value is WFG_CH10 WFG_CH32 WEG CH54 INT8S SelectOCCPCh INT8U WhichMFT INT8U WhichPort INT8U WhichPin L FUNCTION Configure pin work as RTO PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichPort WhichPin Which pin in which port will act as DTTI pin ActMode The mode of switching GPIO when DTTI comes DTTI SWITCH GPIO BY HAND switching GPIO by hand when DTTIF interrupt arrives fi DTTI SWITCH GPIO BY AUTO switching GPIO automatically when Th DTTIF interrupt arrives 77 RETURN none void ConfPinActAsDTTI INT8U WhichMFT INT8U WhichPort INT8S WhichPin INT8U ActMode FUNCTION Clear DTTI interrupt flag DTIF If PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 id
62. not OK FlagSwitchCurrentLoop To denote whether motor is controlled in close loop 1 motor is controlled in close loop 0 motor is controlled in open loop 91 AAN7O6 00043 1v0 E Expand gstMotorRunCtrl Givens some given values can be seen as follows Name Description Expect CL Q15 Motor running target speed mechanical speed unit is Hz This value is Q15 format ExpectW Motor running target speed mechanical speed unit is Hz This variable is used for facilitate user input target speed Expand gstMotorRunCtrl Limits the motor speed limitation can be seen as follows Name Description MinRotSpeed_CL_Q15 Lower limit of motor running speed in close loop mechanical speed unit is Hz This value is Q15 format MaxRotSpeed_CL_Q15 Upper limit of motor running speed in close loop mechanical speed unit is Hz This value is Q15 format Expand gstMotorRunCtrl Derives some derived quantities can be seen as follows Name Description StepLenOfFreqChange_Q15 Motor speed change step Q15 format CurrentSpeed_Q15 Motor current speed Q15 format NextSpeed_Q15 Motor next speed Q15 format Anglelncrement Q15 Rotor angle increment Q15 format RealValueFromSmpl gt a Q15 Real current value of phase U RealValueFromSmpl b_Q15 Real current value of phase V Expand gstMotorRunCtrl
63. oadValForDualTimer INT8U WhichDualTimer INT32U ReloadVal iy FUNCTION To configure reload value for dual timer This function will configure dual timer s background load register PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMERI1 DUAL TIMER2 ReloadVal reload value 23 AAN7O6 00043 1v0 E if RETURN none void ConfBackReloadValForDualTimer INT8U WhichDualTimer INT32U ReloadVal FUNCTION To read reload value from dual timer PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMER1 DUAL TIMER2 RETURN Reload value INT32U ReadReloadValFromDualTimer INT8U WhichDualTimer FUNCTION To configure interrupt period for dual timer PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMER1 DUAL TIMER2 ms Interrupt period ms RETURN none void ConfPeriodForDualTimer INT8U WhichDualTimer FP32 ms FUNCTION To configure interrupt period of dual timer for next time PARAMETERS WhichDualTimer Which dual timer will be configured if valid value is DUAL TIMER1 DUAL TIMER2 ms Interrupt period ms RETURN none void ConfNextPeriodForDualTimer
64. ponding to OC channelx PARAMETERS WhichMFT Which MFT valid value is MFTO MFT1 WhichOCCh Which OC channel to configure Valid value range is OC CHO OC CHS RegVal Register value RETURN 33 AAN7O6 00043 1v0 E none void ConfOccpValForOCChxB INT8U WhichMFT INT8U WhichOCCh INT16U RegVal ff FUNCTION Check RTx status PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 RTx Check which RTx Valid value is OC_RTO OC RT5 RETURN 1 high level 0 low level if INT8U ReadRTxForOCChx INT8U WhichMFT INT8U RTx 34 AAN7O6 00043 1v0 E e Driver for waveform generator in MFT iy FUNCTION Start WFGxx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichWFGxx Which WFGxx to configure Z Valid value is WFG_CH10 WEG CHS4 RETURN none void StartWFGxx INT8U WhichMFT INT8U WhichWFGxx L FUNCTION Stop WFGxx PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichWFGxx Which WFGxx to configure Valid value is WFG_CH10 WEG CH54 Tif RETURN none void StoptWFGxx INT8U WhichMFT INT8U WhichWFGxx if FUNCTION Start WFGxx PARAMETERS WhichMFT Which MFT will be configured valid v
65. ription A flag to define ADC unit 66 AAN7O6 00043 1v0 E Name gstPinToDrvUVWI Type _stPinToDrvUVW Description Save driving pin assignment for phase U V W Name gstDualTimer2 Type _stDualTimer2 Description dual timer ch2 property Name gstMotorRunCtrl Type _stMotorRunCtrl Save parameters related to drive motor gstMotorRunCtrl Givens Save the value given by user gstMotorRunCtrl Flags system running status gstMotorRunCtrl Limit system limit parameters when motor running pescrintion gstMotorRunCtrl Cnts define the control timing gstMotorRunCtrl ObsForPLL save result of PLL algorithm gstMotorRunCtrl Derives derivation quantities according to the user input and running status gstMotorRunCtrl P PI regulator parameters and PI input output gstMotorRunCtrl Output record some output quantities Name math sin ll Type INT16U Description Sine table 67 AAN7O6 00043 1v0 E 7 User Interface Users maybe want to control motors by using MCL motor control algorithm directly and simply This section introduces how to build such system 7 14 Macros on Chip Drive Interface MCL has 2 types of macro driver interface One is realized by definition in header files h the other is realized by functions in source files c The 2 types of interface can be found in the folder of MCL head drive 7 1 1 Inter
66. s MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT_CHO FRT_CH1 FRT_CH2 Mode Count mode valid value is CNT MODE UP CNT MODE UPDOWN RETURN none void ConfCountModeForFRTx INT8U WhichMFT INT8U WhichFRTCh INT8U Mode T T If users want to set the counter mode of FRTO in MFTO to up down counter mode the following coding can be used T ConfCountModeForFRTx MFTO FRTO CNT MODE UPDOWN Further this interface can not only configure bits in registers but also do some complex jobs For example the function as follows can configure several registers automatically to meet advance demanding FUNCTION Configure count cycle for FRT channel PARAMETERS WhichMFT Which MFT will be configured valid value is MFTO MFT1 WhichFRTCh Which FRT channel to configure Valid value is FRT CHO FRT CH1 ERT CH2 ms count cycle ms valid range is from 0 001 to upper limit RETURN none void ConfCntCycleForFRTx INT8U WhichMFT INT8U WhichFRTCh FP32 ms If users want to configure FRT counter period to 0 2ms the following coding can be used ConfCntCycleForFRTx MFTO FRTO 0 2 To see more definition type interface please refer to the files of MCL head drive h 69 7 2 User Parameters configuration Interface 7 2 1 Introduction AN706 00043 1v0 E User para
67. scribed in this document represent goods or technologies subject to certain restrictions on export under the Foreign Exchange and Foreign Trade Law of Japan the prior authorization by Japanese government will be required for export of those products from Japan The company names and brand names herein are the trademarks or registered trademarks of their respective owners Copyright 2011 FUJITSU SEMICONDUCTOR LIMITED all rights reserved Revision History Date Remark IAN706 00043 1v0 E Jul 13 2011 First Edition AAN7O6 00043 1v0 E Table of Contents REVISION HISTOPY s n a He ena 2 Table of elel st nasa Ee she ee eee 3 Wy Introductions weiter Adee GR Mean td ne eae has SRE 5 27 MCL ee eee T 6 2 e 6 PATE EE usteet eeneg eege eebe De geseet tes TTT 7 2 3 Peripheral Occupation sese 7 3 MCL Architecture Introducton eee 8 4 Data Structure Introduction sss esse eee eee eee 9 S de e e 10 SCT Global folderen a e HET 10 52 Driver e EE 11 5 2 1 Functions in CoreCtrl folder sese 11 5 2 2 Functions in PeripheralCtrl folder cccccceseceeeeeeeeeeeeeeeseeeeneeeeeeeeteeeenaes 15 b3 Algorithm Zolder 49 5 3 1 Functions in Control Folder sss sees eee 49 5 3 2 Functions in Math Folde rics nan cine cei See Mine SEENEN 50 5 3 3 Functions in Transfer Folder 51 5 3 4 Functions in Transformation Folder ssssssssseseserereeresrerrrrnereererrerernrneeerrene 5
68. se algorithm in MCL remove this line Figure 20 Introduction for main 86 AAN7O6 00043 1v0 E The code is the entry of on chip macro initialization in MCL If this code is deleted code cannot run correctly So code and code cannot be deleted to the users who want to use motor control algorithm in MCL If the users don t want to use motor control algorithm in MCL code and code can be removed But it is recommend that only remove code because code still can be used to initialize on chip macros according to user configurations Code and code can be removed if users do not debug by GUI But it is recommended to reserve it because GUI can show some quantities as waveform Some of them cannot measure directly by oscilloscope Code maybe need to be modified For example if users configure to use soft watch dog timer instead of hardware watch dog timer this code should be modified as FeedDog FALSE TRUE 9 2 2 Configuring Peripherals Please refer 7 2 9 2 3 ISR Interface in MCL In MCL some interrupts are used for example ERT DualTimer ch2 UART ch6 etc The ISR entry in MCL can be found in startup c as follows ff IRQ L Anomalous Frequency Detection by C jISR_SoftWatchdog l ff Software Watchdog Timer I5R DefaultHandler ff Low Voltage Detector LVD ISR MFT WFG ff Wave Form Generator unit0 uniti I5R DefaultHandler ff External Interrupt Request ch 0 tc
69. tallation package If users have got this installation package please refer the next step 1 Unpack installation package to any folder Unpack it and put it on the desktop E HGH yl SHE Ki SH 3 IRNS GERNE IM Festal hg ts sha gf Mahon Figure 6 unpack installation package on the desktop 2 Change the folder name something you want Rename it to ArmInvPrj for example E STEE S PRERE Figure 7 Rename folder 79 AAN7O6 00043 1v0 E 3 Enter the folder of EWARM project ArminvPrj editor EWARM and then open project file ArmlnverterPlatform eww H ra i A Gen 8 pm MH is S Hiti oi O inistrator AM ArnInvPrj BR a B Debug settings rmInverterPlatform ArmInverterPlatform E define DEFINE_GLOBAL_VARS Files P include User Head HeadInOne User h Gi mena Debug korasan Head d een ALM Source S Initialize all in chip resources 5 pplication Mt Motor AutoConfBYMCL 1 BParalnterface MCL SC User do Head ve short the relay SL Source ve E main c ShortRelay PORT2 PIN_1 TRUE 1500 O startup c H D Output LL RFEEEEEELEEELEEELEEEEREEELEEELEEEES te ArminverterPlatform Lf main Jaan start fram here G gt TEA A RUE Ow Messages GG t Build Debug Log x Ready Errors 0 Warnings 0 Figure 9 open project file 80 AAN7O6 00
70. timer interrupt PARAMETERS WhichDualTimer Which dual timer will be configured ff valid value is DUAL TIMERI1 DUAL_TIMER2 PreVal Prescale value Valid value is DT PRE BY 1 DT PRE BY 16 DT PRE BY 256 RETURN none T 22 AN706 00043 1v0 E void PreOfDualTimer INT8U WhichDualTimer INT8U PreVal 1 FUNCTION To read prescale of dual timer PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMER1 DUAL TIMER2 RETURN Prescale value 1 16 or 256 INT16S ReadPreOfDualTimer INT8U WhichDualTimer FUNCTION To configure counter size for dual timer PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL TIMERI1 DUAL TIMER2 CntSize Counter size Valid value is DT CNT SIZE 16 DT CNT SIZI GI 32 RETURN none void CntSizeOfDualTimer INT8U WhichDualTimer INT8U CntSize e FUNCTION To configure reload value for dual timer This function will configure dual timer s load register PARAMETERS WhichDualTimer Which dual timer will be configured valid value is DUAL_TIMERI DUAL TIMER2 ReloadVal reload value RETURN none void ConfRel
71. tities in symmetrical 3 axis system talnFixAxis quantities in fixed 2 axis system RETURN stDataInFixAxis values transforming from symmetrical 3 axis system void ClarkAmplitude volatile stDataInThreeAxis pstDataInThreeAxis volatile stDataInFixAxis pstDataInFixAxis FUNCTION Clark transformation PARAMETERS pstDataInFixAxis quantities in fixed 2 axis system pstDataInRotAxis quantities in rotational 2 axis system RETURN pstDataInRotAxis values transforming from fixed 2 axis system void Park volatile stDataInFixAxis pstDataInFixAxis volatile _stDataInRotAxis pstDataInRotAxis FUNCTION Park inverse transformation PARAMETERS stDataInRotAxis quantities in rotational 2 axis system stDataInFixAxis quantities in fixed 2 axis system a RETURN stDataInFixAxis values transforming from rotational 2 axis system void InvPark volatile stDataInRotAxis stDataInRotAxis volatile _stDataInFixAxis stDataInFixAxis FUNCT ION Correct angle to its main area 0 360 PARAM ETERS theta_Q15 angle with Q15 32bit format 53 AAN7O6 00043 1v0 E if RETURN angle value in main area Q15 VAL32 CorrectAngleToMainArea Q15 VAL32 theta_Q15 54 5 4 Application folder 5 4 1 Functions in Init Folder Th
72. trl L Driver for clock FUNCTION Configure PLL clock frequency PARAMETERS CrystalFreq External main crystal frequency MHz K Divide Factor of frequency division valid value range is 0 15 N Multi Factor of frequency multiplication valid value range is 0 iy if 311 MainClkWaitTime How long to wait for the main clock stability Available value range is MAIN CLK WAITING TIMEO MAIN CLK WAITING TIME15 PLLC1kWaitTime How long to wait for the PLL stability Available value range is PLL CLK WAITING TIMEO PLL CLK WAITING TIME7 DESCRIPTION The formula of calculating PLL output clock frequency is PLLClock CrystalFreq N Multi 1 E Divide 1 RETURN none void ConfPLLClock INT8U CrystalFreq INT8U K Divide INT8U N Multi INT8U MainClkWaitTime INT8U PLLC1kWaitTime Ti FUNCTION Configure base clock frequency PARAMETERS Div Factor of frequency division Valid range is BASE CLK DIVO BASE CLK DIV6 RETURN 15 none AN706 00043 1v0 E void ConfBaseClock INT8U Div FUNCTION Configure APBx clock frequency PA APBO APB2 RAMETERS API Bx configure which APB Valid range
73. ue S a incl Breakpoints ilnOne User bn Al gstMotorRunCtrl lt array gt Disassembly T Ha 0 lt struct gt Dyoid Memory Givens lt struct gt Symbolic Memory Ha Flags lt struct gt 4 Register L Flagstartup WOU Watch a chip resources H FlagMacroRdy 0x00 Z Locals FlaginitObsVars 0x00 AU Statics L FlagSwitchCloseLoop 0x00 Auto FlagSendStartupvec 0x00 Ree H FlagRecMaxCurrent 0x00 E ick Watd FlagOrientOK 0x00 4 Call Stack l H FlagStartStableRun 0x00 2 Terminal 1 0 Ve TRUE lr FlagSwitchCurrentLoop 0x00 A Code Coverage L Limits lt struct gt Images Cnts lt struct gt s Stack bisa a ObsForPLL lt struct gt Symbols Derives lt struct gt 1 Toolbars p Froen PI lt struct gt e v v Status Bar NI Lee Zi fo O lt M x Workspace Live Watch Watch Disassembly x Ln D X Bs m l v HRB B ab adli E Figure 25 open live watch window and add global variable in Expand gstMotorRunCtrl Flags some flags can be seen as follows Name Description FlagStartup Motor startup flag Modify this flag to startup or stop motor 1 startup motor 0 stop motor FlagMacroRdy To denote whether macro in chip is configured successfully or not 1 macros in chip is already configured 0 macors in chip is not ready FlagOrientOK To denote whether rotor orienting is Ok or not 1 rotor orienting OK 0 rotor orienting is
74. unc INT8U WhichPort INT8U WhichPin BOOL En FUNCTION Configure a pin pull up or not PARAMETERS WhichPort Which port to be configured Valid value is PORTO PORT7 WhichPin Which pin to be configured Valid value is PINO PIN15 En Pull up enable or not RETURN none void ConfPinPullUp INT8U WhichPort INT8U WhichPin BOOL En if FUNCTION Configure data direction for a pin Ld PARAMETERS WhichPort Which port to be configured Valid value is PORTO PORT7 WhichPin Which pin to be configured Valid value is PINO PIN15 Dir Act as an input or output pin Valid value is IO DIRECTION IN IO_DIRECTION OUT id RETURN none void ConfPinDirection INT8U WhichPort INT8U WhichPin INT8U Dir FUNCTION Read bit data from port PARAMETERS WhichPort Which port to be configured Valid value is PORTO PORT7 WhichPin Which pin to be configured Valid value is PINO PIN15 19 SE AN706 00043 1v0 E RETURN Read result BOOL ReadBitFromPort INT8U WhichPort INT8U WhichPin FUNCTION Read byte data from port PARAMETERS WhichPort Which port to be configured Valid value is PORTO PORT7 RETURN Read result INT32U ReadByteFromPort INT8U Which
75. value LowerLimit the maximum value UpperLimit or minimum value LowerLimit will be returned PARAMETERS x Q15 integral variable t 015 integral time ms UpperLimit the upper limit of integral result owerLimit the lower limit of integral result RETURN integral result Q15 VAL32 TntegralByDirect Q15 VAL32 x 015 Q15 VAL32 t_Q15 ms L i4 Q15 VAL32 UpperLimit Q15 VAL32 LowerLimit FUNCTION First order LPF this LPF is realized by an inertia function PARAMETERS piInfoOfLPF relative information which is needed for LPF RETURN Eqf which is the BEMF output from LPF Q15 VAL32 FirstOrderByInertia volatile stInfoOfLPF pInfoOfLPF FUNCTION To calculate the output from PI regulator PI method is to weak the integral component when the output ui exceeds the limit 51 if PARAMETERS pPI_Q15 parameters used to calculate PI RETURN output of PI regulator Q15 VAL32 PI_WeakenI volatile stPIDPara pPI_Q15 52 AN706 00043 1v0 E AAN7O6 00043 1v0 E 5 3 4 Functions in Transformation Folder These functions are in the folder of MCL source Algorithm Transformation LE FUNCT Clark PARAM pstDa pstDa ION transformation ETERS talnThreeAxis quan
76. volatile _stDatalnFixAxis stDatalnFixAxis Q15 VAL32 CorrectAngleToMainArea Q15_VAL32 Correct angle to its main area theta Q15 0 360 8 9 Motor Control Algorithm Interface Before calling these functions please confirm that the user parameters are correctly set as shown in section 7 2 2 Function Description void SendSVPWM B INT8U WhichMFT Send SVPWM vector volatile _stDatalnFixAxis pstVoltagelnFixAxis void RotorOrienting INT8S WhichMFT Orienting rotor to the given direction Q15 VAL32 VecAmp Q15 Q15_VAL32 RotorDir Q15 INT16U SendPeriod Q15 VAL32 CalcAnglelncrement INT8U Calculating the angle increment WhichMFT Q15 VAL32 NextSpeed_Q15 when motor runs 8 10 Others Function Description void DelaySoft FP32 DelayTime Soft delay void FeedDog BOOL EnHWDT BOOL Clear watch dog counter EnSWDT void ShortRelay INT8U WhichPort INT8U Short relay after delaying sometime WhichPin INT8U ActiveLevel FP32 DelayTime 77 8 11 Definition Interface AN706 00043 1v0 E Function Description Qn_Qm Qn n m Transform a Qn value to Qm value 78 AAN7O6 00043 1v0 E 9 Installation and Usage for MCL 9 1 Installation MCL can be installed from a compress package as shown in the following figure Because of the different version the installation package maybe has a different name ZR Figure 5 MCL ins

Download Pdf Manuals

image

Related Search

Related Contents

バッテリバックアップ時間の延長用として外付け大容量  geoTHERM exclusiv  Zotac ZT-61010-10M NVIDIA GeForce GTX 650 2GB graphics card  Quick Start Guía de inicio rápido Démarrage rapide  Descargar  Preparing statistical reports  取空 説明書  SYSTEM AIR CONDITIONER  Replay T1 Box Administrator Manual  

Copyright © All rights reserved.
Failed to retrieve file