Post Go back to editing

Issues while configuring and reading data from ad7792

Someone by email asked:

-----

We tried programming the part but seem to have issues with some registers such as Config and IO registers, which appear not to be programmable, in addition to reading the ADC register (single read) and getting the correct result.

We looked at the code (main.c) for the Renesas board connecting to the AD7792 dev board, and noticed some data level shifting involving the reading of the ADC.

Since we’re having trouble with programming this part to get correct values, we would like to ask why the need to add 0x8000 and subtract it from the ADC readings as shown below:

if(value > 0x8000)

            {

                value -= 0x8000;

                value = ((value * 1170) >> 15);

                ST7579_String(6,10,"+");

            }

            else

            {

                value = 0x8000 - value;

                value = ((value * 1170) >> 15);

                ST7579_String(6,10,"-");

            }

If possible, we’d like to ask a few questions about some issues we’re seeing with trying to write the CONFIGURATION and IO registers, which don’t seem to work. We can’t set the excitation current sources as we would like.

Any help would be greatly appreciated, as we’re struggling to get this part working reliably.

-----

Parents
  • Hi,

    >We tried programming the part but seem to have issues with some registers such as Config and IO registers, >which appear not to be programmable, in addition to reading the ADC register (single read) and getting the >correct result.

    The ad7792 part has an ID Register containing the hexadecimal value: 0xXA (where X=don't care). Are you able to read this value?

    >we would like to ask why the need to add 0x8000 and subtract it from the ADC readings as shown below:

    The code converts the binary value read from the ADC into millivolts and displays it on the LCD.

    The ad7792 is configured to bipolar mode(it's enabled by default) which make us use the following datasheet formula:

    Code = 2^(N-1) * [(Ain * Gain/Vref) + 1], where N=16 (bits)

    which means that:

    Ain = [Code/2^(N-1) - 1] * Vref/Gain     (1)

    Expanding it a little:

    Ain = (Code - 2^(N-1))/2^(N-1) * Vref/Gain

    since:

    N=16

    Vref=1170 mV

    Gain=1

    Code - 2^(16-1) = Code - 0x8000

    leads to:

    Ain = (Code - 0x8000)/2^15 * 1170/1

    Dividing a number to 2^15 can also be done by shifting the value 15 positions to the right which is less computational expensive that a division. This gives us the final formula:

    Ain = [(Code - 0x8000) * 1170 ] >> 15

    We could just as easily go with the first formula (1) but our display function ST7579_Number() can only print the absolute value of a number and we needed to check if the number was negative or positive in order to print the corresponding sign (+/-).

    >If possible, we’d like to ask a few questions about some issues we’re seeing with trying to write the >CONFIGURATION and IO registers, which don’t seem to work. We can’t set the excitation current sources as we >would like.

    Once you are able to successfully read the value of the register ID please let me know what kind of issues are you having and maybe share the code snippet that you are using to configure those registers.

    Regards,

    -Dan

Reply
  • Hi,

    >We tried programming the part but seem to have issues with some registers such as Config and IO registers, >which appear not to be programmable, in addition to reading the ADC register (single read) and getting the >correct result.

    The ad7792 part has an ID Register containing the hexadecimal value: 0xXA (where X=don't care). Are you able to read this value?

    >we would like to ask why the need to add 0x8000 and subtract it from the ADC readings as shown below:

    The code converts the binary value read from the ADC into millivolts and displays it on the LCD.

    The ad7792 is configured to bipolar mode(it's enabled by default) which make us use the following datasheet formula:

    Code = 2^(N-1) * [(Ain * Gain/Vref) + 1], where N=16 (bits)

    which means that:

    Ain = [Code/2^(N-1) - 1] * Vref/Gain     (1)

    Expanding it a little:

    Ain = (Code - 2^(N-1))/2^(N-1) * Vref/Gain

    since:

    N=16

    Vref=1170 mV

    Gain=1

    Code - 2^(16-1) = Code - 0x8000

    leads to:

    Ain = (Code - 0x8000)/2^15 * 1170/1

    Dividing a number to 2^15 can also be done by shifting the value 15 positions to the right which is less computational expensive that a division. This gives us the final formula:

    Ain = [(Code - 0x8000) * 1170 ] >> 15

    We could just as easily go with the first formula (1) but our display function ST7579_Number() can only print the absolute value of a number and we needed to check if the number was negative or positive in order to print the corresponding sign (+/-).

    >If possible, we’d like to ask a few questions about some issues we’re seeing with trying to write the >CONFIGURATION and IO registers, which don’t seem to work. We can’t set the excitation current sources as we >would like.

    Once you are able to successfully read the value of the register ID please let me know what kind of issues are you having and maybe share the code snippet that you are using to configure those registers.

    Regards,

    -Dan

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.