DrawBot - A Drawing Robot
Stepper motors are used in a wide range of applications where precise movements are required, as in a 3-D printer. Here I use two small stepper motors to control the movement of a robot, making it able to draw shapes and write text. It’s relatively cheap to make and you will learn how to write code for stepper motors and read codes from a TV infra-red remote control!
The principal behind this robot is that a pen is mounted vertically between two drive wheels, and lowered to or raised from the paper using a servo motor. If the wheels move in the same direction and at the same speed then a straight line is draw, whereas if the speed of the wheels is different the pen will draw a curve. If the wheels are driven in opposite directions the robot will turn on the spot. So it is possible to turn the robot through a given angle and effectively draw a straight line vector or curve from that point. I decided to use an Arduino MEGA to give me plenty of code space, but the design does allow for use of a UNO board, but the code you put in it may be limited. The stepper motors are 28BYJ-48 which are five wire 5 volt devices and they each need to be driven from a ULN2003 driver pcb, A nice feature of these drivers is that they have four LEDs which show the pulses being applied to each motor winding. Click to watch the video -->
All of the robot chassis components were produced on my 3-D printer and modelled using the free 3-D design package from RS Components, DesignSpark Mechanical. For this design I also constructed an assembly of the complete robot, to ensure that all of the parts aligned. Given the limitations of 3-D printing, the chassis consists of a number of parts screwed together using 3mm nylon countersunk screws. I used Rotring Tikky Graphic fibre tipped pens, which come in a range of point sizes, so the pen lifter clamp and nozzle are designed for these. If you decide to use an alternative pen type, then you will need to make new models of these parts to match the pens dimensions. The pen must be a good sliding fit in the nozzle. All of the .stl files are included below.
The drive wheels were made using 62 mm rubber O-ring seals, with the plastic wheels having a groove in the outer edge to stretch and retain them. It is important that the wheels have a very narrow profile to assist steering, whilst affording a good grip on the underlying paper. The small rear castor supports the off-centre weight of the robot, resulting from the battery pack. You will need a 3mm tap to be able to put threads in all of the 2.5mm holes.
The robot is powered from 6 x AA battery pack, mounted in the centre, and controlled by use of a TV universal remote control, with the infra-red receiver mounted on the top of the robot, facing upwards. With the TV remote you can drive and steer the robot using the arrow buttons, select internal draw functions, or directly draw lines and shapes using the numeric keypad. I have coded into the library file capital letters A to Z and simple drawings like the “UTC ROBOTS ROCK” example shown in the photo opposite.
When the Arduino receives a valid code from the remote it will send the value to the USB serial port, to be displayed in the IDE serial monitor. So it is easy to read any remote and assign codes to the functions included and more. By using the four coloured buttons as ‘mode’ settings it is possible to re-assign the numeric keypad for either drawing selection or for direct entry of line dimensions. The code includes function which will draw polygons with 3 or more sides. It also supports the entry of Cartesian X/Y co-ordinates and the setting of an origin, making it easy to plot out a shape from a piece of graph paper.
The circuit diagram for this project is shown here on the left, with the Arduino connected to the two stepper motors, a servo and the IR receiver on the right, with 6v power being fed to the servo from a diode voltage dropping circuit. Servos will normally operate between 4.8v and 6v, but they work much better at the higher voltage. Note that this circuit assumes an input voltage of 7.5v from a power plug or 7.2v from a 6 x AA rechargeable battery pack. If you want to use a higher voltage you will need to modify this circuitry to suit, otherwise you could damage your servo motor. The diagram would be the same for a MEGA board.
It is also better not to power the servos from the MEGA 5v linear regular, as any dip in supply voltage caused by loading the servo could result in the MEGA being reset via its internal brown-out circuitry. Connecting one servo that way for test purposes is fine, but I wouldn’t recommend any more.
Arduino digital pins aren’t capable of driving a stepper motor directly, so we achieve this using a ULN2003 driver pcb, which contains eight open collector drive transistors, of which we use only four. The code effectively generates a moving pattern of 1’s and 0’s, driving either one or two stepper motor coils at a time. These patterns can be seen at a low stepping speed.
The 28BYJ-48 internal stepper motor requires 64 steps to complete one revolution, and it in turn is connected to the output shaft via a 64:1 gearbox. Hence it takes 4096 steps to move a drive wheel through one revolution, which in this design one step is equivalent to 0.05 mm. This implies high accuracy, however there is backlash in the gearbox and drive shaft end-float to contend with. When a wheel changes direction the code attempts to remove gearbox slack with extra clocking.
The following files can be downloaded to help you complete this project. Each has a hyper-link and an associated description. Depending on how your web browser is configured the links will either open the files directly into the browser or offer them as downloads.
Circuit Diagram - a drawing of what is seen in the view above. Use it as a guide to wiring up your project.
Parts list - the things you will need and budget prices.
3-D Models - a zip file containing all of the STL files, which you can use with a slicer application.
3-D Parts - a pdf file which identifies the 3-D parts, and the quantities of each you will need to print.
Software Code - the all important Arduino .ino file which runs the project and ‘Processing’ application. See comments below on coding.
This project relies on the use of two libraries, Servo.h and IRremote.h, which are included in the IDE set-up. See notes below regarding the need to calibrate your servo motor.
The following notes will help you understand how the files in this project work or can be used in principle. Each note has a bold heading for quick reference and they are listed in alphabetical order.
.ino File - the zip file contains a folder, which in turn contains the source code files. Therefore you will need to unzip it to use it..
3-D Models - this design is based on the use of 3mm nylon countersink screws with niloc nuts as fasteners. This leads to a very clean solution as the length of each screw can be easily trimmed adjacent to the nut using wire cutters.
Calibration - When attaching the lifting arm to the servo motor try to ensure that it can be rotated sufficiently to raise and lower the pen. Values used in the code will not necessarily work with your servo as each one tends to be different. So a degree of trial and error will be needed to determine the lift and lower point values
If you feel that I haven’t included enough information to allow you to tackle a project of this type then send me an email explaining what you need. Or if you just want to give me some general feedback on this site, or to suggest projects what I might include which would be interesting to you, I’d be pleased to hear from you.