Go Down

Topic: Arduino Mega 2560 PWM Pins (Read 3810 times) previous topic - next topic

Mastino

Hello everybody!
Is on Arduino Mega 2560 only 13 PWM Pins? 0 to 13?  And I can use only 2-13, because the 0 and the 1 pin is for tx and rx. So other 14 - 53 pins can`t be used as a PWM pin?
Thanks!

PaulS

Quote
Is on Arduino Mega 2560 only 13 PWM Pins? 0 to 13?

Yes.

Quote
And I can use only 2-13, because the 0 and the 1 pin is for tx and rx.

You can't use them while doing serial input/output. If you don't need to do serial IO, then you can use them.

Quote
So other 14 - 53 pins can`t be used as a PWM pin?

True.

What are you planning that needs more than 12 PWM pins? There are expander chips.

Mastino


What are you planning that needs more than 12 PWM pins? There are expander chips.

I am building a robot (http://arduino.cc/forum/index.php/topic,92533.0.html) And it has motor driver that uses 4 PWM pins, + 4 x PING ultra sound sensor, each needs 2 PWM pins, so for all 8pins. So all my 12 PWM pins are used.. Now I want attach a stepper motor driver, he needs all so 4 PWM pins. But no free PWM pins left.. That`s why I`am asking.
Thank you for you answer!

PaulS

#3
Feb 18, 2012, 06:50 pm Last Edit: Feb 18, 2012, 06:54 pm by PaulS Reason: 1
Quote
And it has motor driver that uses 4 PWM pins

Is it driving 4 motors? If not, it doesn't need 4 PWM pins.

Quote
4 x PING ultra sound sensor, each needs 2 PWM pins

Which sensors are you talking about? The Ping page on the playground indicates that the PING sensor needs one pin for input, and that it doesn't need to be a PWM pin.

Quote
Now I want attach a stepper motor driver, he needs all so 4 PWM pins.

Again, which one? The stepper motor driver I use doesn't need any PWM pins, let alone 4 of them.

Mastino


Is it driving 4 motors? If not, it doesn't need 4 PWM pins.

No, it drives two motors. So one PWM output to turn motor A right, another PWM pin to turn motor A left. And the same with motor B. So I need
4pins.


Which sensors are you talking about? The Ping page on the playground indicates that the PING sensor needs one pin for input, and that it doesn't need to be a PWM pin.

I have this cheap china PING(HC-SR04) for couple bucks:) They have 4pins - gnd, 5v and trigger pin(PWM) and echo pin(PWM).   


Again, which one? The stepper motor driver I use doesn't need any PWM pins, let alone 4 of them.

The same thing.. cheap from ebay(http://www.ebay.com/itm/Arduino-Stepper-Motor-5V-4-Phase-5-Wire-Driver-Board-/280706173833?pt=LH_DefaultDomain_0&hash=item415b644b89) and it needs 4 PWM pins.

Thank you very much for your answers!

dxw00d

#5
Feb 18, 2012, 09:49 pm Last Edit: Feb 18, 2012, 09:51 pm by dxw00d Reason: 1
According to the pdf linked from the ebay page, the stepper driver doesn't require PWM at all.

PaulS

There is a library to drive the sensor you linked:
http://arduino.cc/blog/2011/10/20/hc-sr04-ultrasonic-arduino-library/
In the example that comes with the library:
Code: [Select]
#define TRIGGER_PIN  12
#define ECHO_PIN     13

Ultrasonic ultrasonic(TRIGGER_PIN, ECHO_PIN);

You might notice that neither of those are PWM pins on the UNO or other non-Mega Arduinos.

Quote
No, it drives two motors. So one PWM output to turn motor A right, another PWM pin to turn motor A left. And the same with motor B. So I need 4 pins.

No you don't. The driver most likely needs a non-PWM pin to set direction and a PWM pin to set speed for each motor.

So, to drive the stuff you have listed, you need exactly two PWM pins. Not 16.

Mastino

Yes, you are absolutely right! Thank you PaulS and dxw00d for useful help! This library is wonderful!

WhiteRC

(Updated because of Google search result priority) The above is partly wrong.

There are three pins in the right-hand (Digital) block of pins that can also be used as PWM outputs. Pins 44, 45, and 46 on the Arduino Mega 256  are also PWM pins suitable for use with the analogWrite() function.

Go Up