Update 2023: I have made a YouTube video with some more content about the iterations I went through making this, have a look if you are interested: https://youtu.be/LPYEd50j3s0
I came across a video of a guy manually creating string art and I thought it might be cool to automate this. It turned out to be more complicated than I thought it would be.
The first step was to create some software that could generate a fairly accurate representation of an image using string and nails. I wanted to confirm that I could actually make the software before I bothered building a machine.
The first iteration of the program worked using a very simplistic algorithm.
- Generate a fixed grid of nails
- Start at nail 0 (top left)
- For each pin on the grid, calculate the total image difference to the target image if this pin was connected by string to the current pin.
- Of all the pins choose the pin with the smallest difference to the target image as the next pin.
This actually worked alright. initially the performance was pretty terrible but it was very easy to make it run on all the available cores. I converted the images to black and white and manipulated the image data as byte arrays which allowed more efficient calculation of the image differences.
After the initial success of this proof of concept in the software, I went on to attempting to solve the next unknown: how I would physically align and dispense nails.
Before spending any money building the machine, I first wanted to have a reliable mechanism for taking an unsorted heap of loose nails and placing them vertically downward.
The most obvious idea that came to mind was to use nail gun nails which are perfectly uniform and already designed to be fed into a tool. After researching however, I was unable to find nail gun nails that were a small enough gauge as to not ruin the ‘resolution’ of the final string art.
Brad nails were thin enough but they require a surprisingly high about of force to actually break off which made them unsuitable. Once broken off they also had a gluey residue which looked pretty rubbish.
The nails I decided to use were 1.6mm by 40mm panel pins from screw fix. These were long enough to give enough space to layer the string but thin enough not to be too obvious in the final image.
I tried to think of ways that a machine could filter nails and it turns out it’s actually quite difficult. The nails will behave one way when there is a small quantity and behave another when there are a lot. Small numbers of nails will work pretty much like a fluid but large quantities weave together and produce a clump that will not sieve.
I also considered using an electromagnet to pick up nails into slots but the nails didn’t like co-operating with the slots and would generally just go wherever they wanted.
I gave up on the nail sieving part for a while and thought about what I might do with the nails should I ever come up with a working sieve that produced aligned nails.
After some brain storming and prototyping, I got a somewhat working design the nail sorting mechanism which involved a slot and solenoid with some magnets thrown in. Here is a video of me scientifically simulating how I envisioned the machine working.
Before getting to this design, I went through several revisions — some using an electromagnet instead of permanent magnets and with different solenoids, spring strengths, and magnet separation.
In the above video I used a curved slot to feed the nails. My theory for this was that I could have an indefinitely tall nail queue feeding down into the gate. This turned out not to work though as the nails would jam up further down due to the extra weight of the queued nails so I straightened it out but left a slight incline.
Rather than trying to sort an unlimited amount of nails I found that if I kept the number of nails small I could sieve them straight into the mouth of the nail gate component. This creates a new problem of how I will feed small bundles of nails into the sieve section. I am doing by hand in the video but I’d have to figure that out later.
After this amazingly comprehensive proof of concept, I thought I could now justify spending the money on the rest of the machine. I hadn’t technically figured out all of the problems but it’s more fun to just buy things anyway.
I didn’t want to be limited by the actual dimensions of the machine so I bought four 1 metre long 16mm linear rails with bearings as the main basis of the CNC gantry. These 4 rails were also the most expensive part of the machine totalling around £120.
After the rails and bearings arrived, I was able to pretty easily knock up some designs for mounting them together.
You only need 3 parts to get a functional axis together and the flat top bearings made this especially simple. I designed in some mounts for the motors and for the timing belt to sit. On the Y axis carriage I put a flat tab with some mounting holes as I hadn’t yet designed how the Z axis would fit together. This means I can continuously redesign the nail assembly without having to alter the Y carriage.
After assembling the Y Axis I put some thought into how the machine might actually insert nails into the material. The way the Z axis would be designed depended on the material and method of insertion used for the nails. If I was going to use wood I would need some sort of hammering machine to smash them into the wood. This seemed too extreme and inaccurate for me so I settled on a stepper driven axis that would insert into a soft material.
I designed a basic axis with another generic mounting point that meant I could prototype different nail end tools. I started with a fixed slot for the nail that would magnetically hold the nail in place until it was inserted into the material thereafter friction would keep the nail in place overcoming the magnet. This seemed to work OK in my initial ‘pretend to be the machine’ test.
At this point the Y Axis was starting to look alright and I was eager to get the motors powered up to test. I assembled the machine onto 2 pieces of 1200 mm by 600 mm 18mm MDF supported by some spare planks of wood I had lying around.
I also found a cable chain model on thingiverse that could be easily modified to be suitable for the cabling required for this machine which saved me a small amount of money over buying some on eBay. I also printed some mounts for motors and belt pulleys.
After finishing the main assembly I needed to begin wiring up the electronics and to do that I needed this thing off the floor. It was only after I actually assembled it that I realised how much space it actually took up.
For the electronics I used a RAMPS 1.4 board and for the software and firmware I used a modified version of Repetier. The only modifications required were to support the additional sensors I would need. I also had to add in some solenoid protection code after one of my solenoids melted due to the control software crashing and leaving it turned on.
After some initial configuration the machine was now officially alive.
I temporarily glued my prototype nail sorting assembly to the wooden base and programmed the software to follow a very basic path to pick a nail up and place it in the polystyrene in 1cm intervals.
As you can see toward the end of the video the nails seem to be placed in a disturbingly inaccurate manner.
This was extremely annoying to see and I couldn’t figure out what the hell was going on until I watched it place the nails more carefully. It turned out the structure of the polystyrene was causing the nails to be deflected around the small balls of polystyrene. The difference in densities where the balls came together deflected the nails as they were pushed down.
See this extremely high quality diagram.
So it seemed that polystyrene wasn’t going to be an option as a base material to hold the nails. I went to Wickes and bought a board of 16mm Celotex which didn’t have the same problem as it is a much finer foam.
I was also concerned at the time taken to return to home to pick up the next nail and how long it would take to make each individual string art if I had to continue at this rate.
I thought the ideal place to store the nails would be on the Y carriage itself. There was plenty of space on the platform and the rails were made from 16mm steel so they could easily take the weight.
The only problem with moving the nail loader was that it would need to be behind the nail pickup head. This inevitably meant I would need to have the head movable in some way to accommodate both positions. So I installed a hobby servo.
Unfortunately this significantly reduced the amount of force that I could ram a nail down at because the actual shaft on the servo is so small in diameter at around 5mm and due to the flexibility of the ABS. This meant that I needed to peel the silver foil off of the Celotex before nailing as this put up too much resistance.
With this new configuration I was able to run through some extended nailing tests and discovered that my nail gate was pretty poor in terms of reliability. About 20% of the time the gate would allow multiple nails through which would then jam into the material at random angles.
I spent a long time iterating the nail gate and nail pickup before I got a reliable design. One problem I found was that a nail with a larger head than usual would occasionally get caught at the point the presence check button meets the plastic. To remedy this, I replaced the button with a linear hall effect sensor which measures the change in magnetic field between when the nail is present and when it isn’t.
Using a hall effect sensor left no sharp edges for nails to get caught on and meant that the machine wouldn’t need to attempt to place the nail to detect if there was a nail present or not. It also meant I could easily detect if a nail failed to place correctly.
I introduced a second solenoid gate which worked a bit like an airlock with the gap between the two gates precisely tuned to fit only one nail at a time.
This had a much greater success rate than the first design but still failed around 1% of the time which meant on a piece of string art with 1000 nails you’d get 10 misplaced nails which was still not as reliable as I wanted but it was enough to try to make a large enough grid to test out stringing.
The problem with testing out the stringing operation is that I knew for a fact that as soon as I started the machine it would drive straight through as many nails as it could ripping them up and ruining the Celotex. So I went on eBay and bought some plaster of Paris which I would use to secure the nails after they were initially placed. I guessed that a couple of millimetres of plaster would be enough for the purposes of my testing. So I knocked up a quick test piece.
The plaster wasn’t perfect. It rusted the nails and was quite easy to spill over the tops of the nails, but it did hold them in place. It was good enough. I started to place a 30 by 30 grid on a 50cm by 50cm piece of Celotex.
After pouring the plaster I had a known fixed test grid I could use during the development and testing of the string algorithms.
Now I had everything I needed to actually string a string art except the software. So I started to work on that.
The first step in the software was to choose the string placement order according to which nails would give the closest resemblance to the image and didn’t cause intersections with the other nails.
Then the software needed to understand how to route the string avoiding the other nails. To do this I modelled a safe radius around the nails and any intersection into this radius would cause it to travel along the safe radius until it it no longer intersected. In the case of multiple intersections it would repeat this process until reaching the target spoke.
In the recording you can see during the first phase it renders the potential spoke candidates for each decision and for each of those the resulting art is evaluated for similarity to the target photo and the best is chosen. The simulated outcome for each placement is rendered on the left.
This is fundamentally the same algorithm of the original proof of concept program but rather than simulating point to point it accurately depicts the way a string wraps around the side of the nail.
The second phase is to generate a safe path for the tool head to travel around. The output is colour coded:
- Green is the path to initially wrap the string around the start spoke or to finish wrapping at the end spoke for the segment.
- Red are parts where the path between two spokes has intersected the safe radius of another spoke on the way and the tool head had to travel around.
- Blue is where the program has decided it would have to do a full 360 wrap around because the angle that the string wraps the nail would mean that it doesn’t actually get hooked on the nail if it was to just enter the safe radius of the nail.
In the last few seconds of the video you can see the resultant path the tool head will take and is rendered in grey.
What is not shown on this recording is the string Z offset calculation which is done by detecting collisions between previously laid strings and the current tool path segment. This requires using both the simulation of the resting positions of the strings and the upcoming tool path coordinates. The software uses a quad tree to calculate the intersections and makes a 0.025mm allowance per previously placed string. This can be seen on one of these later string arts.
I fitted a cone of thread on the machine with a PTFE tube, attached a needle and set it up to start threading. The thread travelled through the tube and was pulled out through the needle. In this design the needle was removable to easily switch the machine from nailing to stringing mode.
The first attempts did not work great. It turned out that the real world was not precise enough for such tight tolerances on the end of the needle. Luckily the strength of the nails meant that I didn’t have to go through the time consuming process of rebuilding the grid every time the needle jammed itself into the already laid threads.
I realised that as cool as it looked injecting string into the air, a needle wasn’t going to work. I needed a fatter, rounder, more forgiving head that would sweep any already placed strings gently underneath it as it passed.
So I took a piece of smooth 8mm steel rod and drilled a 3mm hole vertically in it. Then using the same pillar drill, I put it in the chuck and began filing and sanding the end into a nice rounded point. I printed a new mount for this nozzle and installed it into the machine. This worked much more smoothly and meant I could increase the XY movement speed.
Finally I managed to get one complete stringing without a massive number of issues. The first ever completed string art output is below.
As you can see on the right eye there were some missed loops but it turned out pretty good for a first attempt. The missed loops were caused by a bug in the software that would cause the machine to drag straight through a nail in certain circumstances — this was extremely hard to figure out at the time as it happened very infrequently.
Now that I had produced one string art I had to do it again just to make sure that it wasn’t a fluke. So I cut all the string off of my reusable test grid and plugged a picture of my niece into the software.
Again it was pretty good, and no dodgy missing loops this time.
Now that I had working software I needed to optimise the machine to make it more reliable manufacturing as the art was very prone to errors and required a lot of interaction and monitoring to work successfully.
I started by revisiting the nailing process. By now I had increased the speed of pickup and placement which introduced problems that needed to be resolved. The trouble I had was that everything was moving so fast that I couldn’t actually see what was happening. This is where the high speed camera on my phone was incredibly useful.
In this video you can see just one of the issues I had to resolve — the second gate pins were not being retracted far enough causing the nail to be caught as it was pulled from the opening. I also had similar faults occurring between the first and second gates whereby the nail would be caught on the lower inner gate pin causing it to pull and align perpendicularly to the nail placer.
I decided that I had to give up on using pins for gates. The reason I had used them in the first place was because the tolerances were so small that I couldn’t 3D print gates small enough. The ‘airlock’ had to be exactly 1.6mm to only allow one nail at a time. In addition to this it also had to be able to separate the queue of nails which the sharp points worked perfectly for.
This new airlock used 1mm aluminium gates with a sharpened edges and the two solenoids on one side. This completely eliminated any issue with nails being partially caught on gate pins but came with its own problems. If a nail was resting diagonally over the entrance to the gate it would be caught and pressed against sides. The only remedy I could come up with for this was to keep trying to close the gate and to detect if it was successful or not. For this I would need to install another hall effect sensor.
This design again worked better with a failure rate of around 0.3% in the video below you can see that there are 2 nails that were placed with two nails inside the nail holder but overall the speed and error rate was pretty good.
In this video I am nailing nails with irregular positions which presents a new challenge in verifying that the nails were all successfully placed. With the failure rate at around 0.3% there needed to be another step that would allow me to manually correct any nails that were placed incorrectly. This wasn’t an issue with the regular grid as it was immediately visible where a nail had been misplaced.
The verification tool is a simple probe with a magnet inside and a linear hall effect sensor to detect the distance it has been depressed.
At this point I had also abandoned the plaster of Paris and gone with leaving the original silver foil on the Celotex and coating it with white sticky back vinyl. Here is the nail verification process on a freely placed nail grid.
The final improvements I made to the machine were to add some tooling to automatically load nails into the nailing assembly from a larger capacity bucket that supported about 700 nails. This would load about 10–15 nails at a time into the small nail sieve. I also attached a small rotating spring to help guide the nails down the sieve which reduced the chance of nails getting jammed.
Here are some other completed string arts I made before I packed the machine away.