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.

PGA309: Actual Gain DAC and Zero DAC calculation from lookup table

Part Number: PGA309

On the section 3.2.1 page 69 of the user's guide the algorithm of Gain DAC lookup table calculation is used but it uses the Gain DAC Slopes, in an EEPROM it has the positive numbers and I want to know how the PGA calculates Gain DAC Slopes from memory values of EEPROM? For example the value of 64999 in the lookup table was 64999 at first or it was -537 and the twos compliment of the value was calculated and 64999 was the result?

In general, how does the PGA309 figures out from lookup table the actual sign of Gain DAC Slope and Zero DAC Slope from GMi and ZMi? How does it know were they positive or negative and was used twos compliment of the negative value or not?  

I have the same question for temperature value also. How does it know the temperature value was negative or positive? 

Regards,

Hoda

  • Hoda,

    According to your example, 64999 is the number stored in the EEPROM.  The EEPROM has no ability to hold signed numbers.  It just holds a series of 8-bit long words.  The PGA309 reads those words out of the EEPROM and uses them in the algorithm.  Any negative number stored in the EEPROM is stored as a two's compliment.  Step 1 shows how to convert a negative number into its 16 bit equivalent twos compliment number.  Per this example the number stored in the EEPROM for -20C is FEC0h (the number is actually -320 in decimal).  You can use the utility located here to do this conversion:  https://www.binaryconvert.com/result_signed_short.html?decimal=045051050048 

    The same approach applies to temperature, gain slope, and offset slope.  I hope this help.  

    Best regards, Art

  • Dear Art, My question was the reverse calculation by the PGA309 when it wants to get the slopes from EEPROM values. Imagine we have the EEPROM value as 0x851F, how the PGA309 figures out what was the slope at the first place? Was it 34079 or -31457? 

    Considering the table 3-3 on the user's guide page 67. If we have the Gain DAC Slopes (Hex) ,which are values being stored in the EEPROM, how can we get the previous column (Gain DAC Slope (Counts))? https://www.ti.com/lit/pdf/sbou024

    Regards, 

    Hoda

  • Hoda,

    1. The PGA309 assumes the numbers stored in the EEPROM table are 16 bit signed binary numbers.  The number 0x851F would be interpreted by the PGA309 as -31457.
    2. During the calibration process, you will need to determine the gain and offset required to correct your errors over temperature.  The calibration algorithm given in the PDF below illustrates how you would calculate the gain and offset based on measurements with minimum and maximum applied pressure.  Normally this procedure is done at 2 or 3 temperatures and the polynomial interpolation is used to determine the gain and offset at other temperatures.  
    3. Once you have the table with all the temperature, gain, and offset values you will calculate the slope values for the zero dac and gain dac.  The PGA309 users guide provides the equations to calculate the slopes. I attached an excel spreadsheet that calculates the same example from the users guide.  
    4. Once you have the table of gain and offset slopes, these are written into the PGA309 EEPROM.  Since the EEPROM holds 8 bit words at each address you will need to split the 16 bit words in half (MSB and LSB).  The write EEPROM PGA309 command will allow writing the MSB and LSB into two different locations in the EEPROM.  Note, the 16 bit word written into the EEPROM is a signed binary word.  Thus writing 0x851F will be written into two locations as 0x85 and 0x1F, but the PGA309 will read back 0x851F and interoperate it as -31457.
    5. Once the EEPROM table has been fully written the PGA309 will read the table on power-up.  The PGA309 will interpret all numbers in the table as signed binary numbers.  The PGA309 will use this table to adjust gain and offset over temperature to correct for sensor drift.

    I hope that helps.  You may consider getting the EVM to see how the algorithm works for an actual calibration with your sensor.  You can also download the labview source code and use this to understand the calibration algorithm.  Below is the calibration algorithm and the EEPROM table example.

    Best regards, Art

    sbou024b-pga309-calibration-algorithm.pdf

    PGA309 TABLE.xlsx

  • Dear Art,

    Thank you for the table that you send. I have used the Gain Dac Slope hex and tried to derive the first dec counts. However, you can see in the table below that the reverse calculation (HEX2DEC) does not return the first values. So, my question still remains which is how does the PGA309 do the same calculation correctly in order to recover the values of slope counts? I colored the different values from the expected values by red. They suppose to be the same because the PGA309 does the same calculation if I am right.

    In addition, I calculated the binary values of hex slopes and you can see there is not a sign bit (it is normally in the 16th bit) which need to be used for the reverse calculation. 

    Best regards,

    Hoda

    Gain DAC slope counts Gain Dac Slope hex EEPROM MSB EEPROM LSB Gain Dac Slope Counts (Based on hex values)
    65535 FFFF FF FF 65535
    -15726 C292 C2 92 49810
    -31458 851E 85 1E 34078
    -47186 47AE 47 AE 18350
    -10486 D70A D7 0A 55050
    41942 A3D6 A3 D6 41942
    -19566 B392 B3 92 45970
    28107 6DCB 6D CB 28107
    Gain Dac Slope hex Gain Dac Slope binary
    FFFF 1111 1111 1111 1111
    C292 1100 0010 1001 0010
    851E 1000 0101 0001 1110
    47AE 0100 0111 1010 1110
    D70A 1101 0111 0000 1010
    A3D6 1010 0011 1101 0110
    B392 1011 0011 1001 0010
    6DCB 0110 1101 1100 1011
  • Hoda,

    1. A common way digital systems use signed numbers is the "two's compliment method".  That is how the PGA309 handles signed numbers.
      1. The length of the word is a fixed length.  In this case the length of the word is 16 bits.
      2. The most significant bit in the word is the sign bit.  If the sign bit = 1, the word is negative, if the sign bit = 0.  Then the word is positive.
      3. For a 16 bit signed word the range of values is:  -32768 to 32767.  This is represented in hex by 0x8000 to 0x7FFF.
    2. The way the numbers are used internally in twos complement systems is covered in this lecture:  Lecture on signed numbers.  This is not necessary critical to understand, to use the PGA309, but you want to know how the PGA309 interoperates signed numbers and in a very basic sense, this is what is happening internally. 
    3. Another explanation of two's compliment is given in wikipedia:  Wikipedia on signed numbers
    4. In short the number 0xC292 will be interoperated as -15726 by the PGA309 because the PGA309 knows the number is a twos compliment 16 bit number.  Note that 0xC292 is equal to 11000010 10010010, and the Most significant bit is "1".  Thus the number is negative.
    5. This tool can help you translate decimal to hex and binary for twos compliment 16 bit numbers:  tool for conversions 
    6. The vast majority of digital systems handle signed numbers this way.  For another example of a device that uses signed numbers see:  ADS1220 is another device using signed numbers.  This device uses 24 bit signed numbs.  Thus for this device the number 0xFFFFFF is equal to -1 in decimal.  You can look at this to see other examples of signed numbers.  The key point is that the used of 2's compliment signed numbers is common in digital systems.

    I hope this helps.  I think your main questions relates to trying to understand how 2's compliment signed numbers work.  You may want to read through some of the literature in the links above.

    Best regards,

    Art

  • Dear Art,

    Let me use your statement "Note that 0xC292 is equal to 11000010 10010010, and the Most significant bit is "1"Thus the number is negative" that is where the question rises. If we consider the 16th bit as the sign, there are two exceptions on the table in numbers -47186 and 41942. For -47186, the hex value is 0x47AE and the binary value is "0100 0111 1010 1110". You can see the 16th bit is not "1" so how do we know it was a negative number?

    Also for the second number (41942), the hex value is 0xA3D6 and the binary value is "1010 0011 1101 0110". In this binary number the 16th bit is 1 so as you said, it should be interpreted as a negative number which is not true! 

    Gain DAC slope counts Gain Dac Slope hex Gain Dac Slope binary
    65535 FFFF 1111 1111 1111 1111
    -15726 C292 1100 0010 1001 0010
    -31458 851E 1000 0101 0001 1110
    -47186 47AE 0100 0111 1010 1110
    -10486 D70A 1101 0111 0000 1010
    41942 A3D6 1010 0011 1101 0110
    -19566 B392 1011 0011 1001 0010
    28107 6DCB 0110 1101 1100 1011
  • Hoda,

    1. For a 16 bit signed two's compliment number, the range of values you can represent are -32768 to 32767.
    2. In your example, the number -47186 is outside the range.  Note you identify the range as -47186 and 41942.  You accidentally transposed the number 68 to 86.
    3. Please use this tool: https://www.binaryconvert.com/convert_signed_short.html?hexadecimal=8000 to make conversions.  Also, please review the references I suggested.

    Best regards, Art

  • Dear Art, 

    Based on what you said, there should not be numbers below -32768 and above 32767 in 16 bit signed two's compliment. However, based on the user's manual it has many possibilities that numbers out of this range happen. So, the reverse calculation does not acquire the first values.

    To show that the reverse calculation does not acquire the decimal numbers (from hex to counts based on the table 3-3 on the user's manual), I calculate the decimal numbers in the https://www.binaryconvert.com/convert_signed_short.html?hexadecimal=8000 and here are the results: 

    So, please tell me how the PGA309 calculates the first decimal values if this recalculation does not return back the same values? (I am trying to say something is wrong with this calculation)

    P.S. I have read the references you send and I know there should be a sign number which is not considered in the user's manual.

    Best regards,

    Hoda

  • Hoda,

    1. Regarding the number 41943, and the number -47104:  You found an error in the document.  Both of these numbers are outside of the allowable range of -32768 to +32767.  If the device slope exceed the allowable range, the PGA309 would not be able to compensate for that drift level.
    2. Regarding the first row in the table.  This row is not a slope.  This value is a gain value.  All other values in the table are slopes.  So, G0 is the initial gain value at -40C, but all the other values are slopes.  The actual gain DAC value is not a signed integer.  The Gain DAC value is always positive.  A gain of  0x0000 = gain of 0.333333,  GAIN of 0xFFFF - gain of 1.000000.
    3. The PGA309EVM software is written in labview.  In labview, and in other software languages, you can define a variable type to be a signed 16 bit integer.  When you define a variable as a 16 bit signed integer in software it will automatically limit the value from -32768 to +32767.  If you develop your own software to build the table it should use 16 bit signed integers.  If you are familiar with LabView, you could download the source code for the EVM and use the section that builds the table:  https://www.ti.com/lit/zip/sboc394 
    4. Here is a link to a modified spreadsheet.  The excel file has two tabs.  One that matches the existing PGA309 users guide table 3-3, and a modified one that uses gain changes that do not violate the maximum allowable slope.  I added an error test column so that you can see the issues with the existing table and also see that the new table is ok.  PGA309 TABLE-good-vs-bad.xlsx
    5. My apologies, for this error.  I can definitely see how this is very confusing, and I will look into getting the document changed.

    Best regards,

    Art