- #1
HHOboy
- 32
- 0
Hey guys,
I have been trying to design a constant current source that has a digitally controllable (μcontroller) range of maximum current outputs. Ideally the source would be able to be adjusted from .25mA to 2mA. The input voltage for the source would be in the range of 9 to 14 volts. Also I would like to be able to turn the source on and off fairly rapidly (40Hz) via a digital signal but have not really gotten to this aspect yet in my designs.
So far I have tried using an lm317 with a digital potentiometer to set the current level but have not had much success. Here is a picture of the basic circuit but in my case a 10kΩ digital potentiometer (MCP41010) is R1
When testing the circuit with varying simulated load resistors for some reason the resistance of the load resistor has a large impact on the current that is drawn where it should be limited to a constant current assuming that the resistor is not too large and results in a current to a level smaller than the current sources level.
I believe there is a problem with the use of the digital potentiometer because I have had the circuit work with a regular analog potentiometer in its place. I do not know what the problem because I have measured the digital potentiometer's resistance with my multimeter and it seems to swing over the correct resistances with a code I wrote. Here is a rough arduino sketch to test it...
#include <SPI.h>
int bob = 10;
void setup()
{
pinMode(bob,OUTPUT);
SPI.begin();
}
void setvalue(int level)
{
byte command = B00010001;
digitalWrite(bob,LOW);
SPI.transfer(command);
SPI.transfer(level);
digitalWrite(bob,HIGH);
}
void loop()
{
int i = 0;
while(i<=255)
{
setvalue(i);
delay(1000);
i++;
}
while(i>=0)
{
setvalue(i);
delay(100);
i--;
}
}
I have also tried another method with a lesser know chip called the lm334 here is a pic of the basic design however I left off the amplifying transistor as well as R2 and R1 with R3 being the same digital potentiometer
http://www.bristolwatch.com/ccs/lm334.jpg
I had some success with this method as I got an output that could range from a current of .7mA to a current less than .01mA. One problem that I had was that I could not find an easy way to amplify the .7mA to 2mA because I am relativley new in electronics and do not have much experience with op-amp circuit design. The source also works by sinking current so that is also throwing me off. The only amplification method that I can figure is to use a PNP transistor as in the diagram but they all have gains that are much too high for my purpose.
It would be awesome if you guys have any suggestions for what I have already tried or any brand new ideas. I think my next attempt is to use a simple op-amp circuit with the digital potentiometer.
I was also looking into controlling the current with a pwm signal from the μcontroller but could not find much of anything.
Thanks for any help you can give!
I have been trying to design a constant current source that has a digitally controllable (μcontroller) range of maximum current outputs. Ideally the source would be able to be adjusted from .25mA to 2mA. The input voltage for the source would be in the range of 9 to 14 volts. Also I would like to be able to turn the source on and off fairly rapidly (40Hz) via a digital signal but have not really gotten to this aspect yet in my designs.
So far I have tried using an lm317 with a digital potentiometer to set the current level but have not had much success. Here is a picture of the basic circuit but in my case a 10kΩ digital potentiometer (MCP41010) is R1
When testing the circuit with varying simulated load resistors for some reason the resistance of the load resistor has a large impact on the current that is drawn where it should be limited to a constant current assuming that the resistor is not too large and results in a current to a level smaller than the current sources level.
I believe there is a problem with the use of the digital potentiometer because I have had the circuit work with a regular analog potentiometer in its place. I do not know what the problem because I have measured the digital potentiometer's resistance with my multimeter and it seems to swing over the correct resistances with a code I wrote. Here is a rough arduino sketch to test it...
#include <SPI.h>
int bob = 10;
void setup()
{
pinMode(bob,OUTPUT);
SPI.begin();
}
void setvalue(int level)
{
byte command = B00010001;
digitalWrite(bob,LOW);
SPI.transfer(command);
SPI.transfer(level);
digitalWrite(bob,HIGH);
}
void loop()
{
int i = 0;
while(i<=255)
{
setvalue(i);
delay(1000);
i++;
}
while(i>=0)
{
setvalue(i);
delay(100);
i--;
}
}
I have also tried another method with a lesser know chip called the lm334 here is a pic of the basic design however I left off the amplifying transistor as well as R2 and R1 with R3 being the same digital potentiometer
http://www.bristolwatch.com/ccs/lm334.jpg
I had some success with this method as I got an output that could range from a current of .7mA to a current less than .01mA. One problem that I had was that I could not find an easy way to amplify the .7mA to 2mA because I am relativley new in electronics and do not have much experience with op-amp circuit design. The source also works by sinking current so that is also throwing me off. The only amplification method that I can figure is to use a PNP transistor as in the diagram but they all have gains that are much too high for my purpose.
It would be awesome if you guys have any suggestions for what I have already tried or any brand new ideas. I think my next attempt is to use a simple op-amp circuit with the digital potentiometer.
I was also looking into controlling the current with a pwm signal from the μcontroller but could not find much of anything.
Thanks for any help you can give!
Last edited by a moderator: