1
\$\begingroup\$

For an electrochemical etching process I am trying to put together a battery powered, somewhat accurate current source able to provide 1mA to 5mA to a load with a varying resistance. (to be specific, it should be able to switch between 1mA, 2mA and 5mA to a load that is less than a few kΩ.)

The idea I had was to control the current through an NPN transistor using a low-pass filtered PWM signal from a microcontroller:

enter image description here

The values are chosen based on what I had lying around, making sure that the time constant of the low-pass filter is large enough to reduce the ripple somewhat, and R1 limits the output current to about 6mA. This results in the following simulated output current (red) when the duty cycle (blue) is swept from 0% to 100%:

Output current

I thought it would then be possible to use one of the analog inputs of the microcontroller to read out the voltage over the current limiting resistor R1 and use that to calculate the current through it according to Ohm's law. Then I could adjust the PWM duty cycle from the microcontroller using simple PI control.

The use of a microcontroller is convenient as I can show the measured current on a display without having to include a complete multimeter in the setup. Additionally it means I can switch between the target currents with a single button rather than having to use something like a potmeter to adjust the current with less precision.

After implementing this circuit though I ran into something unexpected. The PI control works well and quickly settles on the PWM where the calculated current through R1 is equal to the target current. If I use a multimeter to measure the current through R1 this also matches.

However, if I measure the current in series with the load I measure a current that is about 20% to 30% lower for all current settings. I am using a 220Ω load and the 5V microcontroller supply voltage as Vbat for testing. This supply should be sufficient to drive this load according to the previous plot which uses these parameters.

What could be the problem here? Did I overlook anything in the design? Is my multimeter at fault? :)

Thanks for any insights provided.

New contributor
Mark Marketing is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
10
  • 1
    \$\begingroup\$ Don't quite understand the use of pwm and the whole complexity to get a bad current source instead of using DAC and opamp as it is usually done. \$\endgroup\$ yesterday
  • \$\begingroup\$ What would make this current source bad specifically? The analog input of the microcontroller is a DAC. On top of the added benefit of being able to monitor the current. Could you link an example of such a configuration with an opamp and a DAC? \$\endgroup\$ yesterday
  • \$\begingroup\$ DAC is Digital To Analog converter, it's an output from MCU that outputs voltage (current setpoint). There are thousands of current source circuits, google: opamp current source. It makes no sense to use a PWM for such small current, and then sense with ADC, then compute,...the opamp does it all, almost at speed of light, and precise. \$\endgroup\$ yesterday
  • 2
    \$\begingroup\$ Value of \$V_{BAT}\$? You may not have enough headroom, especially near 5mA. Try a larger voltage and see if 20% 30% error goes away. \$\endgroup\$
    – glen_geek
    yesterday
  • 1
    \$\begingroup\$ @MarkMar What is the dynamic range of resistance to be driven? What exactly are the voltages you are willing to make available? What does "somewhat accurate" mean? (Accuracy requires traceability to standards. Precision is entirely another thing.) And what is the load, exactly? \$\endgroup\$
    – jonk
    yesterday
2
\$\begingroup\$

Here's where the problem is. Your base current in driving the BJT transistor into saturation is going to be a significant part of the current flowing through the emitter resistor. So, what you measure across that emitter sense resistor is true load current plus base current. If you chose a linear circuit using an opamp, the base current would be much less (maybe 0.5% instead of 5%).

You mention a deficit of 20% to 30% and that doesn't surprise me either.

After discussion with the op on this and that, I suggested that emitter and collector pins of the transistor be rechecked because if he had placed the transistor incorrectly in the circuit, it would still work but with a significantly reduced beta value. This seems to be what actually happened.

So, when a person (like me) diagnoses a transistor saturation problem based on apparently poor beta (too much base current), it isn't wise to jump all over my answer and down-vote it because it might not appear to fit your limited scope of knowledge. In doing so you totally run the risk of the op not getting the help they truly deserve. Take note.

\$\endgroup\$
14
  • \$\begingroup\$ BC547 Hfe is a min of 100, so base current is not the reason the output current is deviant. The maximum base current would be about 2uA. \$\endgroup\$ yesterday
  • \$\begingroup\$ That's absolute rubbish when you consider transistor saturation values. \$\endgroup\$
    – Andy aka
    yesterday
  • \$\begingroup\$ The transistor only tends toward saturation when the op has the current range of the multimeter in series. So you whole answer is wrong. At no point could you ever have 20-30% of the output current flowing in the base. \$\endgroup\$ yesterday
  • \$\begingroup\$ This answer seems to be right, measuring the base current it is indeed about 10% of the emitter current. However, I am not certain what could be causing it. Could it be the lowpass? I do not expect the transistor to go into saturation until I reach the current limit somewhere above 6mA. I could use an Opamp in this configuration but it seems to me that there would still be the same base current, at least if I keep the same feedback measuring the current through R1. I could technically also measure the voltage across the load and control the input voltage based on that. \$\endgroup\$ 20 hours ago
  • \$\begingroup\$ I expect that the transistor is going into saturation but have no facilities around me to verify that. You need to look at Vce and decide whether this is happening or not. It may be that the filtering on the base signal is not sufficient to prevent base overdrive at the peak of the filtered signal and that may be happening. I have no facility to help further because I'm in a hospital (not mental I might add lol) \$\endgroup\$
    – Andy aka
    20 hours ago
2
\$\begingroup\$

This is the simple current source with opamp + yours transistor + yours shunt resistor.

enter image description here

The blue line is the setpoint (Iset=V/548) and the green line is the current through the load resistor.

\$\endgroup\$
7
  • \$\begingroup\$ This looks promising, thanks! With a setup like this I would still need to provide the three desired voltages at the positive opamp terminal corresponding to the target currents. If I want to accurately set these input voltage of the positive opamp terminal without having to precisely turn a knob and looking at a current meter, should I still be using an MCU sensing the voltage over the shunt resistor (or the voltage before and after the load, for that matter)? Or is there a better alternative I'm not considering? \$\endgroup\$ yesterday
  • \$\begingroup\$ @MarkMarketing This circuit uses an op-amp. In this configuration, it wants to keep the voltage at its - positive the same as is + pin voltage. It does this by having an high gain and a "slow" (In the megahertz range) skew rate. If you a DAC to input a voltage of 1V into the + pin, the circuit will increase the current until the voltage drop over R1 equals 1V, and since we know its a 548 resistor, we can us ohms law to calculate that this means 1.82mA over this resistor, and about 1.81mA is left after we subtract the transistors base current. (assuming gain around 100). \$\endgroup\$
    – Ferrybig
    20 hours ago
  • \$\begingroup\$ @Ferrybig I understand that. But there may be a difference between the calculated current for a given input voltage and the actual current, depending on e.g. temperature changes or if the load ends up higher than expected. Either way there will probably need to be a way to finetune the input voltage and to measure the resulting current. Doing that with the MCU seems convenient. \$\endgroup\$ 20 hours ago
  • \$\begingroup\$ @MarkMarketing This circuit by Marko automatically compensates for any changes in rload. Even in a short circuit the current stays the same. For the sense resistor, you could sense, it, but its voltage should always match your control voltage, so you don't get any information out of it. If the temperature of the sense resistor is important, mount it in a fixed temperature box. (note that your original circuit also has problems with the resistors changing resistance as their temperature changes) Use kelvin sense to measure the exact resistor value, and use that as your calibration \$\endgroup\$
    – Ferrybig
    20 hours ago
  • \$\begingroup\$ @ferrybig With a too high load I meant the load going above that what Vbat can supply in this configuration. Ideally it would be possible to see if the circuit fails to supply the current. I'll have to check if that's convenient across R1 since if Q2 goes into saturation the current through R3 will decrease but that through R1 will keep increasing slightly. It might be more convenient to add a small sensing resistor in series with R3 then. \$\endgroup\$ 19 hours ago
0
\$\begingroup\$

To deal with the circuit you built, there are a couple of problems with both the design and performing measurements on it.

The good: The circuit as shown would operate.

  • With a 220 Ohm load resistor (R3), to get 5mA load current you will drop 1.1 volts across the load resistor (ignoring the actual plating load you want to drive). The voltage across the 558 Ohm (R1) would be 2.79V and represent approximately 55% duty cycle of your PWM. The transistor is operating as an Emitter follower (wrt Base drive) and is nowhere close to any saturation effects (VCE is about 1.1V).

  • You don't need to have R1 at all, the collector current is limited by the configuration, you should remove it.

The bad:

  • Assuming your input PWM is 0-5V, you can't get more than 4.3V on R1. This gives a maximum current of about 7.7mA max at 100% duty cycle (5VDC on Q2 Base).

  • At 7.7mA through the load resistor (R3) you need to drop 1.69V. Unfortunately with only a 5V supply you cannot provide this current. You need at least 4.3 + 1.69 = 6V. I'd suggest that you need at least 9V to ensure you have sufficient voltage to drive your plating load. If you remove R1 you reduce the supply voltage requirement, but I'd suggest you may want at least 2-4V available across the plating terminals.

  • At low PWM duty cycle you have a problem since to produce any current through Q2 collector you need about 0.7V. So for currents in the microamp range you need a PWM duty cycle of (0.7/5) * 100 = 14% duty cycle. Since you suggest you need plating currents in the 1-5mA range this means you only use duty cycles from about 25% through to 70% or about 40% of the PWM range available. Depending on the resolution of your PWM this may be a constraint.

  • Since you know that the 5V supply is not sufficient for the higher current flows, its likely that any measurement you make with a multimeter could be flawed by the Burden voltage of the current ranges. The Burden voltage for multimeters may vary from 2mV/mA through to 20mV/mA depending on your meter. At 20mV/mA it is the same as putting an additional 20 Ohms in series with your load.

Update: Added a very simple simulation (Square wave input ie 50% duty cycle) where the transistor can never be in saturation. You can see from this that the HFE of the BC547B is around 300. The Emitter current about 3.2mA and the Base current about 10uA. You don't even need to run the simulator ...if you open the schematic and hover over Q1 it will describe the DC conditions and show the Base, Emitter and Collector currents/voltages.

schematic

simulate this circuit – Schematic created using CircuitLab

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Thanks. I am aware the shunt resistor is not needed, but since I only need to go up to 5mA I expected that scaling the current down would improve the resolution following from the limited resolution at the pwm input. I'm missing though how the effects you describe would result in the decrease in measured current even at a low current like 1mA. Even at 5V this should easily drive the 220 Ohm and the current meter. This is still my main problem. Especially since I don't see this in the Sims either \$\endgroup\$ yesterday

Your Answer

Mark Marketing is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.