【正文】
SPLCNT:采樣計數(shù)選擇位,設(shè)置范圍是 0- 15, 0和 1都將被認為是一次。當(dāng)然位置改變會產(chǎn)生一個位置改變的中斷,如果此中斷使能的情 況下,對捕獲到的數(shù)值就可以在位置改變中斷時做出相應(yīng)的處理。使能時,對這些引腳上的輸入信號進行采樣,將結(jié)果鎖存入 POS_DectData 寄存器的 PDR [2:0]位中,一旦禁止該功能, PDR [2:0]中仍保持了先前的狀態(tài)。外部位置信號必須連續(xù)的以與采樣計數(shù)的設(shè)置相匹配的數(shù)值采樣,這樣才算作有效的位置信號。 // 上升沿計數(shù) P_TMR0_Ctrl = 3。這里的設(shè)置將決定速度測量的精度和范圍。清除源的設(shè)置將影響 BLDC 的電角度向機械角度的換算和 BLDC 轉(zhuǎn)速測量的精度。分別是每六次外文翻譯(譯文) 24 P_POSx_DectData(x = 0, 1)變化清除一次 TCNT、每三次 P_POSx_DectData(x = 0, 1)變化清除一次 TCNT 和每一次 P_POSx_DectData(x = 0, 1)變化清除一次 TCNT,也可以說成 BLDC 每轉(zhuǎn)過 360176。輸入捕獲和一般意義上的還有所不同,因為我們用 PDC 位置改變中斷來捕獲在兩次位置改變過程中所經(jīng)歷的時間,這個 時間是以一定頻率脈沖做為時鐘源來計數(shù)得到的,所以要對相關(guān)計數(shù)的事項來進行設(shè)置。若選擇 FCK/1為計數(shù)時鐘,如果為雙沿觸發(fā),那么計數(shù)器將以上升沿方式工作。 0000 = 標準模式 (連續(xù)遞增計數(shù) ) 0100 = 相位計數(shù)模式 1 0101 = 相位計數(shù)模式 2 0110 = 相位計數(shù)模式 3 0111 = 相位計數(shù)模式 4 1x0x = 邊沿 PWM模式 (連續(xù)遞增計數(shù), PWM輸出 ) 1x1x = 中心沿 PWM模式 (連續(xù)遞增 /遞減計數(shù), PWM輸出 ) 第 9:8 位 CLEGS:計數(shù)器清除邊沿選擇位,用于輸入捕獲模式下選擇計數(shù)器清除邊沿。 在測速中我們可能要用到的寄存器有:定時器 0/1控制寄存器 P_TMRx_Ctrl(x = 0, 1)、定時器 0/1 位置偵測控制寄存器 P_POSx_DectCtrl(x = 0, 1)、定時器 0/1輸入 /輸出控制寄存器 P_TMRx_IOCtrl(x = 0, 1)、定時器 0/1 中斷使能寄存器P_TMRx_INT(x = 0, 1)。而直流無刷電機即是依據(jù)位置信 息來改變電流相位。 //Send data to DMC } } Main Process Description The main program performs system initialization and DMC data detection. While the DMC data detection can also be performed in a timer interrupt with a certain frequency. Figure 31 shows the coding flow. Figure 31 Main Process ISR Description In PDC interrupt, system reads and filters the data, then calculates the motor speed. The coding flow is shown as Figure 32 . Start System Initialization 【 API: Spmc75_System_Init()】 Start/stop mand detection 【 API: MC75_DMC_UART_Service()】 外文翻譯(原文) 16 Figure 32 ISR Process Hardware This example is designed for the purpose of study and reference, so we simply need to input a position signal to test the system. The hardware connection is shown as Figure 33 . Figure 33 Test Hardware Connection Y Interrupt vector PDC ISR 【 API: Spmc75_PDCETSPD_ISR()】 Rti PDC int ? N 外文翻譯(原文) 17 Where, the position signal can be generated by MCU or special timing logic circuit instead of necessarily being the real signal from BLDC (see Figure 34 and Figure 35 ). The frequency of position detection change can be adjusted by the potentiometer or ADC in MCU system Figure 34 Hall Signal Figure 34 shows the three position signals timing with the sequence of 010b, 011b, 001b, 101b, 100b, 110b. Figure 35 Hall signal Figure 35 shows Hall3, Hall2, Hall1 timing with the sequence of 110b, 100b, 101b, 001b, 011b, 010b. It is the same to test in real BLDC. The two timings present the different motor directions: move forward or move backward. The file in Appendix shows the code for simulating hall signal with SPMC75F2413A. We can use ADC0 voltage to simulate the speed variation, where IOD15, IOD14 and IOD13 are corresponding to Hall3, Hall2 and Hall1 respectively and IOA0/AN0 is used for ADC conversion to adjust the simulated speed. 外文翻譯(譯文) 19 用 SPMC75 的 PDC 定時器做 BLDC 電機的速度檢測 一、 BLDC 的速度測算 1 直流無刷電動機概述 直流無刷電動機采用電子換向器替代了傳統(tǒng)直流電動機的機械換向裝置,從而 克服了電刷和換向器所引起的噪聲、火花、電磁干擾、壽命短等一系列弊病。 // Average the accumulation data original = (UInt16)(summation SHIFTDIV)。 original MAXRPM) { //Accumulate the captured data and perform moving filter summation = *ptr。 P_TMR0_Status, = 1。 } } Subfunction for speed measurement define TMRPSFCK (+6)/64 //Counter clock source define PAIRPOLE 2 //BLDC pole pairs define PDCCLEAR 1 //CNT clear source define SPDLIMIT 5000 //Define the highest motor speed to avoid the disturbance due to sharp pulse define RADIX (UInt32)((TMRPSFCK*60*PDCCLEAR) //(6*PAIRPOLE)) define MAXRPM (UInt16)(RADIX/SPDLIMIT) static UInt16 a Filter[CAPBSIZE]。amp。 3 Design Tips Demo Listing /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ // Example /*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ 外文翻譯(原文) 13 include include include include main() { Spmc75_System_Init()。 // Sample Delay Speed Calculation In order to obtain the exact parameters, the data must be filtered after captured. There are many filter algorithms, such as lowpass filter, moving average filter, median filter, average filter, limiting filtering, firstorder filter, moving average filtering, etc. In general, the data can be considered valid after processed by these filters. Then the speed can be calculated by substituting these parameters data in the formula. Assume Fcap is PDC capture clock frequency。 // Count on FCK/32 P_POS0_DectCtrl, = 1。 // Normal Counting mode P_TMR0_Ctrl, = 6。 // TCNT cleared by P_POSx_DectData (x = 0, 1) // Each time position detection data change P_TMR0_Ctrl, = 0。 // Sample regularly P_POS0_DectCtrl, = 10。 p is the polepair of BLDC rotor。 //System initialization while(1) { MC75_DMC_UART_Service()。 P_TMR0_INT, ) { Spmc75_PDCETSPD_ISR()。 //Moving average filter data static UInt16 *ptr = a Filter。 // Clear interrupt flag original = P_TMR0_TGRA, W。 *ptr = original。 uiSpeed = (UInt32)RADIX/original。由于直流無刷電動機既具備交流電動機的結(jié)構(gòu)簡單、運行可靠、維護方便等一系列優(yōu)點,又具有直流電動機的運行效率高、無勵磁損耗以及調(diào)速性能好等諸多優(yōu)點,故其在工業(yè)領(lǐng)域中的應(yīng)用越來越廣泛。如圖 11所示 PDC 定時器 0和定時器 1的整體框圖。這里將著重介紹 P_TMRx_Ctrl 寄存器和 P_POSx_DectCtrl寄存器的在測速方面使用時的設(shè)置。 00 =不清除 01 =上升沿 10 =下降沿 11 = 雙沿 第 7:5 位 CCLS:計數(shù)器清除源選擇位,用于選擇 TCNT的計數(shù)清除源。 00 = 上升沿計數(shù) 01 = 下降沿計數(shù) 1X = 雙沿計數(shù) 第 2:0 位 TMRPS:定時器分頻選擇位,用于選擇 TCNT計數(shù)時鐘源。 MODE: MODE 為定時器操作模式設(shè)置位,有七種模式可以設(shè)置,然而這里只能是設(shè)置為 0000=標準模式(連