Voltage/Current control via PWM?

Hey everybody,

I'm working on a project with a Pro Mini 328 3.3 V/8mHz. I'm new to this world. Basically I need an output pin whose voltage and current can be changed via a user interface. This is to test variable electrical conditions on a certain device that I'm not at liberty to discuss. The basic setting that I need is 1.5 V and 10 micro amps. However, the current through the device needs to stay at very low amperage due to its nature. So I really need to be able to manipulate the voltage. I was beginning to do some calculations using PWM, but I don't know if its feasable to drop the current and voltage simultaneously. I'm really trying to keep the size of this as small as possible, so adding resistors might take up some space. I'm relatively new to electronic components and things, so any suggestions on how or what I could use to vary those parameters would be well received.

Also, any suggestions on how to get a nice looking user interface with Processing? Thanks.

any suggestions on how to get a nice looking user interface with Processing

An nice-looking interface for something you can't tell us anything about?

That's an interesting spec.

8mHz.

Suggest the billion times faster 8MHz version.

It must be a fried flux capacitor! Too much current, it disappears into the future.

I don't think you can control current on arduino but you can control voltage, 0V or 5V, only these two choices unless you want additional hardware, which you dislike.

It doesn't matter what the device that I'm trying to control is. All I need is the ability to vary voltage and current near the specified values that I gave earlier. I could hook anything up to the mini and control the voltage going to it. So it doesn't really matter what the device is. I'm mainly looking for the knowledge base of how to do it.

Yeah 8 MHz with the big "M". Typo.

The device needs to be powered for days at a time. I'm thinking just to use PWM to vary the voltage based on user input, and then have a 100K Ohm resistor between the pin and device. But I still would run into current problems if ohm's law holds. What about a potentiometer?

But I still would run into current problems if ohm's law holds. What about a potentiometer?

Well you see that is the crux of the matter, Ohm's law will always win out. Assuming the 'secret external device' acts like a fixed resistance value, you can only control current by manipulating the applied voltage. Wanting to set a fixed voltage and a fixed current at the same time requires that the external resistance value be manipulated.

Now there are lab type power supplies that allow one to set a desired fixed regulated output voltage and also set a current LIMIT, not a constant current, but a current that can rise per ohm's law but will be clamped when reaching the preset maximum current value. How does it do that? By lowering the applied voltage of course, to less then the prior fixed value so that the current stays at the set limit.

So Ohm's law rules. You need to determine if what you want to do will stay within the law or not. Perhaps if you could try and restate what you are trying to accomplish it might be possible to accomplish it without going to jail. :wink:

Lefty

It's nothing I would go to jail for...ha. Rather, it's best to keep quiet with certain technologies due to disclosure issues. I don't know how happy certain people would be if I spewed all of their work and specifications out onto the internet. So, for now, I am protecting myself from legal drama by keeping quiet all while trying to answer the general general question. :smiley:

So, 1.5V - you run a pwm output (analog write) at a setting of (1.5/5)*255 = 76.5, run it thru a low pass filte to smooth it, and then thru a 1.5M resistor to limit current to 10 uA.
Monitor it via analog read, tweak the pwm a little if needed if you see the voltage rising (due to your load resistance increasing) or drooping (your load resistance decreasing).
Or add a digital potentiometer in series also, you could tweak the resistance up & down some.
Example:

Or an I2C controlled current source

Ok, it seems that my "current" issue has been resolved. After inquiry, I was told that the "device" is highly resistive, implying that I should only worry about voltage control. This is no problem using PWM.

However, what is the best way to write a program so a user can enter in their desired voltage from a pc (or later on using an Android device).

Also, I'm going to want the device under user input voltage control to stay on for a certain amount of time, and then turn off, and then turn back on again, etc, and possibly be able to automatically change voltage levels from one cycle to the next. Any suggestions. I'm trying to familiarize myself with all of this. Thanks.

Any suggestions

Yes stop dithering about and decide what you want it to do.

....then turn back on again, etc, and possibly be able to....

Define what you want and then code can be written. Waffle on and you will get nowhere.

I was told that the "device" is highly resistive

What rubbish is that, without numbers it means nothing. How many ohms? What is highly resistive in one context is positively conductive in another.

implying that I should only worry about voltage control.

Have you not got it yet, there is no other sort of control you (or anybody else) can apply BUT voltage control no matter how high or low the resistance is.

so a user can enter in their desired voltage from a pc

How do you want the user to enter this, typing numbers, dragging a slider, clicking a box. Unless you decide you will never know.

Wow grumpy mike is a fitting name.

1.) I know what I want to do.
2.) The device needs to be turned on for a set period of time, then it needs to be turned off, and then it needs to be turned back on, and then it needs to be turned back off, etc, etc, etc. This is defined. Now, the length of time that it needs to be on/off is going to be in the hours range.
3.) It is highly resistive in my context. "Device" to "device" will vary and the resistance will have to be measured at time of assembly and an appropriate resistor will have to be added (until a uniform production facility is implemented). Lab conditions prevent identical "devices".
4.) The problem was needing to keep the current at 10uA. I realize that the voltage is the only variable factor. If the resistance was constant, then increasing voltage would increase current. But, we decided to disregard the current coming directly from the pin, and to worry simply about varying the voltage at ANY current, and to then decide based on the resistive nature of the individual "device" if the maximum current output based on a pre-determined maximum allowable user input voltage was below a certain maximum allowable current level. If it turns out to be too high, then we will have to step it down with a resistor to a usuable range. I hope this clears things up. It's difficult to convey an idea without actually spilling the beans. But I think you can get the point. Actual values do not matter here in this forum. I'm mainly looking for methods.
5.) The method of user input does not matter as long as the user can see the value that they are entering or selecting. I feel it would be best for the user to enter numbers. However, if the user interface is on an Android device, a slider or buttons may be easier to use than typing numbers. But for a pc application, typing number will work fine.

Hope this clears things up. Thanks.

Write your arduino application to monitor the serial port and get your values from there.
You can use the IDE Serial Monitor to enter data manually for debugging, and get fancier from there later on.

I hope this clears things up. It's difficult to convey an idea without actually spilling the beans. But I think you can get the point. Actual values do not matter here in this forum. I'm mainly looking for methods.

I'm afraid you have given us not enough to work with. A schematic drawing would be a nice starting point, showing the wiring and what and where you want to measure and/or control. You don't have to name the mystery parts, just draw their equivalent electrical properties.

I suspect that if this was such a great secret project that the techinical players could better describe the basic function they are requiring from the arduino. Saying it will sometimes be turned on and other times turned off is probably true of 90% of the Arduino projects ever built. :wink: