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

  • 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.
  • This is the schematic. We have connected the SPI pins through Raspberry pi through some isolation circuit

  • Also these are the results at 100ns/div and 200ns/div.

  • BMGuardian,

    I think I misinterpreted your original problem statement as you are using an external reference and I presume desire to use the internal reference buffer.  So we're going to want to change the configuration word to modify the REF selection to use either 3'b011 or 3'b111 depending upon whether you need the temperature sensor or not.  Assuming you don't intend to use the temperature sensor then REF = 3'b11 so the new configuration word becomes 

    Enable Bit INCC INX BW REF SEQ RB TRAILING 00s Configuration Word
    Temperature Sensor Disabled       1 111 010   1  111   00   1   00   0xF5E4h
    Temperature Sensor Enabled       1 111 010   1  011  00   1   00   0xF564h

    Please note here that I've also selected channel 2 as IN0 and IN1 appear to be disconnected in your design.  I would recommend shorting those inputs to ground if they will not be used.

    Please try this modified configuration word settings to see if you see any improvement in the output code accuracy and stability.

Reply
  • BMGuardian,

    I think I misinterpreted your original problem statement as you are using an external reference and I presume desire to use the internal reference buffer.  So we're going to want to change the configuration word to modify the REF selection to use either 3'b011 or 3'b111 depending upon whether you need the temperature sensor or not.  Assuming you don't intend to use the temperature sensor then REF = 3'b11 so the new configuration word becomes 

    Enable Bit INCC INX BW REF SEQ RB TRAILING 00s Configuration Word
    Temperature Sensor Disabled       1 111 010   1  111   00   1   00   0xF5E4h
    Temperature Sensor Enabled       1 111 010   1  011  00   1   00   0xF564h

    Please note here that I've also selected channel 2 as IN0 and IN1 appear to be disconnected in your design.  I would recommend shorting those inputs to ground if they will not be used.

    Please try this modified configuration word settings to see if you see any improvement in the output code accuracy and stability.

Children

Before You Switch


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