Page 1 of 2

Which ports can do PWM?

Posted: Sat Jan 28, 2012 7:31 am
by marcmerlin
I had another look at
http://www.freetronics.com/pages/leosti ... tart-guide
and I can't quite figure out which pins are PWM and which are not.

For starters, my code that does PWM to RGB leds doesn't seem to work for red, which is pin 13, not habitually a PWM pin.

I think I can cheat and put a wire from a PWM pin to pin 13, but I just can't find a definition of which pins can do what and would love that over just trial and error :)

Does anyone have a pointer?

Thanks,
Marc

Re: Which ports can do PWM?

Posted: Tue Feb 07, 2012 9:08 am
by pjf
Using trial and error, D3 and D5 do PWM, and are not connected to anything else.

D9 and D10 do PWM, but are shared with the green and blue on-board LEDs respectively.

D11 apparently causes the board to lock-up on PWM, and is shared with the buzzer.

D13 DOES NOT appear to do PWM. It's shared with the red LED.

D13 not doing PWM seems like a bug, since it prevent one from being able to colour-mix the on-board LED outputs.

All other digital pins do not support PWM (at least, not when I tested them).

Re: Which ports can do PWM?

Posted: Tue Feb 07, 2012 2:01 pm
by pdr
What's wrong with doing it in software?

Re: Which ports can do PWM?

Posted: Mon Feb 13, 2012 2:43 am
by swordfishBob
pdr wrote:What's wrong with doing it in software?
Probably whatever prompted anyone to include PWM in hardware in the first place :-)

D5 and D13 share a PWM according to the chip specs. In terms of Arduino code, it depends on the Leo board definition used in the compiler. They might have prevented the same PWM being used on 2 pins to avoid confusion, and D13 is still an LED colour for compatibility with virtually every other Arduino around.

Re: Which ports can do PWM?

Posted: Sun Feb 26, 2012 9:45 am
by Amadeus3
pjf wrote:Using trial and error, D3 and D5 do PWM, and are not connected to anything else.D9 and D10 do PWM, but are shared with the green and blue on-board LEDs respectively.D11 apparently causes the board to lock-up on PWM, and is shared with the buzzer.D13 DOES NOT appear to do PWM. It's shared with the red LED.D13 not doing PWM seems like a bug, since it prevent one from being able to colour-mi


According to the specs there should be 6 PWM hardware pins, I'm assuming for compatibility they are the same as the usual Arduino ( 3,5,6 9, 10 & 11) but your tests don't seem to confirm this. I only received my Leostick yesterday so I've yet to fully test it to confirm myself. I'll post my results once I get them.

Steve

Re: Which ports can do PWM?

Posted: Thu Apr 12, 2012 1:51 pm
by dgou
Amadeus3 wrote:
pjf wrote: According to the specs there should be 6 PWM hardware pins, I'm assuming for compatibility they are the same as the usual Arduino ( 3,5,6 9, 10 & 11) but your tests don't seem to confirm this. I only received my Leostick yesterday so I've yet to fully test it to confirm myself. I'll post my results once I get them.

Steve
Hey Steve, it's been a month (assuming you're still using these forums), any luck with the test results?

Generally:
I'd like to know if the PWM on 11 is a problem at the hardware level (i.e. fix means buying a new rev of the LeoStick itself) or is something that can be fixed with software?

Specifically, from the discussions over on the viewtopic.php?f=27&t=300 thread, I learned that we can cut the trace that ties the piezo to 11 and wire it to a PWM that "works"... but... I'd really hate to do that if the PWM fix will be in software. I don't mean simulating the PWM, I mean a real fix. ;)

Thanks!
-=Doug

Re: Which ports can do PWM?

Posted: Fri Apr 13, 2012 12:17 am
by jonoxer
I'd like to know if the PWM on 11 is a problem at the hardware level (i.e. fix means buying a new rev of the LeoStick itself) or is something that can be fixed with software?
It's software, relating to the timer channels used in the Arduino core for things like the millis() function. This is something that I assume will be fixed in the Arduino core for the release of the Leonardo, because it'll have the same problem.

No need to worry about the LeoStick hardware being obsolete, it's not a problem at the hardware level.
--
Jon

Re: Which ports can do PWM?

Posted: Fri Apr 13, 2012 12:35 am
by dgou
Whew! Thank you for the quick reply!
I think I'll not be cutting the pin 11 trace then. :-)

Re: Which ports can do PWM?

Posted: Fri Apr 13, 2012 12:47 am
by jonoxer
Cool. Don't worry about cutting the pin 11 trace, though: it isn't a no-going-back thing. The reason there are the two gold pads on either side of the cut-track jumper is to make it trivial to solder-bridge it back again!
--
Jon

Re: Which ports can do PWM?

Posted: Fri Apr 13, 2012 1:29 am
by dgou
Ok.
In the meantime is there a way I can temporarily to wire up to another PWM pin without cutting the trace and without the uncut trace connection to Pin 11 interfering?
Thanks!
-doug