Embroiderino towards open source embroidery
Published: 2018-11-28 16:34:08


Project main repository: git

Digital embroidery appeared in my interest long time ago when I was watching some videos about textile finishing, there was a sequence about sewing graphical details on fabrics with some CNC like sewing machine. The first thing I thought was: hmm that's looks cool and it just a electronic sewing machine, it does not look to be so complicated, probably somebody made it up. Quick search revealed a few projects, but without any sources or detailed description, sometimes it was rather buy it offer. Domestic embroidery machines solutions also seem to be relatively cheap, the stairs begin when you except faster speed, bigger work area and some more additional features. Embroidery design software prices also suggest that this market is a niche. In this article I will report and document my attempt to build this kind of machinery, this text might come in handy when you decide to clone or support the project. Of course it is not easy to even compare features and reliability of the machine from this guide with commercially available sets but if you are patient enough final work piece results are comparable. For less than 100$ you should end up with fully functional setup. As a name suggest this might be very first DIY embroidery machine but actually arduino board has more than enough processing power to control it.

General information

Project aim is to provide all needed to convert almost any sewing machine into digital embroidery machine, only straight stitch functionality is required. Very old machines turn out to be cheap and much less fragile from the new ones and they work well. Commercial machines with electronics failure etc. can be also modified and reused. Sewing machine must be fine tuned to save you frustration and produce best results, there is plenty of instructions how to do that, however in the last section I have described some notes from my observation. Machine is propelled by traditional stock brush AC motor (shipped with the machine) powered from mains network, however it is controlled by electronics in closed feedback loop servo manner. Some others attempts which I found on web use big stepper motor to run the machine, as it is easy to adopt for typical CNC control, as it is out of the shelf solution and needle position is precisely known all the time, there are no more advantages of that. Hoop position is set by actuator powered by two stepper motors, for fast movements its design cannot be bulky in assumption. Movement starts always when needle is in its upper dead position which is detected by typical IR light sensor encoder system and microcontroller interrupt. As a electronic controller AVR based boards like mentioned arduino or derivatives will work but additional shield board is needed to drive two steppers. For project purpose a dedicated firmware for microcontroller was developed, I can't see much sense in starting from scratch so one of minimalist printers firmware was a good point to start with. Firmware receives g-code instructions from host application via mcu UART interface, interprets them and executes. Host application runs on connected PC computer or on embedded computer board (like ex. raspberry PI). Software config is described later on.
Block diagram bellow summarizes flow of information within the system:

As it looks, there is as little peripheral components as possible. Sensors which are generating interrupts are connected through schmitt trigger to eliminate signal bouncing problems.



Main challenge here is to build fast 2D positioning system which is rigidly constrained to sewing machine. Project provides such solution suggestion applicable for most sewing machines, more information and instructions here. Aside from actuator a few necessary sensors must be mounted confidently, way to do it depends of sewing machine type. This can be accomplished within two manners: by interfering into machine construction (invasive way) or practically not.
Piece of chipboard was used as a basis where machine lays on in fixed position and hoop actuator is mounted to by four holders (plotter_mount.scad). Height of the hoop mounting point to suit the machine dimensions can be changed here by adjusting the height parameter of those mounts models before printing.

Hoop is keeped in place by two ergonomic for operation nuts, it is fast and decently easy to put it on or remove.

Notes about wiring and sensors for the machine are detailed in the next electronics section.
For best results sewing machine needs a special embroidery dedicated presser foot, it should start pressing the fabric only when needle is 2 mm above fabric. Higher distances might cause the fabric to being pressed and blocked too early, before hoop moment is complete, that correct foot timing is a problem for faster sewing speeds. Obviously machine built in transporter must be completely turned off.

Embroidery hoops can be 3D printed or bought, in last case additional adapter needs to be printed or fabricated. Printable adapter enclosed in project files (hoop_plotter_adapter.scad) is for printed hoops but it is a good point to start to reuse this file to design a other variant. Project encloses files for fully customizable hoop (hoop.scad), even the extra large 3d printed as a separate parts to fit most printers build platform volume (hoop_large.scad). Those parts are intended to be screwed together using 7x M3x30 screws and nuts.

Set of 3D printed parametric hoops, usable areas sizes: 60x75 mm, 110x120 mm, 145x230 mm.



As a first diagram presents, electronics schematics is rather very simple. Many avr powered electronics boards can suit this demand. For the crucial moment detection an reliable optical sensor was utilized. For homing traditional mechanical switches work fine instead of optical. Schmitt triggers (chip 74HC14N) intermediary in interrupt circuits are very important for elimination of signal bouncing problems.
Servo circuit consists of standard AC/DC (up to 250V AC) brush motor with an rotary encoder on it, discrete PI regulator which is a part of microcontroller logic and motor power driver. Regulator sets the driver output value accordingly to measured encoder pulses and given speed value, so it solves a speed regulation problem. Professional machines probably control position instead of speed what is a different and more difficult issue but makes the whole thing run much dynamically and controllable. Note that there is no direction information since they are not needed, AC motor runs in only one defined by armature and stator windings connected in series. PI controller needs to be tuned by setting two values, default ones can but don't have to work for you, motor must run smoothly and without any big oscillations. PWM frequency needs to be checked as well, when motor runs on closely full speed with 50% or similar duty cycle then frequency is incorrect. Tuning procedure is in firmware related section.
Encoder wheel (file motor_encoder_parts.scad) is mounted to motor's shaft, but machine shaft might be as well. Optimal value for pulses per machine turn is 40-50 - which is doubled for square wave both edges detection.
Optical sensor is a simple integrated unit which is present in many desktop devices, printers, which is mounted on separate circuit board. Sensors output needs to be connected with atmega external interrupt no. 1 pin and power driver with any of timer0 muxable PWM pins!

Ac motor with rotary encoder mounted on it. Driver adapter is plugged into motor's plug socket.

Driver circuit is a AC rectifier and a power mosfet, driven by signal from optocoupler and voltage supplied from zener diodes. PCB for motor driver is made with KiCad, easy to etch and available in project repository ( For safety and tidiness it is closed within printed casing box with direct plug in one side.

Needle position sensors are responsible for hoop movement triggering in the right moment. They can be mounted inside the machine to monitor shaft position or on the presser foot behind the needle. I wold highly recommend the first way (opposite to presented) because of more precise timing possibilities. Sensor has two outputs: one for change detection second for direction information, I have had checked out integrated precise sensor like this but problems occurs after some time when it becomes dirty from dust. Instead I have prepared a different one using discrete elements, it performed very well. There are just a two opto-transitors and one IR led diode, these can be recycled from old ball computer mouse. One line of the sensors output is connected to INT0 pin, second line to any of the configurable digital inputs.

First try with fully integrated sensor chip occurred to work not so well.

Correct timing adjustment for the sensor needs to be done. There are two positions to detect: when the needle is in its top dead position (but thread not fully pulled off) and where the thread is fully pulled off (take up lever top dead position) from the fabric and needle starts to move downwards. The first case is for quick short movements, the second for longer moments which are requiring the stop. It might seem better to start the hoop moment when needle just goes out of the material but it is not, thread which remained on hook causes the troubles here. When sensors are wired up, test them with some test embroidery pattern loaded and by manually turning the machine, when steppers are moving to its next position on every turn and in the moment when needle goes upwards then you got it right.

Picture presents sensor lines arrangements for linear flag or rotary wheel encoders. Row marked A is a moment when needle comes to its top dead position, row B is a combination for take up lever being on its top position when needle moves downwards.

Another advice, use 24-30V power supply for steeper motors, otherwise you have to lower the acceleration and speed. Commercial machines, even those like desktop printers, are using cheap motors, powered by good drivers and voltages around 45V. Higher speeds mean higher frequency whats increases the reactance of the motors windings so a higher voltage values are needed to keep the flow of same current value. Low current means low torque and troubles because of that, search for stepper motors rated for low voltages 3-2V.

Power driver circuit diagram

Encoders sensor circuit



This is most important and expensive (to develop) part in embroiderino. Utilized software toolchain can be divided into three categories:

  • Digitizing environment where embroidery project is prepared with, produced output is simply set of stitching points and other instructions for the machine. This only one part does not belong to origins of development of this project. Surprisingly there is a very little choice for open-sourced tools like embroidermodder or inkscape extension inkstitch, only those two are worth mentioning. Any commercial software will work too for this purpose. Embroidermodder works well for conversions between different formats, so many existing patterns can be reused.
  • Machine control interface software (host), which is communicating with electronics within flat level instruction set. There is the place to set workable settings, load, display preview and validate project pattern. Adjustments like pattern location or rotation are necessary basic facilities.
  • Microprocessor firmware which is receiving instructions from host application and executes them by controlling the electronics parts. Basic functionality is to generate steering pulses for motors drivers, demandingly of the other conditions, this also involves routines like instruction buffering and speed planning.

Procedures for configuration and operation of the software from last two blocks are now described.


For the purposes of the embroiderino, teathimble is a firmware developed on top of teacup 3D printers firmware. It was the lightest and fastest piece of software for printers, not sure how it looks these days but after some relevant code cuts it even performed better than grbl but surely with much less additional features. For now only avr microcontrollers are supported, many "out of the shelf" electronics board configurations are absent and pinout must be configured manually. Firmware can be build and flashed via arduino IDE or enclosed makefile.

Most of the configuration is in config.h file where every option is described by a preceding comment, however a quick start guide bellow.

Set a plotter work area with these lines:

#define X_MIN                    0.0
#define X_MAX                    280.0

#define Y_MIN                    0.0
#define Y_MAX                    280.0

Steps per one meter to fit your pulleys drive setup:

#define STEPS_PER_M_X            87575
#define STEPS_PER_M_Y            87575

Plotter acceleration in mm/s^2:

#define ACCELERATION             2500

This is default and recommended serial communication speed:

#define BAUD                     115200

Activating this line increases the PWM frequency:

//#define FAST_PWM

For a more precise PWM configuration open sensors_control.c file and locate this line (FAST_PWM defined):

TCCR0B =  (TCCR0B & 0b11111000) | 0x02;

and change 0x02 to 0x03 or 0x01 - slow pwm.

Set a number of encoder pulses (doubled) per one machine shaft rotation:

#define PULSES_PER_TURN 84

Define the minimum, maximum workable and default (after reset or power on) machine speed in stitches per minute:

#define MIN_MOTOR_SPEED 80
#define MAX_MOTOR_SPEED 800

Adding a board pin setup

If your board configuration is present in boards.h header file then you can use it by defining relevant constant with config number:


If your setup has any slight differences it can by altered by changing relevant parts of this configuration in boards.h. New configuration can be added in boards or config header files, easiest way is to start editing definitions prepared in config.h.  It is everything between these definines:

    #define X_STEP_PIN               PC3

Digital pin addresses can be defined in two manners: avr-lib style like PC3 above or arduino pin numbering style for example DIO10 where it just references 10th pin. Interrupts and PWM pins are imposed in advance. Define only one homing switch per axis, depending of the side on which they are located use ?_MIN_PIN or ?_MAX_PIN definition macros. Configuration can be checked manually by sending the command to machine in an arduino IDE serial port monitor. List of supported commands is here in readme.

Motor PI controller tuning

If you are not familiar with PI / PID controllers this guide might explain what is going on. You can start the tuning procedure from default values or very low ones - zero close. When speed is not stable and motor oscillates (slows down and accelerates over and over again), especially on low values, try changing kP constant a little bit. Increase it when motor has problem to reach desired speed and decrease it when the speed gets overshoot. If the motor runs stable but desired speed cannot be reached increase kI constant and check P again - for different speeds range. There is a Gcode command  M301 which becomes in handy while tuning the PI, it sets the factors current values and target motor speed, example: M301 S100 P40000 I2000.

Default (used after reset and power up) P and I factors for PI speed controller are defined here:

#define KP_FACTOR 40000
#define KI_FACTOR 2000

Control application is written for Python 3.x and uses Tkinter for GUI. Python tk and pyserial packages are a required dependencies. It will run almost everywhere, including computers dedicated for embedded systems, raspberry, bbone etc. To launch it just type python3, a main window should appear, on first run a machine configurations needs to be created but firstly brief overview. Window is divided into two regions: white canvas where embroidered pattern is shown and control region where there are two tabs with control widgets.
On the top additional menus bar is placed, on the bottom there is a text status bar which displays progress of most important actions. Machine control tab as a name suggests has all the options related to manipulation of the machine actions.
Hoop setup is important, because there is no limit when using preferred customized hoop which fits the job needs, always check if proper one is selected. Different setups can be stored and later selected from list when used. To add a new setup open the settings window (Edit>Settings), there are four parameters to type and check. Hoop dimensions (inner work area) and hoop origin (point 0,0), consider losses due to foot size when measuring and typing hoop size. Origin is a machine coordinate for which presser foot is under left bottom corner of hoop workarea. Type the name for new setup and click add button, existing setup can be updated with this button as well. Check if setup is correct, described later Go to mode might help a lot.

Of course to control the machine at first connection with the electronics needs to be established, select proper port and use connect button. Ports list can be updates within option in "File" menu. Next step after connecting is always to home the machine with home button, thanks to this electronics know what the position of the hoop is. Perform homing with hoop demounted, presser foot and needle up to prevent unwanted damage of colliding parts. By toggling "Go to" button a some special mode is activated, hoop is positioned in the place where you clicked on canvas when mode is on. It comes in handy when precise positioning for the sewing job is desirable. "Border path" button makes machine hoop to move around rectangle to show you where actually loaded embroidery pattern is going to take place. To load a pattern go to File>Open menu, two plain text formats are supported CSV (generated from embroidermodder) or raw Gcode. Analogously when saving the pattern, but if loaded file has any comments in it there is no guarantee to store them back. In case of gcode loading, because of non standardized variety of conventions only known and valid commands are accepted. When pattern is successfully loaded its preview should appear on canvas along with some information updated in machine control tab.

Those information are organized as follows:
tool changes (or thread color changes) - current change number / changes total,
tool points (stitches) left - until next tool change / until end,
estimated end time - until tool change / until end of sewing.

Path manipulation tab has some basic tools to adjust the pattern, from this point it can be moved, mirrored, scaled or rotated. To perform these operations toggle selected mode and click and drag on canvas, for rotation pivot point is where you clicked to start dragging. Scaling should be avoided since patterns are designed for thread thickness.
Use slider thing to limit the amount of stitches drawn in preview, it can be useful when analyzing the sewing progress.
When pattern seems to be prepared, machine threaded and foot lowered "Start job" button on machine tab does the thing, after start - all the manipulators commands are disabled. Pause button (same as start button) pauses the job and it can be resumed, stop button terminates it. Note that for now pause is not stopping machine immediately but when instruction buffer becomes empty (after 8 instructions by default). When thread needs to be trimmed or color to be changed, job is paused and proper message displayed. If for whatever reason you don't want those breaks they can be simply disabled by unchecking the relevant option check boxes. Sewing speed can be limited with speed limit slider. For now I preferred to operate at maximum speed of 800 stitches per minute, without any issues, it also worked when pushed above 1000 however this is untested range when the precision becomes affected. Firmware's speed planner curve can be stretched with max jump len value.

When starting a first stitch of sewing a thread tail might be a problem for some machines, if so then try don't making it longer than 3cm, hold the tail on start or just do first stitches manually turning the machine.
Test the working machine on a few jobs and test pieces before switching to real workpieces. There always are things that may go wrong, if machine jams, thread or needle breaks just turn off main motor power and fix the problem. Remove the hoop if necessary, put it back and turn on the motor power. This accident should not affect embroidery quality significantly. At current stage there is not any problem detecting mechanism. If those problems occurs too often then something is wrong. Next page is related to sewing machine checks.


  • 1
  • 2
Comments (27)
Eggert 2018-12-04 09:59:28
Hi, very nice build. I also plan to build an embroidery machine and found your page via the inkstitch discussion... Can you tell how much power the motor and rpm should have? My machine has none, and I want to start with a meaningful one...
markol 2018-12-14 22:19:57
@Eggert Just simple engineering calculations: assume machine and motor has a 1:5 transmission ratio, for 800 SPM you need 4000 RPM on motor. For brush motors its power and load are the speed limits (theoretically), typical domestic sewing machines motors are rated to 50-100 Watts. If you don't have any and don't want to play with high dangerous voltage find something under 50V and swap driver mosfet to different one capable to handle more amps.
Aatif 2019-04-15 08:43:18
Hi Markol. This is a nice project. Can you please provide the BOM for the same.
ariel 2019-09-29 23:11:52
Hello, if it is not annoyance I would like to ask you about the connection and calibration of the sensors and their connection to an arduino board one, because I cannot understand it, I am from Argentina, thank you
jagadeesh 2019-10-03 02:28:24
my name jagadeesh your project is very good i need circuit diagram pls help me
markol 2019-10-10 09:12:19
@jagadeesh All the circuit diagrams are present in repository along with PCBs, BOM and custom mainboard, you need KiCAD and gEDA (both free) packages to browse it. I'm considering small update to use stock components (like GRBLshield or CNCshield) to make things easier for non-professionals and fit it all into one circuit diagram sheet. @ariel As written use INT0, INT1 and any of the digital pins. From your question I'm assuming that you are missing some background, search for "arduino optical sensors encoders connection" and "74hc14n encoder" to get the basic understanding of how those things work. For now don't worry about calibration, get the basic setup working and hopefully you will find for your self what is going on. Enjoy learning and good luck with making DIY embroidery everyone.
ariel 2019-10-11 20:36:34
Thanks, for the answer, I will learn what you told me, what I can't see is how the address is read, on the sensor connecting to any digital pin, I can't understand it in the microcontroller code, I'm sure I need to learn a lot more, but it is a doubt that I do not see it interact in the code, thanks. (excuse the way I write, use a translator, my English is bad)
Felix 2019-10-15 23:03:42
Hi! What a great job! I am going to go for this project using an old Sigma machine. At the beginning and seeing how Inkscape gives the gcode, I thought on a stepper motor for the stitches and regular grbl firmware. Later I have realised in this way I can easily use the machine regular without big changes. Actually has a foot controlled electric motor, which seems easy to control by the Arduino. So, the questions are: do you have to do any post-processing to the Inkstitch gcode? This includes one G0 lounge and after a Z movs. May a regular gcode sender be used? Thanks!
markol 2019-10-16 20:53:16
@Felix You do not need a Gcode - instructions are much machine specific. I do prefer usage of CSV from embroidermodder 2 - it can load many existing commercial formats. Gcode and CSV compatibility seems to be broken in newer Inkstitch versions. Launch an app and see how it goes. Custom codes is a new feature, firmware changes are needed. @ariel To understand a pin mapping check out an atmega C programming with avr-libc.
ariel 2019-11-12 01:30:02
hello markol, I have a problem, when I move on an axis for example the x, when making 2 or 4 movement followed (RELATIVE MOV), the measurement moves more than 1mm for each movement, it is as if a motor then dinates its rotation, I put a lot of effort into the mechanics, straps ect many times, acceleration and vel varie and remains the same 15 days ago I can not see the error, if you can help me I would appreciate it.
ariel 2019-11-12 01:38:21
arduino mega + a4988 driver are calibrated (0.32volt) + ramp 1.4, the mema17 0.4 amper torque 1.8kg engines, everything is going on but it has the problem that it ments, The first movement does it well and with the exact measurement, the following ones go adding 1mm at a time the steps / mm are at 80000, 20 teeth pulley, gt2 belt and set to 16 microsteps, thanks
markol 2019-11-12 18:31:17
@ariel Have you tried to send an movement commands from python written client (GoTo mode)? Those errors are random or the same when repeating similar command sequence? Crank up the drivers current until they become hot, test and lower it if motor is still losing steps. Also test it with lower speeds, it is a F feedrate parameter. G90 - set to absolute positioning (default, after reset), G91 - set to relative positioning.
ariel 2019-11-12 19:42:43
G28 OK G91 OK G0 X10 Y0 F10000 OR G0 X?? Y0 F10000 OK G0 X10 Y0 F10000 OK G0 X10 Y0 F10000 OR G0 X?? Y0 F?? ERROR ADD +1MM IN X AND +1MM IN Y G0 X10 Y0 F10000 OR G0 X?? Y0 F?? ERROR ADD +1MM IN X AND +1MM IN Y G0 X10 Y0 F10000 OR G0 X?? Y0 F?? ERROR ADD +1MM IN X AND +1MM IN Y G0 X10 Y0 F10000 OR G0 X?? Y0 F?? ERROR ADD +1MM IN X AND +1MM IN Y ECT ?? = TRY WITH MANY DIFFERENT VALUES THE SAME HAPPENS WITH G0 X0 Y10 F10000 OR OTHER VALUE THANK YOU
markol 2019-11-15 16:47:25
Do check if updating Arduino IDE works for you like here: if not then please create an new issue.
Student 2019-11-23 16:34:54
Hi! @markol, I tried opening up the schematic for encoder and power but it states that several libraries were not found and requests a remapping of symbols. Could you please share either a picture of the schematic or check for missing library files? Thanks in advance.
markol 2019-11-23 20:33:11
Please make sure you have an extra symbols packages installed, custom symbols should be already provided as *.lib files, follow a KiCad documentation for more information. I added photos of the scheme.
Enthusiast 2019-11-24 22:20:45
Can you please upload a tutorial with stepper motor instead of servo AC motor. Also kindly upload a tutorial using GRBL.
Kristen 2020-01-30 21:05:51
Great work
Kristen 2020-01-30 21:08:32
Can you please guide regarding... I am using a brothers sewing machine which requires greater torque, to power which I will be using a 180W ac brush motor, please guide if power driver circuit will be able to power this motor. What current does the driver circuit provide? Thank you!
markol 2020-02-01 10:59:03
@Kristen Yeah it should work fine, with brush motors (not inductive AC) try it to find out. Current is limited by power transistor, IRF840 with bigger heatsink is able to handle ~7A, in my case it stays cold.
Kristen 2020-02-02 18:39:07
Thank you so much Markol. Can you also please tell how much is the current rating of your ac brush motor?
Michael 2020-02-25 15:41:14
Awesome work dude. So the circuit you are using for power driver, is it variable frequency drive or are you using a dc drive for controlling motor. Can't understand the circuit working. Would be great if you guide me. Thanks a tonne.
Hector 2020-04-11 05:19:13
Hello, I like your work and I want to ask you if you could add a function in the python app to advance the machine to the next color or jump or delay some stitches, would it be of great help, or can you tell me how to do it? Thank you i'm from Mexico
markol 2020-04-15 22:01:50
@Hector There is a g-code instruction for color change (listed in - machine is stopped and you are asked for thread change, the app has an option to skip those pauses. Color change should work fine when importing .csv, Inkstitch has changed a bit so I'm not sure how it looks now. For other changes you will have to edit stitches manually with mentioned tools.
Ademilson 2020-06-18 04:14:22
Please, where can I download this phyton app?
syauqi 2020-06-21 05:48:07
Great project! where i can download 3d parts?
Tom 2020-07-02 18:53:45
Hi, this is the best DIY embroidery machine solution I've ever seen! I have two problems: 1) I use Arduino MEGA with RAMPS 1.4. I don't know where to set the input pin numbers for the needle position and motor speed sensors in the program, and the output pin for the motor PWM. 2) Unable to start communication app. (I'm using WIN XP), the Python3 window will appear and disappear immediately. Is there any other option? For example, compiling for Python 2.x or EXE / 32? Please help. Thank you.
Add a comment

For problems related questions please use issue tracker on git project repository (if any). Tags in comment will not work for now.