Hi,
I'm attempting at using the ADS1248 with an Arduino to measure the temperature of a 3 Wire RTD. I've set up my circuit as per the Figures 110 and 114 in the data sheet with the only major change being that both AVDD and DVDD are connected to 5V supply as the SPI signals are being generated by the UNO (which are at 5V).
I am able to successfully write and read from the registers and have followed the setting of the registers exactly as per the Table 49 of the data sheet.
Additionally, I am using the pseudo code as a reference to write my code and have more or less followed the same.
Here is my problem, though:
I am able to measure the RTD resistance and actually using the CVD equation even get the temperature. However, when I move the RTD sensor toward a heat source, the resistance and the temperature does not change and then suddenly jumps - the jump is from 22 to 31 deg C. When removing it away from the heat source, the temperature remains high and then once again jumps back to the SAME 22 degC.
The code I'm using for the loop function of my Arduino looks something like this:
void loop() { if(digitalRead(DRDY)==LOW) { Serial.println("DRDY was LOW"); Data_Read = 0x0; Serial.println("Data Found. \nSetting CS pin LOW"); digitalWrite(CS,LOW); delay(0.5); Serial.println("\nIssuing the RDATA command"); SPI.begin(); SPI.transfer(0x12); Data_Read |= SPI.transfer(0xFF); //Write NOP, Read First Byte and Mask to Data_Read Data_Read <<= 8; //Left Bit-Shift Data_Read by 8 bits Data_Read |= SPI.transfer(0xFF); //Write NOP, Read Second Byte and Mask to Data_Read Data_Read <<= 8; Data_Read |= SPI.transfer(0xFF); //Write NOP, Read Third Byte and Mask to Data_Read Data_Read <<= 8; Data = ((double)Data_Read/(double)16777216)*(double)820; Temp_Data = -1 * ( A2DConstA / ( 2 * A2DConstB ) - sqrt( 25 * A2DConstA * A2DConstA + A2DConstB * ( Data ) - 100 * A2DConstB ) / ( 10 * A2DConstB ) ); Serial.println(Temp_Data,20); digitalWrite(CS,HIGH); } digitalWrite(CS,LOW); }
This is something I found weird while checking the individual 8 bits being read from the 24 bit data, if the variable 'Data_Read' was not initialized and set to 0x0, I was actually able to read the resistance and the temperature (albeit with the random jumps from 22 to 31) but on the suggestion of someone I decided to initialize it to 0x0 and noticed that after doing that the first and second read of the 8 bits of data, there was nothing but 0s. The conversion of that data was not at all close to the temperature.
In order to take care of this, I decided to clock in two extra NOP commands to the ADS1248 before reading the data just to be able to get my information but I know this is not correct as it is now 40 clock cycles which is wrong.
Apart from this, I also tried using a fixed resistance of 141ohms (3x47 ohm resistors in series) to measure the resistance and the result was a pretty accurate 140.9 ohms so I believe I am somewhere on the right path but can't figure out what I'm doing wrong at this time. I additionally measured the variation of the resistance of the RTD with varying temperatures and observed it changing but didn't see the change being recorded by my setup.
I apologize for the overload of information and the fact that this might be all over the place. Please let me know if you need any additional information from my side. I will admit I'm a bit of a juvenile in this field but would really appreciate your help in getting this sorted out.
Joe