Drawing Robot for Arduino

by MakersBox in Circuits > Arduino

115445 Views, 477 Favorites, 0 Comments

Drawing Robot for Arduino

01_rear.JPG
00_front.JPG
00_robots rock.JPG
Arduino Drawing robot doing random patterns
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.
  • AA 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 www.3dhubs.com

It took a lot of work, but I'm please with how it turned out. And, I learned quite a bit in the process. Let me know what you think!

Parts

02_parts.JPG
01_parts.JPG
03_parts.JPG
04_parts.JPG

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:

Hardware:

Printed Parts (check out www.3dhubs.com if you don't have access to a printer):

  • http://www.thingiverse.com/thing:1091401
    • 1 x Ball bearing caster
    • 1 x Chassis
    • 2 x Wheels
    • 2 x Stepper bracket
    • 1 x Pen Holder / servo bracket
    • 1 x Pen Collar
  • I use low-resolution, 100% fill, and no support. This is about 4 hours worth of printing.

Supplies:

  • Phillips screw driver
  • Hot glue gun
  • Digital multi-meter
  • Sharp knife
  • Crayola colored markers

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.

  1. Download the Arduino software from www.arduino.cc/en/Main/Software
  2. Open the Arduino software.
  3. Download the attached zip file and unzip it to the Arduino sketchbook location.
    • You can find (or change) this location in the Arduino IDE: [File] -> [Preferences]-> "Sketchbook Location".
  4. Load the test sketch: [File] -> [Sketchbook] -> [TIRL_Arduino_TEST]
  5. Attach your Arduino to your computer with a USB cable.
  6. In the Arduino IDE:
    1. Set you board type: [Tools] -> [Board] -> Your board type.
    2. Set your serial port: [Tools] -> [Port] -> Usually the last one listed.
  7. Upload the sketch using the arrow icon.

If you have any problems, refer to www.arduino.cc/en/Guide/Troubleshooting for help.

Pen Holder and Battery Holders

05_chassis.JPG
06_pen_holder.JPG
07_holder.JPG
10_battery.JPG
  1. Insert the nuts on the top side of the chassis (Image 1). You may have to press them in.
  2. Install the Pen Holder with the Servo Bracket on the top side of the chassis (Image 2 & 3).
  3. Attach the battery holders on the bottom of the chassis using 3Mx6mm flat-head screws (Image 4)
    • You need at least 5xAA to properly power an Arduino via it's onboard regulator. Six would work as well, so I've include holes for either size on both sides.
    • You want the weight shifted toward the caster, so put the 3xAA toward the back.
    • Orient the holders so the leads are closest to the rectangular cable runs.
  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 screws

Stepper Backets

08_bracket.JPG
09_bracket.JPG
11_bracket.JPG
12_bracket.JPG
  1. Insert a nut into the stepper bracket and attach them to the top of the chassis with a screw (Image 1).
  2. Insert the stepper into the bracket and attach with screws and nuts.
  3. Repeat for the other bracket.

Caster

13_caster.JPG
14_caster.JPG
  1. 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.
  2. Attach the caster to the bottom side of the chassis in front of the battery holder.

I've tried other round objects like marbles, but smooth and heavy seems to work well. If you need a different diameter, you can edit the openScad file (http://www.thingiverse.com/thing:1052674) to fit what ever you have on hand.

Breadboard and Brains

18_breadboard.JPG
16_breadboard.JPG
17_breadboard.JPG
18b_breadboard.JPG
15_arduino.JPG
  1. Remove one of the power rails using a sharp knife, cutting through the bottom adhesive (Image 1).
    • One rail has power (red) on outer edge, they other negative (blue). I'm keeping the first attached, and it will match the schematics and photos. If you use the other, just adjust the wires accordingly.
  2. Holding the breadboard over the chassis rails, mark where they intersect the edge (Image 2).
  3. Using a straight edge (like the removed power rail), mark the lines and cut through the backing (Image 3).
  4. Place the breadboard on the chassis with the rails touching the exposed adhesive (Image 4).
  5. Attach the Arduino to the other side of the chassis using 4-20 screws (Image 5).

Capacitor and Part Placement

21_breadboards.JPG
19_capacitor.JPG
20_capacitor.JPG
07_TIRL_Arduino_bb.png
  1. Place the 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.
  2. Trim the capacitor leads if necessary (longer is negative) (Image 2).
  3. Insert the capacitor into the correct rails on the top of the breadboard (Image 3).

Power

22_switch.JPG
23_switch.JPG
24_power.JPG
25_power.JPG
26_power.JPG
27_batteries.JPG
28_power.JPG
08_TIRL_Arduino_bb.png
  1. With the right-hand battery leads:Connect the red line to the first pin of the power switch (Image 1).
  2. Connect the black lead to an empty row between the microcontroller and the darlington chip (Image 1).
  3. With the left-hand battery leads:Connect the red line to the same row as the black lead of the other battery (Image 2).
  4. Connect the black line to the negative rail of the breadboard (Image 2).
  5. Connect power to the microcontroller:
    1. Red jumper from positive rail to the battery pin (orange dot, Image 3).
    2. Black jumper from the negative rail to the pin marked "G" (Image 4).
  6. Install batteries and switch the power on (Image 5).
  7. You should see the green and red lights of the controller come on (Image 6).

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.

Stepper Power

30_darlington.JPG
31_headers.JPG
09_TIRL_Arduino_bb.png

Now that you've got power to the microcontroller, let's finish wiring power to the steppers:

  1. Connect a black jumper from the upper left darlington pin to the negative side of the power rail (Image 1).
  2. Connect a red jumper from the lower left darlington pin to the positive side of the power rail (Image 1).
  3. Connect a red jumper from the lower left darlington pin to one row right of the darlington (Image 2).
  4. Insert pin headers for the stepper's white JST connectors (Image 2).

Stepper Control Signals

32_jumpers.JPG
33_jumper.JPG
34_jumpers.JPG
35_jumpers.JPG
10_TIRL_Arduino_bb.png

The microcontroller provides 5 volt signals to the darlington array which in turn, provides VCC to the stepper coils:

  1. Start with pin next to the ground pin on the darlington driver, and install orange, yellow, green, and blue wires in that order (Image 1).
  2. Attach the jumpers to the following arduino pins (Image 2):
    1. orange - Digital pin 4
    2. yellow - Digital pin 5
    3. green - Digital pin 6
    4. blue - Digital pin 7
  3. Back at the darlington, continue jumper for the other stepper in the reverse of the others:
    • blue, green, yellow, and orange (Image 3).
  4. Attach the jumpers to the following arduino pins (Image 4):
    1. blue - Digital pin 9 (pin 8 used latter for the servo).
    2. green - Digital pin 10
    3. yellow - Digital pin 11
    4. orange - Digital pin 12

Stepper Coil Connections

36_jumpers.JPG
37_jumpers.JPG
11_TIRL_Arduino_bb.png

The stepper's white JST connectors attach to the pin header. The red lead is power, and should match the red power jumpers we installed earlier (Image 1).

All colors should match the microcontroller jumpers on the opposite side of the darlington, with the exception of green, which matches the pink wire of the stepper (Image 2).

Servo

38_servo.JPG
39_servo.JPG
40_servo.JPG
41_servo.JPG
12_TIRL_Arduino_bb.png
  1. Install the servo horn with the servo rotated clockwise to the stop and the horn horizontal (Image 1).
  2. Attach the servo to the holder, and the horn pointed to the right stepper side (Image 1).
  3. Attach brown (ground), red (5V power), and white (signal) jumpers into the servo connector, matching the servo wire colors (Image 2).
  4. Attach the power and ground jumpers to the ground and 5V header on the Arduino (Image 3).
  5. Connect the white signal wire to the Arduino's Digital Pin 8 (Image 4).

Wheels

44_wheel.JPG
43_wheel.JPG
  1. Place the rubber o-ring around the edge of the wheel (Image 1).
  2. If the fit of the hub on the axle is loose, you can use a 3M screw to hold it in place (Image 2).
    • Do not tighten it too much or you will strip the plastic.

Testing

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.

  1. Place your robot on a smooth, flat, open surface.
  2. Turn the power on.
  3. 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.

Calibration

45_calibration.JPG
46_calibration.JPG
47_calibration.JPG
48_calibration.JPG

If your robot is moving in an approximate square, it is time to put some paper down and put a pen in it.

Measure your wheel diameter (Image 1) and wheel base (Image 2) in millimeters.

Your calibration settings in the code are:

float wheel_dia=63;     // mm (increase = spiral out)
float wheel_base=109;   // 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 outward or clockwise each step (Image 3).

I eventually arrived at a value of 63mm (Image 4). You can see that there is still some inherent error due to gear lash and such. Close enough to do something interesting!

Raising and Lowering the Pen

50_pen.JPG
49_pens.JPG

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.

  1. Place the pen collar on the pen (Image 1).
    • If it is loose, tape it in place.
  2. Check that it will touch the paper when the servo arm is lowered.
  3. Check that it will not touch the paper when raised.

The servo angles can be adjusted either by removing the horn and re-positioning it, or through the software:

int PEN_DOWN = 20; // angle of servo when pen is down
int PEN_UP = 80;   // angle of servo when pen is up

The pen commands are:

penup(); 
pendown();

If you want to use different pen sizes, you will have to modify the pen holder (www.thingiverse.com/thing:1052725) and pen collar (www.thingiverse.com/thing:1053273) with the correct diameter.

Have Fun

Robots Rock
Arduino Drawing robot doing random patterns

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:

Other Platforms

TIRL_Pi.jpg
00_front.JPG

Could this robot be done with a <Insert your favorite board here>?

Yes! This platform is very flexible. You would mainly just need to modify the chassis.

I've done it with a Raspberry Pi (Image 1) and an Adafruit Trinket (www.instructables.com/id/Low-Cost-Arduino-Compatible-Drawing-Robot/) (Image 2).

Let me know what you come up with!