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 Channel read

Other Parts Discussed in Thread: ADS1158, ADS1178

I'm writing my firmware to control the ADS1158 and have a question regarding reading the channel data.  It appears that there are 3 commands to do this, and maybe I missed the section on what each actually does and how? But if someone could shed some light on this, I'd appreciate it.

The command byte shows that command 000, 001, and 111 all read the channel data.

The instructions say that command 001 with the MULT bit set, the last 4 bits are "don't care"  and 32 total SCLK cycles sent will give back channel data- which channel? If I send 24*15 more SCLK cycles, will it return all channels? Or is this just checking to see if data is ready, and on which channels it is available? A little confusing the way it's worded in the datasheet.

Commands 000 and 111 both are listed as "Channel Data Read Direct" = so do I set MULT = 0 and A3:A0 are the direct channel read?

I need to set up two functions in my code - one that will read all channels, and one that will read the individually specified channel. If someone could give me an example of which commands/data to send to the ADC, that would be awesome! 

Thanks

  • Hi Anthony,

    There are two types of "read" commands on the ADS1158.

    1. Channel data read direct (no command)
      In this mode, data is read right after it becomes available (i.e. /DRDY goes low). Sending this command retrieves the status byte (if enabled) and conversion result with only 16 or 24 SCLKs (rising edges). Once this command has been performed and data has been retrieved, /CS must be toggled before sending additional commands. Note that reading data in this mode requires that all data bytes be retrieved from the output shift register before /DRDY goes low again, otherwise results will be corrupted by the next conversion's result.

       
    2. Channel data read command (register format)
      In this mode, the data in the output shift register is preserved in another register to avoid possible corruption from following conversions; therefore, reading data in this mode does not require synchronization with the /DRDY signal. This mode requires a total of 32 SCLKs (8 for the command, 8 for the STATUS byte which is always enabled in this mode, and 16 for the data).

    If you're monitoring /DRDY with an interrupt and able to serve the interrupt quickly, then the "read direct" mode is the fastest way to retrieve data.

    If you don't monitor /DRDY, than you'll need to use the "read command" mode which requires additional SCLKs.

    Regarding which channel's data you read back depends on the register settings...

    • In fixed-channel mode, you select the input channel with the MUXSCH register. Once configured, you'll start a conversion, wait for /DRDY to go low, then retrieve the data for that channel using one of the two methods listed above.

    • In auto-scan mode, you select which channels you would like the ADC to cycle through with the MUXDIF, MUXSG0, MUXSG1, and SYSRED registers. After starting conversions, you'll get data out for one of the selected channels, each time /DRDY goes low. The order of the channel scanning is shown in Table 10. Additionally, you can read the STATUS byte to check which of the channel's data you are currently reading.

     

    Unfortunately, you cannot output the data from all channels in one-shot...You'll need to retrieve data one channel at a time, the sequence will look something like this...

    • Write to all registers with the "register write command" (sets the initial configuration - let's assume you decide to use auto-scan mode)
    • Start converting by setting the START pin high.
    • Wait for /DRDY to go low
    • Read the 1st channel's data with the "channel data read direct" command (you'll need to be able to retrieve all data before /DRDY goes low, otherwise you would need to use the fixed-channel mode).
    • Wait for /DRDY to go low
    • Read the 2nd channel's data with the "channel data read direct" command
    • ....repeat waiting for /DRDY and reading data for all remaining channels...
    • Stop conversions and enter power-down mode OR repeat channel cycling.

    I hope that helps!

    Best Regards,
    Chris

  • Thanks Chris,

    I believe I'll have to use fixed channel mode. I didn't connect DRDY or Start to my processor, not enough IO pins. So if I need to scan all 16 channels in fixed channel mode, I would load the the channel number into MUXSCH then read the channel directly - register read mode? And that will return the data (in 2's comp form) to me after 32 total clock cycles, correct? then I would change MUXSCH to the next channel I want to read, and repeat? If I understand this, it is independent of the DRDY pin status... How long do I have after I change MUXSCH to read that channel before the register data is overwritten? I've set my SPI channel to the maximum speed of the ADC, and can lock out the OS from switching tasks until my whole operation is done. Or am I better off trying to connect DRDY and Start to the processor?

    Tony
  • Chris,

    If I understand this correctly... when I'm in auto-scan mode, I pulse the start pin low for some nominal amount of time, and after all 16 channels are converterd (I set it up to scan all 16), the /DRDY pin will go low, prompting me to read the data. I send down the command 000 and the MULT bit =1, and will receive one byte as invalid data, followed by the status byte, then I send 32 more bytes of 0s to get the 16 channels of data... do I have that right?
  • Hi Anthony,

    If you are not monitoring /DRDY, then you could do one of two things...

    1. Operate the ADS1158 in fixed-channel mode and read data with the register read mode (Correct, this would take 32 SLKs to send the read command and retrieve the STATUS + Data bytes).  You would then change the MUXSCH setting and restart conversion to switch channels. You wouldn't need to worry about data being overwritten when using the register read mode.

    2. Additionally, you could still operate the ADS1158 in auto-scan mode, but use the pulse convert command to only run a single conversion. Then you would retrieve the data with either read command and check to make sure the "NEW" bit in the STATUS byte is set. If so, just send the pulse convert command again and the ADC will continue to index through all 16 channels. This method also avoids overwriting data, because only one conversion will complete.

     

    Regarding your last question...

    Anthony Scarnici said:
    If I understand this correctly... when I'm in auto-scan mode, I pulse the start pin low for some nominal amount of time, and after all 16 channels are converterd (I set it up to scan all 16), the /DRDY pin will go low, prompting me to read the data. I send down the command 000 and the MULT bit =1, and will receive one byte as invalid data, followed by the status byte, then I send 32 more bytes of 0s to get the 16 channels of data... do I have that right?

    No, in auto-scan mode the ADC will only measure 1 channel at a time. After measuring a channel, /DRDY will go low to notify you that a 16-bit conversion result has completed. Meanwhile, the ADC automatically switches channels and starts measuring the next channel. This process repeat until you've read data 16 times (one channel's data for each time /DRDY goes low).

    If you don't read data in time (before /DRDY goes low again) then you will lose the measurement result for that channel (at least until auto-scan has cycled back through to that channel again). However, if you instead were to use the pulse convert command, you could slow down this process by making the ADC wait until the next pulse convert command before starting the next conversion, that way you don't lose data OR get corrupted data.

    (To read out data from more than one channels at a time would require a simultaneously sampling ADC that has more than one modulator, such as the ADS1178)

     

    Best Regards,
    Chris

  • Hi Chris -

    A question about the /DRDY and START pins. I'm going to be running in Auto-Scan mode after all to convert all 16 channels. So my understanding is that I assert the START pin high to begin the conversion. I read through the datasheet and I'm not seeing the answer to this, at least it's not clear to me: Once Asserted, if I'm converting all channels, will the /DRDY pin assert low after ALL channels are converted or after only the currently selected channel is complete? And am I correct in assuming that I should keep the START pin high until /DRDY goes low? Just trying tofigure out the read-back... Lastly, if the/DRDY pin does go low after all 16 channels are converted, then I assume they all need to be read back at once - correct? Thanks!

    Tony
  • Hi Tony,

    /DRDY will go low after one conversion completes (i.e. just a single channel's data is available) . At this point you may keep the START pin high and read back data (while the ADC begins converting the next channel).

    So /DRDY must go low a total of 16 times into order for auto-scan to finish one rotation through all the channels. From there, auto-scan will repeat the channel rotation from channel 1.

    Hope that helps!

    Best Regards,
    Chris
  • Thanks Chris,

    This sounds similar to the way the pulse method works, except the pulse method doesn't keep the START pin high... if I use the pulse method, how long should the START pin stay high? Does it only need a rising edge to start the conversion?

    Tony

  • Hi Tony,

    Correct, pulse mode operation is similar; however, the next conversion will wait for the "pulse convert command" or the START to go high before starting. This type of operation may be easier to control in some software implementations, but it will not quite achieve the same data throughput as continuously converting.

    The START signal only needs to remain high for about 4 tCLK periods. Refer to this related E2E post:


    Yes, only the rising edge is needed to start the conversion. The falling edge stops conversion after the current conversion completes.


    Best Regards,
    Chris