Post Go back to editing

How to use AD7998 with BeagleBone

Hello,

I use the AD7998BRUZ-0 with a BeagleBone Black  via I2C and want to read a simple battery-value via V_in_1-Pin.

But I don't know how to configure the control register with shell-commando "i2cset". To get the digital value a have to configure the control register for the next conversion signal but I don't know how.

Thanks!

  • Hi Tigerclaw,

         I am assuming that you are developing a software for the AD7998 to monitor battery value on Vin1. I can refer you to the AD799x family wiki page. You can find here a software driver, design for the AD799x family which can be use as your reference in developing your own software. Please refer to the link below.

    AD7998 IIO ADC Linux Driver [Analog Devices Wiki]

    Regards,

    Jonathan

  • Thanks for reply. I only want to set the control register to read the value via "i2cget -y -r 0x22". I loaded the I2C Overlay and a OVerlay for GPIO configuration (CONVST and BUZY flag) and want to read a simple value. I don't develop a software.

  • Hi Tigerclaw,

         I am not on the familiar beagle bone  command that you are using but when reading from an AD7998, a write operation must be perform first to set the address pointer to know what register will be read. Please refer to fig. 26 of the ad7998 datasheet. Like for example to read conversion result the pointer address is 0000. Once the pointer address is known, a read command then will be followed. Please refer to Fig 29 or 30. When reading a conversion result, which is a 16 bit data, a two byte read is required, please follow fig. 30 for the details.

       

    Regards,

    Jonathan

  • Hi,

    this is what I don't understand. I have this commando "i2cset -y 1 0x22 Y_ X_"

    1: BB-I2C-1 Bus

    0x22: ADC-address

    Y_: which register to write

    X_: value

    I want to need V_in_1. For my project I also need the GPIOs for the start conversion signal and Buzy flag. But in "Mode 2" there is a possibility to use the ADC without conversion signal.For example I want to use adress pointer byte for Vin1: 1 0 0 0   0 0 0 0 == HEX 0x80.

    I tried this:

    >root@beaglebone:/# i2cset -y  1 0x22 0x80

    >root@beaglebone:/# i2cget -y  1 0x22 0x80

    result > 0x07

    But I am not sure if this is the right.

  • I tried this on:

    root@beaglebone:/# i2cdetect -y -r 1

          0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

    00:          -- -- -- -- -- -- -- -- -- -- -- -- --

    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    20: -- -- 22 -- -- -- -- -- -- -- -- -- -- -- -- --

    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

    70: -- -- -- -- -- -- -- --

    Set adress pointer register to conversion result register

    root@beaglebone:/# i2cset -y 1 0x22 0x00

    read 2 bytes
    root@beaglebone:/# i2cget -y 1 0x22 0x00 w

    0xb80f

    I have a 1,5V battery on pin Vin_1 (0x80).

    I also tried this solution to write to config register and read this value but it doesn't work.

      root@beaglebone:/# i2cset -y 1 0x22 0x02

    root@beaglebone:/# i2cset -y 1 0x22 0x02 0x0a

    root@beaglebone:/# i2cget -y 1 0x22

    What can I do to read my analog voltag on Vin_1?

  • Hi Tigerclaw,

        

         Please send a oscilloscope shot of the plots or digital signals so we can have a much better understanding of the problem.

    Regards,

    Jonathan

  • I tried this here without the CONVST-Signal for a 3,3 volt battery:

    root@beaglebone:/# i2cset -y 1 0x22 0x02 0x1000 w (set Config-Register for Vin_1, 0x1000 == 0x010 )

    root@beaglebone:/# i2cset -y 1 0x22 0x80 (Vin_1, Page. 29)
    root@beaglebone:/# i2cset -y 1 0x22 0x02
    (write Conf-Reg. to Adress Pointer Reg.)

    Maybe in Mode 2 it's also possible to use 0x80 / 0x82
    root@beaglebone:/# i2cget -y 1 0x22 0x00 w

    0xad09

    because we have 12 bits and LSB is first.--> result: 0x9ad=2V

    ---------------------------------------------------------------------------

    Batterie mit 1,5V

    root@beaglebone:/# i2cset -y 1 0x22 0x80
    root@beaglebone:/# i2cset -y 1 0x22 0x02
    root@beaglebone:/# i2cget -y 1 0x22 0x00 w

    0xf604

    Whats wrong with my command? Did I forget something?

  • Hi Tigerclaw,

         First, where did the AS pin was connected? If it is AGND, then the I2C bus address is 010 0001 while if connected to VDD address will be 010 0010. Refer to table 6 of the datasheet.

         In the I2C interface it will start with a start command then followed by the bus address for the first 7 SCL clock cycles, the 8th cycle will tell if the next command is a write or read. I can see that you are writing 0x22. If this is the bus address with AS pin connected to VDD, then 0x44 should be the first which means AD7998-0 address at AS connected to VDD and the next command is a write command.

         In the second set after a write command was sent, it will be acknowledge on the 9th clock by the AD7998, on the next 8 clock cycles, need to write the address pointer. This time we need to configure first the ADC for the preference we want. We will write 0x02 to point to Config register.  The configure register is a 16 bit long. In writing we'll refer to figure 28 ( 2byte write sequence).  After the write it will be acknowledge again by the AD7998. This a 2 byte write, please refer to table 9 for function of each bit. If channel 1 is the only preferred channel  and alert are disable, so the next 8 clock cycles will be 0x00 ->acknowledge then another 8 clock cycles  write 0x18, ch1 enable and filter enable. Then a stop command will be initiated.

         The next will be reading ADC result (fig 26) . But first it needs to initiate conversion. So the /CS will go high during power up for at least 1us. A falling edge will initiate conversion. When the conversion is complete, approximately 2us, I2C interface can start again by writing the bus address and write command followed by address pointer conversion result, 0x44( address bus + write) acknowledge then write the address pointer for conversion result which 0x00 (Conversion result register) followed by stop command.

         The next will be reading result (fig. 30). a start command must be initiated, then address bus + read (0x45). An acknowledge from AD7998 then 2 byte read of the data result will follow. Table 13 details the 16 bit description of the conversion result register. Below is the summary.

    Write to config reg(ch1 en)  =>  Bus address + Write (0x44)--> Address pointer (Config reg 0x02)--> Config Reg(0x18) - fig 28

    Write to adrees pointer for read => Bus address + Write (0x44)--> Address pointer (conversion result 0x00) fig. 26

    Read Conversion =>   Bus address + read ( 0x45) --> 16 bit conversion result  fig. 30

    Regards,

    Jonathan

  • This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

    Thank you,
    EZ Admin