0
Offline
Newbie
Karma: 0
Posts: 21
Arduino rocks
|
 |
« on: February 26, 2009, 09:06:13 am » |
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
Full Member
Karma: 0
Posts: 187
Arduino rocks
|
 |
« Reply #1 on: February 26, 2009, 10:45:15 am » |
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
Newbie
Karma: 0
Posts: 21
Arduino rocks
|
 |
« Reply #2 on: March 20, 2009, 10:27:14 am » |
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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #3 on: March 20, 2009, 10:41:56 am » |
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
Newbie
Karma: 0
Posts: 21
Arduino rocks
|
 |
« Reply #4 on: March 20, 2009, 12:24:08 pm » |
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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #5 on: March 20, 2009, 12:42:08 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Rural Arizona
Offline
Edison Member
Karma: 7
Posts: 1712
Incorrigible tinkerer
|
 |
« Reply #6 on: March 20, 2009, 06:02:20 pm » |
This chip looks kind of interesting, too: http://www.web4robot.com/Flexel.htmlI 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
Newbie
Karma: 0
Posts: 21
Arduino rocks
|
 |
« Reply #7 on: March 28, 2009, 12:59:56 am » |
Hey guys, thanks I looked through http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239and http://www.arduino.cc/playground/ComponentLib/Servoseemed 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. 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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #8 on: March 28, 2009, 01:09:07 am » |
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
Newbie
Karma: 0
Posts: 21
Arduino rocks
|
 |
« Reply #9 on: March 28, 2009, 01:41:41 am » |
i commented it out and this happens 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
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #10 on: March 28, 2009, 02:08:10 am » |
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
Newbie
Karma: 0
Posts: 21
Arduino rocks
|
 |
« Reply #11 on: March 28, 2009, 03:55:26 am » |
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?
|
|
|
|
« Last Edit: March 28, 2009, 03:55:53 am by benchaz »
|
Logged
|
|
|
|
|
London
Offline
Faraday Member
Karma: 6
Posts: 6226
Have fun!
|
 |
« Reply #12 on: March 28, 2009, 04:38:48 am » |
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
|
|
|
|
|
|