Innovation studio Deeplocal teamed up with Android Things to create DrawBot, a DIY robotic drawing robot that can take your selfie and sketch your portrait within minutes. From a clever idea to a fully-functioning robot, DrawBot took less than three weeks to create.
Making a DrawBot requires the right hardware, software, and a bit of do-it-yourself assembly. We'll show how we built ours, but feel free to do it your own way. Once completed, your DrawBot can take a selfie and draw your face on the table.Bill of Materials
- (2x) wheels
- (2x) wheel hubs
- (2x) ball casters
- (2x) batteries
- (1x) servo motor
- (2x) stepper motor
- (2x) stepper driver chip
- (1x) breadboard
- (1x) APA102 color LED
- (1x) breakout for LED
- (1x) ribbon cable
- (1x) button
- (1x) 10k resistor
- (1x) brush tip marker
- (12" x 6") acrylic 0.125" thick
- (14" x 8") plywood 0.196" thick
- Nuts and bolts (see attachment "Hardware BOM")
Estimated Parts Cost: $160 (+ an Android Things starter kit)
Estimated Build Time: 5 hours... or a rainy afternoon.
Wiring schematics and file attachments are located at the bottom of this page.Overview
Our DrawBot is built like a sandwich. The top and bottom plates are cut from plywood, and everything else sits inside. Each wheel is driven by it's own stepper motor. Two ball casters under the front and back of the robot keep it balanced.
The DrawBot draws using a brush tip marker. A servo motor raises and lowers the marker to draw lines of different thickness on the paper. The DrawBot can turn in place around the marker, and can drive forward in straight lines, just like the original Logo Turtle programming game! Using only basic commands (TURN and FORWARD), we're able to generate complex drawings.
We use two USB power banks to power our DrawBot. One battery powers the Pico.iMX7 board, which runs Android Things. The other battery powers the motors.Assembly
3. Assemble the motor mounts as shown. Use two #6-32 screws and nuts to hold the motor in place. The second assembly should mirror the first.
4. Mount the wheel hubs onto the wheels using two #4-40 screws. Slide the hub onto the motor shaft and secure it with a set screw.
5. Assemble the marker holder. Slot each clip into the vertical levers, then push the marker through to test fit. Glue the assembly together and check for straightness. Remove the marker while the glue dries.
6. Bolt the marker holder to the pivot point with a #4-40 screw and nylock locking nut. Leave the nut slightly loose, allowing the pivot to rotate freely.
7. Bolt the two caster balls onto the bottom of the lower wood base.
8. Mount the two #4-40 standoffs for the breadboard.
9. Assemble the electronic components following the attached breadboard schematic (at the bottom of this page). We used a prototyping board for ours, but a solderless breadboard can also work.
10. Cut and strip back a USB cable. Solder the red and black wires to the (+) and (-) rails of the breadboard. This will supply power to the motors.
11. Slot the motor mounts and marker holder into the lower wood base. Support the wood base on a roll of tape or a coffee mug to make this step easier.
12. Turn the servo motor arm clockwise until it hits the mechanical stop. Without rotating the servo spline, remove the arm and re-mount it onto the spline pointing directly downwards (towards the longer end of the servo). This sets the "zero" position of the servo arm.
13. Slot the servo into the wood base alongside the marker holder. The servo arm should sit between the two protruding shelves on the marker holder.
14. Slot the servo holder and battery mount acrylic pieces into the wood base. The thicker end of the battery mounts should face towards the inside of the DrawBot.
15. Mount the breadboard onto the standoffs using two #4-40 screws. Route the USB cable under the motor and under the acrylic motor mount as shown.
16. Coffee break!
17. Cut the end off the black ribbon cable (see picture). Separate the conductors and strip according to the attached GPIO pinout chart. Peel back and cut off any unused conductors. The white wire corresponds to pin 1.
18. Solder the DotStar LED to the ribbon cable as shown. Refer to the attached GPIO pinout chart for pin numbers.
19. Solder the button to the ribbon cable as shown. Refer to the attached chart for pin numbers. Use a 10k pull-up resistor.
20. Connect the stepper motor and servo motor wires to the breadboard. We used breakaway headers and 0.1" sockets to make ours easily removable.
21. Mount the Pico Pro and the camera module to the upper wood deck using the M2.5 standoffs and screws.
22. Mount the button and LED to the upper wood deck. We used hot-melt glue for the LED.
23. Thread the camera cable through the upper wood deck. Plug one end into the camera, and the other end into the bottom connector on the Pico Pro board. Thread the end of the black GPIO ribbon cable up through the slot under the Pico Pro, and connect it to the GPIO header on the Pico Pro.
24. Slot the upper wood deck onto the acrylic tabs. Route the wiring internally down each side, between the marker assembly and the stepper motors.
25. Fasten the upper and lower decks together using four long #4-40 screws.
26. Thread the second USB cable through the slot under the Pico Pro board.
27. Thread the WiFi antenna jack through the slot under the Pico Pro board, and connect it to the Pico Pro. Thread the other end through the D-shaped hole on the upper wood deck and secure with the included nut.
28. Push the first battery into the rear slots as shown, and plug in the USB cable that goes to the breadboard. This battery powers the motors.
29. Push the second battery into place, and plug in the USB cable that goes to the Pico Pro. This battery powers the processor.
The board's firmware is written and deployed entirely through Android Studio. It uses the Pico i.MX7D camera module to capture photos, OpenCV for facial detection and photo manipulation, and Android Things hardware drivers to control the button, LED, drive motors, and pen servo.
1. Flash Android Things onto the NXP development board using this guide.
2. Clone the software repository onto your computer.
3. Import the project into Android Studio. (File > New > Import Project)
4. Deploy the application. (Run > Run 'app')Calibrating the DrawBot
Because mechanical systems (like these motors and gearboxes) aren't always perfect, you'll need to calibrate the DrawBot before it can generate pictures.
1. First, test that the stepper motors are wired properly by driving the DrawBot in a square.
On startup, press the button two times (wait for the LED to flash blue after each press). This will set the DrawBot up to run the square test pattern. After five seconds, the LED will flash blue twice to confirm your selection, then turn green. Place the DrawBot on the paper and press the button again to begin the sequence. If the robot doesn't move in a square, skip down to the Troubleshooting section.
2. Tune the servo motor positions with the marker in place.
The servo is able to hold the marker at four different heights: off the page, light pressure, medium pressure, and hard pressure. Turn on the DrawBot and press the button four times to go to the servo test pattern. This will draw line segments at each height, allowing you to adjust the height of the marker in the holder. You may need to adjust the servo positions in RobotConfig.java to get a good result.
3. Tune the stepper parameters until the DrawBot draws straight squares.
Run the square test pattern from step 1. (Press twice for a right-turn square or three times for a left-turn square). Allow the robot to draw a few overlaid squares. If the squares rotate over time, it means the DrawBot is not turning perfect 90-degree turns. Adjust these parameters in the code until the squares are close to perfect.Running the DrawBot
Plug the NXP development board into one battery and the external hardware into the other. Once the LED boots to white, press one time to confirm setup. When the LED turns red, the application is ready and the bot is in the "waiting for photo" state.
1. Tape a clean sheet of paper on a large, level drawing surface.
2. Hold the bot upright at arm's length with the camera facing you, and press the button. The LED will turn yellow to indicate it is processing.
3. If the LED turns green, continue to the next step. If it goes back to red, a face was not detected and you need to re-take the photo (repeat step 2).
4. Place the bot in the center of your drawing surface, facing the top, and press the button to begin drawing.
5. Allow five or so minutes for the bot to draw.
6. Once the bot completes a drawing, it returns to the initial "waiting for photo" state.Troubleshooting
No movement: Make sure batteries are charged/overcurrent hasn't triggered.
Backwards motion or flipped turns: Motor wiring backwards / swapped. Check the wiring diagram.
No face detection: If the DrawBot doesn't detect your face, the LED will turn red after you press the button to take a photo. Check that the face is well-lit and against a white background. After three failed attempts, the DrawBot will proceed and draw the last photo taken.
Error: "cannot open camera 0 without camera permission" when deploying the application? Restart NXP board— it's a "dangerous permissions" situation (See "Permissions" section here).Legal Disclaimer
THESE INSTRUCTIONS ARE BEING PROVIDED FOR INFORMATIONAL PURPOSES ONLY AND ARE NOT INTENDED TO BE USED FOR THE PRODUCTION OF COMMERCIAL PRODUCTS. BY EXECUTING THESE INSTRUCTIONS, YOU AGREE TO ASSUME ALL LIABILITY IN CONNECTION WITH YOUR BUILDING AND USE OF ANY DEVICE. DEEPLOCAL DISCLAIMS ALL WARRANTIES EXPRESS OR IMPLIED WITH RESPECT TO THESE INSTRUCTIONS AND ANY RESULTING DEVICE INCLUDING BUT NOT LIMITED TO WARRANTIES FOR MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, AND NON-INFRINGEMENT. YOU SHOULD USE EXTREME CAUTION WHEN BUILDING AND USING ANY DEVICE PURSUANT TO THESE INSTRUCTIONS. IN NO EVENT SHALL DEEPLOCAL BE LIABLE FOR ANY CLAIM OR DAMAGES, INCLUDING BUT NOT LIMITED TO CLAIMS OR DAMAGES RELATED TO DEATH OR PERSONAL INJURY, PROPERTY DAMAGE, OR PRODUCT LIABILITY.