Intelligent Voltage converter/Power supply????

Ok, so I just got a Duemilanove board and have been playing with it for a few days. I wrote a fairly simple program to create an intelligent power supply from the arduino that can power any small DC device without additional components (resistors).

The idea behind this is simple: when you have a capacitor and a resistor in parallel, and hit it with a pulse of HV electricity, the empty capacitor will cause a voltage drop, and it generally has to fill up before the resistor (or LED in this case) suffers the consequences of overvoltage. (Convert high voltage to low voltage if timed correctly)

These were the requirements:
I want to run some LEDs and I don't want to use resistors.
I want to plug/unplug as many in as I want at any time while making no adjustments - also no resistors added - optionally can add motors or other devices
I want to control the voltage with the push of a button.
For testing and maybe even usage I also want the measured voltage printed to the LCD screen.

Ok. That being said here is my code:

#include <LiquidCrystal.h>


//Make sure to verify pins before hooking up
LiquidCrystal lcd(12, 11, 7,6,5,4);


#define bDuration 25


int OutPin = 8;
int DetPin = 4;
int Vread = 0;
//322 is good for VMAX (voltage = 322 * .0098) about 3.156 Volts for my LEDS
int VMax = 321;
int OutState = 0;

unsigned long time = 0;
unsigned long currTime = 0;

float detV = 0;


volatile int VMaxvar = VMax;
volatile unsigned long bounceTime=0;


void setup(){
  attachInterrupt(0,Increase, RISING);
  attachInterrupt(1,Decrease, RISING);
  pinMode(DetPin,INPUT);
  pinMode(OutPin, OUTPUT);
  lcd.begin(16,2);  
}


void loop(){


  time=millis();
  if(time - currTime > 1500){
    currTime = time;
    digitalWrite(OutPin, LOW);
    OutState = 0;
    detV = Vread * 2 * .004887586;
    lcd.setCursor(3,0);
    lcd.print(detV);
    //lcd.print(" Volts");

  }

  Vread = analogRead(DetPin);

  if(Vread < VMaxvar && OutState == 0){
    digitalWrite(OutPin, HIGH);
    OutState = 1;
  }
  else if(Vread > VMaxvar && OutState == 1){
    digitalWrite(OutPin, LOW);
    OutState = 0;
  }
}


void Increase(){

  if(millis() > bounceTime && VMaxvar < VMax){
    VMaxvar = VMaxvar + 3;
    bounceTime = millis() + bDuration;
  }
}


void Decrease(){

  if(millis() > bounceTime && VMaxvar){
    VMaxvar = VMaxvar - 3;
    bounceTime = millis() + bDuration;
  }
}

The power circuit is:

  1. 1 small & 1 bigger transistor in darlington configuration (npn)

  2. Transistors Fed by Pin 8 via 10K resistor - collectors of both hooked directly to 9V battery

  3. Analog Pin 4 reads off a voltage divider ( 2 10K resistors ) connected between emitter and ground

  4. A 1000uF cap. is connected between emitter and ground to buffer the pulses

  5. LEDs/Motors etc connect between emitter and ground

I have tested this for a while using 9V batteries and ~3V leds and it seems to work great. It will work with a single transistor, but the darlington pair allows more current and zero voltage drop with 10-15 LEDs for example. The voltage appears to hold at 3.14 to 3.16V regardless of whether I have 0-10 LEDs or a small motor hooked up.

One of the main things I'm wondering is if this is used in any mainstream electronics or industrial applications, because I haven't been able to find any examples of it? If so, how and where, etc? If not, why not? I wouldn't say its just PWM, but PWM is kind of a part of it.

My assumption is that efficiency would be fairly high, considering zero power dissipation by resistors, and digital control of the transistor(s).

Also, one of the issues I have is the speed of the LCD printing. If I print both the voltage number and the word "Volts" it creates a noticeable 'glitch' in the output of the LEDs. The work-around I found so far was to simply turn off the Output before printing to LCD, and let it recover on its own. Why is the LCD printing so slow and could it be done in a faster way? How about the timing of it, is there a better way to delay the printing to every 1 or 1.5 seconds than what I currently use?

Also, since I can run up to small bank bank of 3V LEDs, connected almost directly to a 9V source (no resistors), how about scaling this up to say 24 or even 120 Volts input? Is that feasible? I assume the arduino would not be fast enough for 120V...

One of the main things I'm wondering is if this is used in any mainstream electronics or industrial applications, because I haven't been able to find any examples of it? If so, how and where, etc? If not, why not? I wouldn't say its just PWM, but PWM is kind of a part of it.

Your design missed out an inductor, to limit charging current, when output voltage is low, probably this was not noticeable with 9V battery, as it low power device.

how about scaling this up to say 24 or even 120 Volts input? Is that feasible? I assume the arduino would not be fast enough for 120V...

Inductor is answer for higher voltage question, look at the web-sites of TI, Analog Devices, STMicroelectronics for chip design and application notes for more information.

Thanks for the info. I guess I have some reading and testing to do. :smiley:

I want to run some LEDs and I don't want to use resistors.
I want to plug/unplug as many in as I want at any time while making no adjustments - also no resistors added - optionally can add motors or other devices

I think this shows a fundamental misunderstanding about LEDs and how they work.
You can't run an LED at the forward voltage drop for many reasons.
Look at the data sheet, this shows a range not just one value. That is because the value changes from batch to batch of LEDs. It also changes with temperature and changes as the LED ages.
No two LEDs will have exactly the same forward volts drop so when you connect two or more in parallel there will be different currents in each, which at best will show up as different brightnesses at worst will damage one of them.
The point of an electronic design is to produce a stable repeatable circuit, you can never do that with this technique.
See:-
http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

I'm wondering is if this is used in any mainstream electronics or industrial applications

As stated switch mode supplies use a variation on this technique but there is little commercial interest in using exactly this technique for controlling power supplies because there are better cheaper and more stable methods. However, the technique is used in switched capacitive filters:-

Grumpy_Mike:
I think this shows a fundamental misunderstanding about LEDs and how they work.
You can't run an LED at the forward voltage drop for many reasons.

It may, I am an amature when it comes to electronics with zero formal education in this field.

That being said, the max voltage for these LEDs is about 3.2 volts, so I assumed that if I ran them a little under that, (3.1 or 3.15Volts) it wouldn't be too much of an issue? The article you reference seems to indicate that it could be done with no resistors if you have a stable enough voltage and stay a bit below the max voltage of the LEDS. ie: "Also, as you can see from a typical voltage current curve this slope is very high and you have to precisely control the voltage to avoid exceeding the maximum current. "

For example, right now I have 3 LEDS pluggedin and showing 3.15V on the arduino. If I measure the current with my meter, (from emitter to LED +) it shows 52mA of current being drawn. Each LED is rated at 18-20mA, so I assume they should be ok?

I know I'm making a lot of assumptions lol.

Grumpy_Mike:
As stated switch mode supplies use a variation on this technique but there is little commercial interest in using exactly this technique for controlling power supplies because there are better cheaper and more stable methods. However, the technique is used in switched capacitive filters:-
Switched capacitor - Wikipedia

I will be reading up on this also. Thx for the info.

The article you reference seems to indicate that it could be done with no resistors if you have a stable enough voltage and stay a bit below the max voltage of the LEDS

No it doesn't.

I wrote it and it does not say that at all.
It is pointing out that a very small change in voltage produces a vast change in current, it is not obeying ohms law at this point.
If you are so badly misinterpreting that page then I will have to rewrite it!

For example, right now I have 3 LEDS pluggedin and showing 3.15V on the arduino. If I measure the current with my meter, (from emitter to LED +) it shows 52mA of current being drawn. Each LED is rated at 18-20mA, so I assume they should be ok?

No again.
How do you know how much current is going through each LED? You don't, LEDs in parallel will not share the current equally.

So by that theory:
1.I take 3 LEDs and supply them with the minimum forward voltgage to barely light them up (about 2.5V here) by pressing the Decrease button
2.There is still a chance of over-current to the LEDs because no resistors?

How could that be possible when there is about 1mA being drawn? The transistor/capacitor combo is limiting the current here to about 1mA.

While it might work and be fine for that LED at that moment in time it is not a stable situation.
The is because the forward voltage is not a very stable thing.
Fine if you just want to mess about and are not worried about stability but useless for anything else.

It is a piece of dead end knowledge, it is nothing you can use in any design. It is just like balancing an egg on it's point, an interesting exercise but it is unstable, you can't build anything with it.