Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 16 of 16

Thread: amplify signal to 10V

  1. #1

    amplify signal to 10V

    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
    Click image for larger version. 

Name:	tl072_schem.png 
Views:	5 
Size:	10.2 KB 
ID:	21924
    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?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,712
    Quote Originally Posted by alexandros View Post
    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.

    Click image for larger version. 

Name:	tl072.png 
Views:	9 
Size:	178.9 KB 
ID:	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.

  3. #3
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    644
    Yes, use an op-amp that is labeled "rail-to-rail input and output".

  4. #4
    Quote Originally Posted by PaulStoffregen View Post
    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.

    Click image for larger version. 

Name:	tl072.png 
Views:	9 
Size:	178.9 KB 
ID:	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?

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,712
    I'd try LM358.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,712
    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.

  7. #7
    Quote Originally Posted by PaulStoffregen View Post
    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!

  8. #8
    Junior Member
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    10
    I can recommend the MPC600x Series as OpAmps (see here for the MPC6002 https://www.alldatasheet.com/datashe...P/MCP6002.html). They can nicely swing to the Rails and can be used for clamping as well to protect the Teensys inputs from excess Voltage, just use it as a Voltage Follower with the Positive Rail connected to the Teensys 3.3V Out.

  9. #9
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    644
    > 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?

  10. #10
    Senior Member
    Join Date
    Jul 2020
    Posts
    398
    Quote Originally Posted by fdaniels View Post
    I can recommend the MPC600x Series as OpAmps (see here for the MPC6002 https://www.alldatasheet.com/datashe...P/MCP6002.html). They can nicely swing to the Rails and can be used for clamping as well to protect the Teensys inputs from excess Voltage, just use it as a Voltage Follower with the Positive Rail connected to the Teensys 3.3V Out.
    But not for generating a 10V signal as its limited to a 5V supply range...

  11. #11
    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!

  12. #12
    Junior Member
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    10
    Quote Originally Posted by jonr View Post
    > 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?
    Most likely nothing. Its widely used for Modular Synth Modules for input protection of digital Modules, see here for example: https://mutable-instruments.net/modu...braids_v50.pdf

  13. #13
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    644
    > 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.

  14. #14
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    486
    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.

  15. #15
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    644
    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.

  16. #16
    Quote Originally Posted by jonr View Post
    What happens when 5V gets applied to the MPC6002 analog input which is rated to a max of VDD + 1.0V?
    The data sheet addresses this. You add a resistor to limit the fault current.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •