This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Using GPIO pins as input to external op-amp. Did I just burn up the pins?

Other Parts Discussed in Thread: LM324, OPA547

Hello Everyone,

In my application I need to drive some LEDs with a forward voltage of 4.5V at around 20mA. I originally connected the GPIO pins to the base of an NPN transistor and put the LEDs in the collector with a resistor which worked fine however as another part of the work I am using an amplifier so I decided to switch everything over to a quad core amp. I setup the MCU as follows:

#define SENSING_PxDIR             P5DIR     // Use the Register for Pin 5 to control the GPIO pins to drive the sensing LEDs
#define SENSING_PxOUT             P5OUT     // Use the Register for Pin 5 to control the GPIO pins to drive the sensing LEDs
int SENSING_LED_0       = BIT5;     // P5.5 = LED for sensor 0
int SENSING_LED_1       = BIT6;     // P5.6 = LED for sensor 1
int SENSING_LED_2       = BIT7;     // P5.7 = LED for sensor 2

  SENSING_PxDIR |= SENSING_LED_0 + SENSING_LED_1 + SENSING_LED_2; // Flip pin state from in to out
  SENSING_PxOUT = 0;                           // Begin with all pins low

SENSING_PxOUT |= SENSING_LED_0;

Originally this did show an output of 3V at the pin. However, I connected it to the amp and now, even disconnected, it will not create any output. I am thinking i burned up the pins but I have no idea why?

The amp is an LM324N:

http://www.fairchildsemi.com/ds/LM/LM324.pdf

Can anyone help?

 

 

  • Double check the pinout of the OPAMP and the PCB layout to see if you connected the right pins between the MSP and the OPAMP and other components.

    There is no reason why a well designed connection between an LM324N's inputs and the GPIOs of a MSP430 would fry the MSP430, though there are some potential problems to be sure you overcome.

    You did not specify (at least that I see in my browser settings) the schematic of the circuit, so I don't know if you're using the GPIO going to the inverting or non inverting input, and what you're doing with the other input, the feed back circuit of the amp, et. al.  I also don't know what the relative power supply derivations are for the MCU and AMP, so it is hard to say what the problem might be other than bad wiring.

     

    Of course the inverting input through feedback (if hooked up as a feedback amp and not just a comparator / open loop device -- which actually might be reasonable) will try to equal the input voltage at the non-inverting input, so you'd need to make sure the output of the amp could not slew the voltage on the GPIO pin past the MSP430's ground or positive supply rails even if the op-amp had temporarily saturated its output in either the most positive or most negative possible states during any condition.  Obviously if you have no connection between the amp output and the input going to the MSP430 there is less worry of that.

     

    Also I don't know if the MSP430 GPIO goes through a coupling resistor to the AMP or not, but I'd suggest something like a 10k0 series resistor from the MSP out to the AMP-in at which point there would be much attenuation of any possible current caused by an amplifier or transient related voltage before it could affect the MSP430's GPIO as a fault inducing phenomenon.  Even if you applied -12V to the MSP430 GPIO through a 10k0 resistor the clamp diodes that I recall being on the MSP430's pins should work to prevent permanent damage to the part if I recall correctly their presence and 2mA conduction current clamping capacity.

     

    Of course the amp will have certain input bias and leakage currents so even an open circuit AMP IN will drift to some particular voltage level which might exceed the MSP430's voltage tolerances depending on whether the MSP430 was in INPUT mode or OUTPUT mode but if in INPUT mode the MSP430 input is of such high impedance that I suppose it could sway to some significant voltage before the input bias/leakage current of the AMP input could flow, so the result would depend on the relative supply voltages of the parts and the presence/absence of a coupling resistor and the design of the IO circuits in the AMP/MSP.  Shouldn't really typically be a problem if you use a series resistor as above, but something to watch if not and if the L324 had something like a +/-15VDC supply relative to the MSP430 and the MSP might be in input mode for a while during debugging or programming or initialization or such. 

     

    Another common problem is having two circuits on the same PCB connected but having the power supplies of one part versus another part somewhat independent so it might be possible to have the power to the MSP430 off well before the power to the AMP might be off, and 'off' being also relative to the hold-up duration of capacitance in the supply keeping power available at some (different) level  to each part even if they're both turned off at the same time.  Of course power supply ramp rate differentials are a concern for start up as well as shut down.  Anyway not really a problem if you ensure the MSP430 GPIOs are always clamped to its VCC/GND window and that no fault currents the clamp diodes can't handle ever flow due to series resistance or small magnitude of the excess voltage et. al.

     

    Other than that, it should pretty much work, and maybe the problem is unrelated to electrical design -- ESD damage, software bug, et. al.

     

  • Besides the considerations already given, I might add that you may have already damaged the output pins by the previous NPN transistor setup.

    If you didn't put a series resistor between MSP and the trnsistor base, the output pin was shortcut to ~0.4V by the base/emitter junction. Usually, a base current of 0.4mA (given the lowest beta I know of for standard transsitors: 25) would have been sufficient, yet the output pins were trying to pull the base to high voltage, which they couldn't even with maximum current. Over thime this may well have damaged the output pins. As long as they still were able to provide these 0.4mA (or even much less, depending on the transistor), things still worked. Even if they weren't able to raise the voltage much above 0.4V anymore.

    We used the LM324N in out own project (but driven by the DA output rather than a digital pin) and never had a problem with it. The LM is powered by >12V and has a gain of 4, resulting in a 0..10V output and all is well. We also use an LM324N for the input, powered with 5V, gain 1 and a 4:1 divider on its input. It provides 0..2,5V for the MSPs ADC and a series resistor of 1k keeps the input current below 2mA (which is what the clamp diodes on all inputs can sink/source) in case the OpAmp somehow latches to the 5V rail.

  • Hello to both of you! Thank you for the replies!

    First, here is a schematic:

    http://i34.tinypic.com/7303m9.gif

    The amp is powered by a 9V source, the MCU is powered by an independent 3V source, and their grounds are connected together.

    To the last person who replied: I had a 4.8k ohm resistor in series with the base so that should not have been a problem. It all worked fine until I switched it to the amp, at which point the pins stopped producing a voltage. Could you tell me how you arranged your amplifier? Was it a non inverting amp? What did you have in series with the positive going input to the amp, if thats where you connected the DA?

    As shown, in my circuit I did not put any thing between the GPIO pin and the positive going input. I hadn't done so in my prototyping with power supplies and I didn't think to when I switched the MCU. One thing I did notice after was that if there is not a 0V (or better) applied to the positive input (ie open circuit) then the LEDs on the output are somewhat illuminated.

    Clearly I have done something wrong, and probably ruined those pins on the MCU. Before I go any further, though, what the heck was it? I'd love to hear what might have happened so I don't do it again..,

     

     

     

  • Aehm, sorry, bu tmy LM324N doesn't seem to be your LM324N.
    My datasheets (Fairchild and National Semi) tell me it is a quad OpAmp in 14 pin case. And looking at your schematics, pin 7 isn't GND but the output of the 2nd OpAmp and pin6 isn't the output of the first but the negative input of the second OpAmp. On the LM324, the output of the first OpAmp is pin1 and GND is on pin 11.

    If you indeed used an LM324N and this wiring, it may very well have put the 9V directly onto the I/O pins, frying them.

    Besides this, the basic configuraiton is the same we use. But you're hitting the walls with your tuning: The OpAmp runs with a gain of 3. And the MSP is feeding it 3V or more. So the expected output voltage will be ~9V. Yet you're drawing current (and pretty much). This means that the LM324 won't be able to ever reach the 9V output, as hard as it might try. The output voltage drop is almost 4V @13mA. This leaves you with 5V output and a stressed OpAmp.
    You can reduce the gain to 2 with the same result. (Actual values vary with the specs of the driven diode).

    Als, it's not much but you can significantly raise the two resistors in the loopback. At least by a factor of ten. This reduces the boards current consumption by ~1mA without any impact on functionality.

    Anyway, you can rearrange the schematics and replace the 2.4k resistor by the diode itself. It gives better control over the diode current. The OpAmp will drive the voltage on its output (and therefore the voltage over and the current through the diode) so that current throught he bottom resistor (now 1.2k) causes a voltage that is equal to the GPIO voltage. A 100Ohm resistor will cause 30mA, 300Ohm will cause 10mA etc. (provided that the GPIO voltage is 3V). This makes the current through the diode independent of device variances and independent of the OpAmps output voltage. You'll get same brightness on all diodes. Even with changing supply voltage.
    And you save one resistor (the now 100Ohm)
    This setup requires that the OpAmp is capable of supplying the desired current at an output voltage that is U(diode)+3V.

  • Hello,

    Thanks for another thoughtful reply.

    You are correct in noting that the LM324 has way more pins than shown. I am doing this work on a breadboard and so I just threw that schematic together quick using a 741 as my program had the library for it. That was just meant to be illustrative.

    Could you clarify what you meant by the drop is 4V at 13mA? Where is this drop?

    I used the lower value resistors because I only had 1-10k in my office :) I have since moved up a bit and lowered the gain. I did not realize the LM324 could only get to within 1.5V of rail. Thats actually quite poor! I had been using a smaller amp that could get to within 0.25V of rail but it could only source 16mA and I want to be able to draw 30. I tried switching it to an inverting amp as it could sink 16 and then used the 9V power supply but treated the positive terminal as ground. This worked fine on the breadboard but when I went to implement it on the MCU I had problems. What I tried to do, in that case, was put a ground pin at the negative going input to the amp and then put the GPIO pin in the 9V source which I was treating as ground. This obviously friend the pin. What was I thinking!

  • mstarrett said:
    You are correct in noting that the LM324 has way more pins than shown.

    That wasn't the problem. If you only use one of the 4 amps, you don't need to use or even list all the pins. But the ones listed didn't match the ones to use. Of course, if the drawing is from a 741, this explains it. Without the pin numbers I hadn't noticed at all :)

    mstarrett said:
    meant by the drop is 4V at 13mA

    I used the datasheet info about the high-level output voltage. Given for 30V suppl yvoltage is a maximum output voltage of 26V for a 2k load. Which is 13mA current and 4V drop below the reel. This is full operating range. The TI datasheet (other than the Fairchild one, I looked at yesterday) additionally lists a voltage drop of 1.5V for a 2k load at room temperature, yet this would be only 4.5mA for 9V supply.
    In our laser power suipply we use OpAmps which can go to 0.01V (yes, 10mV) to both rails, but only for an output current below 50µA. On 1mA, it is 0.35V off and for 5mA, it can be as much as 1.5V worst case.
    But that's normal for OpAmps. The output transistor is more or less wrking as a controlled resistor, and the voltage over the resistor increases with increasing current.
    If you need full rail at hight current, you need to select an OpAmp with MUCH higher maximum current. Such as the OPA547. Id sources/sinks up to 500mA, and at 30mA, it comes to 1.2V to the upper and 0.6V to the lower rail. Higher temperatures further decrease it.

    mstarrett said:
    What was I thinking!

    Reminds me of the idea to boost the operating voltage by wiring a battery in series to itself. It would give infinite voltage, if there weren't the fact that it would also result in infinite current and so the resulting voltage breaks down to a few millivolts, depending on the wire resistance, but sadly never exceeds the battery voltage. What a shame that so many good ideas fail at the point where the resulting equation is 1+1=1.

     

**Attention** This is a public forum