# A current controller by regulating the voltage

I need some idea of what type of controller I should use. But, I am thinking of a PID controller.

Here is my problem:

I have a simple circuit like this one:

simulate this circuit – Schematic created using CircuitLab

In this circuit, the resistor R is time variance. My goal is to have a desired current amplitude to be generated through this circuit. My idea is to control the voltage source via a PID controller do you think it is possible? Do you have any other suggestion?

Update:

The load characteristic over a wide range of voltage looks like this:

• Sounds like you want a "constant current driver". – pjc50 Aug 24 '15 at 15:28
• It could be possible, depending on numerous factors you haven't shared: What range does R vary over, and how quickly? How accurately do you need to maintain the constant current? There are also several well-known ways to do this with an analog circuit, which might be more robust than a digital method. – The Photon Aug 24 '15 at 15:40
• can you plz elaborate on what is "constant current driver"? – user1801381 Aug 24 '15 at 15:45
• FYI: R varies between 200 ohms to 200k ohms. R also varies very quickly (disproportional to voltage) as voltage varies. I need at least 10% steady state error for the current amplitude. – user1801381 Aug 24 '15 at 15:49
• Also, sorry if I didn't mention. I am looking for a software solution, not a hardware solution. The hardware is fixed as shown in the circuit of the problem. I am given 'target current' and my job is to generate a 'output voltage'. – user1801381 Aug 24 '15 at 15:58

You can certainly close such a loop digitally, but the performance (response time including correction from disturbances such as fast changes in R) will likely be very much inferior to having a good DAC and an analog closed loop.

Anyway, if you deliberately (in analog or digital form) insert a dominant lag that is much longer than the sample time, you can use ordinary PID tuning rules. Suppose your sample frequency is 1kHz and your ADC and DAC respond almost instantly, then you might want a 10Hz cutoff low pass filter on the output.

On the other hand, if the load really looks like a (very linear) R, and if the sample rate is low and the ADC settles completely during each sample time you could simply calculate the estimated R' as Vout/Imeasured and calculate the new V from the estimated R, perhaps with a bit of integral action. This won't work over a wide range if the load is something very nonlinear like an LED, and other precautions would probably be necessary to prevent damaging such a load by overshoot.

• Thank you for your feedback. I have updated the original post with an image of the load's characteristic vary over input voltage. Also, I like simple solution and fast settling time, less than 1000 ms. Would you consider the load I have shown is linear or non-linear? – user1801381 Aug 25 '15 at 13:57
• Extremely nonlinear- a linear load would be a horizontal line (constant resistance). What current are you trying to maintain over that 10,000:1 range in resistance? How much voltage maximum? – Spehro Pefhany Aug 25 '15 at 14:46
• My voltage source can generate a max 160 V. My max current is 50 mA. My max load is 200K ohms. – user1801381 Aug 25 '15 at 15:05
• Should one side of the load be grounded? – Spehro Pefhany Aug 25 '15 at 15:09
• The load is not grounded. However, the load has a return path (-) to the source. The voltage source is common grounded by design. – user1801381 Aug 25 '15 at 15:17

I had very good luck with a 2 op amp circuit similar to the one in Figure 10 from here:

I had a few additional resistors. The current was multiplexed among PLTs sequentially to measure temperature at different points on the system.