Converting ADC output to real values
$begingroup$
On a custom board I have an ADC which measures -5V to +5V. And outputs in Hex via SPI like this:
0x8000 to 0x0000 = most negative to 0
0x0000 to 0x7FFF = 0 to most positive
I just started studiyng ADCs so I am not sure what is going on. I beleive I have negative full scale of -5V and positive full scale of +5V.
Questions:
- What this numbering system is based on? Is it two's complement?
- Why there is no 0xFFFF value?
- How can I convert these numbers to a real voltage?
analog adc measurement
$endgroup$
add a comment |
$begingroup$
On a custom board I have an ADC which measures -5V to +5V. And outputs in Hex via SPI like this:
0x8000 to 0x0000 = most negative to 0
0x0000 to 0x7FFF = 0 to most positive
I just started studiyng ADCs so I am not sure what is going on. I beleive I have negative full scale of -5V and positive full scale of +5V.
Questions:
- What this numbering system is based on? Is it two's complement?
- Why there is no 0xFFFF value?
- How can I convert these numbers to a real voltage?
analog adc measurement
$endgroup$
6
$begingroup$
That's up to the ADC datasheet to define. You don't mention the ADC type, which would be integral to this question...
$endgroup$
– Marcus Müller
4 hours ago
$begingroup$
are you sure your ranges are correct?
$endgroup$
– Colin
4 hours ago
2
$begingroup$
There is a 0xFFFF value. That's-1.
$endgroup$
– brhans
3 hours ago
$begingroup$
VTC until the specific ADC is mentioned, otherwise we can only guess. @MarcusMüller You should probably also VTC if you really think the information is integral to the question.
$endgroup$
– pipe
18 mins ago
add a comment |
$begingroup$
On a custom board I have an ADC which measures -5V to +5V. And outputs in Hex via SPI like this:
0x8000 to 0x0000 = most negative to 0
0x0000 to 0x7FFF = 0 to most positive
I just started studiyng ADCs so I am not sure what is going on. I beleive I have negative full scale of -5V and positive full scale of +5V.
Questions:
- What this numbering system is based on? Is it two's complement?
- Why there is no 0xFFFF value?
- How can I convert these numbers to a real voltage?
analog adc measurement
$endgroup$
On a custom board I have an ADC which measures -5V to +5V. And outputs in Hex via SPI like this:
0x8000 to 0x0000 = most negative to 0
0x0000 to 0x7FFF = 0 to most positive
I just started studiyng ADCs so I am not sure what is going on. I beleive I have negative full scale of -5V and positive full scale of +5V.
Questions:
- What this numbering system is based on? Is it two's complement?
- Why there is no 0xFFFF value?
- How can I convert these numbers to a real voltage?
analog adc measurement
analog adc measurement
edited 1 hour ago
Electric_90
640115
640115
asked 4 hours ago
DEKKERDEKKER
977
977
6
$begingroup$
That's up to the ADC datasheet to define. You don't mention the ADC type, which would be integral to this question...
$endgroup$
– Marcus Müller
4 hours ago
$begingroup$
are you sure your ranges are correct?
$endgroup$
– Colin
4 hours ago
2
$begingroup$
There is a 0xFFFF value. That's-1.
$endgroup$
– brhans
3 hours ago
$begingroup$
VTC until the specific ADC is mentioned, otherwise we can only guess. @MarcusMüller You should probably also VTC if you really think the information is integral to the question.
$endgroup$
– pipe
18 mins ago
add a comment |
6
$begingroup$
That's up to the ADC datasheet to define. You don't mention the ADC type, which would be integral to this question...
$endgroup$
– Marcus Müller
4 hours ago
$begingroup$
are you sure your ranges are correct?
$endgroup$
– Colin
4 hours ago
2
$begingroup$
There is a 0xFFFF value. That's-1.
$endgroup$
– brhans
3 hours ago
$begingroup$
VTC until the specific ADC is mentioned, otherwise we can only guess. @MarcusMüller You should probably also VTC if you really think the information is integral to the question.
$endgroup$
– pipe
18 mins ago
6
6
$begingroup$
That's up to the ADC datasheet to define. You don't mention the ADC type, which would be integral to this question...
$endgroup$
– Marcus Müller
4 hours ago
$begingroup$
That's up to the ADC datasheet to define. You don't mention the ADC type, which would be integral to this question...
$endgroup$
– Marcus Müller
4 hours ago
$begingroup$
are you sure your ranges are correct?
$endgroup$
– Colin
4 hours ago
$begingroup$
are you sure your ranges are correct?
$endgroup$
– Colin
4 hours ago
2
2
$begingroup$
There is a 0xFFFF value. That's
-1.$endgroup$
– brhans
3 hours ago
$begingroup$
There is a 0xFFFF value. That's
-1.$endgroup$
– brhans
3 hours ago
$begingroup$
VTC until the specific ADC is mentioned, otherwise we can only guess. @MarcusMüller You should probably also VTC if you really think the information is integral to the question.
$endgroup$
– pipe
18 mins ago
$begingroup$
VTC until the specific ADC is mentioned, otherwise we can only guess. @MarcusMüller You should probably also VTC if you really think the information is integral to the question.
$endgroup$
– pipe
18 mins ago
add a comment |
4 Answers
4
active
oldest
votes
$begingroup$
It looks like you have a 16-bit, 2's-complement ADC with a range of $-5V le V_{IN} < 5V$. If that's the case, then the digital values can be interpreted as signed integers from -32768 to +32767. The measured voltage is
$ V_{IN} = frac{DigitalValue}{32768} times 5$
$endgroup$
add a comment |
$begingroup$
If you count most negative to 0 using integers, you count ..., -4, -3, -2, -1, 0
If you count most negative to 0 using hexadecimals, you count (in your case) 0x8000, 0x8001 ..., 0xFFFE, 0xFFFF, 0
So, there is the 0xFFFF.
Now, your scale is 0X8000 to 0x7FFF, so, in decimal -32768 to 32767, the full scale is 65636 (-32768 +-32767 + 1). The scale represents -5V to +5V, full scale 10V.
The conversion is:
Vmeasured = SPI_OUPUT_in_HEX / 65536 * 10V
P.S. I guess using 65536 or 65535 for dividing is a matter of taste; it hardly influences the accuracy. Using 65535 may be preferable/nessecary in old tiny microprocessors.
$endgroup$
$begingroup$
So how do you get -5 out of your formula when the digital value is 0x8000? I think you are assuming an input range of 0 to 10V rather than -5V to +5V.
$endgroup$
– Elliot Alderson
2 hours ago
1
$begingroup$
How would 65535 be necessary? 65536 doesn't need a divide instruction at all, it's just a right-shift by 16 places (in integral or fixed-point math) orldexp(x, -16)on floating-point.
$endgroup$
– Ben Voigt
1 hour ago
$begingroup$
You're right, my reason was that 65536 is easier to shift. I made a typo.
$endgroup$
– Huisman
37 mins ago
$begingroup$
@Elliot The question says 0x8000 = most negative number... so in the context of the question it is -32768
$endgroup$
– Huisman
35 mins ago
$begingroup$
So you should use a signed, integer value rather than the HEXVALUE in your equation? I think that part is confusing.
$endgroup$
– Elliot Alderson
34 mins ago
add a comment |
$begingroup$
I'll just add to @Eliot's answer that in reality if you have floating point math available (and choose to use it) you should convert DigitalValue to floating point before dividing.
If you only have integer math available you can multiply by five (you need more than 16 bits, obviously) and then throw away the least-significant 2 bits (or round) and place the radix point right of the 4th bit. For example 0x7FFF FFFF -> 0x27FF FFFF FB -> 0x4.FFF FFFF (one LSB less than 5.0000).
$endgroup$
add a comment |
$begingroup$
Recommended thing would be to grab datasheet for your ADC chip and see in chapter named "Data Format". In this chapter it will be explained how the numeric values (data) from the ADC is represented.
It seems that your digital representation is something named 2's complement. Here is the wiki link.
From values you have provided I assume it is 16-bit ADC. So, max value 0x7FFF is your +Vref (positive reference voltage) and 0x8000 is -Vref (negative reference voltage).
Example:
Let's say your positive reference voltage is 2.5V, and negative reference voltage is -2.5V, then when you see obtained value of ADC equal 0x7FFF it means you have 2.5V on the ADC input. To calculate other positive values you take Vref and divide it by numbers of bits value (0x7FFF equals to dec 32767), so if your ADC gives you 0x0001 is equivalent of 2.5[V]/32767 = 0.000076[V]
For negative numbers: if your ADC value is bigger or equal to 0x7FFF then your action may be: negative_measured_value = measured_value - (0xFFFF + 1)
So, when ADC provides you value of 0xFFFF it goes:
negative_measured_value = 0xFFFF - (0xFFFF +1) = -1
true_volt_value = -1 * (2.5[V]/32767) = -0.000076V
Huisman answers it as well.
$endgroup$
$begingroup$
If you are doing the math on a 16 bit integer your formula for negative_measured_value just returns measured_value.
$endgroup$
– Elliot Alderson
2 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
return StackExchange.using("schematics", function () {
StackExchange.schematics.init();
});
}, "cicuitlab");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "135"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f421205%2fconverting-adc-output-to-real-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
It looks like you have a 16-bit, 2's-complement ADC with a range of $-5V le V_{IN} < 5V$. If that's the case, then the digital values can be interpreted as signed integers from -32768 to +32767. The measured voltage is
$ V_{IN} = frac{DigitalValue}{32768} times 5$
$endgroup$
add a comment |
$begingroup$
It looks like you have a 16-bit, 2's-complement ADC with a range of $-5V le V_{IN} < 5V$. If that's the case, then the digital values can be interpreted as signed integers from -32768 to +32767. The measured voltage is
$ V_{IN} = frac{DigitalValue}{32768} times 5$
$endgroup$
add a comment |
$begingroup$
It looks like you have a 16-bit, 2's-complement ADC with a range of $-5V le V_{IN} < 5V$. If that's the case, then the digital values can be interpreted as signed integers from -32768 to +32767. The measured voltage is
$ V_{IN} = frac{DigitalValue}{32768} times 5$
$endgroup$
It looks like you have a 16-bit, 2's-complement ADC with a range of $-5V le V_{IN} < 5V$. If that's the case, then the digital values can be interpreted as signed integers from -32768 to +32767. The measured voltage is
$ V_{IN} = frac{DigitalValue}{32768} times 5$
answered 3 hours ago
Elliot AldersonElliot Alderson
6,76511022
6,76511022
add a comment |
add a comment |
$begingroup$
If you count most negative to 0 using integers, you count ..., -4, -3, -2, -1, 0
If you count most negative to 0 using hexadecimals, you count (in your case) 0x8000, 0x8001 ..., 0xFFFE, 0xFFFF, 0
So, there is the 0xFFFF.
Now, your scale is 0X8000 to 0x7FFF, so, in decimal -32768 to 32767, the full scale is 65636 (-32768 +-32767 + 1). The scale represents -5V to +5V, full scale 10V.
The conversion is:
Vmeasured = SPI_OUPUT_in_HEX / 65536 * 10V
P.S. I guess using 65536 or 65535 for dividing is a matter of taste; it hardly influences the accuracy. Using 65535 may be preferable/nessecary in old tiny microprocessors.
$endgroup$
$begingroup$
So how do you get -5 out of your formula when the digital value is 0x8000? I think you are assuming an input range of 0 to 10V rather than -5V to +5V.
$endgroup$
– Elliot Alderson
2 hours ago
1
$begingroup$
How would 65535 be necessary? 65536 doesn't need a divide instruction at all, it's just a right-shift by 16 places (in integral or fixed-point math) orldexp(x, -16)on floating-point.
$endgroup$
– Ben Voigt
1 hour ago
$begingroup$
You're right, my reason was that 65536 is easier to shift. I made a typo.
$endgroup$
– Huisman
37 mins ago
$begingroup$
@Elliot The question says 0x8000 = most negative number... so in the context of the question it is -32768
$endgroup$
– Huisman
35 mins ago
$begingroup$
So you should use a signed, integer value rather than the HEXVALUE in your equation? I think that part is confusing.
$endgroup$
– Elliot Alderson
34 mins ago
add a comment |
$begingroup$
If you count most negative to 0 using integers, you count ..., -4, -3, -2, -1, 0
If you count most negative to 0 using hexadecimals, you count (in your case) 0x8000, 0x8001 ..., 0xFFFE, 0xFFFF, 0
So, there is the 0xFFFF.
Now, your scale is 0X8000 to 0x7FFF, so, in decimal -32768 to 32767, the full scale is 65636 (-32768 +-32767 + 1). The scale represents -5V to +5V, full scale 10V.
The conversion is:
Vmeasured = SPI_OUPUT_in_HEX / 65536 * 10V
P.S. I guess using 65536 or 65535 for dividing is a matter of taste; it hardly influences the accuracy. Using 65535 may be preferable/nessecary in old tiny microprocessors.
$endgroup$
$begingroup$
So how do you get -5 out of your formula when the digital value is 0x8000? I think you are assuming an input range of 0 to 10V rather than -5V to +5V.
$endgroup$
– Elliot Alderson
2 hours ago
1
$begingroup$
How would 65535 be necessary? 65536 doesn't need a divide instruction at all, it's just a right-shift by 16 places (in integral or fixed-point math) orldexp(x, -16)on floating-point.
$endgroup$
– Ben Voigt
1 hour ago
$begingroup$
You're right, my reason was that 65536 is easier to shift. I made a typo.
$endgroup$
– Huisman
37 mins ago
$begingroup$
@Elliot The question says 0x8000 = most negative number... so in the context of the question it is -32768
$endgroup$
– Huisman
35 mins ago
$begingroup$
So you should use a signed, integer value rather than the HEXVALUE in your equation? I think that part is confusing.
$endgroup$
– Elliot Alderson
34 mins ago
add a comment |
$begingroup$
If you count most negative to 0 using integers, you count ..., -4, -3, -2, -1, 0
If you count most negative to 0 using hexadecimals, you count (in your case) 0x8000, 0x8001 ..., 0xFFFE, 0xFFFF, 0
So, there is the 0xFFFF.
Now, your scale is 0X8000 to 0x7FFF, so, in decimal -32768 to 32767, the full scale is 65636 (-32768 +-32767 + 1). The scale represents -5V to +5V, full scale 10V.
The conversion is:
Vmeasured = SPI_OUPUT_in_HEX / 65536 * 10V
P.S. I guess using 65536 or 65535 for dividing is a matter of taste; it hardly influences the accuracy. Using 65535 may be preferable/nessecary in old tiny microprocessors.
$endgroup$
If you count most negative to 0 using integers, you count ..., -4, -3, -2, -1, 0
If you count most negative to 0 using hexadecimals, you count (in your case) 0x8000, 0x8001 ..., 0xFFFE, 0xFFFF, 0
So, there is the 0xFFFF.
Now, your scale is 0X8000 to 0x7FFF, so, in decimal -32768 to 32767, the full scale is 65636 (-32768 +-32767 + 1). The scale represents -5V to +5V, full scale 10V.
The conversion is:
Vmeasured = SPI_OUPUT_in_HEX / 65536 * 10V
P.S. I guess using 65536 or 65535 for dividing is a matter of taste; it hardly influences the accuracy. Using 65535 may be preferable/nessecary in old tiny microprocessors.
edited 31 mins ago
answered 3 hours ago
HuismanHuisman
1457
1457
$begingroup$
So how do you get -5 out of your formula when the digital value is 0x8000? I think you are assuming an input range of 0 to 10V rather than -5V to +5V.
$endgroup$
– Elliot Alderson
2 hours ago
1
$begingroup$
How would 65535 be necessary? 65536 doesn't need a divide instruction at all, it's just a right-shift by 16 places (in integral or fixed-point math) orldexp(x, -16)on floating-point.
$endgroup$
– Ben Voigt
1 hour ago
$begingroup$
You're right, my reason was that 65536 is easier to shift. I made a typo.
$endgroup$
– Huisman
37 mins ago
$begingroup$
@Elliot The question says 0x8000 = most negative number... so in the context of the question it is -32768
$endgroup$
– Huisman
35 mins ago
$begingroup$
So you should use a signed, integer value rather than the HEXVALUE in your equation? I think that part is confusing.
$endgroup$
– Elliot Alderson
34 mins ago
add a comment |
$begingroup$
So how do you get -5 out of your formula when the digital value is 0x8000? I think you are assuming an input range of 0 to 10V rather than -5V to +5V.
$endgroup$
– Elliot Alderson
2 hours ago
1
$begingroup$
How would 65535 be necessary? 65536 doesn't need a divide instruction at all, it's just a right-shift by 16 places (in integral or fixed-point math) orldexp(x, -16)on floating-point.
$endgroup$
– Ben Voigt
1 hour ago
$begingroup$
You're right, my reason was that 65536 is easier to shift. I made a typo.
$endgroup$
– Huisman
37 mins ago
$begingroup$
@Elliot The question says 0x8000 = most negative number... so in the context of the question it is -32768
$endgroup$
– Huisman
35 mins ago
$begingroup$
So you should use a signed, integer value rather than the HEXVALUE in your equation? I think that part is confusing.
$endgroup$
– Elliot Alderson
34 mins ago
$begingroup$
So how do you get -5 out of your formula when the digital value is 0x8000? I think you are assuming an input range of 0 to 10V rather than -5V to +5V.
$endgroup$
– Elliot Alderson
2 hours ago
$begingroup$
So how do you get -5 out of your formula when the digital value is 0x8000? I think you are assuming an input range of 0 to 10V rather than -5V to +5V.
$endgroup$
– Elliot Alderson
2 hours ago
1
1
$begingroup$
How would 65535 be necessary? 65536 doesn't need a divide instruction at all, it's just a right-shift by 16 places (in integral or fixed-point math) or
ldexp(x, -16) on floating-point.$endgroup$
– Ben Voigt
1 hour ago
$begingroup$
How would 65535 be necessary? 65536 doesn't need a divide instruction at all, it's just a right-shift by 16 places (in integral or fixed-point math) or
ldexp(x, -16) on floating-point.$endgroup$
– Ben Voigt
1 hour ago
$begingroup$
You're right, my reason was that 65536 is easier to shift. I made a typo.
$endgroup$
– Huisman
37 mins ago
$begingroup$
You're right, my reason was that 65536 is easier to shift. I made a typo.
$endgroup$
– Huisman
37 mins ago
$begingroup$
@Elliot The question says 0x8000 = most negative number... so in the context of the question it is -32768
$endgroup$
– Huisman
35 mins ago
$begingroup$
@Elliot The question says 0x8000 = most negative number... so in the context of the question it is -32768
$endgroup$
– Huisman
35 mins ago
$begingroup$
So you should use a signed, integer value rather than the HEXVALUE in your equation? I think that part is confusing.
$endgroup$
– Elliot Alderson
34 mins ago
$begingroup$
So you should use a signed, integer value rather than the HEXVALUE in your equation? I think that part is confusing.
$endgroup$
– Elliot Alderson
34 mins ago
add a comment |
$begingroup$
I'll just add to @Eliot's answer that in reality if you have floating point math available (and choose to use it) you should convert DigitalValue to floating point before dividing.
If you only have integer math available you can multiply by five (you need more than 16 bits, obviously) and then throw away the least-significant 2 bits (or round) and place the radix point right of the 4th bit. For example 0x7FFF FFFF -> 0x27FF FFFF FB -> 0x4.FFF FFFF (one LSB less than 5.0000).
$endgroup$
add a comment |
$begingroup$
I'll just add to @Eliot's answer that in reality if you have floating point math available (and choose to use it) you should convert DigitalValue to floating point before dividing.
If you only have integer math available you can multiply by five (you need more than 16 bits, obviously) and then throw away the least-significant 2 bits (or round) and place the radix point right of the 4th bit. For example 0x7FFF FFFF -> 0x27FF FFFF FB -> 0x4.FFF FFFF (one LSB less than 5.0000).
$endgroup$
add a comment |
$begingroup$
I'll just add to @Eliot's answer that in reality if you have floating point math available (and choose to use it) you should convert DigitalValue to floating point before dividing.
If you only have integer math available you can multiply by five (you need more than 16 bits, obviously) and then throw away the least-significant 2 bits (or round) and place the radix point right of the 4th bit. For example 0x7FFF FFFF -> 0x27FF FFFF FB -> 0x4.FFF FFFF (one LSB less than 5.0000).
$endgroup$
I'll just add to @Eliot's answer that in reality if you have floating point math available (and choose to use it) you should convert DigitalValue to floating point before dividing.
If you only have integer math available you can multiply by five (you need more than 16 bits, obviously) and then throw away the least-significant 2 bits (or round) and place the radix point right of the 4th bit. For example 0x7FFF FFFF -> 0x27FF FFFF FB -> 0x4.FFF FFFF (one LSB less than 5.0000).
answered 2 hours ago
Spehro PefhanySpehro Pefhany
207k5157415
207k5157415
add a comment |
add a comment |
$begingroup$
Recommended thing would be to grab datasheet for your ADC chip and see in chapter named "Data Format". In this chapter it will be explained how the numeric values (data) from the ADC is represented.
It seems that your digital representation is something named 2's complement. Here is the wiki link.
From values you have provided I assume it is 16-bit ADC. So, max value 0x7FFF is your +Vref (positive reference voltage) and 0x8000 is -Vref (negative reference voltage).
Example:
Let's say your positive reference voltage is 2.5V, and negative reference voltage is -2.5V, then when you see obtained value of ADC equal 0x7FFF it means you have 2.5V on the ADC input. To calculate other positive values you take Vref and divide it by numbers of bits value (0x7FFF equals to dec 32767), so if your ADC gives you 0x0001 is equivalent of 2.5[V]/32767 = 0.000076[V]
For negative numbers: if your ADC value is bigger or equal to 0x7FFF then your action may be: negative_measured_value = measured_value - (0xFFFF + 1)
So, when ADC provides you value of 0xFFFF it goes:
negative_measured_value = 0xFFFF - (0xFFFF +1) = -1
true_volt_value = -1 * (2.5[V]/32767) = -0.000076V
Huisman answers it as well.
$endgroup$
$begingroup$
If you are doing the math on a 16 bit integer your formula for negative_measured_value just returns measured_value.
$endgroup$
– Elliot Alderson
2 hours ago
add a comment |
$begingroup$
Recommended thing would be to grab datasheet for your ADC chip and see in chapter named "Data Format". In this chapter it will be explained how the numeric values (data) from the ADC is represented.
It seems that your digital representation is something named 2's complement. Here is the wiki link.
From values you have provided I assume it is 16-bit ADC. So, max value 0x7FFF is your +Vref (positive reference voltage) and 0x8000 is -Vref (negative reference voltage).
Example:
Let's say your positive reference voltage is 2.5V, and negative reference voltage is -2.5V, then when you see obtained value of ADC equal 0x7FFF it means you have 2.5V on the ADC input. To calculate other positive values you take Vref and divide it by numbers of bits value (0x7FFF equals to dec 32767), so if your ADC gives you 0x0001 is equivalent of 2.5[V]/32767 = 0.000076[V]
For negative numbers: if your ADC value is bigger or equal to 0x7FFF then your action may be: negative_measured_value = measured_value - (0xFFFF + 1)
So, when ADC provides you value of 0xFFFF it goes:
negative_measured_value = 0xFFFF - (0xFFFF +1) = -1
true_volt_value = -1 * (2.5[V]/32767) = -0.000076V
Huisman answers it as well.
$endgroup$
$begingroup$
If you are doing the math on a 16 bit integer your formula for negative_measured_value just returns measured_value.
$endgroup$
– Elliot Alderson
2 hours ago
add a comment |
$begingroup$
Recommended thing would be to grab datasheet for your ADC chip and see in chapter named "Data Format". In this chapter it will be explained how the numeric values (data) from the ADC is represented.
It seems that your digital representation is something named 2's complement. Here is the wiki link.
From values you have provided I assume it is 16-bit ADC. So, max value 0x7FFF is your +Vref (positive reference voltage) and 0x8000 is -Vref (negative reference voltage).
Example:
Let's say your positive reference voltage is 2.5V, and negative reference voltage is -2.5V, then when you see obtained value of ADC equal 0x7FFF it means you have 2.5V on the ADC input. To calculate other positive values you take Vref and divide it by numbers of bits value (0x7FFF equals to dec 32767), so if your ADC gives you 0x0001 is equivalent of 2.5[V]/32767 = 0.000076[V]
For negative numbers: if your ADC value is bigger or equal to 0x7FFF then your action may be: negative_measured_value = measured_value - (0xFFFF + 1)
So, when ADC provides you value of 0xFFFF it goes:
negative_measured_value = 0xFFFF - (0xFFFF +1) = -1
true_volt_value = -1 * (2.5[V]/32767) = -0.000076V
Huisman answers it as well.
$endgroup$
Recommended thing would be to grab datasheet for your ADC chip and see in chapter named "Data Format". In this chapter it will be explained how the numeric values (data) from the ADC is represented.
It seems that your digital representation is something named 2's complement. Here is the wiki link.
From values you have provided I assume it is 16-bit ADC. So, max value 0x7FFF is your +Vref (positive reference voltage) and 0x8000 is -Vref (negative reference voltage).
Example:
Let's say your positive reference voltage is 2.5V, and negative reference voltage is -2.5V, then when you see obtained value of ADC equal 0x7FFF it means you have 2.5V on the ADC input. To calculate other positive values you take Vref and divide it by numbers of bits value (0x7FFF equals to dec 32767), so if your ADC gives you 0x0001 is equivalent of 2.5[V]/32767 = 0.000076[V]
For negative numbers: if your ADC value is bigger or equal to 0x7FFF then your action may be: negative_measured_value = measured_value - (0xFFFF + 1)
So, when ADC provides you value of 0xFFFF it goes:
negative_measured_value = 0xFFFF - (0xFFFF +1) = -1
true_volt_value = -1 * (2.5[V]/32767) = -0.000076V
Huisman answers it as well.
edited 55 mins ago
answered 3 hours ago
smajlismajli
47439
47439
$begingroup$
If you are doing the math on a 16 bit integer your formula for negative_measured_value just returns measured_value.
$endgroup$
– Elliot Alderson
2 hours ago
add a comment |
$begingroup$
If you are doing the math on a 16 bit integer your formula for negative_measured_value just returns measured_value.
$endgroup$
– Elliot Alderson
2 hours ago
$begingroup$
If you are doing the math on a 16 bit integer your formula for negative_measured_value just returns measured_value.
$endgroup$
– Elliot Alderson
2 hours ago
$begingroup$
If you are doing the math on a 16 bit integer your formula for negative_measured_value just returns measured_value.
$endgroup$
– Elliot Alderson
2 hours ago
add a comment |
Thanks for contributing an answer to Electrical Engineering Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f421205%2fconverting-adc-output-to-real-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
6
$begingroup$
That's up to the ADC datasheet to define. You don't mention the ADC type, which would be integral to this question...
$endgroup$
– Marcus Müller
4 hours ago
$begingroup$
are you sure your ranges are correct?
$endgroup$
– Colin
4 hours ago
2
$begingroup$
There is a 0xFFFF value. That's
-1.$endgroup$
– brhans
3 hours ago
$begingroup$
VTC until the specific ADC is mentioned, otherwise we can only guess. @MarcusMüller You should probably also VTC if you really think the information is integral to the question.
$endgroup$
– pipe
18 mins ago