Make It Last Build Series #3: Building the Drawbot controller

Craft & Design


Illustration of the drawbot rig

As discussed in the first post, the Drawbot is a rig for drawing algorithmic designs on a wall. The mechanism is made up of two motorized spools holding monofilament, which is connected to a marker; the two motors tug on the marker, and gravity tensions the line. The friction between the marker tip and the wall holds the marker to the wall. By turning the motorized spools clockwise and counterclockwise we can precisely control where the marker goes (with a little math).

Drawbot block diagram

The project can be broken down into the three components shown in the diagram above: power, controller and driver.

Power distribution is a major consideration in the design of any circuit, especially when driving higher current loads such as motors. The motors speced in our project operate at 5V, but often you will find motors that run at 9V, 12V, or 24V. The controller runs at 3.3V or 5V so we will have to distribute power to the controller and the motor drivers separately.

Because the pins on the microcontroller can only source a few milliamps (not nearly enough to driver a motor directly), we’ll need a separate driver circuit to provide enough current to the motors. The motors we are using are stepper motors, which can be precisely controlled by pulsing its four control lines in a particular order. The motor driver circuit we will be using will reduce the number of control lines from four to two.

We’ll be discussing the motor operation and building the motor driver next week; for now, we will concentrate on the controller, which will have two control lines for each motor as outputs. Our goal this week is to set up a working prototype controller and program it to blink four LEDs, one for each control line.

The schematic for the controller is almost exactly like the one used in the two previous builds.

Drawbot schematic

The only addition is four LEDs on lines RA0-RA3, which will eventually be used to control the two motorized spools. Follow the schematic to get all the components on a breadboard. If you’ve never used a breadboard, start with the blog post from project #1 that describes Hello World blinky light on a PIC.

Start with the PIC18LF25K22 microcontroller and connect the other components to the microcontroller, following the directions for the Hello World project. Be sure to connect all of the power and ground pins to the microcontroller. Also connect the ground rails on the breadboard to each other, and the power rails to each other. Finally, add an LED between each of pins RA0 through RA3. The long lead goes toward the pin, and the short lead connects to GND.

A prototype

The finished prototype should look something like the above. We’ll be using the PICKit3 programmer to compile and upload code (you can also use the PicKit 2, as described in the Forums).

As in previous builds, we’ll use the MPLAB environment to compile and upload code. If you haven’t installed MPLAB yet, follow the instructions from Make It last project #1. The device definitions and include files for the microporcessor we are using (the PIC18LF25K22) are included in the latest distribution of MPLAB; if you have an older version you may have to upgrade or update your device definitions.

The PIC will run at voltages up to 5V; for now we’ll run the circuit at 3.3V so we don’t have to add current-limiting resistors to the LEDs. As a convenience, the PICKit3 can power the circuit. Before attaching the programmer to the circuit, open MPLAB and change the settings under Programmer->Settings->Power to power the circuit at 3.3V. Then connect the programmer to the six-pin header with Pin 1 in the proper orientation (it’s marked with a white arrow).

Download the sample code to test the prototype controller. Create a new project and add the main.c file to it. If all the connections are made properly, you should be able to connect to the microcontroller, select “Build All” and upload the code with the “Program” command. A working circuit will blink each LED in turn.

Next week, we we’ll build a stepper motor driver circuit and connect it to the controller in place of the LEDs.

Sign Up for the Newsletter!

If you want to get the weekly newsletter and enter the prize drawing, sign up at the Make It Last landing page!

Discuss this article with the rest of the community on our Discord server!
Shawn Wallace

Shawn Wallace is a MAKE contributor, artist, programmer, and editor living in Providence, R.I. He designs open hardware kits at Modern Device and organized the Fab Academy at the Providence Fab Lab. He makes iPhone synthesizers with the Fluxama collective and is a member of the SMT Computing Society.

View more articles by Shawn Wallace