• Resolved

ADS1248: ADS1248 is not working and receiving garbage ADC value

Prodigy 80 points

Replies: 13

Views: 139

Part Number: ADS1248

Hi,

I am using ADS1248 in one of our project to convert Analog 4-20mA signal to Digital value, the problem i am facing is I am unable to receive ADC value correct to Pin voltage. I dont think it is working and I am getting garbage value anything unrelated to applied voltage/current. I dont know whether is ADS1248 configuration problem or hardware related but i need support to understand and troubleshoot the issue.

NOTE: i had one mistake in Schematic , we didnt add capaictor at Vrefcom and vrefout earlier but that is now added, but still same result

I here by attach ADS1248 driver files, Schematic Part, and sample code.

AIN% is grounded(not shown in schematic)

// read ADC function
int32_t ADS1248_sample_raw( )
{
	int32_t res = 0;
	unsigned int Temp = 0;

	// test spi
	Temp = ADS1248GetIntRef();

	Temp = ADS1248_DRDY_OFF;
	ADS1248WriteRegister(ADS1248_10_IDAC0, 0x01, &Temp);

	// ref v channels
	Temp =  (ADS1248_INT_VREF_ON ) | (ADS1248_INT_REF0) | (ADS1248_MEAS_NORM);
	//ADS1248SetVoltageReference(Temp);
	ADS1248WriteRegister(ADS1248_2_MUX1, 0x01, &Temp);

	// Setup gain and sample rate
	ADS1248SetGain(ADS1248_GAIN_2 ) ;

	ADS1248SetDataRate(ADS1248_DR_80);
	//Temp = ADS1248_DR_320|ADS1248_GAIN_1;
	//ADS1248WriteRegister(ADS1248_3_SYS0, 0x01, &Temp);

	Temp = ADS1248GetDataRate();

	// read CH 3 wrt CH5
	// Choose channels
	ADS1248SetChannel (0, ( ADS1248_AINN3) );
	ADS1248SetChannel (1, (ADS1248_AINP5) );

	ADS1248_startSingle();

	delayMS(500);
	res = ADS1248ReadData();
	float tempV = res;

	tempV *= 2.048; // internal ref 2.048
	tempV /= 8388608; // 2^23
	tempV *= 1000; // value in mV

	return res;
}

// freertos task to read ADC

static void vLEDTask1(void *pvParameters) {
	bool LedState = false;
	int Temp;
	InitSPI();
	InitDevice();						// Initializes the SPI port pins as well as control
	InitConfig();
	ADS1248SetStart(0);
	tmp_adc = ADS1248GetID();
	tmp_adc = ADS1248GetChannel(0);

	while (1) {
		LedState = (bool) !LedState;

		/* About a 100ms on/off toggle rate */
		vTaskDelay(100/portTICK_RATE_MS );
		//Temp = ADS1248GetDataRate();
		ADS1248_sample_raw();
	}
}
// Toggle START Pin for conversation
void ADS1248_startSingle(){

	int relVal = 1;
	ADS1248SetStart(1);
	delayMS(100);
	ADS1248SetStart(0);

}

ads1248.h

2867.ads1248.c

  • Hi Admin,

    Thanks for posting this piece of code and the schematic. Can you also help explain what's going on in more detail?

    What signals are you applying to your inputs, what is the expected voltage you want to measure, and what is the data you are seeing from the device?

    It was also not clear to me from your schematic how you are measuring the inputs? If you want to measure across the shunt you will need to measure between 1TW1 and 1TW2 for example, but I don't see any connection points from these nodes back to the ADC. The code also says that you are reading AIN3 with respect to AIN5. But AIN5 is not connected to anything in the schematic you sent. And AIN3 is connected to net A4, but I don't see A4 anywhere else in the picture you sent other than connected to AIN3. Where does this net go?

    Please help provide more details. Thanks!

    -Bryan

  • In reply to Bryan Lizon86:

    Hi Admin,

    Also, please note that you need to hold the START pin high when writing registers. This is mentioned in the footnote underneath Table 19 (SPI Commands) on pg. 45 in the ADS1248 datasheet. Looks like you are only toggling the START pin to perform a conversion, so none of your registers are actually being written.

    -Bryan

  • In reply to Bryan Lizon86:

    Hi Bryan Thanks for reply and your time,

    - What signals are you applying to your inputs, what is the expected voltage you want to measure, and what is the data you are seeing from the device?

    As whole it was not working , so what i did is appliead 1 Volt at c40 Capacitor , A5 is connected at AIN4 and i connecetd GND to PIN AIN5(pin 14 of IC is GND), and i am measuring AIN4 wrt to AIN5 or AIN3 wrt AIN5.

    it was a mistake and not reflected in the original schematic.

  • In reply to Bryan Lizon86:

    Hi Bryan

    In changed the Start Single Pulse code as below, but still not getting reading

    void ADS1248_startSingle(){
    
    	int relVal = 1;
    	ADS1248SetStart(0);// low
    	delayMS(100);    // wait for 100 ms
    	ADS1248SetStart(1); // high
    
    }

  • In reply to Admin heap:

    The below image shows the reading taken in an array, as you can see reading keeps on fluctuating and it is nowhere near to 1V.

    the internal reference is 2.048V, 

  • In reply to Admin heap:

    Hi Admin,

    Are you holding the START pin high when writing all of your registers? Note that the ADS1248 requires you to hold the START pin high for the duration of the register writes and reads. At least in the original code you sent, you do not call the ADS1248_startSingle()function until after all of your register writes.

    Can you make sure this occurs correctly by writing all of your registers and then reading them back to make sure they all updated? Once we know that you are able to read and write registers, we can then focus on the conversion results.

    -Bryan

  • In reply to Bryan Lizon86:

    Hi Bryan Thanks for reply,

    sorry for late delay as we had holiday period.

    Now i have updated my code for change as you have mentioned, as you can see i had added Datarate verification if i read datarate register and if it is not same i have used while loop for error.

    my code run fines and doesnt go in while loop, so data register are updated correct that can be concluded.


    int32_t ADS1248_sample_raw( ) { int32_t res = 0; unsigned int Temp = 0; //keep START HIGH ADS1248SetStart(1); Temp = ADS1248_DRDY_OFF; ADS1248WriteRegister(ADS1248_10_IDAC0, 0x01, &Temp); // ref v channels Temp = (ADS1248_INT_VREF_ON ) | (ADS1248_INT_REF0) | (ADS1248_MEAS_NORM); //ADS1248SetVoltageReference(Temp); ADS1248WriteRegister(ADS1248_2_MUX1, 0x01, &Temp); // Setup gain and sample rate ADS1248SetGain(ADS1248_GAIN_1 ) ; ADS1248SetDataRate(ADS1248_DR_1000); //Temp = ADS1248_DR_320|ADS1248_GAIN_1; //ADS1248WriteRegister(ADS1248_3_SYS0, 0x01, &Temp); Temp = ADS1248GetDataRate(); // verify if data register is updated if(Temp != ADS1248_DR_1000){ while(1); // error } // read CH 3 wrt CH5 // Choose channels ADS1248SetChannel (0, ( ADS1248_AINN4) ); ADS1248SetChannel (1, (ADS1248_AINP5) ); ADS1248_startSingle(); delayMS(500); res = ADS1248ReadData(); rawADC[adcCounterSample++] = res; if(adcCounterSample > 31) { adcCounterSample = 0; } float tempV = res; tempV *= 2.048; // internal ref 2.048 tempV /= 8388608; // 2^23 tempV *= 1000; // value in mV return res; }
    
    

    i have also updated start pulse code for conversion

    void ADS1248_startSingle(){
    
    	ADS1248SetStart(0);
    	delayMS(100);
    	ADS1248SetStart(1);
    	delayMS(100);
    	ADS1248SetStart(0);
    	ADS1248SetStart(1);
    }

    Still there is no result

  • In reply to Admin heap:

    Hi Admin,

    Can you try reading back some of the system monitors on the ADS1248 and see if you get valid data? For example, the power supply monitor and/or the VREF monitor. This will give you an idea if you can read valid data from the device or not, and maybe there is an issue with the inputs.

    -Bryan

  • In reply to Bryan Lizon86:

    Hi Bryan,

    As You suggested i have added 2 lines to read ref and system monitor, you can see in below code

    /**
    * @brief This function will return raw reading of channels by passing +ve channe, --ve channel, gain setting, samplerate and reference voltage
    * @author Mohammed Asim Merchant
    * @date 27/02/2019
    * @param void.
    * @return int32_t.
    */
    int32_t ADS1248_sample_raw( )
    {
    	int32_t res = 0;
    	unsigned int Temp = 0;
    
    	//keep START HIGH
    	ADS1248SetStart(1);
    
    	Temp = ADS1248_DRDY_OFF;
    	ADS1248WriteRegister(ADS1248_10_IDAC0, 0x01, &Temp);
    
    	// ref v channels
    	Temp =  (ADS1248_INT_VREF_ON ) | (ADS1248_INT_REF0) | (ADS1248_MEAS_NORM);
    	//ADS1248SetVoltageReference(Temp);
    	ADS1248WriteRegister(ADS1248_2_MUX1, 0x01, &Temp);
    
    	// Setup gain and sample rate
    	ADS1248SetGain(ADS1248_GAIN_1 ) ;
    
    	ADS1248SetDataRate(ADS1248_DR_1000);
    	//Temp = ADS1248_DR_320|ADS1248_GAIN_1;
    	//ADS1248WriteRegister(ADS1248_3_SYS0, 0x01, &Temp);
    
    	/*
    	 * Read back the ref and sys monitor variable for verification
    	 * */
    	Temp = ADS1248GetVoltageReference();
    
    	Temp =  ADS1248GetSystemMonitor();
    
    	Temp = ADS1248GetDataRate();
    
    	// verify if data register is updated
    	if(Temp != ADS1248_DR_1000){
    		while(1);	// error
    	}
    
    	// read CH 3 wrt CH5
    	// Choose channels
    	ADS1248SetChannel (0, ( ADS1248_AINN0) );
    	ADS1248SetChannel (1, (ADS1248_AINP5) );
    
    	ADS1248_startSingle();
    
    	delayMS(500);
    	res = ADS1248ReadData();
    	rawADC[adcCounterSample++] = res;
    	if(adcCounterSample > 31)
    	{
    		adcCounterSample = 0;
    	}
    	float tempV = res;
    
    	tempV *= 2.048; // internal ref 2.048
    	tempV /= 8388608; // 2^23
    	tempV *= 1000; // value in mV
    
    	return res;
    }

    The following code return value as 

    	Temp = ADS1248GetVoltageReference(); // Temp is read back as 3 
    
    	Temp =  ADS1248GetSystemMonitor();// Temp is read back as 0
  • In reply to Bryan Lizon86:

    Hi Bryan,

    I started reading back all register that i was writing, it turns out the Register for Positive ch and the negative channel was not getting updated,

    The following line of code was not working

    ADS1248SetChannel (0, ( ADS1248_AINN4) );
    ADS1248SetChannel (1, (ADS1248_AINP5) );

    after this, i have updated the code and now it works,

    actual code is 

    ADS1248SetChannel ( 4 , 0);
    ADS1248SetChannel ( 5 , 1);

    This ADS12548 library is from TI source but there is no documentation for the same, so i happen to have passed 

    ADS1248_AINN4 as argument

    Thanks for guiding me, it was nice getting a response from you, Have a nice year ahead.

    Thanks for Your time and words