Which ports can do PWM?

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
marcmerlin
Posts: 1
Joined: Sat Jan 28, 2012 7:20 am

Which ports can do PWM?

Post by marcmerlin » Sat Jan 28, 2012 7:31 am

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

pjf
Posts: 1
Joined: Tue Feb 07, 2012 8:53 am

Re: Which ports can do PWM?

Post by pjf » Tue Feb 07, 2012 9:08 am

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).

User avatar
pdr
Posts: 1
Joined: Sat Feb 04, 2012 4:26 pm

Re: Which ports can do PWM?

Post by pdr » Tue Feb 07, 2012 2:01 pm

What's wrong with doing it in software?

swordfishBob
Posts: 31
Joined: Sun Nov 27, 2011 10:27 pm

Re: Which ports can do PWM?

Post by swordfishBob » Mon Feb 13, 2012 2:43 am

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.

Amadeus3
Posts: 1
Joined: Sat Feb 25, 2012 1:57 pm

Re: Which ports can do PWM?

Post by Amadeus3 » Sun Feb 26, 2012 9:45 am

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

dgou
Posts: 4
Joined: Thu Apr 12, 2012 1:36 pm

Re: Which ports can do PWM?

Post by dgou » Thu Apr 12, 2012 1:51 pm

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

User avatar
jonoxer
Freetronics Staff
Freetronics Staff
Posts: 297
Joined: Sat Oct 15, 2011 11:31 am

Re: Which ports can do PWM?

Post by jonoxer » Fri Apr 13, 2012 12:17 am

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

dgou
Posts: 4
Joined: Thu Apr 12, 2012 1:36 pm

Re: Which ports can do PWM?

Post by dgou » Fri Apr 13, 2012 12:35 am

Whew! Thank you for the quick reply!
I think I'll not be cutting the pin 11 trace then. :-)

User avatar
jonoxer
Freetronics Staff
Freetronics Staff
Posts: 297
Joined: Sat Oct 15, 2011 11:31 am

Re: Which ports can do PWM?

Post by jonoxer » Fri Apr 13, 2012 12:47 am

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

dgou
Posts: 4
Joined: Thu Apr 12, 2012 1:36 pm

Re: Which ports can do PWM?

Post by dgou » Fri Apr 13, 2012 1:29 am

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

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests