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:读取环境温度与放大器时出错;热电偶同时!!

Guru**** 2540720 points
Other Parts Discussed in Thread: ADS1118

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/data-converters-group/data-converters/f/data-converters-forum/731755/ads1118-error-when-reading-ambient-temperature-thermocouple-simultaneously

器件型号:ADS1118

你(们)好

我正在使用 ATMEGA32A 和 ADS1118从事1000度的熔炉控制器工作。 我从 github.com/hydrosense 下载了 ads1118库。当我单独读取环境温度或热电偶时、一切都正常、但当我想同时读取这两者时、数字会相等。 我的意思是环境温度和热电偶显示相同的数字(内部传感器值)。 如果有人能提供帮助,将不胜感激。

此致

#include 
#include 
#include 
#include "Ads1118.h"
#include 



CONST int LS100_LED = 8;
CONST int LS200_LED = 9;
CONST int Metalcast_LED = 10;
CONST int HP_LED = 11;
CONST int MP_LED = 12;
CONST int LP_LED = 13;
CONST int LS100_SW = 24;
CONST int LS200_SW = 25;
CONST = 26 INT_SW
;CONST = 27;CONST = INT_SW;CONST = INT_SW;CONST = INT_SW
const int MP_SW = 28;
const int LP_SW = 30;
const int start_SW = 29;
const int stop_SW = 31;
const int SSR = 3;
const int 继电器= 4;
const int 蜂鸣器= 2;
//const int TEMP = 1;//ADS1232/const
int MUX = 0; //ADS1232
//const int GAIN0 = 23;//ADS1232
//const int GAIN1 = 22;//ADS1232
//const int speed = 21;//ADS1232
//const int PWDN = 20;//ADS1232//const
int SCLK = 15;//ADS1232 /const



int 缓冲区= 10;/dprom = 0.90;/int float = 10;/dm = d.int EEPROM
unsigned long lastmillis1 = 0;
unsigned long lastmillis2 = 0;
unsigned long lastmillis3 = 0;
unsigned long lastmillis4 = 0;
float Ctemp = 0;
// int Eraser = 0b10000000;
// int Prescaler = 0b01101010;

LiquidCrystal _I2C LCD (0x27、2、1、0、0、0、 4、5、6、7、3、 正极);// I2C 地址可以是0x3F 或0x27

Ads1118 ads1118 (1);

void setup ()
{
pinMode (LS100_LED、输出);
pinMode (LS200_LED、输出);
pinMode (Metalcast_LED、 输出);
pinMode (HP_LED、输出);
pinMode (MP_LED、输出);
引脚模式(LP_LED、输出);
引脚模式(LS100_SW、INPULLUP);
引脚模式(LS200_SW、 Input_pullup);
pinMode (Metalcast_SW、input_pullup);
pinMode (HP_SW、input_pullup);
引脚模式(MP_SW、INPUT_PULLUP);
引脚模式(LP_SW、INPULLUP);
引脚模式(START_SW、 INPUT_PULLUP);
引脚模式(STOP_SW、INPULLUP);
引脚模式(蜂鸣器、输出);;
pinMode (继电器、输出);
pinMode (SSR、输出);
// pinMode (TEMP、 输出);//ADS1232
// pinMode (MUX、输出);//ADS1232
// pinMode (GAIN0、输出); //ADS1232
// pinMode (GAIN1、OUTPUT);//ADS1232
// pinMode (SPEED、OUTPUT);//ADS1232
// pinMode (PWDN、 输出);//ADS1232
// pinMode (SCLK、输出);//ADS1232
// pinMode (DRDY、输入); //ADS1232
// digitalWrite (TEMP、LOW);
// digitalWrite (MUX、LOW);
// digitalWrite (GAIN0、 高电平);
// digitalWrite (GAIN1、高电平);
// digitalWrite (speed、高电平);
// digitalWrite (PWDN,高电平);
Wire.begin();
delay (500);
digitalWrite (SSR, low );
digitalWrite( relay, low );
lcd.begin(16,2);
lcd.clear();
ads1118.begin();
ads1118.setGain(0b101);
///========================= PWM 频率预分频器===================
//TCCR2 &=橡皮擦;
// TCCR2 |=预分频器;
// ocr2 = 0x00;
////========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

lcd.setCursor(0、0);
lcd.print (" LIDOMA Ltd ");
lcd.setCursor(0、1);
lcd.print (" Pressmatik ");
delay (3000);
lcd.setCursor(0、0);
lcd.print ("选择程序");
lcd.setCursor(0、1);
lcd.print (") ");
}

