Author Topic: Opamp, Mosfet, LED, Voltage Offset issue  (Read 7557 times)

0 Members and 1 Guest are viewing this topic.

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Opamp, Mosfet, LED, Voltage Offset issue
« on: April 15, 2016, 10:40:29 pm »
Hi,

I am putting together an LED driver/Current monitor circuit and i am having some issues with the input voltage offset of the opamp being too high.

The circuit takes a PWM signal from an Atmega 328p (arduino), at 490Hz at the positive input of the opamp, divided by 4 through the R66 and R68 voltage divider. This takes the 5v amplitude of the PWM signal down to 1v. R66 also limits the current going to the opamp input.

The output of the opamp drives the mosfet gate through R81. The value of the resistor is chosen from the graph in Figure 4-5 in page 16 of the datasheet (Capacitive Loads).
I'm not sure what the capacitance of the mosfet is, from the datasheet i can see 2 values, input capacitance and output capacitance, 447pf and 96pf respectively.

The voltage at the shunt resistor R69 (1Ohm) os fed back to the inverting input of the opamp.

Capacitor C8 is there to eliminate noise in the supply input as suggested in the opamp datasheet.

This opamp has a maximum offset voltage at the inputs of -+250uV, however I am seeing between 2-20mV offset depending on the duty cycle of the PWM signal.

I have observed that the voltage offset increases as the frequency of the PWM signal increases. I have tried lowering the PWM frequency as low as 120Hz but I am still seeing 2-3mV offset.

By just placing a .47uF capacitor after R66, acting as a low pass filter and smoothing out the PWM signal, the offser voltage goes into spec being less than 1mV.

The reason however why i don't want to filter the PWM signal is becasue the LED has different Vf depending on the current. Therefore if I'd have to change the voltage together with the current.


I've tried removing R81, R82 and C8 and makes no difference.

If anyone could shed some light into the issue i'd really appreciate it.
Thanks in advance!


The schematic is attached to the post.

The opamp being used is the MCP609, a quad opamp.
http://ww1.microchip.com/downloads/en/DeviceDoc/11177f.pdf

The Mosfet is a PSMN022-30PL, a N-Channel, Logic Level.
http://www.nxp.com/documents/data_sheet/PSMN022-30PL.pdf

The LED Cree XP-G2.
http://www.cree.com/~/media/Files/Cree/LED-Components-and-Modules/XLamp/Data-and-Binning/XLampXPG2.pdf

« Last Edit: April 15, 2016, 10:56:06 pm by swat3d »
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #1 on: April 15, 2016, 11:17:51 pm »
How are you measuring the input offset voltage?
I don't quite understand the end-user issue that you are trying to solve.
I'm thinking that you might be hitting the slew rate limitation of 0.08V/uS.
That gives you a rise time of about 12uS to 1V, which would obviously lag the input by a bit.
Are you interpreting this as an input offset voltage issue ?
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #2 on: April 15, 2016, 11:35:41 pm »
I am measuring the voltage across the non-inverting and inverting inputs of the opamp.

That's where I am seeing up to 30mv. When I place the low pass filter it goes down to below 1mV as specified in the data sheet.
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #3 on: April 15, 2016, 11:51:44 pm »
What are you using to measure the voltage difference ? I'm assuming oscilloscope. Are you seeing 30mv difference during the rise time of the PWM signal or after the input signal has risen to maximum value, just before the falling edge of the PWM signal ? A scope trace showing opamp inputs + opamp output would be useful.
« Last Edit: April 15, 2016, 11:53:21 pm by michaeliv »
 

Offline uncle_bob

  • Supporter
  • ****
  • Posts: 2441
  • Country: us
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #4 on: April 16, 2016, 12:02:47 am »
Hi

If you are putting a PWM into the circuit that you have shown ... you have an AC circuit. The op amp and mosfet are trying to follow a square wave signal. The op amp will not do this at the same "nanosecond rise time" speed as the PWM output. The 7.5K ohm resistor in the op amp output and the speed of the MOSFET will slow things down even more than just the op amp's performance.

Simple answer ... If you want to drive the mosfet with a square wave, this is not the right way to do it. You need a high speed driver for that. If you want to drive it with a DC voltage, put a cap at the + input of the op amp.

Bob
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #5 on: April 16, 2016, 12:33:04 am »
I was measuring it with a multimeter (i know is not a valid way).

I am now probing the non-inverting and inverting inputs on the oscilloscope now and i can see that obviously the inverting input lacks behind a little which is of no concern, it just needs some time to catch up as you guys mentioned below.

