Post Go back to editing

AD7699

Category: Software
Product Number: AD7699

Hi I am working with AD7699 and Raspberry pi. I want to read the data from the second channel and send it to raspberry pi using SPI communication. But I am struggling with it. I am using internal reference of 4.096V. Can anyone help me with the code please?

Parents
  • BMGuardian,

    Just a few quick comments that will hopefully get you started.  I'm going to assume that in this case you want to use the configuration mode to address the channel of interest for the conversion rather than use the sequencer.  However, if you do decide to use the sequencer the process doesn't really change significantly.

    1) The first thing to remember is that the configuration word you write should be left justified in a sixteen bit transfer such that the MSB is a logic 1'b1 to instruct the AD7699 that you wish to update the configuration.

    2) Secondly, the AD7699 has a single conversion latency (one-deep delay) between the configuration word write into the serial buffer before the buffer contents are moved into an internal register and applied to the subsequent conversion.

    So in this case we are going to attempt to read from channel 1 (second channel) and assume that we have the following configuration.

    • INCC:  Unipolar, with respect to COM   (3'b110)
    • INX:     Channel 1    (3'b001)
    • BW:     Full (1'b1)
    • REF:   INTERNAL, 4.096V Buffered (3'b001)
    • SEQ:  DISABLED (2'b00)
    • RB:    Disabled (1'b1)

    So the configuration word is  1_110_001_1_001_00_1 (0x38C9h) but we need to left justify this so the hex code becomes (0xE324h).

    To update and read the results of channel 1 we then follow the process:

    1. Execute a serial transfer (including toggling CNV) to write the content 0xE234h to the AD7699, being careful to observe the conversion timing for the device.
    2. Initiate a conversion and read back the data at the end of conversion.  The data read back shall correspond to the channel previously programmed by the configuration word.  At the end of the conversion the configuration word you wrote in step 1 will be loaded into internal memory and the device will initiate acquisition of channel 1.
    3. Initiate another conversion and read back the data at the end of conversion.  This time you should have data corresponding to channel 1.   

    To verify your sequence is working you can modify the RB bit to be a zero and then request an additional word of data after the conversion result.  The AD7699 should return the configuration word on SDO if successful.  Note the MSB will be forced to 0.

    I hope that helps get you back on track,


    Sean

  • Thank you Sean, 

         But I am still struggling previously i didn't know to do this left justify of the config. But now I have changed that.

    So my problem is this

    I am using raspberry pi which has the GPIO 13 should be high to power up the PCB which contains the AD7699.

    I have connected the AD7699 using SPI and CE0 as the chip select which is connected to CNV pin. 

    So right now i have set GPIO 13 high to power up the board.

    Configuration used as follows

    • CFG : overwrite the contents of config (1'b1)
    • INCC:  Unipolar, with respect to GND   (3'b111)
    • INX:     Channel 2    (3'b010)
    • BW:     Full (1'b1)
    • REF:   INTERNAL, 4.096V Buffered (3'b001)
    • SEQ:  DISABLED (2'b00)
    • RB:    Disabled (1'b1)

    CFG = 1_111_010_1_001_00_1 . Left Justified 1111 0101 0010 0100 converted to hex (0xF924)

    Here's the code i used

    This is the output i get 

    adc, data, voltage are getting printed as per the code

    Please help me with this

  • BMGuardian,

    Thank you for scope captures, they were invaluable in establishing a baseline for your timing.  Could I ask you to do the following.

    1) With your current setup repeat captures of the setup you have in figure #1 with the time base in s/div such that you capture two sequential conversion bursts so that we can measure the time between the rising edge of one and the edges of the next one.

    2) Then I would ask if you could capture the serial transmission to the AD7699 where you attempt to program the device to capture only only channel 2.  This will let us verify the serial input timing.

    3) Finally I would recommend modifying your code in the main loop to extend the readback to 4 bytes and to invert the RB bit in the configuration word (set to 0) to enable the configuration word readback .  You'll have to modify your data extraction code to separate the data and configuration data but that is fairly straightforward.

    Sean

      

  • 1) Since we have given the sleep time between each acquisition in the code as 0.1s each burst comes with a interval gap of the same. But I'm not able to capture it in scope with such a large scale. So I changed the sleep time and got the results below which has the time interval between two transfers as 0.5.

    2) This is the first transfer where I'm sending the configuration byte to read channel zero with a readback.

    3) I have tried to read four bytes as you suggested. But I'm not able to split them as first part was supposed to be the data and second part was supposed to be the readback of configuration resistors. But I don't think the results which i had got are correct. I will attach the results.

    This was with the configuration readback enabled (last bit was changed to 0).

  • BMGuardian,

    Let me clarify that for step #2 I was looking for the relative timing of MOSI and SCLK so that I could make sure the data was correctly aligned. 

    I'm even more curious for this information now given that in step #3 you are now getting all 0's back from the SDO.   Could you please repeat the experiment for #2 with CNV replaced by MOSI.

    Then for step #3 could you move the MOSI channel back to CNV/CS and capture a scope shot with the 4 byte transfer of SCLK and CNV.  I'm curious how the RaspPI is executing this command, I'm wondering if CS isn't toggling.  

    Sean

  • Sean,

    Step #2 MOSI and SCLK of the first Config Transfer

    Step #3 CNV/CS and SCLK for four byte transfer

    Please find the attached results.

  • BMGuardian,

    Something is not quite right with your setup as the traces are definitely not what I would have expected given your previous scope captures.  Your channel 1 and 2 data streams to be inverted versions of some arithmetic combination of the data signals we're interested in.   Can you recheck if something changed with the configuration or with your connectivity between the RaspPi and your AD7699 hardware?  

    Sean

  • I have just removed and remade the connections. Check these new results and let me know.

    Step #2 MOSI and SCLK of the first Config Transfer

    Step #3 CNV/CS and SCLK for four byte transfer

  • BMGuardian,

    So I found a mistake in my original recommendation for the configuration word.  I had said to program the device with 0xF924h which accidentally set the active channel to channel 4.  Instead try making the configuration value 0xF324 or 0xF320 (for readback).   

    Also could you repeat the capture in #2 with a bit more resolution.  I would like to see how much setup/hold time we have for the data around the SCLK rising edge.  This will give us some indication if the write is working. 

    I would then take a look at the MISO pin relative to SCLK on the scope after a minimum of 2 conversions to see if you readback 0x7320h (assuming readback is enabled).

    Sean 

  •  the MISO pin relative to SCLK

     

    Whenever I get four zeros (with readback enabled and i read 4 bytes)

    Whenevr i get four 255 (with readback enabled and i read 4 bytes)

    #2 with bit more resolution

  • BMGuardian,

    I should have been more clear on the zoom I need on the last plot.  If you can really zoom in (say 100ns/div) at the rising edge of SCK when the data is transitioning that would be helpful.

    Also we're going to need to start looking at other pins/voltages on your board to tease out what is going on here.  Can you please share a snapshot of your hardware schematic, at least the portions around the AD7699 so that we can get a look at how the device is connected?   Then I can offer additional measurement suggestions.

  • Dear Sean, 

    I have attached the results at two different resolutions. I will send you the schematic as soon as possible.

    This is at 100ns/div

      

    This is at 200ns/div
    I will send you the schematic as soon as I get it.
Reply Children
No Data

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.