9
\$\begingroup\$

I would like to generate a positive and negative voltage (sine wave without offset) from an AVR microcontroller. I think it needs an external DAC, because the internal ones are not able to generate a negative voltage.

Is there a possibility to do it or is there a DAC which makes that?

\$\endgroup\$
1
  • \$\begingroup\$ For what purpose? \$\endgroup\$
    – starblue
    Feb 6, 2015 at 15:41

4 Answers 4

10
\$\begingroup\$

Some of the AVRs have fairly decent 12-bit DACs. You could merely shift the zero using an op-amp. Say your DAC reference is 2.5V, then you could shift the output by an input-referred -1.25V so you get a bipolar output signal with output 0V at 0x800.

The general approach would be something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

Just throw a bit of algebra at it- for example for Vref = 2.5V and desired output -4.0V to +4.0V you could pick Rf = 10.0K, then R1 = 6.25K and R2 = 16.67K.

The above circuit does not load the DAC output, but it does present some load to the Vref. If it's not very low impedance you could use another op-amp in a dual as a unity-gain buffer so Vref also is not loaded.

Of course your op-amp requires bipolar supplies or it won't give you a bipolar output.

\$\endgroup\$
4
  • \$\begingroup\$ Hi, @Spehro. Can you please explain this calculation? I am working on similar circuit but my voltage levels are different. It would be so nice of you if you provide equations for this circuit. Thanks \$\endgroup\$ Feb 13, 2023 at 21:33
  • 2
    \$\begingroup\$ @Farid-ur-Rahman I don't really remember how I solved this 8 years ago, but try fixing one resistor (say Rf) at 10K and then for Vin = 0 Vout = -4V so R1/Vref = - Vout/10K which gives you R1 = 6.25kΩ, and then you can solve for R2 from the gain 8/2.5 = 3.2, so we know R1||R2 = 10kΩ/(3.2-1) = 4.54kΩ so R2 = 1/(1/4.54kΩ - 1/6.25kΩ). When you are done you can scale the three resistors by whatever value you like within reason (eg. multiply each by 2.00). \$\endgroup\$ Feb 13, 2023 at 21:46
  • 1
    \$\begingroup\$ You can solve it with simultaneous equations with slightly more effort but the 'trick' of choosing "0V in" eliminates R2 since we know that the voltage at the inverting input will be 0V so R2 has no current flowing through it. \$\endgroup\$ Feb 13, 2023 at 21:48
  • \$\begingroup\$ A similar question that others might find useful linked here. \$\endgroup\$
    – Shaken_U
    Sep 12, 2023 at 16:43
12
\$\begingroup\$

How about a DC blocking cap with a resistor to bias the output at ground (simple RC high pass filter)? It's rather easy to shift signals around if you don't care about preserving the DC component.

There are definitely lots of DACs available that support bipolar analog supplies, but they may be a bit expensive. If you plan on performing any analog signal processing or buffering with op amps, then it may not be worth finding a DAC that can produce a bipolar output as you can just shift the DAC output in one of the amplifier stages.

\$\endgroup\$
0
1
\$\begingroup\$

You may be able to get a span of both negative and positive voltage using the VREFN and VREFP pins on some DACs as Alex alluded to. For instance, the datasheet on the AD5726 says:

Output voltage swing is set by two reference inputs, VREFP and VREFN. The DAC offers a unipolar positive output range when the VREFN input is set to 0 V and the VREFP input is set to a positive voltage. A similar configuration with VREFP at 0 V and VREFN at a negative voltage provides a unipolar negative output range."

\$\endgroup\$
1
\$\begingroup\$

I use the AD5761R 16-bit, voltage output digital-to-analog converter (DAC) it has output that can swing positive or negative. You do have to have both external +/- rails. But its a great 16bit device.

\$\endgroup\$

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.