Read data is 0XF4,0X53,0XFE, how to parse?
help
[edited by: ljln119 at 3:25 AM (GMT 0) on 14 Jan 2020]
LTC2439-1
Production
The LTC2439-1 is a 16-channel (8-differential) micropower 16-bit ?S analog-to-digital converter. It operates from 2.7V to 5.5V and includes an integrated...
Datasheet
LTC2439-1 on Analog.com
Read data is 0XF4,0X53,0XFE, how to parse?
Looking at the timing diagram of Figure 3a, I think there could be something wrong with your communication with the ADC. The first two bits should always be zeros. Can you provide an oscilloscope photo showing CSL, SCK, SDI and SDO? A schematic of your circuit would also be helpful.
Looking at the timing diagram of Figure 3a, I think there could be something wrong with your communication with the ADC. The first two bits should always be zeros. Can you provide an oscilloscope photo showing CSL, SCK, SDI and SDO? A schematic of your circuit would also be helpful.
Thank you for your reply. This problem has been bothering me for a long time. Could you please provide relevant reading and writing routines for ltc2439-1?
The first two bits should always be zeros,why?
Read channel 0 data, single-end input, single chip sends 0XB0, right
This is a relatively old device. I do not have code examples for you. If you look at some of the newer devices that have Linduino support you can find code examples.
If you look at the timing diagram of Figure 3a you will see that the first two data bits clocked out of SDO (bits 18 and 17) are always zero.
Sending 0XB0 on SDI will configure the ADC to read CH0 with respect to the COM pin.
When B0 is sent, the received data is hexadecimal 88,40, F0.Actual channel B0= 0.260v.When sending B1, the received data is hexadecimal E8,A7,FC, and the actual channel B1=2.495V.The Numbers don't match.Is the received data high or low?How do I parse data?Thank you very much!
This is the waveform that sends B0,
The waveform received after sending B0
Looking at the oscilloscope photo, I decoded 22,03,9F. If you look at SDO at the rising edge of the first two SCK pulses you will see they are both zero. At the next rising edge SDO is high and at the 4th rising edge SDO is again zero. 0010 is a hex 2. Continue decoding in this manner and you will get 22,03,9F.
Next you have to strip out the extra bits. You have 24bits and the ADC only outputs 16 actual data bits. The first 3 bits (EOC DMY and SIG) combined with the MSB (B15) are used to determine over-range. You can look at Table2 of the data sheet and see that 0010 indicates that the data is greater than 0 and less than Vref/2.
Bits 15 through 0 are the data you want. The five 1s after Bit15 can be ignored.
Parsing B15-B0 yields 10,1C in hex. This is 4124 in decimal. 4124/32768 * Vref/2 should equal your input voltage. You haven't stated the reference voltage but I will assume it is 5V which indicates an input voltage of 0.314V. This is close to your stated input voltage of 0.26V but the ADC should be much more accurate than that. Do you have a filter at the analog input? Actually, it would be a good idea if you provided your schematic and even a photo of your circuit if that is possible.
void Write_SPI_Byte(unsigned char SPI_Byte)
{
char bit_mask, k;
SPI_CS(0);//片选
bit_mask = 0x80; // MSB order first
for (k = 0; k < 8; k++)
{
if(SPI_Byte & bit_mask) // load bit value
SPI_SIMO(1);
else
SPI_SIMO(0);
SPI_CLK(1); // clock it out
bit_mask /= 2; // next bit (the "/= 2" provides necessary delay over ">> 1")
SPI_CLK(0); // clock reset
}
SPI_CS(1);
}
//--------------------------------------------------
unsigned char Read_SPI_Byte(void)
{
unsigned char i;
unsigned char SPI_Byte=0;
//SPI_CS(0);//片选
for (i = 0x01; i != 0; i <<= 1) //低位在前,逐位读取
{
if (SPI_SOMI != 0) //首先读取此时的IO引脚,并设置dat中的对应位
{
SPI_Byte |= i;
}
SPI_CLK(1); //然后拉高时钟
SPI_CLK(0); //再拉低时钟,完成一个位的操作
}
return SPI_Byte; //最后返回读到的字节数据
}
void Read_LTC2439_Data(void)
{
unsigned char Data[3]={0,0,0};//从SPI总线读取的数据,Data[0]是最高位
unsigned char i,j;
Write_SPI_Byte(0XB0);
delay_ms(200);
SPI_CS(0);//片选
SPI_Data[0]=Read_SPI_Byte();//接收数据,Data[0]是最高位
SPI_Data[1]=Read_SPI_Byte();//接收数据,
SPI_Data[2]=Read_SPI_Byte();//接收数据
SPI_CS(1);//片选
delay_ms(200);
Write_SPI_Byte(0XB1);
delay_ms(200);
SPI_CS(0);//片选
SPI_Data[4]=Read_SPI_Byte();//接收数据,Data[0]是最高位
SPI_Data[5]=Read_SPI_Byte();//接收数据,
SPI_Data[6]=Read_SPI_Byte();//接收数据
SPI_CS(1);//片选
}
Is there something wrong with my SPI program? Please give me the guidance. Thank you!
I am not a programmer. It appears that your program is correctly telling the ADC what to do but it is not correctly deciphering the data that comes from the ADC. Did my description of how to decode the data from the ADC make sense to you? Can you use that to determine where your program is misinterpreting the ADC data?
Looking at your schematic, I think I understand why the ADC reading is not correct. You have a large filter on the CH0-CH11 inputs. This filter will not settle in the time allowed. I suggest you put the same filter on the COM pin or reduce the size of the filter.