amplify signal to 10V

Status
Not open for further replies.

alexandros

Well-known member
This is a question regarding electronic circuits rather than code, but I'm posting it in case someone can provide some tips.
I want to amplify the signal of the MCP4728 DAC from Adafruit to a range from 0 to 10V. I'm using a TL072 op amp with the current circuit
tl072_schem.png
And this is the code:
Code:
#include <Adafruit_MCP4728.h>

Adafruit_MCP4728 mcp;

int channel;
int value;

void setup() {
  mcp.begin();
  // initialize all channels to 0
  for (int i = 0; i < 4; i++) {
    mcp.setChannelValue((MCP4728_channel_t)i, 0);
  }

  Serial.begin(115200);
  while (!Serial);
}

void loop() {
  if (Serial.available()) {
    // receive a message of the type "0c1023v"
    // which will send 1023 to channel 0
    static int temp;
    byte in = Serial.read();
    if (isDigit(in)) {
      temp = temp * 10 + in - '0';
    }
    else {
      if (in == 'c') {
        channel = temp;
        temp = 0;
      }
      else if (in == 'v') {
        value = temp;
        temp = 0;
        mcp.setChannelValue((MCP4728_channel_t)channel, value);
        Serial.print("channel: ");
        Serial.print(channel);
        Serial.print(", value: ");
        Serial.println(value);
      }
    }
  }
}
I'm sending messages from the serial monitor like this one "0c2047v" which assigns the value 2047 to channel 0. The readings I get from my multimeter from the DAC are correct but the readings I get from the op amp are correct only for values above 1100. If I send a value less than 1100 the op amp starts raising its voltage and when I send a 0 value the op amp outputs 11.71V. I'm using a 12V power supply for the op amp.
Anyone knows why this is happening?
 
Anyone knows why this is happening?

I'm going to guess you have the opamp's negative power pin connected to GND. If so, you're probably hitting limits of the opamp's output range.

Here's the relevant specs for that opamp.

tl072.png

Since this is +/-15V power, they're basically saying the output get to within 1.5V of the negative power before the opamp isn't able to work properly, at least in the "typical" case, at room temperature, driving only a 10K load. It gets worse if the opamp needs to output more current, or at extreme temperatures. But often these specs are pretty conservative and the parts tend to perform better than the typical spec. Getting to 1.1V of the negative power would not be very surprising, even though the spec says to expect only 1.5V.

Using this opamp, the solution would be the power the opamp's negative power pin with at least -2V and ideally -5V so you meed those worst case specs.

But using an opamp which is designed to be able to have its output go all the way (or very close) to the negative power would probably be easier than creating a negative power supply.
 
I'm going to guess you have the opamp's negative power pin connected to GND. If so, you're probably hitting limits of the opamp's output range.

Here's the relevant specs for that opamp.

View attachment 21926

Since this is +/-15V power, they're basically saying the output get to within 1.5V of the negative power before the opamp isn't able to work properly, at least in the "typical" case, at room temperature, driving only a 10K load. It gets worse if the opamp needs to output more current, or at extreme temperatures. But often these specs are pretty conservative and the parts tend to perform better than the typical spec. Getting to 1.1V of the negative power would not be very surprising, even though the spec says to expect only 1.5V.

Using this opamp, the solution would be the power the opamp's negative power pin with at least -2V and ideally -5V so you meed those worst case specs.

But using an opamp which is designed to be able to have its output go all the way (or very close) to the negative power would probably be easier than creating a negative power supply.
Thanks for the detailed answer! Actually I'd much rather use an opamp that can operate properly with 0V in the negative supply as all results I got when searching for how to create a negative voltage from a positive supply seemed a bit cumbersome. Can you suggest an opamp that operates as you describe?
 
You may also need to add a resistor between the DAC output and LM358 positive input. For a starting guess, use the same resistor value as the resistor between the negative input and GND.

The purpose of this resistor is to correct for small error which is caused by the tiny current which flows in/out of the opamp's input pins. Opamps like LM358 have PNP input transistors, so the input current is not as low as JFET or MOSFET opamps. Both pins will have nearly identical current flow. On the negative pin, that current goes through the 2 resistors, which creates a tiny voltage at the negative pin. By adding a similar resistor in series with the positive pin, the same current will flow through the same resistance, creating the same tiny error voltage. The opamp will then cancel out the 2 tiny errors because it is a differential input.
 
You may also need to add a resistor between the DAC output and LM358 positive input. For a starting guess, use the same resistor value as the resistor between the negative input and GND.

The purpose of this resistor is to correct for small error which is caused by the tiny current which flows in/out of the opamp's input pins. Opamps like LM358 have PNP input transistors, so the input current is not as low as JFET or MOSFET opamps. Both pins will have nearly identical current flow. On the negative pin, that current goes through the 2 resistors, which creates a tiny voltage at the negative pin. By adding a similar resistor in series with the positive pin, the same current will flow through the same resistance, creating the same tiny error voltage. The opamp will then cancel out the 2 tiny errors because it is a differential input.
Thanks! I'll give that a try and report back!
 
> MPC6002 ... can be used for clamping

What happens when 5V gets applied to the MPC6002 analog input which is rated to a max of VDD + 1.0V?
 
The LM358 did the trick! Adding the extra resistor seems to make things more noisy. My multimeter is not a fancy one, but voltages seemed to take more time to settle and there was some moving up and down, while without the resistor it seems to be working well. I do have to test this in the actual application I'm making this for though, which is control a Eurorack synth by sending CV signals.
Thanks for the help!
 
> Its widely used for Modular Synth Modules for input protection of digital Modules

Looks to me like the op amp before it (rated for VCC– + 36) is providing the protection.
 
You might have an oscillation. You'll never observe an opamp's settling time with a multimeter -- it's in the us range at worst.
You don't really need the extra input resistor anyway; opamp input offset will likely cause a greater error.
 
It's not the case here, but if the input were capacitor coupled with no resistor, the input voltage would rise to be a huge error.
 
Status
Not open for further replies.
Back
Top