18. Mechanical Machine Design

The objective this week is to put all of our learning together into designing and building a workshop machine.

The Machine

The team decided to build a CNC embroidery machine using my daughter’s sewing machine as the central core. The idea came from inkstitch.org. We started from a photograph from their website, but designed our own machine from scratch.

Here is my daughter’s machine (with a ruler for scale):

Job 1: CAD-ing the sewing machine

The first step was to create a Fusion360 model of the sewing machine. Rather than get fancy with a 3D scanner, since there were only really a few places where the exact dimensions matter, I just relied on the ruler and tried to be precise to within about 0.5mm.

The machine itself presented no huge problems to Fusion. I drew the stepper motor from the spec sheet provided by the manufacturer. They are basically just blocks with lots of cutouts and fillets.

Job 2: z-transmission

The sewing machine is fully functional, but it is borrowed, so we didn’t want to hack into its controls to use its own motor to power the needle. Instead we chose to connect a stepper motor to the handwheel and drive the mechanics of the machine completely externally. Because there is quite some force to be overcome even with all of the mechanical advantages built into the machine, we decided to use the largest stepper motor we had available, which is a Nema 17 42-75 that can deliver 65 Ncm of torque. Though that’s a significant improvement over the little steppers we selected for the axes, we felt it would still not be enough to rotate the sewing machine’s internal mechanism.

Since we had to add a driving gear to the system anyway to turn the hand wheel, we decided to design in a mechanical advantage gearbox using some bicycle gears that were available in the lab. The gear ratio is 15:36, or a little better than 1:2. We’ll need to spin the big stepper quickly, but we shouldn’t have any trouble with stalling.

The parts of the transmission and the sewing machine’s original handwheel are shown below:

I didn’t want to destroy my daughter’s handwheel, so I measured it carefully, inside and out, and made a new wheel to hold the large bicycle sprocket. The original wheel and the CAD for the new sprocket holder are shown below.

Job 3: z-motor bracket & wheels

I then designed a bracket with a slider face for the motor. The idea was that the slots in the faceplate would allow us to push the motor down to tension the belt, whereupon we’d tighten the bolts on the faceplate. The assembly looks like this:

The belt in the picture was made using projections in the plane of the gears after the machine block and motor had been “joined” to the base plate (not shown). I created a joint between the handwheel on the sewing machine and the needle, though that will need revisiting later, as it is a rack-and-pinion joint rather than a sinusoidal one.

Job 4: The CAD assembly

Fusion 360 made our lives easier with its integrated and online PDM system. It wasn’t the fastest of systems, but it did mean that we could each work on our own part of the project then combine them when we were done. There were a couple of clashes where people were working on components within the same assembly, which resulted in some duplication of effort. There is a balancing act to be lived between the team-work friendly placing of all components in the Fusion browser and the more convenient editing capability when the parts are directly in the local assembly file. In future, we’ll have to agree a working protocol to make that all smoother.

The team did their various parts, and it fell to me to integrate them all into a single assembly to make sure that all of the dimensioning was correct. That job ended up being a lot more time consuming because of the different approaches everyone took to designing their parts, which meant that I couldn’t easily adjust the various lengths. Nothing was done parametrically - each had drawn his parts to the dimensions he was given and then simply brute forced his way with multiple sketches on multiple faces, with extrusions and cuts to make the part work. The end result was a part that was functionally correct and exactly what had been specified, but modifying it to make other parts fit was a nightmare that went on till 3 in the morning.

In the end however, it did all go together. This is what it looked like at 3AM that morning:

