Maker Pro
Maker Pro

Why does my op amp sink/source current?

Hi All, I'm having a little trouble with a circuit, please could someone help?
Project Objective
To produce a circuit which can modulate a high power LED. The assembly is intended to have real time current feedback via an op amp amplifying the PD across a low ohm resistor, before feeding back to an ADC on my μC. I have a switched 10k pot which switches on the voltage regulator circuit while the pot is used as a voltage reference to set the PWM DC.

The problem
When I prototyped this circuit it worked fine. However, after producing a board and using SMD components I noticed that the LEDs glow very slightly when the circuit is switched off. I have measured the current and it is tiny, almost too small for me to measure. I have traced the source back to the op amp (by removing various components until the phenomena stopped).

Additional info:
Supply Voltage: 14V
Regulated voltage: 5V
LED max current 3A
μC is actually a PIC16F88 not the PIC16F84 in schematic (same footprint as a PIC16F84)
Summery
I have provided a schematic for you guys to have a look at and would be very grateful if someone could point out my silly mistake, because I, for the life of me, can't figure it out!

BTW: I do not profess to be at all electronically literate; rather I enjoy playing with electronics to support my core abilities in Mechanical engineering. That said all constructive abuse welcome!

Many thanks,

Matt
 

Attachments

  • uC PWM.png
    uC PWM.png
    304.6 KB · Views: 139
Did the same thing happen when you prototyped the circuit? If not, maybe there's an error in your PCB, or a slight short causing a current leak.

If it happened in the prototype as well, it could be current through R6 and R4 to ground. What voltage is the supply to the LED positive lead? If it's 15V, the current would be around 41 microamps, possibly enough to light the LED dimly, depending on how sensitive it is. Additionally, some current could leak through R7 and R5.

Putting Q1 on the "top" part of the circuit, source connected where R6 connects to R3, drain directly to the LED should allow the LED to turn off completely.

Also, a resistor between the gate and source will ensure the transistor is "off" if for some reason RB0 becomes an input (i.e. PIC fails, firmware is corrupted or MCLR is held low via an external programmer).
 
Last edited:
Hi kpatz, thanks for your reply.

As I say it worked as I expected during prototyping. Moving the MOSFET to the top is a good idea - how did I not see that, wood for the trees and all that!

Thanks for the tip RE. the pull down resistor. What kind of value would you recomend 10k?

Thanks again,

Matt
 

CDRIVE

Hauling 10' pipe on a Trek Shift3
Hi kpatz, thanks for your reply.

As I say it worked as I expected during prototyping. Moving the MOSFET to the top is a good idea - how did I not see that, wood for the trees and all that!

Thanks for the tip RE. the pull down resistor. What kind of value would you recomend 10k?

Thanks again,

Matt
No, you can't do that as that configuration would be a source follower. The FET will not saturate causing it to fry in short order. You would be better advised to add a switch arrangement from the 15V to the LED's anode.

Chris

EDIT: I just re-read the reply. If we're talking about connecting the LED cathode to the drain this might work because the source resistance is only .005 Ohms which is quite low. Sorry for the misinterpretation. ;-)
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Some random thoughts:

There are two clear paths from LED- to 0V (i.e. in parallel with the MOSFET) in the current monitoring op-amp circuit: R6+R4 and R7+R5.

You can sense the LED current by connecting your shunt between the MOSFET source and 0V. This voltage drop will be referenced to 0V. You will probably still need an op-amp to amplify this voltage to a usable level, unless you increase the shunt resistance. You may also need to take the MOSFET's gate-source capacitance into account; when you drive the MOSFET's gate high, a brief current pulse will flow out the source as the gate-source capacitance charges up.

If the idle LED current is very small, and you want an easy fix, you could just put a high-value resistor across the LED to reduce the voltage across the LED to comfortably less than the minimum illumination voltage when that amount of current is flowing.

Gate current limiting resistor R10 is quite high at 250 ohms. Also, the PIC can only source or sink around 25~30 mA on a single output. The MOSFET is a large geometry device with a gate-source capacitance of around 2 nF. This all means that the MOSFET will not switch instantaneously either ON or OFF. What is your switching frequency?

How is the LED current set? Do you have a current source in between the positive supply rail and LED+?

Why are you monitoring the LED current? Do you have an inductor in series with it? Can you show the circuitry going to LED+?
 