The problem is the difference after both signals have risen up. Unfortunately my oscilloscope is analog and it's hard to measure but i can almost see the 20mV difference.

So my concern is, if i am feeding a PWM signal at 50% duty cycle at 1V i am expecting 1V across the shunt resistor of 1Ohm, therefore 1Amp. And i am getting based on what i see 1.020A.

Which is not a big deal at 1A but at lower duty cycles is where i am concerned.

Pictures attached.
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #6 on: April 16, 2016, 02:35:39 am »
I think I was getting it wrong all along. If I use a low pass filter and drive the led with a dc signal, I can just make sure there is enough voltage to cover the led Vf, the resistor drop and the rest will be dissipated by the mosfet.

Is that correct?

Thanks in advance.
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #7 on: April 16, 2016, 04:09:36 am »
I'm having trouble understanding your question.
What are you trying to have the circuit do and what is it (not) doing ?
Indeed you only need to provide enough voltage to the LED to cover the VF + drop across fully on mosfet + resistor, the opamp will take care of the rest.
Quick question -- Why use a current monitor at all, why not a current limiting resistor ? LEDs can be PWM'ed at more than their rated current.
http://electronics.stackexchange.com/questions/26025/is-it-safe-to-exceed-an-led-max-current-when-on-time-is-less-than-100
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #8 on: April 16, 2016, 04:58:47 am »
The reason is because I need to precisely control the led current, be able to control the intensity and create a curve of current/lumens. A simple current limiting resistor won't work because of the possible voltage fluctuation and the change in Vf with temperature.
By having a constant current circuit I can eliminate those variables and guarantee a precise current flowing through the led.

I was trying to drive the circuit with PWM directly to make it more efficient, dissipate less heat in the mosfet.

However it seems like when I feed it the PWM signal directly there is a voltage offset between what I am feeding to the non inverting output and what I am seeing in the shunt resistor and the inverting output for some reason I haven't figured out.

Using a low pass filter eliminates the offset but is less efficient.
« Last Edit: April 16, 2016, 05:03:22 am by swat3d »
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #9 on: April 16, 2016, 05:14:46 am »
Any particular reason that you're PWM'ing the LED ?
I would think the obvious approach would be to PWM into a RC filter and create a voltage, then use that voltage to drive the + of the opamp.

So basically using this : http://www.instructables.com/id/Analog-Output-Convert-PWM-to-Voltage/ , convert PWM to a voltage and use that voltage to control the op-amp current source.
What you'll get is a more stable + debugable circuit.
Note that you'll have to have a very high PWM frequency in order to avoid voltage swings(not mentioned in the article)
For best results use a DAC.
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #10 on: April 16, 2016, 05:27:58 am »
As I mentioned above, just for efficiency.
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #11 on: April 16, 2016, 05:42:03 am »
Oulps I missed that.
Well I can somewhat see what you mean ... What I'm wondering is why choose a mid-point between two ideal solutions.
1. Op-amp permanent constant current - inefficient but very precise.
2. Current limiting resistor with PWM into the MOSFET directly, this is the most power efficient solution. Using this you will absolutely be able to get a PWM duty cycle -> average lumens mapping. It's true that the current through the LED will fluctuate during a single duty cycle but it will average out on the whole. Just like it averages out on your attached schematic. In any case when you're PWM-ing the LED you won't be able to measure the the current through the LED precisely due to MOSFET turn on delay & op-amp rise time.
Not sure if I'm making myself understood.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #12 on: April 16, 2016, 11:15:08 am »
Several considerations -

1) The OpAmp you have chosen is incredibly slow, GBW and slew rate.
2) The OpAmp has very poor C loading, and those effects are aggravated by miller of the OpAmp and
your gate series R.
3) Because of 1) and 2) your current control loop will take a very long time to settle,
hence your current control effectiveness severely compromised.

You might consider using a sink current mirror and a fast OpAmp and a gate driver to eliminate the
slow parts of your loop, unload the C load from OpAmp output.

Gate driving considerations - google "mosfet gate drive application note", many hits.

What is the accuracy, resolution, you want for current control ?

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline uncle_bob

  • Supporter
  • ****
  • Posts: 2441
  • Country: us
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #13 on: April 16, 2016, 01:43:07 pm »
As I mentioned above, just for efficiency.

HI

Ok so let's start from scratch:

For an efficient PWM, you want the MOSFET to either be full on or full off. Anything in the middle wastes power in the FET.

... but ..

When the FET is full on, the LED can only accept a certain maximum current. You need a limiting resistor to keep it from catching fire. Power goes
into the resistor, but that's just the way it is.

