STM32驅動模數轉換芯片ADS1120(基礎知識篇)第1篇


1. 先看下ADS1120的結構圖,ADS1120是個比較奇葩的ADC模數轉換器,因為比較適用於熱電阻之類的溫度采集器。看下圖,有個MUX多路復用器,應該是選擇兩個差分信號去測試,通過輸入多路復用器 (MUX) 實現的兩個差分輸入或四個單端輸入,一個低噪聲可編程增益放大器 (PGA),PGA,內部 PGA 提供高達128V/V 的增益。此 PGA 使得 ADS1120 非常適用於小型傳感器信號測量 應用 ,例如電阻式溫度檢測器(RTD)、熱電偶、熱敏電阻和橋式傳感器。

2. 看下寄存器,4個寄存器

3. 命令

4. 參考例程

VOID main(VOID) { signed long tData; WDTCTL = WDTPW + WDTHOLD;        // Stop watchdog timer
    Init_StartUp();                 // Initialize device
    ADS1220Init();                    // Initializes the SPI port pins as well as control
    ADS1220Config();                // Set base configuration for ADS1x20 device
    while(1) { /* Add specifc command for reading and writing ADS1220 here */
        /* dFlag is set in the interrupt service routine when DRDY triggers end of conversion */
        if (dflag)                        /* check if new data is available */ { tData = ADS1220ReadData();    /* get the data from the ADS1220 */ dFlag=0; } /* other routines could be added here, such as change the mux setting */ } /* end of while(1) */ } /* end of main() */

其中配置函數比較重要,如下是1增益,也是就不變,然后ADS1220_MUX_0_G=0x80

void ADS1220Config(void) { unsigned Temp; ADS1220ReadRegister(ADS1220_0_REGISTER, 0x01, &Temp); /* clear prev value; */ Temp &= 0x0f; Temp |= ADS1220_MUX_0_G; /* write the register value containing the new value back to the ADS */ ADS1220WriteRegister(ADS1220_0_REGISTER, 0x01, &Temp); ADS1220ReadRegister(ADS1220_1_REGISTER, 0x01, &Temp); /* clear prev DataRate code; */ Temp &= 0x1f; Temp |= (ADS1220_DR_600 + ADS1220_CC);        /* Set default start mode to 600sps and continuous conversions */
    /* write the register value containing the new value back to the ADS */ ADS1220WriteRegister(ADS1220_1_REGISTER, 0x01, &Temp); }

ADS1220_MUX_0_G=0x80,那么看下寄存器,什么意思呢?就是測量AIN0引腳的電平,得出一個結論,如果要想測量4個通道,那么需要依次次修改MUX[3:0],一個測量完再測試另外一個

讀數據,這個例程比較簡單,只測量了AIN0的電壓,我們的應用是需要做2線PT100鉑電阻溫度測量,所以需要繼續

long ADS1220ReadData(void) { long Data; /* assert CS to start transfer */ ADS1220AssertCS(1); /* send the command byte */ ADS1220SendByte(ADS1220_CMD_RDATA); /* get the conversion result */ Data = ADS1220ReceiveByte(); Data = (Data << 8) | ADS1220ReceiveByte(); /* sign extend data */
   if (Data & 0x8000) Data |= 0xffff0000; /* de-assert CS */ ADS1220AssertCS(0); return Data; }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM