0
\$\begingroup\$

Suppose we have a signed 12-bit output which is capable of representing both positive and negative numbers, how can this be converted to a +/- 10v signal using DACs, op-amps, etc.

For example, 1100 1011 0111 would result in a negative voltage and 0111 1101 1000 would result in a positive voltage.

What formula could be used to calculate the desired voltage(+/-)?

\$\endgroup\$
4
  • \$\begingroup\$ The voltage originates from the DAC with the correct polarity. The op-amp is just a noise-filter and buffer. Use a TL081 or TL082. With only 12 bits of resolution you do not need a ultra-quiet op-amp like the TL071 or TL072 series. A cheap LM358 might work just fine. The TL071 and TL081 have offset adjust pins. \$\endgroup\$
    – user105652
    May 25, 2016 at 21:22
  • \$\begingroup\$ @Sparky256 - actually, there are a lot of DACs which output current, in which case effectively the voltage comes from the op-amp in (potentially offset) proportion to the DAC current. \$\endgroup\$ May 25, 2016 at 21:40
  • \$\begingroup\$ NOTE: If the DAC only outputs a +/- 5 volts range then the op-amp can be set for a gain of 2 to get an output of +/- 10 volts. I suggest using one with an offset trim due to asymmetry in the DAC outputs as mentioned by Spehro. \$\endgroup\$
    – user105652
    May 25, 2016 at 21:40
  • \$\begingroup\$ @ChrisStratton. You are correct in that the DAC chosen by the OP determines how the op-amp stage is constructed. With a current DAC the first op-amp inverts the signal, so a second inverter is needed to obtain the original polarity. A TL082 or LM358 can do this. \$\endgroup\$
    – user105652
    May 25, 2016 at 21:45

2 Answers 2

2
\$\begingroup\$

It depends a lot on the DAC (and also on the representation). You may be able to find a bipolar DAC that accepts a 2's complement input, for example. One common method is to use a unipolar 12-bit DAC and add an offset to the output so 0x000 would be about -10 and 0xFFF would be +10.

However, your example appears to indicate 2's complement or sign+number. Assuming the former (2's complement), and assuming you have a bipolar DAC that outputs some voltage +Vmax to (about) -Vmax for the full range you might have to add an amplifier to change Vmax to 10V.

So in the case of a 12-bit 2's complement number the maximum positive number is 0x7FF and the smallest negative number is 0x800 (possibly sign-extended to 0xF800 if 16-bit representation is used).

So if we set 0x800 = +10V (for 2047) then the output voltage is:

\$V_{OUT} = R'\cdot \frac{10}{2047}\$ where R' is the (integer) decimal equivalent of the 2's complement DAC input R.

So for R' = 2047 (0x800) we get 10.000V, for R' = 0 (0x000) we get 0.000V and for R' = -2048 (0x800) we get -10.005V. Note that there is a slight asymmetry between the maximum positive and negative voltage because of the way 2's complement works.

\$\endgroup\$
8
  • \$\begingroup\$ The method of using a unipolar DAC with an offset is an interesting one. I take it I would scale the 12-bit output from the MCU by adding (2^12/2) to it. Is this correct? \$\endgroup\$
    – M-R
    May 25, 2016 at 22:21
  • \$\begingroup\$ Yes, it can be correct. You have to discard any carry to bit 12 (13th bit), so (for example) 'and' the result with 0xFFF if you're doing 16 bit math. \$\endgroup\$ May 26, 2016 at 3:31
  • \$\begingroup\$ I'm not entirely sure what you mean by discarding the carry bit. Do you mean than there are cases where a 12th bit may be required? If so, wouldn't this rest the first 11 bits to all 0s? How does 'anding' the result help? \$\endgroup\$
    – M-R
    Feb 12, 2017 at 0:05
  • \$\begingroup\$ Discard the 13th bit. \$\endgroup\$ Feb 12, 2017 at 15:42
  • \$\begingroup\$ How would I do this? And how would I ensure that the first 11 bits don't reset to 0? \$\endgroup\$
    – M-R
    Feb 12, 2017 at 19:08
0
\$\begingroup\$

You have 12 bits to encode a range of 20V. So your resolution will be

20V / 2^12 = 0.0049V per LSB 

So in order to get X volts, you just divide X by 0.0049 and round it. It will give you the value which you convert into (signed, 2's complement for example) binary to represent it. Of course the floating point math is impresise, so you should check always you are in the range of 12bits. And of course you can easily invert the calculation.

\$\endgroup\$
1
  • \$\begingroup\$ Actually, resolution is 20/(2^12 - 1). \$\endgroup\$ May 25, 2016 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.