Pages: [1]   Go Down
Author Topic: Arduino Mega 2560 PWM Pins  (Read 3421 times)
0 Members and 1 Guest are viewing this topic.
Baltic states
Offline Offline
Jr. Member
**
Karma: 0
Posts: 97
new day, new try
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 50294
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Baltic states
Offline Offline
Jr. Member
**
Karma: 0
Posts: 97
new day, new try
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 50294
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: February 18, 2012, 12:54:56 pm by PaulS » Logged

Baltic states
Offline Offline
Jr. Member
**
Karma: 0
Posts: 97
new day, new try
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

According to the pdf linked from the ebay page, the stepper driver doesn't require PWM at all.
« Last Edit: February 18, 2012, 03:51:57 pm by dxw00d » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 50294
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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.
Logged

Baltic states
Offline Offline
Jr. Member
**
Karma: 0
Posts: 97
new day, new try
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(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.
Logged

Pages: [1]   Go Up
Jump to: