Convert Teensy DAC Single Ended Output to Differential Output

Status
Not open for further replies.

spumoni

Member
Hi All,

I am a complete noob here with analog circuits and I am trying to get the Teensy 3.2 to control a laser galvonometer.

I need an op amp circuit to convert the DAC single ended output from Teensy (0-3.3v) to a differential output (+5v to -5v). I have searched the web and found chips by Linear and Analog Devices that do this but they are MSOP8 packages (looking for DIP).

I am thinking that I would feed the DAC output to an Op Amp configure as a buffer amp for the positive side of the differential output (0 - +5v) and the also feed it into the (-) terminal of an differential Op Amp (0 - -5v) configured and the (+) input connected to 3.3v? On differential amp I would used the feedback resistors to adjust the gain.

I would welcome any suggestions on what op amp would be a good candidate for this application. I need between 20-30khz driver frequency.

Thanks in Advance!
 
The easiest way would probably be a dual-supply differential amplifier comparing the DAC output to a reference of 1.66V?
 
If I use differential amplifier comparing the DAC output to a reference of 1.66V, will the output range on the positive side will be 0 to +1.66v and the negative to negative side will be 0 to -1.66v?

Then to get the +5v range I need, I should add on two non-inverting op amp stages with the appropriate gain resistors? For the voltage reference, can I just make a voltage divider with 2 10k resistors, connected to 3.3v and grd?

Do you think a generic 741 op would be ok?

Also do you know of any tiny (fit on circuit board) dual +-10v supply that I can use to power the op amps?

Thanks for the help.
 
If I use differential amplifier comparing the DAC output to a reference of 1.66V, will the output range on the positive side will be 0 to +1.66v and the negative to negative side will be 0 to -1.66v?

It will be if you use 4 equal resistors.

300px-Op-Amp_Differential_Amplifier.svg.png

But if you make Rf and Rg 3 times the value of R1 & R2, and of course connect a stable 1.65 volts at V1, you'll get output from -5 to +5 volts.

For the voltage reference, can I just make a voltage divider with 2 10k resistors, connected to 3.3v and grd?

No, that's not so simple. The problem is the current into R1 changes. So if you connect that resistor divider to R1, the V1 voltage will change as the signal tries to change in response to V2 changing. You need V1 to remain fixed at 1.65V.

The simplest solution is to connect another opamp as a unity gain follower, to buffer the 1.65V from the resistor divider. The opamp drive the R1 resistor without disturbing the current in those 10K resistors.

Do you think a generic 741 op would be ok?

Should work fine, but you'll need at least 3 of them.

Don't forget the opamp offset voltages will add small errors, and the opamp bias currents will also flow through your resistors, adding more small errors.

Also do you know of any tiny (fit on circuit board) dual +-10v supply that I can use to power the op amps?

Lots of these exist on the market. Some have noisy outputs, especially the very small ones, so if you care about noise add extra capacitors.

Be very careful with those voltages. Accidentally touch +10V or -10V to your Teensy can instantly kill it.
 
Also remember the DAC can't drive resistance lower than 3K, and ideally 10K or higher should be used for best accuracy. So R2 + Rg should be 10K or higher.
 
You can split R1 into two resistors in series, each twice the original value. Connect one end to GND, the other end to 3.3 V, and the junction to the opamp's inverting input ('-').

Basically this incorporates the desired value of R1 into the resistor divider.
 
For the voltage reference, can I just make a voltage divider with 2 10k resistors, connected to 3.3v and grd?
Should work, but will be dependent on the stability of 3.3V line. You could also use a dedicated voltage reference chip.

Do you think a generic 741 op would be ok?
In general I try to avoid these because there are much better alternatives (lower power, lower voltage, lower noise, higher slew rate) to this ancient beast. My weapon of choice is the MCP6402T-E, but that's a SMD only part. I think relatively modern parts like TL071 or LM358 are also available in DIP. Or look for a rail-to-rail 5V part, saves you an additional power supply (assuming you already have a 5V line).

Also do you know of any tiny (fit on circuit board) dual +-10v supply that I can use to power the op amps?
Your best option here would probably be a small PCB mounted DC-DC converter. However if current draw is very limited you could also make dual voltage using an inverting charge pump, which is cheaper.

Also: be sure to test your circuit before use! Differential amplifiers are known to have 'unsymmetrical' gain.
 
Last edited:
Great! I've found couple Quad LM324 op amps in my junk pile that I will try to use. Until I get a power supply brick, I will use couple 9v batteries for my supply. I will use the following resistor values Rf = Rg = 30k 5% R1 =R2 = 10K 5%
For the voltage divider 10K 5%. Paul, should all the tolerance values be 1% or 5% ok?

Another quick question concerning programming the Teensy DAC. I need to generate a triangular stair-step signal to position the galvonometer at discrete positions. I am thinking of putting the step values in an array and in a loop, index the values at a rate determined by looking at an "elapsed time" variable. Within this same loop, I will also be reading other sensors to control the operation of this device.

Anyway this device I am trying to build something called a Laser Harp. It is a laser bean being deflected by a galvonometer servo motor by the triangular stair-step signal. When the laser beam is intercepted, its reflection is detected at which time a MIDI note will be sent out to synthesizer. Looks like a fun project to do with Teensy.

[URL="https://www.youtube.com/watch?v=zqMdUQvN-Dk[/URL]

Once again Epyon, Paul and Jp3141, thanks for all the help! For me, this analog stuff still a mystery, but I sure helps to have all in this forum.

Paul, I am amazed and thankful that you have devoted the time and are willing to share your knowledge and diligently monitoring this forum!
 
Since the DAC uses the same 3.3 V, you can use that for the reference also.

Resistor tolerances affect how precise your common-mode voltage needs to be. You can basically have two types of errors - -1) the common-mode voltage (where the two signals swing around) is not precisely 1.66 V, but somewhat of; 2) the gain of the + and the - channels is not equal. This effectively means that the common-mode voltage also has some signal on it. Whether or not these effects are critical depends on your application. Withoug going through the calculations, 5% resistors could mean ~ 5 % errors.

From your proposal, make R1 two 20 k in series broom 3.3 V to GND, and connect the opamp '-' (and Rf) to their junction.
 
Jp3141,

I programmed the Teensy to give me a triangular 13 stair-step signal from about 0v to 3v and back again down to 0v. I got several 9v batteries for my supply and put together the circuit Paul described above. The common point between the batteries was connected to ground.

I did as you suggested, creating the voltage divider to get me 1.65 volts. I then connected it to point V1 in Pauls diagram - Note: I did NOT remove R1 and the circuit works fine! The amplitude, though was only +2.5v to -2.5v. I then removed R1 and made the connection as you suggested but the output was missing the lower half of the stair-step signal!

To boost the output signal, I changed Rg and Rf from 30K to 40K, but the bottom of the stair-step signal was starting to truncate. No sure why.
Should I just add another stage of amplification?

I then tried Paul's idea of putting a buffer amp for the 1.65v and then connecting it to V1. The signal disappeared completely! Any ideas why that happened.

Thanks again.
 
Keep R1 and R2, and R3 and R4 the same value. Connect R1 to the voltage reference (e.g. the buffer opamp). Tune your gain by increasing both R3 and R4 identically.
 
I re-read your original post. If you need two signals, each from -5 V to +5 V (so a differential of +/- 10 V), you will need two opamps. There are many ways to do this; here's one:

Opamp.png

Use 2 copies of this circuit.

This opamp circuit generates VOUT = Rf/R1*(InputPos - InputNeg). This assumes that Rf==Rf2, and R1a=R1b=R2a=R2b, and R1 = R1a/2. With the example given, Rf=40k, R1a=20k, giving a gain of 4x.

With the 1st copy, if you connect InputNeg to +3.3 V, and InputPos to the DAC (which ranges from 0 to 3.3 V), then the output of this opamp will be VOUT = 4*(DAC-1.65). With DAC at 0, you'll get -6.6 V; With DAC at 3.3V, you'll get +6.6 V.

With a 2nd copy of the circuit, exchange the DAC and 3.3 V connections. You'll then get VOUT2 = 4*(1.65-DAC), or just the inverse of the other one. These will form your differential output.

If the gain (4x) is too high, change both Rf and Rf2 in each copy. 30k will give a gain of 3x.

If you really only need a differential signal of 5 V (so each output is +/- 2.5 V), Make the Rf values = 10k*2.5/1.65 = 15k.

In this circuit, with DAC at 1.65 V, each opamp will generate 0 V, and as the DAC changes, one output will go high, and the other will go low by the same amount. This will require a + supply and a negative supply (e.g. -5 V or so).

If you really only needed about +/- 2.5 V swing for each output, you could nearly squeeze by with just a +5 V supply (e.g. the Teensy's 5 V VIN input), and change the R1a/R1b (and R2a/R2b) values. Let me know and I'll calculate the appropriate values for you.
 

Attachments

  • Opamp1.png
    Opamp1.png
    19.8 KB · Views: 210
Jp3141, you rock! Thanks again!

I spent all day yesterday on the breadboard messing with these op-amps and I must say it is frustrating and satisfying at the same time. One moment everything looks great and the next, zero output! Anyways, I implemented the first circuit you suggested and that works like a charm. I just added a second stage non-inverting op-amp with a variable pot for the feedback and its dialed in at +5v to -5v.

These galvos that I am interfacing to can be interfaced to in two ways. One is directly into the amplifier using a +5v to -5v bipolar signal and the other is a differential method with positive side going from 0 to +5v and the negative going from 0 to -5 in an inverse manner. The circuit you have given above will satisfy this second method. I will incorporate this as an option using a jumper in the circuit. In your circuit above, I will probably replace the fixed resistors with multi-turn pots.

Question: Is there an easy way to breadboard these things? My board looks like a rat nest of wires and resistors and it is so easy to short things out here and there!

Once again, thanks for the help! Could not have done this without people like you on this forum!
 
For semi-permanent setups you can use solid straight wires (like the ones that comes with Wisher breadboards) and cut to length flexible, tinned wires like this.

However when it's meant for anything more than research or demonstration purposes you're better of soldering it down on perfboard or making a custom PCB. Breadboards have a lot of stray capacitance and contact resistance that can mess up sensitive analog signals or high speed digital.
 
My board looks like a rat nest of wires and resistors and it is so easy to short things out here and there!

Many different styles can be used for solderless breadboards. Using only pre-made breadboard wires with little pins on the ends always end up messy-looking if you have a lot of connections, partly because the wires are all fairly long and partly because the actual wire is so thin and flexible.

Some people go the opposite extreme, using solid wires carefully measured to the exact length between holes with the ends formed at sharp right angles.

I personally prefer to use formed wires for the power and ground connections. I just bend bare solid wire over a lead forming tool, which is quick & easy. Then I use longer wires for the signals. Just getting the power and ground wires flat against the breadboard greatly reduces the number of wires looping up into the air. Usually you know in advance and with good confidence which pins need power and ground wires, so getting the unlikely-to-change wires flat to the breadboard gives you more room to play with the likely-to-experiment signal wires.

Using #22 solid wire also helps. Those "breadboard wire" products with the header pins are cheap, but the wires tend to flop around. They also usually have incredibly thin wire, often 3 to 5 ohms. The same length of #22 solid is below what my hand-held multimeter can measure.
 
Jp3141, just breadboarded your circuit and it worked like a charm! I'll be replacing the 40Ks with a variable so I can tweek if needed.

Epyon , Paul... thanks again for the assist.

Oh by the way, I think I killed the DAC on one of my Teensys while messing around. I was disconnecting the 9v supply and things went south.
What that Teensy now outputs are remnants of my staircase signal which is really odd. In the 1st third of the signal, it just slowly ramps up and then I see the middle portion of the staircase signal. Then on the last third of the signal is does the slow ramp up again. Is this a common failure mode of the DAC?

BTW, I found a dual 12v supply on Mouser. Input is 5v, output is +12v, -12v Part# PEM1-S5-D12-Sb from a manufacturer CUI, Inc.
 
Status
Not open for further replies.
Back
Top