MAXQ3180入門:寄存器配置
雖然多相、多功能電能計(jì)量AFE芯片MAXQ3180具有很多配置寄存器,但僅需配置幾個(gè)寄存器即可實(shí)現(xiàn)基本的測(cè)量功能。本篇應(yīng)用筆記介紹如何成功配置這幾個(gè)寄存器,列舉了必須配置的寄存器,并給出了哪些寄存器必須使能,哪些寄存器不用修改。
簡(jiǎn)介
MAXQ3180是一款復(fù)雜的三相電能計(jì)量IC,可在很多計(jì)量環(huán)境中應(yīng)用。為了適應(yīng)各種復(fù)雜的計(jì)量環(huán)境,MAXQ3180共有68個(gè)配置寄存器可供修改。正確理解如何使用所有寄存器是一項(xiàng)艱巨任務(wù),但幸運(yùn)的是在大多數(shù)情況下并不需要配置全部68個(gè)寄存器。實(shí)際上在通常環(huán)境下僅需配置10個(gè)寄存器即可實(shí)現(xiàn)MAXQ3180的基本功能。
本篇應(yīng)用筆記介紹了必須進(jìn)行初始化設(shè)置的MAXQ3180寄存器,以及在使用特定功能時(shí)需要初始化的寄存器,有些寄存器在大多數(shù)應(yīng)用中都可以不設(shè)置。
基本初始化過(guò)程
MAXQ3180上電后即開(kāi)始測(cè)量電壓、電流、功率,計(jì)量電能。所以,只有正確配置MAXQ3180,使其與傳感器相匹配才能得出正確、有意義的讀數(shù)。
MAXQ3180執(zhí)行兩步測(cè)量:第一步,讀取物理參數(shù)(如:電壓、電流、功率等),在內(nèi)部用一種“電表單位”表示;第二步,將用“電表單位”表示的參數(shù)轉(zhuǎn)換成現(xiàn)實(shí)世界中的計(jì)量單位,如伏特,安培和瓦。
讀取物理參數(shù)(計(jì)量單位)
MAXQ3180第一步先執(zhí)行所要求的測(cè)量,并在內(nèi)部用適合測(cè)量電路的“電表單位”精確表示,隨后的校準(zhǔn)過(guò)程將確保伏特、安培、瓦、千瓦時(shí)等計(jì)量單位可以用內(nèi)部“電表單位”精確表示。一旦電流、電壓、功率、電能可以用內(nèi)部“電表單位”精確表示,器件必須將其轉(zhuǎn)換成有實(shí)際意義的單位。
我們以電壓校準(zhǔn)舉例,但其過(guò)程也適用于電流、功率和電能。假設(shè)一個(gè)600:1的電阻分壓網(wǎng)絡(luò)作為輸入電路,這意味著600V直流電壓作用在電阻分壓器輸入端,其分壓輸出約為1V,MAXQ3180的電流和電壓輸入可分為224級(jí),所以對(duì)于600V直流輸入,輸出編碼每改變一個(gè)最低有效位(LSB),對(duì)應(yīng)輸入電壓變化600 × 2-24伏,即35.8μV。換言之,如果輸入120VRMS正弦波,則原始RMS電壓寄存器讀數(shù)為120/(600 × 2-24),或3,355,443 (0x33 3333)。
由于輸入級(jí)用于放大和濾波的無(wú)源器件參數(shù)以及輸入ADC自身參數(shù)的離散性,ADC讀數(shù)有可能和期望值不同,所以,需要輸入一個(gè)修正系數(shù),該修正系數(shù)位于x.V_GAIN (x代表某一相:A、B或C)寄存器。本例中,如果原始RMS寄存器讀數(shù)為3,000,000 (0x2D C6C0),說(shuō)明需要的增益為3,355,443/3,000,000 = 1.12。
增益調(diào)整寄存器值設(shè)為0x4000 (16,384)時(shí)增益為1,如需額外增益,則需要增大該值。本例中增益寄存器需設(shè)為16,384 × (3,355,443/3,000,000) = 18,325 (0x4795)。
由此完成了第一步,使電壓讀數(shù)能夠精確反映以“電表單位”表示的電壓測(cè)量真實(shí)結(jié)果。第二步,將一個(gè)LSB等于35.8μV的系統(tǒng)轉(zhuǎn)換成一個(gè)LSB等于1mV的系統(tǒng)。
計(jì)算轉(zhuǎn)換系數(shù)
目前遇到的問(wèn)題是MAXQ3180只提供整數(shù)乘法操作,而實(shí)現(xiàn)這一轉(zhuǎn)換需要除以一個(gè)非整數(shù),即1,000/35.8。解決方案是選取一個(gè)系數(shù),使目標(biāo)單位乘以一個(gè)2的整數(shù)次冪。在本例中,一個(gè)LSB將不再是1mV,而是1mV/216,即15.3nV。所以進(jìn)行測(cè)量時(shí),丟掉低16位,剩下的就是以毫伏表示的電壓。
而轉(zhuǎn)換系數(shù)就是原始LSB值(35.8μV)除以目標(biāo)LSB值(15.3nV),即2,344 (0x0928),將該值寫入VOLT_CC寄存器。
這樣,每次讀取V.A虛擬寄存器時(shí),MAXQ3180會(huì)將A.VRMS寄存器值乘以2,344,然后報(bào)告結(jié)果。該結(jié)果就是以1mV/65,536為單位的RMS電壓值。主機(jī)軟件丟掉低16位,直接就可以得到以毫伏為單位的RMS電壓值。
對(duì)于多數(shù)應(yīng)用來(lái)說(shuō),只需先校準(zhǔn)(得到正確的VRMS和IRMS),然后計(jì)算轉(zhuǎn)換系數(shù)(分別對(duì)應(yīng)于電壓、電流、功率和電能)。
其它可選初始化過(guò)程
按上述步驟初始化,就可得到電壓、電流、電能、功率的精確讀數(shù)。但MAXQ3180還可提供許多其它功能。
中斷
MAXQ3180有一套復(fù)雜的中斷子系統(tǒng)來(lái)通知上位機(jī)出現(xiàn)異常,可以觸發(fā)中斷的條件包括:
- 某一相有功或無(wú)功電能流向改變。
- 某一相檢測(cè)到無(wú)過(guò)零事件時(shí)間超過(guò)某一閾值。
- 某一相檢測(cè)到欠壓、過(guò)壓或過(guò)流故障。
- 某一相的某一電能寄存器溢出(通常表示需要進(jìn)行累加操作)。
- 校驗(yàn)和配置發(fā)生改變。
- MAXQ3180電源即將失效。
關(guān)于中斷子系統(tǒng)的更多信息,請(qǐng)參考MAXQ3180的參考設(shè)計(jì)。
脈沖配置
計(jì)量脈沖通常用于遞增機(jī)械計(jì)數(shù)器或電能累加寄存器。MAXQ3180能夠支持這兩種計(jì)量脈沖,每一種都有一個(gè)配置寄存器用于選擇脈沖參數(shù),一個(gè)閾值寄存器用于設(shè)置電表常數(shù),一個(gè)脈沖寬度寄存器用于設(shè)置脈沖寬度。關(guān)于計(jì)量脈沖子系統(tǒng)的更多信息,請(qǐng)參考MAXQ3180的參考設(shè)計(jì)。
提高精度
使用理想電流和電壓傳感器,MAXQ3180可以在很寬的輸入范圍內(nèi)實(shí)現(xiàn)極高精度。但實(shí)際上電流傳感器很少有理想的,在測(cè)量范圍的兩端會(huì)有非線性;通常傳感器的相位響應(yīng)還會(huì)隨電流變化而改變。需要通過(guò)配置MAXQ3180寄存器對(duì)其進(jìn)行補(bǔ)償以提高精度。
MAXQ3180有兩個(gè)精確校準(zhǔn)機(jī)制來(lái)補(bǔ)償傳感器的非線性。第一個(gè)精確校準(zhǔn)機(jī)制是在低電流時(shí)單獨(dú)設(shè)置增益,在高、低電流下分別設(shè)置失調(diào)。這樣就可以實(shí)現(xiàn)高、低電流下增益和失調(diào)最多四個(gè)點(diǎn)的校準(zhǔn)。
第二個(gè)精確校準(zhǔn)機(jī)制是微調(diào)電壓-電流的相位失調(diào)。在這一機(jī)制下,通過(guò)設(shè)置兩個(gè)閾值將電流范圍分成三段。低于兩個(gè)閾值為第一段,兩個(gè)閾值之間為第二段,高于兩個(gè)閾值為第三段。A、B、C每一相的每一段相位失調(diào)都可以單獨(dú)設(shè)置。
關(guān)于使用精確校準(zhǔn)寄存器提高M(jìn)AXQ3180精度的更多信息請(qǐng)參考MAXQ3180參考設(shè)計(jì)。
總結(jié)
MAXQ3180是一個(gè)靈活的電表模擬前端(AFE),具有靈活配置,支持多種電能計(jì)量應(yīng)用。僅需配置少數(shù)幾個(gè)寄存器(主要是校準(zhǔn)和增益寄存器),系統(tǒng)即可實(shí)現(xiàn)高精度的電能計(jì)量功能。
圖例 | |
???????????? ???????????????????? |
該顏色代表在通常應(yīng)用中必須初始化的寄存器。 |
???????????? ???????????????????? |
該顏色代表僅在使用MAXQ3180特定功能時(shí)需配置的寄存器,在許多應(yīng)用中可能無(wú)需配置。 |
???????????? ???????????????????? |
該顏色代表在大多數(shù)應(yīng)用中無(wú)需配置的寄存器。 |
Address | Default | Name | Comment |
0x002 | 0x00 | OPMODE1 | Set this register only if your connection mode is not standard delta or wye, if you wish to reverse pulse output polarity, or if you wish to enable communication CRC. |
0x003 | 0x00 | OPMODE2 | This register contains bits for features that are infrequently used. |
0x006 | 0x0000 | IRQMASK | Load only if interrupts are used. |
0x010 | 0x0000 | AUX_CFG | Load only if the auxiliary channel is used (typically specialized applications). |
0x014 | 0x0001 | VOLT_CC | Conversion constant for meter unit to real units conversion. |
0x016 | 0x0001 | AMP_CC | Conversion constant for meter unit to real units conversion. |
0x018 | 0x0001 | PWR_CC | Conversion constant for meter unit to real units conversion. |
0x01A | 0x0001 | ENR_CC | Conversion constant for meter unit to real units conversion. |
0x01C | 0x0010 | CYCNT | Load only if the DSP cycle time must be set to something other than 16 line cycles. |
0x01E | 0x00 | PLSCFG1 | Load if meter pulses are in use. |
0x01F | 0x00 | PLSCFG2 | Load if meter pulses are in use. |
0x020 | 0x009C | PLS1_WD | Load if meter pulses are in use. |
0x022 | 0x00100000 | THR1 | Load if meter pulses are in use. |
0x026 | 0x009C | PLS2_WD | Load if meter pulses are in use. |
0x028 | 0x00100000 | THR2 | Load if meter pulses are in use. |
0x02C | 0x00C8 | REJ_NS | Line-cycle filter; handle with care! |
0x02E | 0x4000 | AVG_NS | Line-cycle filter; handle with care! |
0x030 | 0x4000 | AVG_C | Signal-path filter; handle with care! |
0x032 | 0x00C8 | HPF_C | Signal-path filter; handle with care! |
0x034 | 0x0091 | B0FUND | Fundamental-mode filter; handle with care! |
0x036 | 0x000003B6 | A1FUND | Fundamental-mode filter; handle with care! |
0x03A | 0x0091 | B0HARM | Harmonic-mode filter; handle with care! |
0x03C | 0x000003B6 | A1HARM | Harmonic-mode filter; handle with care! |
0x040 | 0x03E80000 | Number of ADC frames per DSP cycle; automatically calculated and seldom needs manual intervention. | |
0x044 | 0xFFFF | OCLVL | Load only if overcurrent limits are used. |
0x046 | 0xFFFF | OVLVL | Load only if overvoltage limits are used. |
0x048 | 0x0000 | UVLVL | Load only if undervoltage limits are used. |
0x04A | 0x0003 | NOLOAD | Modify to match with your design specification. |
0x054 | 0x2328 | NZX_TIMO | No zero-crossing timeout; generally no need to adjust this. |
0x056 | 0x03E8 | COM_TIMO | Communications timeout; generally no need to adjust this. |
0x058 | 0x0005 | ACC_TIMO | Energy accumulation startup delay; generally no need to reload this. |
0x05A | 0x0B00 | ZC_LPF | Zero-crossing filter; handle with care! |
0x05C | 0x0000 | I1THR | Set only if multirange phase compensation is desired. |
0x05E | 0x0000 | I2THR | Set only if multirange phase compensation is desired. |
0x12E | 0x0000 | N_GAIN | Neutral gain; adjust only if neutral current monitoring is used. |
0x130 | 0x0000 | A.I_GAIN | Primary calibration register for phase A current. |
0x132 | 0x0000 | A.V_GAIN | Primary calibration register for phase A voltage. |
0x134 | 0x0000 | A.E_GAIN | Primary calibration register for phase A energy and power. |
0x136 | 0x0000 | A.EF_GAIN | Adjust only if fundamental mode is used. |
0x138 | 0x0000 | A.OFFS_HI | Secondary calibration for enhanced accuracy: phase A current offset, high range. |
0x13A | 0x0000 | A.GAIN_LO | Secondary calibration for enhanced accuracy: phase A current gain, low range. |
0x13C | 0x0000 | A.OFFS_LO | Secondary calibration for enhanced accuracy: phase A current offset, low range. |
0x13E | 0x0000 | A.PA0 | Secondary calibration for improved phase compensation. |
0x140 | 0x0000 | A.PA1 | Secondary calibration for improved phase compensation. |
0x142 | 0x0000 | A.PA2 | Secondary calibration for improved phase compensation. |
0x145 | 0x00 | A.MASK | Set only if interrupts from this phase are desired. |
0x21C | 0x0000 | B.I_GAIN | Primary calibration register for phase B current. |
0x21E | 0x0000 | B.V_GAIN | Primary calibration register for phase B voltage. |
0x220 | 0x0000 | B.E_GAIN | Primary calibration register for phase B energy and power. |
0x222 | 0x0000 | B.EF_GAIN | Adjust only if fundamental mode is used. |
0x224 | 0x0000 | B.OFFS_HI | Secondary calibration for enhanced accuracy: phase B current offset, high range. |
0x226 | 0x0000 | B.GAIN_LO | Secondary calibration for enhanced accuracy: phase B current gain, low range. |
0x228 | 0x0000 | B.OFFS_LO | Secondary calibration for enhanced accuracy: phase B current offset, low range. |
0x22A | 0x0000 | B.PA0 | Secondary calibration for improved phase compensation. |
0x22C | 0x0000 | B.PA1 | Secondary calibration for improved phase compensation. |
0x22E | 0x0000 | B.PA2 | Secondary calibration for improved phase compensation. |
0x231 | 0x00 | B.MASK | Set only if interrupts from this phase are desired. |
0x308 | 0x0000 | C.I_GAIN | Primary calibration register for phase C current. |
0x30A | 0x0000 | C.V_GAIN | Primary calibration register for phase C voltage. |
0x30C | 0x0000 | C.E_GAIN | Primary calibration register for phase C energy and power. |
0x30E | 0x0000 | C.EF_GAIN | Adjust only if fundamental mode is used. |
0x310 | 0x0000 | C.OFFS_HI | Secondary calibration for enhanced accuracy: phase C current offset, high range. |
0x312 | 0x0000 | C.GAIN_LO | Secondary calibration for enhanced accuracy: phase C current gain, low range. |
0x314 | 0x0000 | C.OFFS_LO | Secondary calibration for enhanced accuracy: phase C current offset, low range. |
0x316 | 0x0000 | C.PA0 | Secondary calibration for improved phase compensation. |
0x318 | 0x0000 | C.PA1 | Secondary calibration for improved phase compensation. |
0x31A | 0x0000 | C.PA2 | Secondary calibration for improved phase compensation. |
0x31D | 0x00 | C.MASK | Set only if interrupts from this phase are desired. |
評(píng)論
查看更多