NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Basic Electronics » Programmable current source

June 13, 2012
by JamesFysh
JamesFysh's Avatar

Hi,

I've been working on creating a current-source using a transistor, some fixed-value resistors and a 100k digital pot (I2C-controlled). I put something together in Circuitlab here which mostly seems to work.

The goal is to get a programmable current source that can deliver between ~10uA and ~400uA. And this circuit does just that - the current (available at the NPN emitter node) varies over 10-400uA as the variable resistor (R1) is varied over 100K->0.

However what I really need to do is connect the emitter to a pin on an IC, which shall sink between 10uA and 400uA. So the questions are:

What is the input impedence on this IC pin? How can I measure this safely (and reliably), without e.g. damaging the IC? Or, how can I build my current-source to be largely unconcerned with the input impedence of the pin on the IC?

Anyway, if anyone has any wisdom to share, it would be much appreciated. I've just read through the first two chapters of The Art of Electronics and not all of it made a whole lot of sense to me - I'm sure the answer is somewhere in there but I would love a different perspective on this. Or am I going about creating a programmable current source COMPLETELY THE WRONG WAY? :)

June 13, 2012
by pcbolt
pcbolt's Avatar

Hi James -

The max amperage rating for any input/output pin for the ATmega168 is 40mA. Since you are dealing with amperage 1/100th of this you should be OK. To measure the input impedance, you'll need a voltmeter and a 10k ohm resistor. Place the 10k resistor between the pin you want and the output of the 5v voltage regulator. Power up the MCU and have it programmed to make the pin in question an input pin (no pullup). Measure the voltage between ground and the 5v output to get an accurate reading of the regulator - call this V1. Now measure the voltage between ground and the input pin - call this V2. The input impedance is given by:

Rin = (R * V2) / (V1 - V2)     //   R should be 10,000 but you may have to verify

I'm sure I've seen some Op Amp circuits with negative feedback do what you are describing but I cannot be certain of it. There are people on this forum who are way more qualified to answer that question than I am (Mongo comes to mind).

June 13, 2012
by JamesFysh
JamesFysh's Avatar

Thanks pcbolt, I'll give that a go. It's actually a MAX038 IC that I'm dealing with, but that approach should work just the same. I feel much better putting a 10K resistor between V+ and the pin -- seems a lot safer to me than how I was thinking of testing :)

I'm still experimenting with the best way to achieve this - I might end up going with an Op-Amp (I will have +/- rails to work with, so it should be easy enough to drive any old Op-Amp I choose) if it's easier or more reliable.

June 14, 2012
by JamesFysh
JamesFysh's Avatar

OK, so I've come up with the following numbers (based on tests with 10K, 20K and 47K resistors):

  R           V1        V2          Rin

9980        2.456     0.0016    6.5058670143
19970       2.47      0.00068   5.4993277501
46800       2.481     0.0001    1.8864121891

I'm just going to go out on a limb and guess that the variation in Rin is due to the fact that the current being fed into this pin is being used to continually charge/dischage a capacitor, and with a lower resistor value (= higher current) the frequency of (dis)charging increases, leading to a higher impedence across the capacitor, hence Rin being higher for lower values of R. But I might be miles off :P

Anyway, back to the drawing board with the current-source. The one I've come up with so far is definitely NOT suitable for driving a low-impedence load.

June 14, 2012
by pcbolt
pcbolt's Avatar

James -

Why is the voltage regulator output so low (2.48v)? The ATmega168 needs to see at least 2.7v to operate "safely". If you're using the 14 Mhz oscillator, the input voltage should be 3.6v or more.

As far as your circuit, have you looked into a voltage divider cutting the 5v down to 1v and feeding that into your pot (put a 2k resistor in series with it). Then monitor the voltage (use the ADC) across a known resistor to calculate current?

June 14, 2012
by JamesFysh
JamesFysh's Avatar

I'm working with the REF voltage output pin of the MAX038, nominally 2.5V, which is why the voltage is so low :)

Measuring the current isn't really something I want or need to do. Basically, my intention is to use an ATmega with an LCD + buttons to let the user select a desired frequency. Then, the ATmega shall select an appropriate capacitor to achieve roughly this frequency (via a CD4051 analog switch or similar), then tune to the correct frequency first by getting IIN approximately correct (digital pot-based current source), and then fine-tune using the FADJ pin (a voltage between -2.4V and +2.4V should be fed into FADJ - I haven't gotten to that bit yet).

The reason I don't want to measure the current is that I want to measure the frequency (the SYNC pin on the MAX038 outputs a 50% duty-cycle square-wave (at the same frequency as the output pin), regardless of the waveform + duty-cycle setting of the output pin, so I'll measure the frequency on that pin) and then tweak capacitor selection, current on IIN and voltage on FADJ pins based on the frequency measured.

This probably all seems very draconian, and it probably is. I fully acknowledge the fact that there are much, much better ICs out there for signal generation (the AD98XX line of ICs use digital synthesis and apparently achieve a much more accurate output signal than the MAX038, for instance), but by using this chip which is very "analog", I'm being forced to learn how to drive analog circuitry. I suspect with the AD98XX chips, I would just be doing everything with digital signals - also very useful, but something I can learn later on.

Post a Reply

Please log in to post a reply.

Did you know that spinning a permanent magnet motor makes a voltage? Learn more...