Dimming LED with PWM?
Crosswinds
Posts: 182
Hi Guys!
Well got my LED feeding issues sorted! So now ive start playing around and tried out to dim an LED, just to experiment with it.
I used the SquareWave object, but i could not find a frequency that made it "dim" just blink real fast, or stay on all the time.
Am i way out here or what am i doing wrong?
I both tested on a simple LED, and also my 12v G4 LED´s that i will use in the project!
Thanks
Well got my LED feeding issues sorted! So now ive start playing around and tried out to dim an LED, just to experiment with it.
I used the SquareWave object, but i could not find a frequency that made it "dim" just blink real fast, or stay on all the time.
Am i way out here or what am i doing wrong?
I both tested on a simple LED, and also my 12v G4 LED´s that i will use in the project!
Thanks
Comments
Or does that object do pulse width modulation? I'd want to set the frequency to 100hz or so and change the amount of on time.
old wisdom that I ( a medium old programmer) heard from really wise really old programmers:
"your program does always what you have coded. If what your program does is somehthing different than you expected you don't really understand what you have coded.
a squarewave is a signal half time on half time off. Feeding this into a LED makes the LED light up means the LED gets a current which is 50% of the current if the voltage would be on all the time (100%)
In other words a squarewave is a PWM-signal with cnstant duty 50% (50% on time)
You need a real PWM-signal and an object than can vary the duty from 0% up to 100%. For dimming the LED the ontime has to vary from 5= on =LED.off to 100% on LED gets current all the time.
I had a quick look into some PE-Kit objects but I did not find a set and forget code using the counters.
By set and forget I mean
1.) configuring the a counter to operate as a PWM-generator and as long as I don't chance the duty-value the counter will produce the PWM-signal just alone
without any repeat-loop in spin or PASM.
2.) if a want to change the duty-value I write it once to the counter and after that the counter is able to produce an endless PWM-signal again.
I can't believe it! 32 counter-modes and none of them is producing a self-sufficient-pwm-signal like described above?
Is this really true? Do I have to engage a cog running code to create PWM?
keep the explanations coming
best regards
Stefan
Mygod i feel stupid now. I jumped on the wrong stuff here
But i have not gotten it to work! Used "Single-Ended DUTY Mode". Works great.
But now i have discovered a problem with the G4 LED´s i bought. i get the 6 middle to do what they supposed to. But the 4 on the edges seem to stay on all the time. This is ofcourse how they are connected to each other.
Stupid enough i did buy the ones that was not "dimmable" Since i tought the ones that is dimmable should have some special circuit made for some other dimmer. And these should just be stupid and work great with a microcontroller.
If you have the time to have a look at the video and the picture, there may be some way to modify these to make them work?
Link to picture: http://gallery.me.com/svenssondaniel/100034/IMG_0713
Link to video: http://gallery.me.com/svenssondaniel/100034/IMG_0710
Thanks for all your help man! Your'e great.
Thank you very much for your informative reply!
I noticed directly after posting my question that i had the stuff mixed up!
Now I'm at a loss. If what you say is true about there only being a rectifier in the lamps I can't think what would make them not dimmable.
Hello again Heater!
Sorry if im confusing you, but the other thread were about a way to drive these suckers. In this case a ULN-IC!
This thread is about dimming them via PWM! Have had a chance to take a look at the photo and the video i linked to?
There you can see there is 4 resistors and one rectifier? I just cant see any other components. And as you can see in the video, they do dim, but i cannot see why the 4 outer LED´s dont?
Given that there are 4 resistors and 10 LEDs, we also have to wonder about the configuration. Could be the middle groups are wired 3 LEDs + 1 resistor and the outer groups are wired 2 LEDs + 1 resistor. Different configuration causes different characteristics?
Just a few guesses...
The board is probably designed for AC, using the positive half-cycles for one set of LEDs and the negative half-cycles for the others. I've seen this in 120VAC LED strings.
Excellent point. A link to a data sheet for the module would be very helpful.
Thats a good point! I will try to contact the seller to see if i can get a schematic.
But i would think that the 6 in the middle is in series, and the 2 on the sides are in series just with eachother. Making these "rails" uneven? Would that be a teory?