Machine Making
When this exercise was announced, several ideas were thought of to possibly go forward with. Most of the ideas were for building machines that built other things, or drawing machines. Some of the concepts and directions included
- a delta printer (I am familiar with the regular 3-axis printers, but a delta would be a new thing)
- a clay printer (pottery and clay has always fascinated me, and working out digital fabrication with clay would be amazing)
- a spirograph drawing machine (math equations and generative art, what's not to love ?)
- a plotter machine, on the lines of an Axidraw (I have an off-the-shelf plotter for my generative art but I'd like to build one to experiment with different media)
- Jalebi CNC (I'd seen one of these at the Maker's Asylum, a makerspace that I used to volunteer at, and back then this was like magic and wizardry to me) and a few others.
I have always been fascinated by Spirographs - whether as the small plastic toys a long time ago, or coding them using Processing or P5.js these days. Since I needed to decide what I could reasonably finish in the time available and given my interest and skillset, it seemed a natural thing to try making a Spirograph Drawing Bot.
older video
newer video
reversing direction
It looks fairly tragic right now, but I am actually glad it has taken off, and I am in the process of making improvements following Spiral Development.
Description
The Spirograph is a fairly simple drawing machine that gives out a fairly complex output.
Various versions exist, but the essential principle is to follow the output of multiple rotary motions, and a trace its path. Mechanically, the entire upper section is a 5-bar linkage, with 2 joints rotating independently, moving with relative motion against a third rotary motion provided by the drawing disk.
Mathematically, the path can be described by harmonic equations.
Mathematically, the variables include
- radius of circle 1
- radius of circle 2
- length of arm 1
- length of arm 2
- distance between centres of rotation
- radius of circle 3
- rotational speed of circle 1
- rotational speed of circle 2
- rotational speed of circle 3
Of the above, the following will be controllable for this build :
- Distance between centres of rotation - fixed
- Radii and Lengths - Changeable if needed but otherwise fixed
- Rotational Speeds - Direct inputs from sliders
Parts and Components
I followed a couple of builds online to figure the general method of the build. While the mechanics of the machine weren't a problem, I was concerned about the electronics - the how-to as well as what would be the suitable parts, which were also available to shop for.
The machine consists of 2 stepper motors rotating their respective cranks, with 2 arms attached to the cranks as well as each other on rotating pin joints.
A penholder assembly is attached to the end of the drawing arm.
A third motor rotates a disc to which the paper gets attached.
Another base holds the input sliders and the Arduino.
The build can be roughly split into 3 general areas :
- The mechanicals and geometry
- The code
- The electronics
Mechanicals
I worked on the modelling of the individual parts as well as working out the geometry in Fusion, then 3D printed on my Prusa MK3+, or lasercut on the SIL Lasercutter at the Lab.
The first version is a slap-dash file with only the most relevant dimensions added and a lot of ad-hoc modelling to quickly derive parts for the 3D printing and lasercutting. While this is not the approach I usually prefer, it was what I went with in the interest of time. Since I was working on the fly with an uncertain set of parts and dimensions, my usual approach of a fully constrained assembly would have given rise to complex dependencies and frequent downstream cleanup, apart from the time taken to get it right the first time.
The following parts were modelled
- Motor Base : to mount 3 stepper motors, with mounting holes, etc | Acrylic sheet, 3mm, lasercut
- Controls Base : to mount 3 sliders and the Arduino Uno | Acrylic sheet, 3mm, lasercut
- Drawing disc : Base for the rotating drawing sheet | Acrylic sheet, 3mm, lasercut
- Crank Arm, 2x : Crank arms to mount on the motor shaft and attach to the drawing arms | PLA, 3D Printed
- Drawing Arm, 2x : Drawing arms connecting to the crank arm | Acrylic sheet, 3mm, lasercut
- Drawing disc mount : to mount the drawing disc onto the stepper motor | PLA, 3D Printed
- Penholder : to mount at the end of the drawing arm and hold the pen
- Assorted bolts and nuts : for all the mounting | M3, 12 mm, 30 mm, etc.
All the modelling was done in Fusion 360, and lasercutting drawings exported from Fusion to CorelDraw for cleanup and layout.
Electronics
I went through Robu.in to check out and understand what parts were available (and at what cost) to figure out the right stepper motors, drivers, etc.
Parts
- 288BYJ-48 stepper motors : to rotate the arms and drawing disc | 3x
- ULN2003 drivers : to run the stepper motors from the Arduino Uno | 3x
- Linear slider potentiometers : for input speed | 3x
- Arduino Uno : the "brain" | 1x
- 12V 2A power supply
- DC barrel jack female
288BYJ-48 stepper motor DataSheet
288BYJ-48 stepper motor Tutorial
The Arduino Uno can be swapped out for other boards or MCUs if you skip the rotating drawing disc. The number of pins required falls, in that case. Here, however, I decided to go with the Uno since I required a large number of pins.
The Steppers cannot be run directly off the Arduino since they require too much power. An external 12V supply is used, and it is maintained to have common GND with the Arduino. I burnt out a 1A supply when running this over a longer time, after which I switched to a 2A supply.
Connections
- The three stepper motors connect to each of the three drivers
- The drivers have 6 pins
- 2 pins for 12V and GND to the DC barrel jack
- The other 4 pins go to Digital pins on the Arduino
- The linear potentiometers have 3 pins each
- to GND, Arduino
- to 5V, Arduino
- to an Analog pin on the Arduino
- GND from the 12 V DC supply to GND on the Arduino
PCB
PCB v1 - this was just all the connections on the breadboard.
PCB v2 - since the major connections were all to the Arduino 5V, DC 12 V and GND, I used a perfboard and created 3 bus lines to ease those three sets of connections, while keeping the 1-1 connections between the components and the Arduino intact. A switch was also added for On-Off control.
PCB v3 - a milled PCB designed keeping all the above considerations and learnings in mind.
I milled out the PCB on the E44 Protomat at the Lab. There is scope for some improvements, but this version is workable, although I did have to jump-wire some points, especially since I was not using a 2-sided PCB. In the future I would use the Uno's multiple GND pins instead of stretching paths across the PCB.
stuffing in progress
I used vertical pin headers where the PCB was inserted into the Uno, and 90 degree headers along the outer edges to connect to the driver and slider connections more easily. This was a good decision in hindsight.
I had designed the PCB to have 2 paths on the bottom layer connected through vias since there would be an intersection if kept on one layer. I knew was going to use 1-sided PCB to mill it, then I inserted some single core copper wire and jumped the connections.
A mess of wires !
My first Arduino shield ?
Input sliders subsystem
Output - Stepper motors
Overview of entire system
Code
I initially used the Stepper library with the Arduino.
Then moved to using the Accelstepper library to control multiple motors in parallel.
At first, I was referring to examples and tutorials online. After a while, I got a hang of what I needed and what the library was capable of. I went to the documentation of the Accelstepper Library and figured a better set of functions to use. Instead of using position-based controls and keeping the position several thousand steps away, I found that speed based controls would be simpler and more effective.
After manually trying out various settings for stepsPerSecond (from 20 to 2000), I realised that about 600 steps per second is a good upper limit, anything more than that was making the stepper act erratically. It is also a fast enough speed to be practical.
So I mapped out the inputs from the sliders (0-1024) to the speed of the steppers (-600 to +600) to control both speed and direction.
The Build
Round 1 - A motor spins
Since the electronics was the area I was most uncertain about, I decided to tackle that first. I connected one stepper motor to the Uno and ran the basic stepper code and rotated it. This in itself was heartening enough to me since I was in unknown territory without a hand, and I'll consider this the first loop of the spiral development.
Round 2 - A motor is controlled
I added a single slider to the arduino and read it's input through the analog pin. Once this was working, I mapped that value to use it as an input to the motor.
Round 3 - Drawing the rest of the horse
I modelled, printed, and lasercut the first set of parts, and assembled them. I assembled the motors to the bases, and mounted the 3 sliders, the Uno, etc. Unfortunately, my 3 motors came with only 2 drivers, and the seller shipped me a third a few days later. This added to the delays. Once assembled, I got it running, first with just one motor.
Then I changed the code to use the Accelstepper library, allowing me to control multiple motors.
I also mounted the pen holder when I realised that it was too short and the pens were not being held correctly. One of the pitfalls of the ad-hoc modelling approach, but also easily corrected.
At this point, the whole machine worked as a proof-of-concept, but needed a lot of updates to be smoother.
Round 4 - Cleaning up
I swapped out the breadboard connections for the perfboard connections described in the PCB section above.
Geometrically determining area of action based on arm lengths
I did better calculations for the area of action, and derived better arm lengths. I swapped out the 3D printed arms with longer laser-cut ones for a smoother movement as well. I also gave better clearance to the holes this time. 3D Printed holes also tend to be higher in friction.
The crank arms also got taller to accomodate the height differences between the motor mount and the drawing disc, which was causing the pen mount not to work correctly in the previous stage.
This is the version seen in the video.
Round 5 - PCB update
Once the PCB was milled and stuffed, I rewired the entire electronics assembly. The PCB streamlined a lot of messy connections, especially common GND, 12V and 5V, etc. It's not absolutely neat even after that though. There are simply too many wires that it will never be minimized beyond a point.
The position of the Uno with respect to the sliders also shifted due to the PCB, since the slider inputs were all aligned on one side of the PCB and Stepper driver inputs on the other.
Round 6 - Major updates
This is an ongoing set of major updates.
Stiffer Arms : The arms keep sagging, so they need to have a higher stiffness.
One option would be to simply use thicker acrylic, or metal. But I would like to solve this without such a brute force approach, preferring to increase stiffness by increasing the vertical component of the cross section.
Making the arms have a vertical cross section instead of a horizontal one would make them as light, but much stiffer.
3D Printed with vertical sections for extra stiffness
3D printing the arms was going to be time consuming as well as limited by the bed size, so I considered going back to lasercutting. But this time, with 2 crossed members instead of a horizontal one. Taking projections on a 45 degree plane, I derived the part as well as the elliptical holes that run through it. A 3D printed holder keeps everything in alignment at the pivot points.
Support to the drawing disc :
Taking some inspiration from the microwave oven, I 3D printed a set of wheels and a ring to support the rotating disc.
Improved pen holder :
Allows a longer length along the pen to be held in place, with better fit.
Files
CAD
Spirograph v19.f3d - Fusion file
Machine_parts.dxf - lasercuts
Spirograph stls.zip
PCB
Spirograph PCB from Eagle v2 - Gerber files
Spirograph PCB from Eagle v4 - Gerber files
Spirograph v2.fbrd
Spirograph v2.brd
CODE
Spirograph_v3.ino