led dimmering and PWM
labsmoke
Posts: 38
im trying to dimmer some leds, and i realise that the PWM is done with those internal counters FRQ, CRT and so on.
but im trying to find some "ready-to-go" code snippet for dimmering leds or just outputing PWM trains.
im not asking for someone to do my work but·you guys always seems to have something in you archives for rainy days.
i just need to dimmer a led with a code witch i can control setting a variable or something...
thanks anyway!
but im trying to find some "ready-to-go" code snippet for dimmering leds or just outputing PWM trains.
im not asking for someone to do my work but·you guys always seems to have something in you archives for rainy days.
i just need to dimmer a led with a code witch i can control setting a variable or something...
thanks anyway!
Comments
http://www.parallax.com/Portals/0/Downloads/appnt/prop/AN001-PropellerCountersv1.1.zip
You can use the counter module to do this really nicely...
PWM is the most simple and trivial thing to do.
You have to know SPIN of course, as with all other programming activities...
Days with the prop--7
weeks reading the materials--3
Completed leds, temperature probe, speaker, ir reciever(still trying to decipher remote codes)
Mosquito
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mosquito: An animal which buzzes in your ear and never stops. He may byte you, he may nibble you, but you will know you were bit.
·A good engineer borrows from others, a great engineer steals everything outright!!
There are two possibilities:
(A) You setup a timer in DUTY-mode to do it all itself. This is not in the tuturial, as it is not strict PWM, and is not useful for the servos But it is very automatic, and will work with LEDs (I think..)
You change FRQA whenever appropriate..
(B) You set-up a COG to supervise the PWM; lets call the routine PWM
(B1) PWM cycles in an endless loop synchronizing each 10 ms using WAITCNT
(B2) It lights the LED
(B3) It waits to the synctime + 10ms *dutyCycle
(B4) it clears the LED
6 lines of code, maybe 8
Don't confuse DC-motors and servos. Servos are connected to steady 5 to 6 Volts and CONTROLLED by a specific PWM signal I have explained this at least twice during the last days... o.k. I just can do it again:
1 ms is left 1.5 ms is center 2 ms is right, all 10 ms (sorry: 20 ms , or course), over and over again.
BTW - You can modify a servo by repacing its internal potentiometer by two constant 10k resistors and cutting away a small plastic nipple, so it can work as a motor. This is comprehensivly explained in the web, with pictures
You can also regulate the voltage to a DC motor through a transistor.
However in that case you should use an integrating low pass filter at the transistor base.
Your PWM (or even duty cycle signals) then will add up to a true analogue signal, using the trasistor as its inventors had anticipated
This is the poor man's DAC!
Post Edited (deSilva) : 12/24/2007 3:54:25 PM GMT
Mosquito.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mosquito: An animal which buzzes in your ear and never stops. He may byte you, he may nibble you, but you will know you were bit.
·A good engineer borrows from others, a great engineer steals everything outright!!
".. And this taxing was first made when Cyrenius was governor of Syria..."
----
Edit: Publius Sulpicius Quirinius was a brave soldier and able administrator BTW, someone like Eisenhower I should say, coming back to American presidents
Post Edited (deSilva) : 12/23/2007 10:52:12 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Jason
www.pr0jects.com