When everybody else got up, it took a few direct hits in the design feels. There were little things all over that needed fixing. There were essentially four problems:

  1. The dimensions needed to be fit around the actual sewing machine to ensure there would be enough clearance. That required the corner posts all to be adjusted in height, but as they’d been redrawn with a parametric length and grounded sketches, that was easy to do.

  2. All of the various openings and holes had to be enlarged to take into account the effective “kerf” of the 3D-printer, which was said to be about 0.2mm.

  3. There was a worry about overhangs and infill/support material. This required some fairly significant redrawing of parts to create as many flat sides as possible from which to print.

  4. A new guiderail had to be included on the y-axis, to take up the torque that we expect will be generated by the needle going through the cloth. Although the ring is being designed to be simply supported on the working are of the machine, nothing is level there, so the torques are likely to be significant. Furthermore the y-axis driving “nut” consisted of two rather flimsy 3D printed top-hats, themselves connected to the mechanism with 3mm bolts. All of that just said, “add another guiderail”. That introduced all kinds of dimensioning and clearance problems, but all was solved by the end of the day.

The final assembly, after all of the fussing, looks like this:

Job 4: Printing/Cutting parts

Once the design was complete, we could start producing the parts.

The Z-motor mount parts were cut out on the Epilog laser cutter from a block of POM we happened to have lying around. The mount assembly is shown here:

The final assembly came out like this:

The lower sprocket and drive wheel are also shown in the picture.

We 3D printed the rest of the parts out of PLA using several different printers.

The upper sprocket holder was 3D printed on the lab’s Ultimaker, which gave us no issue (but man is it easier to use than the previous version I was introduced to two years ago!).

The Ultimaker also had no trouble printing the embroidery loop:

We tried to print the rest of the mechanism parts on the lab’s Felix Tec4 printers, but for some reason they failed overnight. Luckily we had predicted there would be trouble, and so I printed the two X-sliders on the Ender-3 in my home lab, along with a backup of the embroidery hoop. They turned out beautifully.

The only bummer was that I miscalibrated the z-axis too close to the bed and the brim ended up smeared too thinly on the bed, with the painful consequence that it’s taken several hours of scraping to restore the printer bed to use…

Once the parts were printed, the machine was assembled and powered up as described by the other team members. It came for a visit to Qualburg over the weekend where I got to try out the software control to make it work.

* Split here.**

Job 5: CNC control of the x-y axes

The instructions I was provided were to install grbl as the driver for the Arduino- and Satchakit-based stepper motor controller, and then to use CNCjs as the g-code interpreter. It works very nicely, as does the Candle interface that came with my Sainsmart CNC-mill.

To test the x-y function of the axes, I used the example CNC cutout that came with my mill, of a simple wheel. I then removed the embroidery ring and zip-tied a pencil to the y-traveller before starting the job. Here’s the little machine getting started.

After testing that the CNC-controller worked with the x-y axes, I downloaded the extension called “inkstitch” from this website which creates the g-code required to run an embroidery machine directly from drawings in Inkscape. I tested one of their example files using the pencil connected to the y-traveller to confirm that it would all work:

It was painfully slow, so I paused the CNCjs job and increased the speed and acceleration settings as shown below in the console window of CNCjs as the Arduino is first powered up and connected to:

The x and y speeds had been set to 500 mm/min, and the z one to 50 mm/min. Accelerations were 50,50,10 mm/sec2. I increased the accelerations to 250mm/s2 and the speeds to 2500mm/min. That made a big difference, but it might also have introduced an error, as one can see in the picture below, where the Inkstitch “needle” or “spear” has been drawn in the middle of the lettering, rather than above it.

Job 6: Assembling the machine and test

The machine came together nicely. A 16mm MDF board was cut to size and holes were milled to fit both the x-y apparatus and the sewing machine. We then placed the motor mount such that the driving gear was aligned directly below the handwheel gear, marked the holes and drilled them out. All that remained was to split the chain and set it to the right length.

The following day, we fit the chain and powered everything up. Here’s proof the machine runs!

Job 7: CNC calibration of the needle

The next step was to set up the z-axis with the sewing machine. We set a piece of paper under the needle, between the tip and the strikeplate, then zeroed the CNCjs position. Then we stepped the z-axis through the whole cycle until the needle was back in the same position, just tickling the paper. The measurement was 30.65mm.

