Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: sanzoghenzo on April 10, 2014, 01:20:50 PM

Title: Info about PWM output
Post by: sanzoghenzo on April 10, 2014, 01:20:50 PM
Hi all,
still trying to make something useful from this board, given my poor electronic knowledge...
I'm planning to use the PWM output to make a Wakeup light using a chinese led lamp :P It has 8 LED in parallel, I found that they operate at 3,2V and that I need about 68mA to drive them at maximum output light.
can PWM output draw this current? or should I use a transistor to make an ON/OFF switch using the 3.3V (or 5V) pin?

thanks for the attention
Title: Re: Info about PWM output
Post by: herter on April 10, 2014, 04:26:52 PM
Hello,

I don't think that the PWM output can draw this current. So, you have to use a transistor which is controlled by the PWM output and you can fade your led.
But only 68 mA for the 8 LED, or for one LED?
You have succeeded to enable the pwm under linux?
Title: Re: Info about PWM output
Post by: sanzoghenzo on April 10, 2014, 05:45:11 PM
Thankyou for your help.

I didn't enable PWM yet, so I can't tell you if what is written in the wiki is sufficient to do it.
I also saw another topic in this forum that uses GPIO to output PWM signals. I imagine that I should use a transistor also in this situation.

As per the load current I tried to calculate it in the following way:
Originally the LEDs were attached to 4.5V (3 AAA batteries) with no resistance.
I used a 10K trimmer (tester says 9.76K) and a 12V (well, my buggy tester says 18.33V) ac-dc power supply. I reduced the resistance of the trimmer until the led were really bright (but not too much because they shifted to 6V, risking of frying them!). the final resistance was 220ohm, and the LEDs voltage 3.2V. So (18.33-3.2)/220=68mA. Am I missing something?

Thanks again for your help!
Title: Re: Info about PWM output
Post by: dave-at-axon on April 10, 2014, 07:43:50 PM
Your calculations are correct. I ran them through Electrodroid on my phone and got 68.773mA with your values.

:)

Are you running an OS on your A20?

That's going to be the issue in getting access to the registers to be able to configure the processor for PWM. It should work if you can but may need a kernel mode driver to do this if you are running something like Linux.
Title: Re: Info about PWM output
Post by: herter on April 11, 2014, 10:02:42 AM
I agree too, but I hope your resistance of 220 ohm can dissipate at least 1W with the 68 mA!
By the way, I'm also looking for enable the pwm on the A20 under debian.
Title: Re: Info about PWM output
Post by: sanzoghenzo on April 11, 2014, 05:29:54 PM
Quote from: dave-at-axon on April 10, 2014, 07:43:50 PM
Your calculations are correct. I ran them through Electrodroid on my phone and got 68.773mA with your values.

:)

Are you running an OS on your A20?

That's going to be the issue in getting access to the registers to be able to configure the processor for PWM. It should work if you can but may need a kernel mode driver to do this if you are running something like Linux.
https://www.olimex.com/wiki/How_to_add_pwm (https://www.olimex.com/wiki/How_to_add_pwm)
I'm hoping that these informations are correct.
If it doesn't work, I will try to use https://www.olimex.com/forum/index.php?topic=2403.msg10506#msg10506 (https://www.olimex.com/forum/index.php?topic=2403.msg10506#msg10506)
Title: Re: Info about PWM output
Post by: bubi on April 12, 2014, 02:11:43 AM
Hello, I tryed to do what's explained in https://www.olimex.com/wiki/How_to_add_pwm and it seems to work. Unfortunatly I don't have an oscillo, so I did some test simply using a led, and varying period and duty-cycle of the pwm output. The only thing that doesn't work is the polarity of the pwm; even if I change it from 0 (default) to 1, it returns to 0. I tryed to set to 1 as default in script.fex but it doesn't work. Also, duty-cycle of 0% gave the same result of 100% (but from 1% to 99% it works correctly).
Another issue is that pwm pin doesn't have a default state, so when you stop pwm (echo 0 > run) the pin keeps the last state of pwm.

Next step is try to use https://www.olimex.com/forum/index.php?topic=2403.msg10506#msg10506, as I use an LCD and I need 4 pwm out.
But maybe it's better to use an external chip connected via I2C.

Regards
Renato