This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

有ADS1118评估板用热电偶测温度的C示例程序吗?

Other Parts Discussed in Thread: ADS1118, OPA335

主页给的是labview的,没那个软件,估计也看不太懂,有用C写好的吗?

  •       论坛里面没有完整的。

  •         呃,不同系列的MCU用的程序还是不一样的吧.......想找那种完全可以参考的很难了

  •         可以考虑CCS5.3里面的例子程序,MCU与ADS1118主要就是四线SPI的通讯,在CCS5.3里面有现成的SPI通讯例子,通过Lauchpad连接ADS1118,ADS1118取六根线简易焊接就成,能快速测试。不过这种方式用MSP430F/G的MCU。

            寄存器配置都在手册上有,建议从低采样率和1倍放大可是测试。

            如果要是做评估的话,实验板严格按照手册制作。

            如果不打算做实验板的话,那还是买个EVM什么的吧。

  • 谢谢楼上几位,这里回复快多了。我先去做一个实验板,回来参考手册编写程序试试吧

  • 我这里有基于MSP430 Launchpad的C语言程序,这是为ADS1118 Booster Pack设计的程序。ADS1118 Booster Pack即将release.

    下面把关键代码贴在论坛里。如有问题也可以发email给我。

    我在头文件里定义了

    //Set the configuration to AIN0/AIN1, FS=+/-0.256, SS, DR=128sps, PULLUP on DOUT
    #define ADSCON_CH0 (0x8B8A)
    //Set the configuration to AIN2/AIN3, FS=+/-0.256, SS, DR=128sps, PULLUP on DOUT
    #define ADSCON_CH1 (0xBB8A)

    下面是C语言程序的两个关键函数。

    int WriteSPI(unsigned int config, int mode)
    {
    int msb;
    unsigned int temp;
    char dummy;

    //change the polarity of UCI0B_CLK to driver ADS1118.
    UCB0CTL1 |= UCSWRST;
    UCB0CTL0 = UCMSB + UCMST + UCMODE_0 + UCSYNC;
    UCB0CTL1 &= ~UCSWRST;

    temp = config;
    if (mode==1)
    temp = config | 0x8000; // mode == 1, means to read the data and start a new convertion.


    while(!(UC0IFG&UCB0TXIFG));
    UCB0TXBUF = (temp >> 8 ); // Write MSB of Confige
    while(!(UC0IFG&UCB0RXIFG));
    msb=UCB0RXBUF; // Read MSB of Result

    while(UCBUSY & UCB0STAT);

    while(!(UC0IFG&UCB0TXIFG));
    UCB0TXBUF= (temp & 0xff); // Write LSB of Config
    while(!(UC0IFG&UCB0RXIFG));
    msb = (msb << 8) | UCB0RXBUF ; //Read LSB of Result

    while(UCBUSY & UCB0STAT);

    while(!(UC0IFG&UCB0TXIFG));
    UCB0TXBUF = (temp >> 8 ); // Write MSB of Config
    while(!(UC0IFG&UCB0RXIFG));
    dummy=UCB0RXBUF; // Read MSB of Config

    while(UCBUSY & UCB0STAT);

    while(!(UC0IFG&UCB0TXIFG));
    UCB0TXBUF= (temp & 0xff); // Write LSB of Config
    while(!(UC0IFG&UCB0RXIFG));
    dummy=UCB0RXBUF; //Read LSB of Config

    while(UCBUSY & UCB0STAT);

    //change back the polarity of UCI0B_CLK for deriving LCD
    UCB0CTL1 |= UCSWRST;
    UCB0CTL0 = UCCKPL + UCMSB + UCMST + UCMODE_0 + UCSYNC;
    UCB0CTL1 &= ~UCSWRST;

    return msb;
    }

    /******************************************************************************
    * function: ADS_Read(unsigned int mode)
    * introduction: read the ADC result and tart a new conversion.
    * parameters:
    * mode = 0, ADS1118 is set to convert the voltage of integrated temperature sensor.
    * mode = 1, ADS1118 is set to convert the voltage of thermocouple.
    * return value:result of last conversion
    */
    int ADS_Read(unsigned int mode)
    {
    unsigned int tmp;
    int result;

    if(flag & BIT9)
    {
    if (mode==1) // Set the configuration to AIN0/AIN1, FS=+/-0.256, SS, DR=128sps, PULLUP on DOUT
    tmp = ADSCON_CH1;
    else
    tmp = ADSCON_CH1 + ADS1118_TS;// temperature sensor mode.DR=8sps, PULLUP on DOUT
    }
    else
    {
    if (mode==1) // Set the configuration to AIN0/AIN1, FS=+/-0.256, SS, DR=128sps, PULLUP on DOUT
    tmp = ADSCON_CH0;
    else
    tmp = ADSCON_CH0 + ADS1118_TS;// temperature sensor mode.DR=8sps, PULLUP on DOUT
    }

    // Reset CS low
    P2OUT &= ~BIT0;

    // Write Config
    result = WriteSPI(tmp,1);

    // Set CS high to end transaction
    P2OUT |= BIT0;

    return result;
    }

  • 画好原理图了,但是发现不好买元器件e络盟都没有,中发问了好多家也没有

  • 可以联系TI的授权代理商,如安富利,新晔等。

  • 有完整的示例程序吗?我现在写入寄存器能读出来,但是温度数值读出来不对。

  • 是片上的sensor不对,而是转化电压不对?

  • 是片上的sensor读数不对

  • 朋友,请问你用的缓冲器的运放是哪种,还有你加没加RC滤波的?我选用的OPA335,发现不知道是不是布线的问题,OPA335并不是跟随而是有微小的增益,感觉很困惑,求高人解惑?谢谢啦?

  • 有微小增益是因为环路幅频响应有上翘,而你输入的频率正好在上翘的部分。可以考虑用个RC滤波,但是需注意这样一来可能降低整个前端的带宽。方便的话,把电路图发上来,同时说明运放输入的共模,频率,摆幅等信息。

  • 请问第2个函数中的 flag 是什么?ADS1118_TS 是如何定义的?