The software (Inkstitch) we plan to use to create the G-code puts the fictive z-axis through a 5mm motion which should take the sewing machine needle through one complete cycle. In order not to require the eventual user to fiddle with any of the default settings in Inkstitch, we decided to calibrate the machine to suit the 5mm steps.

The GRBL driver was set when we did the needle test with a z-resolution of 250steps/mm. That times the 30.65mm and divded by 5mm/cycle gave us a calibration constant of 1532steps/cycle. We tested that and found it to be a little over 360degrees, so we scaled back to 1547 experimentally. We also changed the sign of the z-axis in GRBL using the $3=4 command. (The 4 in binary is 0b100, with the three bits indicating that the z-axis should be negated, while the y and x axes should be left as they are.)

Job 8: Smoke test

Now it was time to run the machine with a test from Inkstitch. We created an “o” in Inkscape, ran it through Inkstitch, and saved the G-code. We started the machine and whooped with excitement as it did exactly as requested.

That is, until it broke.

Several things went wrong with the z-drive. The end result was that the chain jammed and then came off the lower sprocket, which by that point was precessing wildly around the drive shaft, having completely failed in its centre.

The cause of the failure was a perfect storm of little things:

  • The nut holding the upper sprocket on to the machine had come loose from being turned both ways during setup.
  • The lower motor unit wasn’t lined up properly parallel to the long axis of the sewing machine.
  • The chain was too tight.
  • The lower sprocket was driven only by a plastic square side in the centre hole, which broke due to the torque.
  • It caught us by surprise.

The solution was to design a new lower sprocket, this time with a wider base to accommodate a nut through which a set screw could be threaded to hold the torque against the flat of the stepper motor drive shaft. The new part was quickly 3D printed and the centre hole was drilled to size (I’d have preferred to mill it exactly, but time was of the essence.)

With the new sprocket in place, the alignment all sorted, and the upper sprocket properly fastened, we fired up the system again, only to have it immediately stall. The quick-and-easy fix was to limit the maximum z-motor speed to 80 mm/min in the GRBL settings.

After all of the futzing, this was the end result:

We’re pretty stoked.

Job 9: “Spiral” development

The next step was to confirm that the CNC stage moved the fabric correctly into place for the needle to stab. This we tested by poking a spiral of holes a piece of tissue paper.

There were several challenges on the way to that output. The first was that we were asking the motors to accelerate far too quickly, so we used the $120 and $121 commands to limit their performance. This was particularly important when the starting point for the embroidery was a long way from the centre of the x-y plane.

The next issue took us a lot longer to sort out. Despite our $3=4 command, the z-axis would often start out backwards, then seemingly switch direction at random. After some careful debugging, we realised that the problem was occurring after we’d stopped the machine and restarted without first zeroing all of the axes. The machine was therefore first sending the z-axis back from whatever quite distant coordinate back to the “5” that was first commanded in the G-Code.

Once all of the bugs were worked out, we could start on making a final test piece. We threaded the machine, then clamped a new piece of cloth into the embroidery holder, and set it the task of stitching a spiral. Here is part of the process:

We discovered during the stitching that our z-calibration was a bit off, such that the x-y table would try to move while the needle was still in the fabric, so we had to stop from time to time to move the handwheel manually forward about a quarter cycle. Some minor changes to the $102 line will eventually fix that.

We also discovered that the foot of the sewing machine is an important part of the process. It is required for the upwards travelling needle to secure the knot in each stitch. Without it, the fabric simply distorts and the stitch is left loose. The solution was to manually operate the foot lifting lever, but obviously that will need to be automated in the next version of the machine. You can see what I mean in the following video:

The final masterpiece is shown below.

Seems a lot of work to draw an “@” symbol in a piece of cloth, but the learning made it all worth it!


The final assembly can be downloaded using these links: - As a Fusion 360 archive. - In STL format

Group Assignment

Our group page can be found here