I need programmable current control, fading from zero to 2 milliAmps. I was hoping to use Arduino's AnalogWrite(), which uses Phase Width Modulation (PWM) to simulate analog output with a sawtooth wave on a duty-cycle; to control an LM334Z to deliver a slowly ramped low current delivery. [The application is a TransCranial Direct Current Stimulation (TDCS) micro-current delivery to the human scalp. Jumping straight to 2 milliAmps is uncomfortable]. Will PWM work? Or, do I need some sort of smoothing circuitry to soften the PMW before it is applied to the LM334Z's Rset pin to accomplish the above?

  • an LED glued to the face of an LDR converts voltage to resistance, but a digital pot would be simpler to calibrate. I'm using a MCP41010 with the 334, which works very well and cost me ~$1us
    – dandavis
    Mar 5, 2017 at 12:50
  • an LM317 can provide 0-2ma CC with common 1/4watt resistors, look at the datasheet.
    – dandavis
    Mar 5, 2017 at 13:48
  • On Arduino, PWM stands for Pulse Width Modulation, not “Phase Width Modulation” Mar 5, 2017 at 21:47

3 Answers 3


If you don't need super high accuracy, using a MOSFET's ohmic region, plus a smoothing filter on the output of your PWM (analog out), could be a solution.


You control the LM334 with a resistance, not a voltage. The current is set by multiplying the current through the resistor.

Maybe you can do what you want by replacing the Rset with a digital potentiometer?


LM334Z's Rset pin to accomplish the above?

Most of that type of circuit has its operations be determined by the current In or out of that pin. So a voltage signal may not work - you will need to experiment. I have had some success with analogs dds chips and linear programmable osscillators.

So try it on your chip. Nothin to lose.

  • since it's output current is independent of any voltage, that will not work, it needs a resistor.
    – dandavis
    Mar 5, 2017 at 13:46

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.