I have a ADC HX711 which gives output in 2s complement form. I want to calculate the input voltage at given to ADC.
What all calculations i need to do to recalculate the ADC input voltage.
Ref = 1.25 Volts ADC count = 2s complement.
Thanks
I have a ADC HX711 which gives output in 2s complement form. I want to calculate the input voltage at given to ADC.
What all calculations i need to do to recalculate the ADC input voltage.
Ref = 1.25 Volts ADC count = 2s complement.
Thanks
-Conversion from Two's Complement-
Use the number 0xFFFFFFFF as an example. In binary, that is:
1111 1111 1111 1111 1111 1111 1111 1111
What can we say about this number? It's first (leftmost) bit is 1, which means that this represents a number that is negative. That's just the way that things are in two's complement: a leading 1 means the number is negative, a leading 0 means the number is 0 or positive.
To see what this number is a negative of, we reverse the sign of this number. But how to do that? The class notes say (on 3.17) that to reverse the sign you simply invert the bits (0 goes to 1, and 1 to 0) and add one to the resulting number.
The inversion of that binary number is, obviously:
0000 0000 0000 0000 0000 0000 0000 0000
Then we add one.
0000 0000 0000 0000 0000 0000 0000 0001
So the negative of 0xFFFFFFFF is 0x00000001, more commonly known as 1. So 0xFFFFFFFF is -1.
-ADC point of view-
As you haven't mention number of bit as output, will give generic answer:
The Value you get back is proportional to the reference that you are using.
10 bits = 1024 steps (0 to 1023)
So the calculation to work out the voltage for your result is:
Result_mV = ( Reference voltage in mV / 1023) * Result(decimal value by ADC)