Pages: [1]   Go Down
Author Topic: More than two PWM output in Arduino Pro mini ?  (Read 2725 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone

I am using 4 servo motors for my project and using an arduino pro mini. I am using Pin 9 and 10 for PWM function, and I need to connect other two motors to be able to use the PWM library function to write to the Servos. Is there any simple way to do thi s? How many different ways could I make my other two servo motors run. Arduino Pro mini have only 2 pins that uses pwm library. So how can i overcome this problem ?  I want to connect and use other two motors to be able to use pwm function, where should i connect it ?
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1670
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Can't you just use the servo library, see here-

http://rcarduino.blogspot.com/2012/01/can-i-control-more-than-x-servos-with.html

Also checkout the two links in my signature regarding powering your servos

Duane B

rcarduino.blogspot.com
Logged


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

You can Run the Servos but you cannot write it. According to Servo library in arduino main page it says - The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.

And I need to use that functionality of writing on to two other motors as well. I have heard of using a motor controller, but i dont know which one to use
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1670
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I don't think you are right. If I understand you want to run two normal motors and several servos. The Arduino has six pins which support analogWrite, the servo library effects two of these so you still have four analogWrite pins left for motors - they are the ones with the wggley lines next to the pin numbers printed on your board, check out pins 6,5 and 3.

You will most likley want a motor driver ic of some sort, this will allow you to supply the motors with their own power and also gives forwards and reverse control, look up l293 it's what many of the motor shields use.

Duane B



Logged


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

Thanks, that helped me a bit. But I don't get this. Why does this link says pwm functionality is disabled on pins 9 and 10 if we use library :s  . What does it mean ? And i connected it on pin 6 and servo motors moves but very strangely.

http://arduino.cc/it/Reference/Servo
Logged

0
Offline Offline
Shannon Member
****
Karma: 161
Posts: 10442
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, that helped me a bit. But I don't get this. Why does this link says pwm functionality is disabled on pins 9 and 10 if we use library :s  . What does it mean ? And i connected it on pin 6 and servo motors moves but very strangely.

http://arduino.cc/it/Reference/Servo

It means PWM is disabled on pin 9 and 10 if you use that library.  It can't be stated any simpler.

On standard (not Mega) Arduinos:
timer0 does PWM for pins 5 and 6, and also does the timing for millis(), micros(), delay() etc
timer1 does PWM for pins 9 and 10
timer2 does PWM for pins 11 and 3

The Servo library takes over timer1 completely, no more PWM on pins 9 and 10.  Simple.
Logged

[ I won't respond to messages, use the forum please ]

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 21
Posts: 1670
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

If your servos are moving strangely,nits your code or your power. Check the links in my signature for info and examples about servo power with Arduino.

Duane B

rcarduino.blogspot.com
Logged


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

The Servo library takes over timer1 completely, no more PWM on pins 9 and 10.  Simple.
Okay, so how can I have two more pins that function similar to pin 9 and 10 ? I want Servo library to take over for example timer 2.
Logged

0
Offline Offline
Shannon Member
****
Karma: 161
Posts: 10442
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Servo library needs a 16 bit timer IIRC, and only timer1 is 16 bit, the others are 8 bit.  The Servo library can drive any pin for Servo style PWM, but the built-in PWM is then limited to pins 3,5,6,11 - that's what the hardware gives you.  Arduino Mega has many more timers, and most are 16 bit, note.
Logged

[ I won't respond to messages, use the forum please ]

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

16 bit PWM outputs on Timer1 which support fast PWM mode versus only one 8 bit PWM on Timer2

So I guess I have no way to have 16 bit PWM on other pins for other servo motors but to use 8 bit PWM which is provided by Timer 2 or timer 0 and is not good option.
Logged

Pages: [1]   Go Up
Jump to: