I'm controlling a home-built current regulator, using a PIC microcontroller (PIC12F1572).

The regulator is implemented using an op-amp and mosfet, and works well. The input to the regulator is a voltage 0V to 0.25V, with zero corresponding to 0A and 0.25V corresponding to 0.5A.

I'm thinking of controlling the current regulator directly from the PIC, by having a resistor based voltage divider connected to an output pin on the PIC, to yield between ~0V and 0.25V.

According to the datasheet for the PIC, the output low is guaranteed to be at most 0.6V. With my voltage divider, this means ~0.03V to the current regulator, or approx 60mA out.

However, I want it to be able to shut off completely.

The output low quoted in the datasheet is valid at 8mA, so when (practically) unloaded, it should give lower voltage.

Do I dare assume that the output low voltage will always be very close to zero in practice under these conditions? Or am I inviting trouble?

  • \$\begingroup\$ Intuitively I would say that if you want to cut off the regulator, you could do it another way than acting on the current limiter, maybe with a MOS in series somewhere. \$\endgroup\$
    – clabacchio
    Oct 2, 2014 at 6:17
  • \$\begingroup\$ I would be very careful about nearby induced voltage spikes being picked up by your control circuitry. Such a small voltage range for current control like that is sure to pick up undesirable oscillation from nearby magnetics or high voltage switching etc. Even the 50-60Hz light in your room might even contribute to a few millivolts of variation... If you do not intend to do fast control of this current regulator, you should ensure that each of your control lines are heavily filtered with capacitors to smooth out any hijacked signals \$\endgroup\$
    – KyranF
    Oct 2, 2014 at 13:38
  • \$\begingroup\$ Good point about the noise sensitivity. In my test bench I can see how my circuit faithfully reproduces my op-amp supply voltage ripple almost exactly as a current fluctuation. \$\endgroup\$
    – avl_sweden
    Oct 2, 2014 at 15:44
  • \$\begingroup\$ I meant to say "microcontroller supply voltage ripple", not op-amp (though they are the same). \$\endgroup\$
    – avl_sweden
    Oct 2, 2014 at 15:57
  • \$\begingroup\$ KyranF: I've done some calculations. I really can't see that ceiling lighting could induce many millivolts. What mechanism do you figure would induce 1mV at 50-60Hz into a tiny trace loop on a PCB? \$\endgroup\$
    – avl_sweden
    Oct 3, 2014 at 6:21

2 Answers 2


You are misinterpreting what the datasheet says. Fortunately.

Vout low is the voltage at specified current when load is from output pin to Vdd and the port is pulling the pin low against the pullup load.

When you are driving a ground referenced divider the load is from pin to ground. The port is "perfectly happy" to turn off essentially completely and allow the load to pull the pin to ground - but it will in fact (probably) help with an active pulldown. .

There MAY be some issues with bias and leakage currents (usually associated with input modes) if you are aiming for the last few microvolts, but in your application it will reach true-enough ground.

Datasheet (which you should always provide a link to) is at http://ww1.microchip.com/downloads/en/DeviceDoc/40001723C.pdf

See ~= page 251


Worst case specifications should be used for design BUT the conditions under which they are specified should be noted and where these do not match your conditions suitable adjustments may be made. With due care :-).

If you did care about Voutlow then you also need to note the conditions under which it is specified.

P251 in the datasheet says Vout low max = 0.6V (as you note). BUT they also state the loading conditions under which this is true.

AT 8 mA with Vdd = 5V = (5V-0.6V) / 8 mA = 550 Ohm load or
6 mA at Vdd = 3.3V = (3.3-0.6)/100 Ohm load or 450 Ohm load or
1.8 mA at Vdd = 1.8V = (1.8-0.6)/1.8 mA or 667 Ohm load.

While port pin resistance is NOT linear with load it is liable to be somewhat linear with load.

If you use higher load resistors (to Vdd) than above you can expect approximately proportionately lower Vout.

  • \$\begingroup\$ Thank you for your well though-out answer! It confirmed what I was expecting. \$\endgroup\$
    – avl_sweden
    Oct 2, 2014 at 15:42

The PIC12F1572 has a 5-bit resolution rail-to-rail DAC built-in (which is fairly unusual, almost all microcontrollers have ADC's but few have DAC's).

Rather than use Vdd (5v) as the high end of the DAC, you can choose to use the fixed reference FVR_buffer2 lead instead, which is by default 1.024v. This, divided by the 32 steps of the DAC yields 0.032v per step. So values sent to the DAC of 0-8 will give you 0.0 volts to 0.256 volts.

  • \$\begingroup\$ Ah, interesting idea, I might save a few components this way. Hadn't thought about it! I chose Russel's answer since it answered the question I posed, but I'm grateful for your suggestion! \$\endgroup\$
    – avl_sweden
    Oct 2, 2014 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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