The goal of this article is to document my approach or my realization of markol's project Embroiderino. The heavy lifting was done by him. His documentation is amazing and sufficient to realize an embroidery machine. Still I think that the documentation of my take on his project might be useful for
- people using the same or a similar sewing machine like mine
- peope using the popular GRBL shield for Arduino since this way the PCB work gets simpler and more approachable.
Additionally I will mention details which I had to find workarounds for or which made my life harder such that you may have a little bit less debugging to do. :)
So whom is this article for? For people following markol's tutorial and looking for some additional inspiration. If you you are using a BERNINA 730/731/732 you will also be able to profit of all the 3D files.
What is this article NOT? A step-by-step tutorial on how to build this machine. This article is an addition to the tutorial by markol.Word of caution
The original project uses circuits that work with mains voltage which can be lethal. If you lack proper certification and/or experience to handle such voltages do not attempt this project in the way it is presented. Attempt this project only at your own responsibility and use this article for entertainment purposes only rather than for education.Introduction
An embroidery machine has been on my bucket list for quite some time because it would complement my sewing projects quite nicely. When I then could get hold of a beautiful old BERNINA 732 for free I had to start this project.There are quite some open source projects for DIY embroidery machines to choose from. My personal requirements were
- Embroider at speeds above 400 stitches/minute
- Use the motor of the sewing machine
- Have as much of the sensors and wiring hidden inside the machine for a clean look
After some searching I found the website of markol with his take on building an embroidery machine. His implementation allows for fast stitching and uses the machine's built in motor. Perfect!Overview
The project can be roughly divided into four areas:
- The XY gantry for the hoop movement and driving of the associated stepper motors
- The high voltage driving circuit for the motor of the sewing machine
- The sensing of the sewing machine's speed and position
- The microcontroller coordinating everything including the UART interface to the computer
In the following I will adopt the sections as they were in markol's blog.
For the mechanics you basically need to build a plotter. A coreXY architecture is beneficial because it keeps the moving gantry lightweight and the motors out of the way. Markol has his own take on this. I used the frame by Lehavier mainly because I started with this and I was not aware of markol's project by then. I think I would prefer markol's approach now because the fabric of what you are emboidering can jam the gantry of Lehavier's frame if it gets between the axes. On the other hand the framed design allows for a smaller overall footprint of the machine. The coreXY frame is suspended on four holders which bring the frame up to the required height (contained in the 3D files). Note that I flipped the frame such that the timing belts are on the underside of the frame. The thought behind this was that the fabric will not interfere with or jam the belts. The disadvantage of this is that a part connecting the belts on the underside to the linear rail on the top is necessary (Belt_to_block.STL). This (gray) part inroduces additional elasticity which worsens the quality for larger hoops and/or faster stitching speeds. This part might be replaced by one out of metal in the future.
You might have noticed the cable chain on the x axis. It is based upon the design of dani_b. I designed the end pieces for the chain to be mounted onto the 2020 extrusion and glued to the the y gantry respectively. The cable chain is only for the two limit switches on the y gantry. Is it strictly necessary? No. Does it look cool? Yes. Be aware that the firmware only uses the limit switches for homing and not for limiting movements. I rarely use the homing feature so I do not know If I would put in the same effort into the limit switches again.
I used embroidery hoops from aliexpress which are meant for Brother Innovis machines and designed adapters for them.
Some general informations about the physical realization:
- I used two 20cm MGN12H linear rails for the x axis and one 30cm MGN12H linear rail for the y axis. This is also the maximum I am able to embroider.
- The sewing machine and the plotter are mounted on a 72cm x 50cm x 15mm film coated plywood. I wanted the contraption to be compact and easily movable. A frame under the plywood makes picking it up easier and allows to route cables unter the plywood.
- The sewing machine and the main electronics box are not screwed down but stand on 3D printed feet which hold them firmly in place.
- The electronics box has the dimensions of 14.5x14.5x7cm.
The way I installed the sensors and electronics was influenced mainly by my goal of integrating all sensors neatly into the machine.
To install the needlesensor the plate formerly housing the light bulb was removed inculding the light bulb and the corresponding wire. The studs of the screws were reused to hold a plate onto which the light barrier and the corresponding circuitry are fastened. The small plate triggering the light barrier is clipped onto the needle shaft. This solution works very well but has to be designed specifically for the machine at hand. The position of the light barrier can be fine adjusted by moving the light sensor up and down (attaching it with isolation tape allows for easy adjustment) and trimming the size of the small plate. This solution proved to work very reliably and stable. I added a salvaged high power LED from a headlamp to the bottom of the needle sensor PCB sinced there are 5V present on the PCB anyway. It is used to shed light on the piece you are working on.
The shaft speed sensor is located on the right hand side of the housing at the wall just inside after the hand turning wheel. I designed the disc for the rotary encoder to fit on the narrow space to the left of the belt driving the hand turning wheel/the shaft. The disc is printed in two parts and fastened to the metal shoulder terminating the hand turning wheel to the left using just a drop of CA glue. I went for 72 fins/slots which is a good trade-off between being fine grained and the fins not being fragile. As the sensor I used one of these cheap speed sensor boards which also have an OpAmp (often a LM393) on board. I attatched it preliminarily to the case using removable poster putty. This way you can easily adjust the position of the light barrier. I originally planned to use a more permanent putty but the poster putty holds up just fine even after quite some embroidering.
The wires beloning to each of the sensor units are routed inside the case of the machine to the junctionbox. My sewing machine does not need to serve another purpose than being a part of the embroidery machine but nevertheless I did not want to drill holes into the main body. That is why I designed a spacer body to go between the main body and the upper thread holder. The spacer provides just enough offset to house a 5 pin socket to connect the sensors to the main PCB. Like that you just need longer M4 screws and you can attatch the whole assemby neatly and without drilling holes to the main body. From there the sensors are connected to the box housing the main PCB using a shielded (!) cable.
The motor of my machine is an universal motor. It is called universal because it can be driven by AC or DC. This can be easily identified by the replacable brushes and the windings on the rotor as well as on the stator which are connected in series. The driving circuit from markol drives the motor with a DC current. His solution is really nice and has several advantages over the "classical" approach of phase angle control which was also implemented in the pedal of the machine. Be aware that the gate driving circuit used does not allow for much higher switching frequencies than the approx. 500Hz used in this project. Driving a universal motor with DC has several advantages, some of which are described nicely in this application note for the interested reader. The driving circuit providing DC current also allows you to use it with brushed permanent magnet DC motors if your sewing machine happens to have such a motor. It will however not work with newer brushless DC motors as they require a different kind of driving circuitry.The cables attached directly to the motor are routed through the case to the main electronics box on the front.
In front of the sewing machine is the main electronics box. It houses the motor driving circuit, the sensor interface aka the schmitt triggers and an Arduino UNO with the CNC shield and the stepper motor drivers stacked upon it. Markol fabricated his own PCB and used a different uC than the one present on the Arduino UNO. I had an UNO and a CNC shield laying around so I used them. The stepper drivers are A4988s which are sufficient for the task at hand. The side panel of the box houses an AC input socket, an AC switch, a cutout to access the USB port of the Arduino, a low voltage input (XT60 connector) as well as a NC push button on the top left. The push button is in series with the low voltage supply. This lets you easily interrupt the supply of the steppers which is really handy to quickly reposition the hoop.
When you want to tackle such a project it is important to consider electromagnetic interference (EMI) because we need good sensor data. The main source of EMI in this setup is the universal motor. It has carbon brushes which ride on a sectioned slip ring. On these brushes there will be sparks. So even tough the running motor sounds acoustically like a purring cat it is sounding like a dying one in the electromagnetic space, emitting HF-EMI. This in turn can and will be picked up by our circuitry and wiring and distort our sensor data. I will list some measures you can take to reduce the EMI you circuit has to endure:
- Check the filter capacitor at the motor. Machines running universal motors will always have one. That is the part which has most often failed in old machines. When in doubt replace it, else you are fighting a lost battle.
- Twist all the unshielded wires and use a shielded cable for making connections. Pull the shield to a defined potential.
- Most older machines I have seen are class II devices hence the metal body will be floating and its EMI shielding potential will be limited. This may be improved if the metal housing is pulled to a defined potential. The same can or should be done for the (metal) enclosure of the main electronics.
- If you are still experiencing conducted EMI through the wires running to the motor you can employ a common mode choke.
- Having the gate drive interface optocoupler on your low voltage side reduces the exposure of your low voltage side to noise originating from the high voltage switching.
I chose the location of my main electronics box to be as far away from the motor as possible. The drawback of this way is the rather long sensor cable running staight over the motor. Hence the importance of a shielded wire.One drawback of choosing the Arduino UNO + CNC shield way of realizing this project is that you are at least encouraged to use jumper wires to connect everything up. This setup/mess with large loops of wire in the electronics box is a warm welcome for trouble with EMI so make sure you shield everything properly.
Important: The schmitt triggers need to be close to the main board such that any Interference picked up on the way from sensor to the main board is also filtered.
Arduino & CNC shield setupThe usage of the CNC shield simplifies the PCBs we have to build but there are some things we have to consider.
- We are forced to use the pins PD2 and PD3 for the external interrupts since these are the only ones providing this feature on the ATMega328p. Unfortunately these are also the ones used for the Step Pulse X and Y respectively on the CNC shield. Thus we need to use the Z and the A axis for our motors. Luckily the design of the CNC shield allows us to use the A axis with the pins PB4 (Step) and PB5 (Dir). To make use of this feature you have to place the respective jumpers.
- Another pin which is reserved is the PD6. It is the output for the OC0A which is used to generate the PWM signal for the motor driver. It corresponds to the the "Y-axis Direction" pin on the CNC shield.
Summarizing the connections to the CNC shield are as follows (the last column is the name of the pin on the CNC shield):
- X_STEP_PIN/X_DIR_PIN -> PB4/PB5 -> Axis A STEP/DIR
- Y_STEP_PIN/Y_DIR_PIN -> PD4/PD7 -> Axis Z STEP/DIR
- MOTOR_ENCODER_PIN -> PD2 -> Axis X STEP
- ENCODER_PIN_A -> PD3 -> Axis Y STEP
- ENCODER_PIN_B -> PC3 -> Coolant Enable (somewhat arbitrarily)
- PWM_OUT_PIN -> PD6 -> Axis Y DIR
You can check out my config.h for the rest of the pins. Note that
PWM_OUT_PIN are hardcoded in the
The software workflow is as follows: You create a.txt or a.gcode file using a suitable program. Markol recommends embroidermodder, I used InkStitch (a plugin for InkScape) because I am used to InkScape. This file gets loaded into the control app from the emroiderino repository which then sends the commands via USB to the uC. The uC is running teathimble.
InkstitchAs mentioned, InkStitch is a free open source plugin to the also free open source program InkScape. To create files readable for the host application you have to save them as.gcode files. For that purpose you can enter custom GCODE commands to match the ones of the embroiderino project. However this does not work perfectly yet:The current release of Inkstitch has some issues with the custom GCODE output. You can alter the STITCH command but not the MOVE command. The MOVE command being G1 by default in inkscape you will get a file with only G1 commands. Also it does not insert the color change commands at all. Up until now I just added/altered the commands manually afterwards which is of course not a sustainable way of solving the issues. They of course can be resolved by adjusting either programs. It just has not been done yet.Side Note: This is not documented on the teathimble/embroiderino site but to perform a color change the command "M6 R? G? B?" is expected (so M6 R245.0 G111.0 B3.0 for example).
control_appThe control app works nicely for me. Up to some hickups like the pause button not working from time to time everything has been working flawlessly.
teathimbleAlso a very nice piece of code and the author foresaw compatibility with the ATMega328p which sits on the Arduino UNO. However there were two issues which gave me headache:
- The Waveform Generation Mode and the Compare Output Mode bits are not set for the ATMega328p leading to no ouput signal on the OC0A output pin (PD6 for ATMega328p). There was also a line declaring the complete D bank as outputs thus disabling the sensor inputs.
- I observed inconsistent movement of the x axis when using the jog buttons of the control app. I could narrow it down to the variable
startpoint_stepsin motor.c. It seems that a different process/variable is colliding in memory with it leading to inconsistent steps taken. I found that removing
startpoint_stepsfrom the BSS section for the ATMega328p works out fine altough this is not the most elegant solution.
These bugs have been removed to an extent that it is working for the ATMega328p. I issued a merge request but until that is approved you can copy the attached files and replace the ones from the repo with them on your local machine. Namely motor.c and sensors_control.c need to be replaced. Alternatively you can checkout my fork of teathimble.Result
All in all the machine works like a charm. At least from an electroics and software perspective it just works. I still have some issues with the upper thread breaking but that is a matter of fine tuning the upper and lower thread tension. I found that it is a fine line between having no tension at all on the upper thread and having too much such that the thread breaks. There is still some tuning to do I guess.
Anyway here is a video where you can see the machine in action:(be aware that the audio is terrible, my mic was covered)
The embroidery file is from Low Tech Linux who provides the files for download on his website. I edited the file such that it has less jumps and exported the gcode file to use with my machine. You can find the gcode file attached. Low Tech Linux has amazing tutorials on youtube on how to digitize images and how to use InkStitch; a very valuable ressource if you plan on using InkStitch!
I really do like the results I am getting from the machine. There are some small areas here and there which I am not quite satisfied with but I still have a lot to learn about embroidering.
The STL files are collected on Thingiverse. I collected all the parts specifically for the embroidery machine in one thing and the other ones which might be of use for other projects/replacements are in seperate things, listed below.
Machine specific remarks:
- I covered the original sockets for the pedal and the power cable with 3D printed parts. They are also attached with all the other STL files here.
- There were two versions of the BERNINA 730 Record (the Models 730/31/32 differ only by the stitch selection) of the upper thread tensioner. Machines up until March 1964 had a pretensioner before the main upper thread tensioning assembly. I have a machine from 1963 and the pretensioner was missing. You will not get good results by installing just a guide. So I designed a pretensioner consisting of some 3D printed parts and some hardware. You can find the files and how-to of the pre-tensioner here.
- For embroidery a stitchplate with only a small hole is benificiary. I desigend one for this machine and it is included in the files. Note that you have to remove the hooks of the transporter. You can find the stitch plate here.
- One of the caps retaining the carbon brushes was brittle and broke. I designed a replacement part which you can find on thingiverse. You can find it here.
It took me about 6 months to complete the project. It was as fun as it was challenging and I learned a lot! And I have an embroidery machine now! :)If you are interested in embroidery and/or have an old sewing machine which is craving a second life then I am encouraging you to tackle it as well!