Op amps are slow devices designed to be neither on nor off. They "like" being in-between the two voltage rails. Try to drive them to one or the other limit, they are not going to do what you expect. Logic gates are designed to be on or off. They don't like being in-between the supply rails. Drive them rail to rail and they will do what you expect them to do.

So simple answer:

Drive the FET out of the PWM from the MCU via a logic gate. Use that gate to turn the FET on and off. Pick a FET that is happy when driven with your
logic levels. Put a resistor in series with the LED to limit the current when the FET is full on.

Bob
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #14 on: April 16, 2016, 03:38:54 pm »
@michaeliv
The problem of the current limiting resistor is not the current fluctuating but the maximum current changing based on the power supply voltage and the Led Vf which is affected by manufacturing tolerance and temperature.

@danadak
Very good information, thanks a lot i 'm gonna read it all! I'm looking at 1mA resolution. That's why i chose an opamp with less than 1ma input offset.
I did lack the knowledge when it comes to speed considerations, the slew rate and GBW are not factors i considered.

@uncle_bob
The the idea was to replace the current limiting resistor and all the variables that come with it by using the opamp as a constant current sink.
This mixed with PWM.

So while pwm signal high -> opamp adjusts the mosfet to only let through the current determined by the amplitude of the signal, reading it from the shunt resistor voltage.
pwm signal low -> opamp turns off mosfet.

So if i'm feeding a 1v, 500Hz signal (2ms pulse width), at 10% duty cycle, the opamp during those 20us would adjust it's output to control the mosfet gate to get 1v at the inverting input.
So the current of the LED is limited by the amplitude of the signal. The overall brightness is limited by the duty cycle.

Why would i use a logic gate? At that point, wouldn't i just drive the mosfet from the mcu directly?

Thanks.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #15 on: April 16, 2016, 04:01:49 pm »
When driving low Rdson MOSFETS you are looking into a large C load, miller effect,
presented bu MOSFET gate. Thats why you use a hi current driver, as Q = C x V,
I = C x dV/dT, more current drive = faster dV/dT.

https://www.fairchildsemi.com/application-notes/AN/AN-6069.pdf
https://www.fairchildsemi.com/application-notes/AN/AN-6076.pdf
http://ww1.microchip.com/downloads/en/AppNotes/00786a.pdf
http://www.infineon.com/dgdl/an-944.pdf?fileId=5546d462533600a40153559eb9841190

Regards, Dana.

Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19517
  • Country: gb
  • 0999
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #16 on: April 16, 2016, 06:00:35 pm »
PWM will not make the circuit any more efficient. To do that, you need to add an inductor, forming a switched mode power supply. To control the brightness, either the current needs to be varied or the SMPS can be PWM'd, at a much lower frequency, than its switching frequency.
« Last Edit: April 16, 2016, 06:30:38 pm by Hero999 »
 

Offline monkeysuncle

  • Contributor
  • Posts: 17
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #17 on: April 16, 2016, 06:28:09 pm »
Hero999 is correct. As long as the dropping inductance is resistive, you are not improving the efficiency of the circuit by pulsing the LED. You are just dissipating twice the power for half the time.

You also will not get a meaningful measurement of lumens vs. current. The light output of an LED will not be the same for a constant current of 1 mA vs a pulsed current of 2 mA at 50% duty cycle.

It will be the same to a linear approximation, but presumably the purpose of this exercise is to determine the non-linearity of the characteristic.

If you are concerned about the temperature rise of the LED, then you need to use a single short pulse, or a very low duty cycle with a slow repetition rate.

One way to generate a short current pulse is to use a constant current supply, and place a transistor in parallel with the LED. You drive the transistor into saturation to turn the LED off (all of the current goes through the transistor). Drive the transistor to cutoff to turn the LED on.

And you should seldom worry about efficiency for test rigs.
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #18 on: April 16, 2016, 06:58:29 pm »
That's very good information.

Since the goal is to determine the curve of current vs lumens. I thinki will just rc low pass the pwm signal or use a dac and forget about pwm'ing the opamp directly.

Should be the easiest approach.

Correct?
 

Offline uncle_bob

  • Supporter
  • ****
  • Posts: 2441
  • Country: us
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #19 on: April 16, 2016, 07:36:17 pm »
That's very good information.

Since the goal is to determine the curve of current vs lumens. I thinki will just rc low pass the pwm signal or use a dac and forget about pwm'ing the opamp directly.

Should be the easiest approach.

Correct?

Hi

I believe you will find that recommendation in a post right up near the top of this thread ....

Bob
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #20 on: April 16, 2016, 09:02:37 pm »
Yeah I know. Just wanted to confirm :)

