Control Voltage in LED

I need to vary the voltage from 0 to 3.3 in an LED. I am using a FEZ Hydra board and i have uysed up the available 3 PWMs for different purposes. I need a 4th PWM which is not available in the Hydra. Is there a different way i can control the voltage?

You could contribute an RLP implementation of OutputCompare for Hydra :wink:

or you can get the IO60P16 module and gain 16 more PWM pins. The driver is still under development but I do have PWM working and would be glad to have you test it :wink:

http://www.ghielectronics.com/catalog/product/363

PWM does not vary the voltage to a LED only the duty cycle,o which changes the brightness.

Try D to A

It does not change the peak voltage, but the average voltage does indeed change. At a 50% duty cycle you have an average voltage of 50% of the peak voltage and so the power consumed by the LED is 50% (and we see the LED as being dimmer.)

@ Jeff_Birt,

I’m sure the word current is missing from your post. If you are looking at the voltage on the led pin then the voltage will indeed drop due to the current, or you are taking too much current from the uC pin. @ mike is correct.

@ Jeff_Birt -

PWM signals are usually not used to vary voltages. in the case of LEDs it would be interesting to understand if the intensity effect is due to average voltage or duty cycle. when it is powered it is on at full intensity.

Here’s a nice article on the subject:
http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/

@ Mike Its the on time thats important or duty cycle/freq. The rest is down to P of V.

Guys, if you measure a PWM signal with a voltmeter what you are measuring is the average voltage over the sample period (or RMS if you have a nicer meter.) The more on time the higher the average voltage. Since the LED is a constant load and you apply a PWM signal it is on only part of the time the intensity of the LED will be related to the duty cycle, the more on time the greater the apparent brightness. If you measure the voltage you will also see that the voltage you measure (which is the average) also varies with duty cycle. Anytime the LED is on it will draw the same amount of current, the average current though will vary with the PWM.

@ jeff_Birt If you use a DVM, then what you see will not be the true voltage, when looking at pulses, due to the response time of the DVM, you need to use a scope.

Yep, I am pretty sure that’s exactly what Jeff said; “average voltage over sample period”.

To the original poster: what do you REALLY want to do? Do you really want to change the voltage, or do you just want to have the illusion of a dimmed LED?

@ Dave: A ‘True RMS’ DVM will provide a correct voltage measurement of arbitrary waveforms, a less expensive meter uses an averaging technique that is not as accurate. You can still see the effect with a cheap DVM even if the readings are not accurate though.

The point was it sounded like the original poster wanted to control the intensity of an LED, so controlling output voltage is not really required. That was my whole point in bringing up the whole subject of average voltage. Since all the PWM channels are taken up maybe output compare could be used.

Guys I surrender, I hope you take prisoners, because I need to get my scope re-calibrated!

Not unless he writes it. OutputCompare() doesn’t exist for Hydra yet.

I would actually like to get varied voltage. But PWM seems to be giving the illusion of varied voltage as i change the duty cycle. That is exactly what i want. I am not using the average voltage as a pulse so when i read the voltage from the PWM output with 50% duty cycle i get half the voltage and that is good enough.

Is there a way in which i can actually vary the voltage without PWM in Hydra?

@ srivatsan: is your goal to change the brightness of the LED?

srivatsan,

please state clearly what your goal is. What is the purpose of the varying voltage?

“varied voltage” means Digital-to-Analog, which means a DAC. On Gadgeteer, that’s an O (for Orange) socket. On Hydra, that doesn’t exist; so you can buy a DAC chip and interface it.

I want to vary the light intensity, of a laser guide light, like 35%, 70%, etc… I am using the 0-3.3 volts from the board and converting that to the power i need using a simple circuit with transistors.