I agree with Kris. I do not see how this circuit in controlling the current in the LED, unless the voltage on the gate is being driven by a DAC and you are using the MOSFET in the linear region. But the 16F88 does not have a DAC.

Bob
 
Hi Kris/Bob thanks for getting back to me.
I think kpatz's comment regarding the placement of the MOSFET is valid and a good place to start, thank you Kris for reiterating this point.
Kris - resistors across LED's to 'burn off' energy to stop LED illumination are not an option for a number of reasons but mainly efficiency and if the circuit was designed properly it is not something I would need!
Both - I'm getting confused with your confusion regarding current regulation. The LED's are free to pull whatever voltage they need from the source. The op amp amplifies the voltage drop across the sense resistor, as I'm sure you are aware, this difference in voltage is directly proportional to the current (I=V/R). This is an analogue signal interpreted through the PIC’s ADC (no need for a DAC) @ 500 times per second. I have an over damped PID transfer function which tracks the measured current relative to the PWM (on CCP1) duty cycle and ensures the current never exceeds a pre-set value.
Kris - you are right 250 ohms is too big for R10 and was change after prototyping.
Thanks for your time guys,
Matt
 
You might not need a differential amplifier for this. The Mosfet will connect the inverting terminals gain components to 0V. Just try and remove R4. Or are you adjusting the current by PWM on the gate? you don't say.
Adam
 
Hi Adam, thanks for your reply, yes PWM to the gate.
Ultimately the proto board worked well, I think it may have been that I had unwittingly placed the FET on the LED side of the sense resistor R3.
Thanks for your help.
Matt
 
Both - I'm getting confused with your confusion regarding current regulation. The LED's are free to pull whatever voltage they need from the source. The op amp amplifies the voltage drop across the sense resistor, as I'm sure you are aware, this difference in voltage is directly proportional to the current (I=V/R). This is an analogue signal interpreted through the PIC’s ADC (no need for a DAC) @ 500 times per second.
We understand how you are measuring the current. The question is how you are controlling it.
I have an over damped PID transfer function which tracks the measured current relative to the PWM (on CCP1) duty cycle and ensures the current never exceeds a pre-set value.
Sorry, but this does not work. PWM will not control the current in the LED, except in a binary manner. During the ON part of the cycle, as much current as can will flow. During the OFF part, no current will flow. This controls the average current, and the perceived brightness, but then there would be no reason to measure the current. You would already know it: Imax * DutyCycle.

Please answer Kris's question about the missing part of the schematic. i.e. how is the LED connected?

Edited to add: With an inductive load, PWM will, in a manner, control current. An LED is not an inductive load.

Bob
 
Last edited:
Hi Bob, thanks for your reply, and don't be sorry that something doesn't seem to work - after all its my project ;)

All circuits have conductors right, quelle surprise all circuits have inductance. As I have not disclosed the value of this inductance and the frequency at which I'm running the PWM, it's probably best not say it 'won't work' too quickly as people may draw conclusions to your motivation! Despite this, and as identified by Kris, there is more to this circuit than I have shown and I'm genuinely grateful for your interest but I do not wish to digress.

I want to thank everyone who took the time to reply to my question - I rearranged the circuit as originally suggested by kpatz and problem solved!

Best regards,

Matt
 
So it's secret then? When asking for help, it is good manners to also answer the questions of those who you expect help from.

Bob
 

KrisBlueNZ

Sadly passed away in 2015
As I have not disclosed the value of this inductance and the frequency at which I'm running the PWM, it's probably best not say it 'won't work' too quickly as people may draw conclusions to your motivation!
I HATE it when people say this kind of thing.

"Please, strangers, help me fix my circuit... But some of the specifics of the schematic are out-of-date, I'm only going to tell you about the things that I think are important because I know what's important and what isn't (even though I realise you may know more than me), and I'm going to withhold an important aspect of the circuit because it's a secret and I'm sure it will work (ditto)."

We already know that you aren't PWMing the MOSFET at more than 1 MHz. Stray inductance isn't going to have any useful effect. You haven't addressed my concern about the PIC being able to provide enough gate current to switch the MOSFET cleanly (unless you're using the gate capacitance to smooth the PWM signal - which would have its own problems). You haven't addressed my suggestion of moving the current shunt to the source so you don't need a differential amplifier whose common-mode voltage will be jumping around constantly and causing measurement errors.
 
Top