[求助] ads1220

wtyiyou   2017-11-3 16:44 楼主
1.超时时间是怎么设定的?你看是不是这样的,1*数据更新速率相对应的时钟数目/256KHZ,是这样的吗?比如我设置正常模式,数据采集是20sps,DRDY转换完时
钟是204850超时时间是不是1*204850/256。
2.ADS1220初始化两种情况:
A.采集热电偶,冷端是PT100,ADS1220初始化是我一次性配置完所有参数,然后切换通道读取通道数据.
B.第一步测量热电偶的电压,配置和热电偶相关的,不配置关于PT100的,然后采集读取数据。第二步配置和PT100相关的,不配置和热电偶相关的,然后采集读取数据。通过两次的采集计算温度。
这两种采用哪种配置呀?看DEMO都糊涂了。TI 的DEMO和我前面说的都不一样,TI的DEMO为什么这样,有什么好处吗?
void main (void)
{
Setup_SPI_Master ();
ADS1220_Reset();
Setup_ADS1220 (ADS1220_MUX_AIN3_AIN2, ADS1220_OP_MODE_NORMAL,
ADS1220_CONVERSION_SINGLE_SHOT, ADS1220_DATA_RATE_20SPS, ADS1220_GAIN_32, ADS1220_USE_PGA,
ADS1220_IDAC1_AIN3, ADS1220_IDAC2_DISABLED, ADS1220_IDAC_CURRENT_250_UA,ADS1220_VREF_EXT_REF0_PINS);
__delay_cycles(CPU_CLK/2);
while (1)
{
// Configure ADS1220 for first RTD measurement
Setup_ADS1220 (ADS1220_MUX_AIN3_AIN2, ADS1220_OP_MODE_NORMAL,
ADS1220_CONVERSION_SINGLE_SHOT, ADS1220_DATA_RATE_20SPS, ADS1220_GAIN_32, ADS1220_USE_PGA,
ADS1220_IDAC1_AIN3, ADS1220_IDAC2_DISABLED, ADS1220_IDAC_CURRENT_250_UA,ADS1220_VREF_EXT_REF0_PINS);
__delay_cycles(CPU_CLK/1000);
ReadConversionData = 0;
ADS1220_Start ();
while (!ReadConversionData); // Wait for Data Ready interrupt
ADS1220_Get_RTD_Conversion_Data_Calibrated (&ADS1220RTDdata); // Get the temperature data with the calibration value subtracted
// Configure ADS1220 for second chopped RTD measurement
Setup_ADS1220 (ADS1220_MUX_AIN2_AIN3, ADS1220_OP_MODE_NORMAL,
ADS1220_CONVERSION_SINGLE_SHOT, ADS1220_DATA_RATE_20SPS, ADS1220_GAIN_32, ADS1220_USE_PGA,
ADS1220_IDAC1_AIN3, ADS1220_IDAC2_DISABLED, ADS1220_IDAC_CURRENT_250_UA,ADS1220_VREF_EXT_REF0_PINS);
RTDtemperature = ADS1220RTDdata;
__delay_cycles(CPU_CLK/1000); //
ReadConversionData = 0;
ADS1220_Start (); // Only one start needed for Continuous Mode
while (!ReadConversionData); // Wait for Data Ready interrupt
ADS1220_Get_RTD_Conversion_Data_Calibrated (&ADS1220RTDdata); // Get the temperature data with the calibration value subtracted
// Configure ADS1220 for first Thermocouple measurements
Setup_ADS1220 (ADS1220_MUX_AIN0_AIN1, ADS1220_OP_MODE_NORMAL,
ADS1220_CONVERSION_SINGLE_SHOT, ADS1220_DATA_RATE_20SPS, ADS1220_GAIN_32, ADS1220_USE_PGA,
ADS1220_IDAC1_AIN3, ADS1220_IDAC2_DISABLED, ADS1220_IDAC_CURRENT_250_UA,ADS1220_VREF_INTERNAL);
RTDtemperature += ADS1220RTDdata; //now averaging RTD results
RTDtemperature = RTDtemperature/2;
RTDtemperature = interpolateRTDTemperatureValue (RTDtemperature); // Get the RTD temperature and convert into millidegrees C
//cold junction compensation
CJCcode = calc_CJC(RTDtemperature); // convert RTD temperature into thermocouple voltage
__delay_cycles(CPU_CLK/1000); //
ReadConversionData = 0;
ADS1220_Start ();
while (!ReadConversionData); // Wait for Data Ready interrupt
ADS1220_Get_TC_Conversion_Data_Calibrated (&ADS1220TCdata); // Get the temperature data with the calibration value subtracted
TCtemperature = ADS1220TCdata/2;

// Configure ADS1220 for second chopped Thermocouple measurements
Setup_ADS1220 (ADS1220_MUX_AIN1_AIN0, ADS1220_OP_MODE_NORMAL,
ADS1220_CONVERSION_SINGLE_SHOT, ADS1220_DATA_RATE_20SPS, ADS1220_GAIN_32, ADS1220_USE_PGA,
ADS1220_IDAC1_AIN3, ADS1220_IDAC2_DISABLED, ADS1220_IDAC_CURRENT_250_UA,ADS1220_VREF_INTERNAL);
__delay_cycles(CPU_CLK/1000);
ReadConversionData = 0;
ADS1220_Start (); // Only one start needed for Continuous Mode
while (!ReadConversionData); // Wait for Data Ready interrupt
ADS1220_Get_TC_Conversion_Data_Calibrated (&ADS1220TCdata); // Get the temperature data with the calibration value subtracted
ADS1220TCdata = ADS1220TCdata/2;
TCtemperature -= ADS1220TCdata;
TCtemperature += CJCcode; //CJC
TCtemperature = interpolateTCTemperatureValue (TCtemperature); // Get the temperature and convert into millidegrees C
}
这是TI的DEMO 也是做热电偶采集,冷端补偿是PT100.这里面的初始化参数,有一样的也有不一样的,我看了它的初始化糊涂了。希望大家给解释一下

回复评论 (5)

我看了一下手册,在使用内部振荡器时 fClk (ADC时钟频率) = 4.096MHz
正常和占空比模式fMOD(调制器以调制器时钟频率)=4.096/16 = 256KHz

QQ图片20171103192958.png
SPI超时时间正常模式,占空比模式 = 13955 fMOD
Turbo 模式= 27910 fMOD
以正常和占空比模式为例,fMOD为256KHz,1Hz对应的时间为3.9us
13955个fMOD=3.9us*13955 = 54ms

QQ图片20171103192536.png

虾扯蛋,蛋扯虾,虾扯蛋扯虾
点赞  2017-11-3 19:40
给楼主加油
点赞  2017-11-3 19:45
第二个问题
我从官方下了一下你说的这个代码,看了一下也没看懂
官方代码在初始化没进while时先配置了一次
1.ADS1220_MUX_AIN3_AIN2
注释是// Configure ADS1220 for first measurement
然后又配置了一次RTD
2.ADS1220_MUX_AIN3_AIN2
注释是Configure ADS1220 for first RTD measurement
比对了一下,这两个配置是一样的,按理应该省去第一次

然后在while里启动一次转换
读取了上一次配置转换后的结果
然后配置一次RTD
3.ADS1220_MUX_AIN2_AIN3
这次的AIN+和AIN-和上一次是反的

把上一次的转换结果2保存在RTDtemperature中
启动RTD第3次配置的转换
读取第3次配置转换后的结果

配置TC
4.ADS1220_MUX_AIN0_AIN1
将RTD第2次结果和第1次结果相加再除2
注释是//now averaging  RTD results
意思是求平均,不过如果两次采样结果输入极性是相反的,结果相加理论上应该为零
这个不太理解

通过RTD结果计算RTD温度
通过RTD温度计算冷端补偿码

启动第4次配置转换
读取第4次结果

第4次结果除2
配置TC
5.ADS1220_MUX_AIN1_AIN0(与上一次极性相反)
启动转换
读取第5次配置转换后的结果
将第5次结果除2
将2次结果相减
因为2次结果极性相反,除2再相减应该可以得到2个结果的平均值

将TC结果和冷端补偿码相加
通过补偿后的TC结果得到TC(热电偶)温度值



读取ADS1220内部温度传感器………………………………
虾扯蛋,蛋扯虾,虾扯蛋扯虾
点赞  2017-11-3 19:55
谢谢,不过最主要的是第二个问题,第一个我觉得我的理解是对的
点赞  2017-11-6 08:35
对了,咨询大家一个问题,一般rtd的故障检测是硬件做的还是软件做的?我觉得是软件做的,硬件不知道是怎么样的思路,希望知道的朋友给解释一下
点赞  2017-11-6 08:37
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复