void loop(){
if ( digitalRead ( LS100_SW )== low ){
digitalWrite (LS100_LED,高电平);
digitalWrite (LS200_LED,低电平);
digitalWrite (Metalcast_LED,low);
digitalWrite (LP_LED,低电平);
digitalWrite (MP_LED,low);
digitalWrite (hp_LED,low);
Buffer = 10;
lcd.clear();
lcd.setCursor(0、0);
lcd.print (" 100克 ");
//Display();

}
如果( digitalRead ( LS200_SW )=low ){
digitalWrite (LS100_LED,低电平);
digitalWrite (LS200_LED,高电平);
digitalWrite (Metalcast_LED,low);
digitalWrite (LP_LED,低电平);
digitalWrite (MP_LED,low);
digitalWrite (hp_LED,low);
Buffer = 20;
lcd.clear();
lcd.setCursor(0、0);
lcd.print (" 200克 ");
//Display();

}
如果(digitalRead (Metalcast_SW)== low)则为{
digitalWrite (LS100_LED,低电平);
digitalWrite (LS200_LED,低电平);
digitalWrite (Metalcast_LED,高电平);
digitalWrite (LP_LED,低电平);
digitalWrite (MP_LED,low);
digitalWrite (hp_LED,low);
缓冲区= 30;
lcd.clear();
lcd.setCursor(0、0);
lcd.print (" pfm preheat ");
//Display();

}
否则,如果(( digitalRead ( LP_SW )== low )&&( Buffer=10|| Buffer=12 )){
digitalWrite (LP_LED,高电平);
digitalWrite (MP_LED,low);
digitalWrite (hp_LED,low);
Buffer = 11;
Htemp = 910;
//lcd.clear();
lcd.setCursor(0、1);
lcd.print ("HT-MT-HO-Impulim");
//Display();

}
否则,如果(( digitalRead ( MP_SW )== low )&&( Buffer=10|| Buffer=11 )){
digitalWrite (LP_LED,低电平);
digitalWrite (MP_LED,高电平);
digitalWrite (hp_LED,low);
缓冲区= 12;
Htemp = 915;
//lcd.clear();
lcd.setCursor(0、1);
lcd.print (" LT-MO ");
//Display();

}
否则,如果(( digitalRead ( LP_SW )== low )&&( Buffer == 20 || Buffer == 22 || Buffer == 23 )){
digitalWrite (LP_LED,高电平);
digitalWrite (MP_LED,low);
digitalWrite (hp_LED,low);
缓冲区= 21;
Htemp = 915;
//lcd.clear();
lcd.setCursor(0、1);
lcd.print ("HT-MT-HO-Impulim");
//Display();

}
否则,如果(( digitalRead ( MP_SW )== low )&&( Buffer == 20 || Buffer == 21 || Buffer == 23 )){
digitalWrite (LP_LED,低电平);
digitalWrite (MP_LED,高电平);
digitalWrite (hp_LED,low);
Buffer = 22;
Htemp = 917;
//lcd.clear();
lcd.setCursor(0、1);
lcd.print (" 左 ");
//Display();

}
否则,如果(( digitalRead ( HP_SW )=low )&&( Buffer==20|| Buffer=21|| Buffer==22 )){
digitalWrite (LP_LED,低电平);
digitalWrite (MP_LED,low);
digitalWrite (HP_LED,高电平);
缓冲区= 23;
Htemp = 920;
//lcd.clear();
lcd.setCursor(0、1);
lcd.print (" 穆 ");
//Display();

}
如果(digitalRead (start_SW)== low)则为{
STARTPRESS ();
}


//delay (50);

float A =(ads1118.adsReadRaw (ads1118.DIF01)* 0.256 / 32768)* 1000;
//float B = ads1118.readTemp ();

lcd.setCursor(0、0);
lcd.print (" ");
//lcd.print( B,1 );
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(" ");
lcd.print( convert (A),5);
lcd.print(" ");
//ads1118.update_config (0x008B);
delay (50);

}

void STARTPRESS (){



float translat (float MV){
float T = 137.9263 +(((((MV - 0.93395)*(0.09615 * MV * MV * MV * MV * MV * MV * MV + 19.62905 * MV * MV * MV * MV * MV + 73.97377 *)*)/ 1.330451) (0.20813 * MV * MV + 0.57668 * MV + 0.27986));
///float T = 137.92 +(127.61*(MV - 0.933)+ 110.89*(MV - 0.965)*(MV - 0.933)+ 19.89*(MV - 0.933)*(MV - 0.933)*(MV - 0.933)*(MV )+ 0.096*(MV - 0.965)*(MV - 0.933)*(MV )*(SV - 0.933*(SV - 0.933)*(SV - 0.933)*(SV - 0.933*(SV - 0.933)*(SV - 0.933)*(SV - 0.933*(SV - 0.933)*(SV - 0.933*(SV -
0.

e2e.ti.com/.../ADS1118_2D00_master.zip

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    米拉德、


    ADS1118无法同时对环境温度和热电偶进行采样。 该器件具有单个 ADC、并且有一个输入多路复用器、用于从不同通道(包括板载温度传感器)收集数据。 如果您从热电偶读取数据、然后更改温度传感器的设置、则器件会完成进行中的转换、然后移至下一个多路复用器设置。

    您最好的方法是在通道之间交错转换。 首先启动转换以读取热电偶、等待转换完成、然后设置下一个通道/回读第一个转换。 然后等待下一个转换完成、然后重复上一个通道。

    因为您希望交替信道、所以我建议使用单次转换模式。 这是设置通道和获取数据的最可靠方法。 在连续转换模式下、您可以更改通道、但在进行中的转换完成之前、设置不会更改。


    吴约瑟
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    尊敬的约瑟夫
    您的建议对我有很大帮助,因此最后我解决了问题,并对库文件进行了一些修改。 首先、我要感谢您、因为这个项目对我来说非常重要、所以我可以从前图书馆写作人员那里获得将我的代码放在这里的津贴
    此致
    Milad Chalipa