Thanks a lot everyone it's certainly people like you sharing knowledge that makes me want to keep learning!

Keep it up!
 

Offline uncle_bob

  • Supporter
  • ****
  • Posts: 2441
  • Country: us
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #21 on: April 16, 2016, 09:13:49 pm »
Yeah I know. Just wanted to confirm :)

Thanks a lot everyone it's certainly people like you sharing knowledge that makes me want to keep learning!

Keep it up!

Hi

Go with a nice big fat "more than a microfarad" cap for the filer. Tantalum is fine. Ceramic if fine if you have good ones. Aluminum electrolytics are not a really good idea. Plastic capacitors will likely cost you more than any of the rest. They may / may not work well depending on exactly which ones you get.

Bob
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #22 on: April 16, 2016, 10:19:39 pm »
I'm assuming for filler you mean the rc filter cap.
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #23 on: April 17, 2016, 01:15:41 am »
So i have changed the circuit to feed a dc signal to the opamp by adding a 2 pole rc low pass filter. The signal after the filter is pretty clean and steady, i can go pretty high with the cap values since i don't need it to be very responsive but very stable.

The problem is that i am getting oscillation in the opamp. I've tried it with the resistors between the output and the mosfet and from the shunt to the non-inverting input and without them. Without them is actually much better.

The only way i've been able to get rid of the oscillation is by adding a cap at the opamp output.

I've observed this in the past but i've looked for info/theory online and i don't think it's common practice.

Anyone can shed some light?


NOTE:
The PWM frequency is 490Hz and the cutoff frequency for the first stage is set at ~ 7Hz

I've attached the schematic.

Thanks in advance.
« Last Edit: April 17, 2016, 01:17:12 am by swat3d »
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #24 on: April 17, 2016, 06:00:05 am »
I found an article from Linear where they tackled the issue by placing a resistor on the output, another one in the inverting input and a cap across the output and the input.

Tried it and it's spot on.

Schematic attached.

Thanks a lot!
 

Offline michaeliv

  • Frequent Contributor
  • **
  • Posts: 260
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #25 on: April 17, 2016, 06:26:44 am »
I found an article from Linear where they tackled the issue by placing a resistor on the output, another one in the inverting input and a cap across the output and the input.
Link to article for anyone that might be interested in knowing more details ?
 

Offline uncle_bob

  • Supporter
  • ****
  • Posts: 2441
  • Country: us
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #26 on: April 17, 2016, 11:37:48 am »
I found an article from Linear where they tackled the issue by placing a resistor on the output, another one in the inverting input and a cap across the output and the input.

Tried it and it's spot on.

Schematic attached.

Thanks a lot!

Hi

If you check the Linear article against your schematic, there should be cap between the op amp output and the inverting input. Your schematic does not have that cap.

Bob
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #27 on: April 17, 2016, 05:22:40 pm »
Here is the article
http://www.linear.com/designtools/currentsense/19-current_control.pdf

The voltage controlled current source on page 3

Uncle_bob my latest schematic 2 posts above has the cap. I had to use a .2uF. The .1uF didn't cut it.
 

Offline uncle_bob

  • Supporter
  • ****
  • Posts: 2441
  • Country: us
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #28 on: April 17, 2016, 05:34:05 pm »
Here is the article
http://www.linear.com/designtools/currentsense/19-current_control.pdf

The voltage controlled current source on page 3

Uncle_bob my latest schematic 2 posts above has the cap. I had to use a .2uF. The .1uF didn't cut it.

Hi

The schematic *has* the cap shown on it. That is true. The problem is that the cap is shown at the wrong location in the circuit. It connects between op oamp pins. The schematic you show has the cap connecting at the far end of the resistors. Simply put: It goes between pins 1 and 2 on the op amp and not across the MOSFET.

Bob
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #29 on: April 17, 2016, 08:29:26 pm »
Ops, you are totally right! Sorry about that. That may be why I had to increase the capacitance.
 

Offline swat3dTopic starter

  • Contributor
  • Posts: 27
Re: Opamp, Mosfet, LED, Voltage Offset issue
« Reply #30 on: April 17, 2016, 10:01:11 pm »
I fixed the issue and actually ended up lowering the value of the opamp output instead of increasing the capacitance which didn't feel right. It works perfectly now.

Here are a few links that anyone running into the same issue might find useful.

http://www.electronicsweekly.com/blogs/engineer-in-wonderland/current-sink-stability-2015-10/
http://electronics.stackexchange.com/questions/69506/stability-problem-in-unity-gain-opamp
http://www.analog.com/library/analogdialogue/archives/38-06/capacitive_loading.pdf

Thanks.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf