主页给的是labview的,没那个软件,估计也看不太懂,有用C写好的吗?
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.
hi haichao shen,
没有非常规范的C样例程序,建议你参考 http://e2e.ti.com/support/data_converters/precision_data_converters/f/73/t/231496.aspx
谢谢楼上几位,这里回复快多了。我先去做一个实验板,回来参考手册编写程序试试吧
我这里有基于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络盟都没有,中发问了好多家也没有
有完整的示例程序吗?我现在写入寄存器能读出来,但是温度数值读出来不对。
有微小增益是因为环路幅频响应有上翘,而你输入的频率正好在上翘的部分。可以考虑用个RC滤波,但是需注意这样一来可能降低整个前端的带宽。方便的话,把电路图发上来,同时说明运放输入的共模,频率,摆幅等信息。