Go Down

Topic: Multiple motor pwm (Read 1 time) previous topic - next topic

benchaz

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.

Ill Mill

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.

benchaz

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??

mem

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?

benchaz

#4
Mar 20, 2009, 06:24 pm Last Edit: Mar 20, 2009, 06:36 pm by benchaz Reason: 1
It depends, maybe around 3-4 of them
How would i do it? what are the different ways for doing it?

mem

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

Ran Talbott

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

benchaz

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: [Select]
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,



mem

#8
Mar 28, 2009, 07:09 am Last Edit: Mar 28, 2009, 07:39 am by mem Reason: 1
remove  the line in servo.h that includes wiring.h :
 #include <wiring.h>
and move it into servo.cpp

benchaz

i commented it out
and this happens
Code: [Select]

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


mem

#10
Mar 28, 2009, 08:08 am Last Edit: Mar 28, 2009, 08:10 am by mem Reason: 1
add  #include <wiring.h> to servo.cpp

( I added that shortly after i first posted, so you may not have seen it)

benchaz

#11
Mar 28, 2009, 09:55 am Last Edit: Mar 28, 2009, 09:55 am by benchaz Reason: 1
Thank you so much for your prompt reply and working solution!
It works now :)

Why is this, do you know?
and is it like this on every machine?

mem

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.

Go Up