Pages: [1]   Go Down
Author Topic: Multiple motor pwm  (Read 1426 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys

I'm creating a robot that has 5 motors.
I need PWM for all 5 motors. I have a arduino diecimila. What is the best way of doing this with my arduino? I know the diecimila has 3 pwm pins, but that's not enough.

The program is very simple. All it's doing is reading serial input, and changing the motor's speed according to the serial input.

Thanks guys.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 187
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are actually 6 pwm pins on the diecimila, pins 3,5,6,8,9 and 10. So that aspect shouldn't be a problem. However, you will probably need some sort of driver circuitry to actually be able to control the motors because the Arduino pins can only source 40 milliamps.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With the 5 motors, i would like to have servos connected to the arduino too
What is the maximum number of servos can i connect??
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Theoretically, without external hardware you can have as many as you have free digital pins. Practically I would say up to 8 servos.

How many do you need?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It depends, maybe around 3-4 of them
How would i do it? what are the different ways for doing it?
« Last Edit: March 20, 2009, 12:36:16 pm by benchaz » Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

there are some links in this post: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239

this one is may be the most suitable for what you want:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239
Logged

Rural Arizona
Offline Offline
Edison Member
*
Karma: 7
Posts: 1711
Incorrigible tinkerer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This chip looks kind of interesting,  too:

http://www.web4robot.com/Flexel.html

I haven't tried one yet,  though.  I bought one of their I2C LCD controllers,  and am moderately impressed with it:  it's well-made,  inexpensive,  and has a well-thought-out feature set.  The reason I'm only saying "moderately" is that the documentation looks good,  but doesn't fully reveal or explain some of its quirks (most notably,  only some of the cases where you need to give it some time to execute commands are identified).  I'm having to uncover some of those quirks by experimentation.

But I'm impressed enough that I'd buy one of their chips to try out if I had a lot of servos to control,  and will probably pick up one to play with for its other features.

Ran
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys, thanks
I looked through http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239
and http://www.arduino.cc/playground/ComponentLib/Servo
seemed the most suitable for my problem

I tried it out, downloaded the libraries, put the unziped Servo folder into arduino-0015/hardware/libraries, and replaced the old Servo folder (i kept a backup)

I ran the demo software and it couldn't compile. This error appeared.
Code:
In file included from F:\Documents and Settings\Ben\Desktop\arduino-0015\hardware\cores\arduino/WProgram.h:4,


f:/documents and settings/ben/desktop/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected unqualified-id before 'int'


f:/documents and settings/ben/desktop/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'


f:/documents and settings/ben/desktop/arduino-0015/hardware/tools/avr/lib/gcc/../../avr/include/stdlib.h:111: error: expected `)' before 'int'


In file included from F:\Documents and Settings\Ben\Desktop\arduino-0015\hardware\cores\arduino/WProgram.h:6,

Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

remove  the line in servo.h that includes wiring.h :
  #include <wiring.h>
and move it into servo.cpp
« Last Edit: March 28, 2009, 01:39:40 am by mem » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i commented it out
and this happens
Code:
Servo.cpp: In member function 'uint8_t Servo::attach(int)':
Servo.cpp:28: error: 'digitalWrite' was not declared in this scope
Servo.cpp:29: error: 'OUTPUT' was not declared in this scope
Servo.cpp:29: error: 'pinMode' was not declared in this scope
Servo.cpp: In member function 'void Servo::write(int)':
Servo.cpp:52: error: 'clockCyclesPerMicrosecond' was not declared in this scope
Servo.cpp: In static member function 'static void Servo::refresh()':
Servo.cpp:74: error: 'millis' was not declared in this scope
Servo.cpp:107: error: 'digitalWrite' was not declared in this scope
Servo.cpp:109: error: 'TCNT0' was not declared in this scope
Servo.cpp:124: error: 'digitalWrite' was not declared in this scope
o: In function `__static_initialization_and_destruction_0':
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:6: undefined reference to `Servo::Servo()'


F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:7: undefined reference to `Servo::Servo()'


o: In function `loop':
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:34: undefined reference to `Servo::write(int)'


F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:38: undefined reference to `Servo::detach()'


F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:41: undefined reference to `Servo::attach(int)'


F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:46: undefined reference to `Servo::refresh()'


o: In function `setup':
F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:11: undefined reference to `Servo::attach(int)'


F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:12: undefined reference to `Servo::setMaximumPulse(unsigned int)'


F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet/sketch_090328a.cpp:13: undefined reference to `Servo::attach(int)'


Couldn't determine program size: F:\Documents and Settings\Ben\Desktop\arduino-0015\hardware/tools/avr/bin/avr-size: 'F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet\sketch_090328a.hex': No such file


avrdude: can't open input file F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet\sketch_090328a.hex: No such file or directory
avrdude: write to file 'F:\Documents and Settings\Ben\My Documents\Arduino\sketch_090328a\applet\sketch_090328a.hex' failed
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

add  #include <wiring.h> to servo.cpp

( I added that shortly after i first posted, so you may not have seen it)
« Last Edit: March 28, 2009, 02:10:00 am by mem » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you so much for your prompt reply and working solution!
It works now smiley

Why is this, do you know?
and is it like this on every machine?
« Last Edit: March 28, 2009, 03:55:53 am by benchaz » Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some Arduino definitions were added in release 0012 that conflict with the core language if they are included in a library header file. This is generally only an issue with older libraries and is easily fixed once you know how.
Logged

Pages: [1]   Go Up
Jump to: