PWMPal LED dimmer?
Interactives
Posts: 83
Good evening,
For a long time now I have been aspiring to reproduce the wonderful glow of the old G4 Macintosh on/off buttons. It is clearly a white LED that ramps up, and then ramps down repeatedly- resulting in a wonderful glow that seems to be breathing. I just cracked open my PWMpal, which I have ordered to attempt recreating this look. However, the documentation does not make it 100% obvious how I would go about programming this feat. I have replaced the DC motor with a bank of LEDs using the PWMPla_simple_motor.BS2 files, but the lights dont ramp up smoothly. I have attempted the same circuit using plain old resistors+capacitors, but have never been able to produce anything as lovely. Any help/advice would be greatly appreciated! Thanks
For a long time now I have been aspiring to reproduce the wonderful glow of the old G4 Macintosh on/off buttons. It is clearly a white LED that ramps up, and then ramps down repeatedly- resulting in a wonderful glow that seems to be breathing. I just cracked open my PWMpal, which I have ordered to attempt recreating this look. However, the documentation does not make it 100% obvious how I would go about programming this feat. I have replaced the DC motor with a bank of LEDs using the PWMPla_simple_motor.BS2 files, but the lights dont ramp up smoothly. I have attempted the same circuit using plain old resistors+capacitors, but have never been able to produce anything as lovely. Any help/advice would be greatly appreciated! Thanks
Comments
Heres an example:
·
and some code to test it.
' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Word
DO
'ramp up
FOR x=0 TO·80
· PWM 0,x,50
NEXT
'pause & hold
FOR x=0 TO 5
· PWM 0,80,50
NEXT
'ramp down
FOR x=80 TO 0
· PWM 0,x,50
NEXT
'pause & hold
FOR x=0 TO 10
· PWM 0,0,50
NEXT
LOOP
When testing LED dimmers it's best to have a non-dimmed LED next to the dimmed one as a reference, because your eyes compensate for brightness. You don't·have to use the full throttling range of the PWM command to achieve the effect you want - a value of 80 yields 6.274 mA. The op amp gives you a very linear rise in current and pwm gives you a linear rise in voltage so the dimming is very controlled. Increasing the OpAMP voltage allows you to make the LED brighter. 7.5 volts on the op ampallows you to goto to 12 mA using a 160 output from the PWM command.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 7/2/2007 10:41:04 AM GMT
I don't think the LED's have a linear response to the PWM Pal.· You may need to experiment with percieved brightness vs. power level.·
I'm not familair with the orginal effect you're trying to get, but maybe try randomizing the brightness levels within a certain range?· You may need to set a lower range for dim and an upper range for the bright.·
Trying to help!
It runs at 1mhz at 5V. You can run it on a single LED at 20ma or add a fet for higher amp LED's. I use LuxeonIII and run 1AMP through a mosfet.
If you vary the voltage from 5V down to 2.7V you can change the cycle time as well as the on chip oscillator is dependent on the voltage supplied to the chip.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
The following puts out a 1 hertz sine wave, which looks petty smooth...
but that is faster than the G4 pulsation. Try something like this...
That steps through 1/2 of a cycle, so SINe goes from zero to maximum and back to zero. The formula that starts with "x =" adds an offset (so the LED won't go completely off), and scales the values from 64 to 255. That is what is output as PWM, at nominally 16 cycles per step, which makes it pulsate at about 3 seconds period. However, one more refinement, the amount of time spent at high value of x is decreased. That is to compensate for the logarithmic perception of light intensity by the eye. You just have to play with it until it matches the tempo and timber of the Mac G4 light. I think you could use the same sort of logic with the PWMPAL.
The Stamp can't do anything else while it is pulsing the light though. Metron9's chip would be a good deal!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
"Increasing the OpAMP voltage allows you to make the LED brighter. 7.5 volts on the op ampallows you to goto to 12 mA using a 160 output from the PWM command."
And I changed the PWM duration to 50 (oops). I'm sure you can port this circuit to the PWMPAL.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Have Fun
TR
Post Edited (TechnoRobbo) : 7/2/2007 10:59:57 AM GMT
I added some comments to some of the code. I accelerate the duty cycle curve at higher duty cycles and slow it down on lower duty cycles to make the fade look better.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!