Introduction: Low-Cost, Arduino-Compatible Drawing Robot
Note: I have a new version of this robot that uses a printed circuit board, is easier to build, and has IR obstacle detection! Check it out at http://bit.ly/OSTurtle
I designed this project for a 10-hour workshop for ChickTech.org whose goal is to introduce teenage women to STEM topics. The goals for this project were:
- Easy to build.
- Easy to program.
- Did something interesting.
- Low-cost so participants could take it home and continue to learn.
With those goals in mind, here were a couple of the design choices:
- Arduino compatible for ease of programming.
- 4xAA battery power for cost and availability.
- Stepper motors for accurate motion.
- 3D Printed for ease of customization.
- Pen plotting with Turtle graphics for interesting output.
- Open Source so you could make one of your own!
Here is the robot that came closest to what I wanted to do: http://mirobot.io. I don't have a laser cutter and shipping from England was prohibitive. I do have a 3D printer, so I guess you can see where this is going . . .
Don't let the lack of a 3D printer deter you. You can locate local hobbyists willing to help you out at https://www.3dhubs.com/.
This project is licenced under Creative Commons, and utilizes 3D parts based on designs by others (as indicated in the next section), the most restrictive of which is the wheel, which is Non-Commercial. That means this project must also be Non-Commercial. Don't be this guy.
Step 1: Parts
There are a number of ways to power, drive, and control robots. You may have different parts on hand that will work, but these are the ones I've tried and found to work well:
Electronics:
- 1- *Adafruit Pro Trinket 3V- adafruit.com/products/2010
- Hardware under CC BY-SA licence
- Software (Bootloader) under GPL licence
*Note: See the last step for a discussion on using regular Arduino or Raspberry Pi boards.
Hardware:
- 2- 1 7/8" ID x 1/8" O-ring- mcmaster.com/#9452K96
- 1- Caster 5/8" bearing- mcmaster.com/#96455k58/=yskbki
- 10- M3 x 8mm pan head screw- mcmaster.com/#92005a118/=z80pbr
- 4- M3 x 6mm flat head screw- mcmaster.com/#91420a116/=yskru0
- 12- M3 Nut- mcmaster.com/#90591a250/=yskc6u
3D-Printed Parts (check out www.3dhubs.com if you don't have access to a printer):
- 1 x Ball bearing caster - thingiverse.com/thing:1052674 (based on work by onebytegone, CC BY-SA 3.0)
- 1 x Chassis - thingiverse.com/thing:1053269 (original work by Maker's Box, CC BY-SA 3.0)
- 2 x Wheels - thingiverse.com/thing:862438 (based on work by Mark Benson, CC BY-NC 3.0*)
- 2 x Stepper bracket - thingiverse.com/thing:1053267 (based on work by jbeale, CC BY-SA 3.0)
- 1 x Pen Holder / servo bracket - thingiverse.com/thing:1052725 (original work by Maker's Box, CC BY-SA 3.0)
- 1 x Pen Collar - thingiverse.com/thing:1053273 (original work by Maker's Box, CC BY-SA 3.0)
* Note: CC BY-NC is a non-commercial licence
Tools and Supplies:
- Phillips screw driver
- Hot glue gun
- Digital multi-meter
- Sharp knife
- Crayola colored markers
Step 2: Flash the Firmware
Before we get too far into construction, lets load the test firmware on to the microcontroller. The test program just draws for boxes so we can check for proper direction and dimension.
To talk to the Trinket Pro, you are going to need:
- Driver from https://learn.adafruit.com/introducing-pro-trinket...
- Arduino software from https://learn.adafruit.com/introducing-pro-trinket...
Lady Ada and the Adafruit team have created a far better set of instructions in the links above than I can provide. Please use them if you are stuck.
Note: The one trick that makes the Trinket different from regular Arduino is that you have to reset the board before uploading the sketch.
Attachments
Step 3: Pen Holder and Battery Holders
- Install the Pen Holder with the Servo Bracket on the shorter side of the chassis (Image 1).
- Insert the nuts on the top side of the chassis (Image 2)
- Attach the battery holders on the bottom of the chassis using 3Mx6mm flat-head screws (Images 3 & 4).
- Thread the battery leads through the rectangular cable runs (Image 4 & 5).
- Repeat for the other battery holder.
Note: Unless specified, the remainder of the screws are 3Mx8mm pan head srews.
Step 4: Wheels
- Test fit your wheel to the stepper shaft (Image 1).
- If it is too tight, you can heat the wheel hub with a hair drier or hot air gun and then insert the shaft.
- If it is too loose, you can use a 3Mx8mm screw to hold it against the flat of the shaft (Image 2).
- If you are a perfectionist, you can calibrate your printer and get it just right.
Step 5: Stepper Backets
- Insert a nut into the stepper bracket and attach them to the top of the chassis with a screw (Image 1).
- Insert the stepper into the bracket and attach with screws and nuts.
- Repeat for the other bracket.
Step 6: Caster
- Insert the ball bearing into the caster.
- Do not force it in or it will break. Use a hair-drier or hot air gun to soften the material if needed.
- Attach the caster to the bottom side of the chassis in front of the battery holder.
Step 7: Breadboard
- Remove one of the power rails using a sharp knife, cutting through the bottom adhesive (Image 1).
- Holding the breadboard over the chassis rails, mark where they intersect the edge (Image 2).
- Using a straight edge (like the removed power rail), mark the lines and cut through the backing (Image 3).
- Place the breadboard on the chassis with the rails touching the exposed adhesive (Image 4).
Step 8: Power
- Place the microcontroller, darlington driver, and power switch on to the bread board (Image 1).
- I've added orange dots for visibility to mark the following:
- Pin 1 of the darlington driver.
- The battery pin of the microtroller.
- The power switch "on" position.
- I've added orange dots for visibility to mark the following:
- With the right-hand battery leads:
- Connect the red line to the first pin of the power switch (Image 2).
- Connect the black lead to an empty row between the microcontroller and the darlington chip (Image 2).
- Connect the red line to the same row as the black lead of the other battery (Image 3).
- Connect the black line to the negative rail of the breadboard (Image 3).
- Red jumper from positive rail to the battery pin (orange dot, Image 4).
- Black jumper from the negative rail to the pin marked "G" (Image 4).
Troubleshooting: If the microcontroller lights do not come on, immediately turn the power off and troubleshoot:
- Batteries installed in the correct orientation?
- Double check battery leads positioning.
- Double check switch leads positioning.
- Use a multi-meter to check voltages of batteries.
- Use multi-meter to check power rail voltages.
Step 9: Headers and Servo Wiring
Male header pins allow us to connect the 5-pin servo JST connectors to power and the darlington driver (Image 1):
- The first 5-pin header starts one row in front of the darlington driver.
- The second servo header should then line up with the end of the darlington driver.
Before the wiring gets to complicated, lets get the servo wired up:
- Add a 3-pin header for the servo on the right edge of the forward section of the breadboard( Image 2).
- Add a red jumper from the center pin to the positive side of the power rail.
- Add a black or brown jumper from the outer pin to the negative side of the power rail.
- Add a colored jumper from the inner pin to Pin 8 of the microcontroller.
- Install the servo horn with the shaft to the full clock-wise position and the arm extending to the right-side wheel (Image 3)
- Install the servo in the pen holder using the servo's screws (Image 3).
- Connect the servo connector aligning the colors (Image 4).
Step 10: Stepper Control
Time to wire power for the darlington driver and steppers, which will be driven directly from the battery:
- Connect a black or brown jumper from the lower right darlington pin to the negative side of the power rail (Image 1).
- Connect a red jumper from the upper right darlington pin to the positive side of the power rail.
- Connect a red jumper from the upper left pin header to the positive side of the power rail (Image 2).
- Connect the left stepper connector to the left side pin header with the red lead on the right side (Image 3).
- Connect the right stepper connector to the right side pin header with the read lead on the left side.
Note: The red lead of the stepper connector is the power and should match the red leads on the breadboard.
Step 11: Stepper Control (Continued)
Now we will connect the stepper signal wires from the microcontroller to the input side of the darlington driver:
- Starting with Pin 6 of the microcontroller, connect the leads for four control jumpers for the left stepper motor (Image 1).
- Match these jumpers to the input side of the darlington on the right. All colors should match with the exception of green, which matches the pink wire of the stepper (Image 2).
- Starting with Pin 13 of the microcontroller, connect the leads for the four control jumpers for the right stepper motor (Image (3).
- Match these jumpers to the input side of the darlington on the left. All colors should match with the exception of green, which matches the pink wire of the stepper (Image 3).
Step 12: Testing and Calibration
Hopefully you already uploaded the firmware in Step 2. If not, do it now.
The test firmware just draws a square repeatedly so we can check direction and accuracy.
- Place your robot on a smooth, flat, open surface.
- Turn the power on.
- Watch your robot draw squares.
If you are not seeing lights on the microcontroller, go back and troublshoot power as in Step 8.
If your robot is not moving, double check the power connections to the darlington driver in Step 9.
If your robot is moving erratically, double check the pin connections for the microcontroller and darlington driver in Step 10.
If your robot is moving in an approximate square, it is time to put some paper down and put a pen in it (Image 1).
Your calibration points are:
float wheel_dia=66.25; // mm (increase = spiral out) float wheel_base=112; // mm (increase = spiral in) int steps_rev=128; // 128 for 16x gearbox, 512 for 64x gearbox
I started with a measured wheel diameter of 65 mm and you can see the boxes rotating inward (Image 2).
I increased the diameter to 67, and you can see it was rotating outward (Image 3).
I eventually arrived at a value of 66.25 mm (Image 4). You can see that there is still some inherent error due to gear lash and such. Close enough to do something interesting!
Step 13: Raising and Lowering the Pen
We've added a servo, but haven't done anything with it. It allows you to raise and lower the pen so the robot can move without drawing.
- Place the pen collar on the pen (Image 1).
- If it is loose, tape it in place.
- Check that it will touch the paper when the servo arm is lowered.
- Check that it will not touch the paper when raised (Image 2).
The servo angles can be adjusted either by removing the horn and re-positioning it, or through the software:
int PEN_DOWN = 170; // angle of servo when pen is down int PEN_UP = 80; // angle of servo when pen is up
The pen commands are:
penup(); pendown();
Step 14: Have Fun!
I hope you made is this far without too many curse words. Let me know what you struggled with so I can improve the instructions.
Now it is time to explore. If you look at the test sketch, you will see I have provided you some standard "Turtle" commands:
forward(distance); // millimeters backward(distance); left(angle); // degrees right(angle); penup(); pendown(); done(); // release stepper to save battery
Using these commands, you should be able to do just about anything, from drawing snow flakes or writing your name. If you need some help getting started, check out:
Step 15: Other Platforms
Could this robot be done with a regular Arduino? Yes! I went with the Trinket because of the low cost and small size. If you increase the chassis length, you can fit a regular Arduino on one side and the breadboard on the other (Image 1). It should work pin-for-pin with the test sketch, plus, you now can get to the serial console for debugging!
Could this robot be done with a Rasberry Pi? Yes! This was my first line of investigation because I wanted to program in Python, and be able to control it over the web. Like the full size Arduino above, you just place the Pi on one side, and the breadboard on the other (Image 2). Power becomes the primary concern because four AA is not going to cut it. You need to provide about 1A of current at a stable 5V, otherwise your WiFi module will stop communicating. I've found the Model A is much better on power consumption, but I'm still working out how to supply reliable power. If you figure it out, let me know!
79 Comments
6 weeks ago
Excelente proyecto!
Estoy usando drivers uln2003 pero al poner en marcha el robot las llantas giran en direcciones opuestas los pines que estoy usando son
motor izquierdo 12, 11, 10,9
Motor derecho. 7, 6, 5, 4
Espero puedan ayudarme!
Reply 5 weeks ago
It sounds like you need to switch the wire order on one stepper.
You can also switch the pin order in the code.
Let me know if you need more details.
Reply 4 weeks ago
Gracias! Ya quedo, cuando termine unos detalles que me faltan lo compartiré en este blog.
Reply 4 weeks ago
3 years ago
I wish I'd spotted this when it was posted! Nice work on building your own turtle. If you haven't already seen it, have a look at our version: https://www.instructables.com/id/Etch-a-Sketch-LOG... - would have been nice to do a LOGO for your turtle. Full circle!
3 years ago
I already put it together, I had a hard time getting some pices like the tire and the steel ball, I also used the drivers that the stepper motor brings to avoid using a Protoboard and the chip and fed it without problems with 4 AA batteries, Also note that you use a down and not just any pen.
Question 4 years ago
Alguien tiene la programación en Arduino??
Answer 4 years ago
El programa de prueba está en el Paso 2.
Question 4 years ago
Hi, I don't know if you still read those posts. This is a wonderful project in my opinion. I'm making your model, I'm planning to use an arduino uno, and I want to program it with mblock (this is scratch for arduino) to make it programmable with children. Have you already tried to program it with blocks ?
Reply 4 years ago
I worked a little with Ardublocks several years ago, but not with the robot. I think it would be really useful for younger kids. I think we would just need to create the blocks for the Turtle moves, which doesn't seem impossible: http://download.makeblock.com/mblock/mblock_extension_guide.pdf
Reply 4 years ago
Hi, I'm back with my version of your robot. It's programmable with mblock, so it's very useful for younger kids, they love it !! Thank you again for your sharing. You can see it here: https://www.youtube.com/watch?v=j0jcd-5KL9Q
Reply 4 years ago
Very nice! The use of block programming will make it more acessabile to beginners. I love the changes like use of the driver boards and lower profile servo bracket!
7 years ago
I am making it today, could someone please answer my question quick.
Thanks,
BossBoy
Reply 7 years ago
Check the information at https://learn.adafruit.com/introducing-pro-trinket/overview to learn how to program it. The code you need to upload to the Trinket is attached to Step 2 ("TIRL_Trinket_TEST.ino").
7 years ago
Hello, awesome project! I was wondering how to program the robot, I do not understand why you gave little 3 lined list of code. Could you please define each function more clearly, thanks.
-BossBoy
7 years ago
Hello, its an amazing project, I was hoping to increase the speed of the motors is there any suggestions?
7 years ago
This is awesome! I made it with and arduino Uno that has a prototype shield. I am attempting to write a function for arcs using an input for radius and degree. I have been partially successful, but haven't been able to match the inputs to what it is drawing. It could be my math is off. Have you had success with drawing arcs? Here is what i wrote if you are interested in seeing it. http://bit.ly/1PgRqCW
Reply 7 years ago
I've done a little work on the Python version. I think the key is to just make it a 12 - 20 sided polygon which will look like circle.
Reply 7 years ago
Hi.. I would like to know the structure of the robot where to find it
7 years ago
Hi,
First of all thanks for this great project. I printed all parts and procure all other electronics, but I have a issue. In Romania I can't find such o-rings that you are using. I was thinking to modify the wheels but the max o-ring i can find is with OD=40mm or 110mm.
Did someone successful use alternatives for this o-rings?
Thanks.