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.

ADS1158: ADS1158 AND ESP32 SAMPLE CODE FOR SINGLE ENDED INPUTS USING ARDUINO IDE

Part Number: ADS1158
Other Parts Discussed in Thread: ADS1148

Hello,

1.Want to use autoscan mode channel direct read (no command)  as it is by default.

2. Able to send data over spi bus, observed the same on DSO

3. But always getting zero on MISO Pin

4. Controlling start with software but DRDY is always at High level

Please help me to get it work, i have spent almost 2 weeks without any fruitful result. 

Thanks and regards,

Maharudra Bade

  • Hi Maharudra,

    If DRDY is always high, then this means the ADS1158 is not starting up. This is usually indicative of a clocking issue, though there is a possibility it is something else. This E2E post explains the possible causes of this issue in more detail.

    Are you using a crystal with the ADS1158 or an external oscillator? Tuning the crystal drive circuit can be a challenge, as you can see from these other E2E posts about the issue.

    If you would like, you can post your schematic and provide your register settings so we can review. But if you are using a crystal, this is most likely the the root of your problem.

    -Bryan

  • Thanks Bryan,

    Observed the following points as per your suggestions.

    1. There is no clock signal from crystal oscillator, I am using 8Mhz crystal with 22pF capacirors as load.

    2. I am using all default settings, not changing any configuration.

    3. Please find the attached schematic diagram to analyse any other issues.

    I want to get the all single ended channel readings through pulse convert command,please guide me for sending the commands to get channel AIN0 TO AIN15 Readings without/with status byte.

    Once again thank you very much for your valuable guidance.

    - MaharudraSchematics -ida controller card.pdf

  • Hi Maharudra,

    Thanks for sending this information.

    The schematic you sent shows a 16 MHz crystal with 4.7pF load caps, not what you described above. Either way, the recommended crystal frequency is 32.768 kHz, and you cannot use an 8 or 16 MHz crystal with the ADS1158. You can use an external clock oscillator with a 16 MHz frequency however, but this is not the system you have described nor shown in your schematic. The oscillator would need to be connected via the CLKIO pin as shown in Figure 27 in the ADS1148 datasheet.

    I would recommend using the correct clock source (32 kHz crystal OR 16 MHz oscillator) for your application, or the device will not work properly. An oscillator is recommended over the crystal given the issues described in the e2e posts I linked to in my previous response.

    -Bryan

  • Dear Bryan,

    Thanks for the reply.

    Did following modifications as per your suggestions.

    1. Changed crystal to 32.768khz with 14.7 pf capacitor load 

    2. Started getting the MISO signal from ads1158.

    > Now i would like to measure the channels in fixed mode

    > Command to configure CONFIG0 and MUXSCH Register

    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x60);                       //register write command to write config0 
    SPI.transfer(0x22);
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x62);                       //register write command for muxsch
    SPI.transfer(0x01);
    digitalWrite(adc_ss,HIGH);

    > Then to insure whatever is written to register issued following commands to read the default values of resisters

    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x40);
    byte config0 = SPI.transfer(0);
    Serial.print("config0:");Serial.println(config0,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x41);
    byte conf1 = SPI.transfer(0);
    Serial.print("config1:");Serial.println(conf1,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x42);
    byte MUXSCH = SPI.transfer(0);
    Serial.print("MUXSCH:");Serial.println(MUXSCH,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x43);
    byte muxdif = SPI.transfer(0);
    Serial.print("muxdif:");Serial.println(muxdif,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x44);
    byte muxsg0 = SPI.transfer(0);
    Serial.print("muxsg0:");Serial.println(muxsg0,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x45);
    byte muxsg1 = SPI.transfer(0);
    Serial.print("muxsg1:");Serial.println(muxsg1,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x46);
    byte sysred = SPI.transfer(0);
    Serial.print("sysred:");Serial.println(sysred,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x47);
    byte gpioc = SPI.transfer(0);
    Serial.print("gpioc:");Serial.println(gpioc,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x48);
    byte gpiod = SPI.transfer(0);
    Serial.print("gpiod:");Serial.println(gpiod,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);
    digitalWrite(adc_ss,LOW);delay(5); //toggle the ss signal to reset the spi interface as per ads1158 datasheet
    digitalWrite(adc_ss,HIGH);
    digitalWrite(adc_ss,LOW);
    delayMicroseconds(1);
    SPI.transfer(0x49);
    byte id = SPI.transfer(0);
    Serial.print("id:");Serial.println(id,HEX);
    digitalWrite(adc_ss,HIGH);
    delay(1000);

    > Found following results which are not matching for most of the registers.

    Please refer the attached image file for register status.

    Either I am not able to write data to registers correctly or read it correctly. Please share your views on this problem. 

  • Hi Maharudra,

    How are you configuring your SPI peripheral?
    I would double check that your MCU's SPI peripheral is configured for SPI mode 1 (CPOL = 0 -> SCLK is low when inactive, CPHA = 0 -> data is valid on SCLK's rising edge) and that the SCLK frequency is no faster than 0.5 times the ADC's master clock (refer to tSCLK requirement on page 7 of the datasheet).