Hacking the Brother KH-930e knitting machine
Limor “Ladyada” Fried and I just finished up an extensive tutorial on hacking the Brother KH-930e knitting machine. We show you how to make your own cable for interfacing with the machine, then how to use it to put custom patterns on the machine without entering them by hand, as I had been doing previously (one excruciating pixel at a time). I made the above tessellating adafruits fabric and the dithering experiment below.
Have questions? Don’t ask them here or send me email, ask in the adafruit forum.
The video above overviews the process which is detailed in this tutorial.
Working with these machines is very difficult. Before you begin, look at your life, and what choices brought you to this point. Are you proficient at using the knitting machine’s normal functions? Can you read and run Python scripts? Have you ever done any serial communication between your computer and another device before? If you answered “no” to any of these questions, work on these skills first before attempting to follow this guide.
Adventures in communicating with the Brother KH-930e knitting machine! The order of operations:
- Make the FTDI interface cable
- Prepare the computer by downloading the software
- Backup your Brother Knitting Machine’s memory to your computer
- View patterns from the machine’s memory
- Adding a new pattern from an image
- Load your new file back to the knitting machine
Much of this tutorial is directly adapted from Steve Conklin’s totally awesome knitting machine wiki page!
- If the RAM data has been corrupted, the screen will flash “888” and the machine will seem unresponsive. Hold down INPUT and STEP at the same time, and when the display should change. Perform a memory reset by hitting CE, 888, STEP.
- download the PDF knitting machine manual (many other knitting machine manuals here as well)
- Troubleshooting Brother machines – includes how to do an 888 reset of memory
- Good forum post – includes what to do when all the machine will do is flash “888”
- Newton’s Yarns – in Anaheim, CA, claims to carry Brother machines/accessories incl. KE-100 motor drive
Make your own cable
The kh930e is designed to work with a Tandy PDD1 floppy drive. We don’t need it! Make your own cable to communicate between your computer and the machine. You will need:
- FTDI cable – you should be able to use a ‘3.3v’ or ‘5v’ cable.
- 2×4 connector part number WM8036-ND on Digikey
You will need to make some minor mods to get the cable talking to your knitting machine. Follow the tutorial to get your knitting cable going.
Change ‘polarity’ of the FTDI cable
FTDI cables have standard ‘inverted’ TTL (zero is 3-5V and one is 0v) but the KH930E requires the opposite. Luckily its very easy to fix this by reprogramming the software.
You will need a copy of FTDI MProg (windows only) and your FTDI cable. Plug in the FTDI cable into your windows computer and install the driver that matches your computer bestFor Windows users, http://www.ftdichip.com/Drivers/CDM/CDM%202.08.28%20WHQL%20Certified.zip is the best choice
Please read our detailed tutorial on installing the driver here then come back when the driver is installed
Now download FTDI MProg (Search for MProg in the page, v3.5 was the latest version last we checked) and run the program
Select Scan… from the menu
The message window should say it found a cable.
Now select Read and Parse to read in the cable programming.
Click the buttons that say to Invert TX and RX.
Here is the wierd thing, you have to Save as… the settings so just save it anywhere.
Now you can click the Program button (lightening bolt).
The message window will say it programmed.
You’re done! Quit Mprog.
Rewire the connector
Next we need to rewire the FTDI cable to match the pinout of the knitter. The cable comes with a 1×5 connector, but we need a 2×4 connector. You can also follow Davi Post’s excellent rendition of this cable-rewiring section.
Use tweezers to lift up the black connector tabs.
Then gently pull out the wire.
Repeat for all the wires.
You’ll want to cut away a few inches of the black cable sheathing so you have plenty of ‘space’ to work with the wires. Cut down the sheathing without cutting the colored wires, use a fine scissors. Cut 1 or 2″ away.
Now grab the 2×8 cable connector you bought from Digikey or whatever. You’ll need to insert the wires so that they snap into the connector to match the following diagram. Do not insert the red or green wires yet!!! Insert just the orange and yellow wires. Look at the photos below to make sure you have the wires in the right order, they should just snap in. If they don’t snap make sure the little lock-tab is facing ‘out’
This diagram assumes you’re looking at the connector from the end that goes into the machine. Again, check with the photos many times to be sure you get this right!
Pin 1 is black, pin 2 will be red, pin 3 will be green, pin 6 is orange, and pin 7 is yellow.
Next is the one tough part, you’ll want to cut the green wire as close as you can to the black sheathing. Use the piece of green wire to branch off from the red wire by stripping a small opening in the red sheathing and soldering the green wire on. This produces one wire with two header inserts – red and green. See the following image:
Wrap it up in electrical tape or heatshrink:
TODO: We’re pretty sure its possible to make this part less difficult by using the RTS (green) wire without splicing it to the 5V (red) wire and using setRTS() in the python code but we already mangled the cable before trying this. If you try and succeed, please post up in the forums!
In this section we will download and install the software that emulates a disk drive to the knitting machine.
Now that you have the cable running, its time to download the software. Visit the Adafruit github repository and click on Download to download the source code.
This code is based on Steve Conklin’s knitting machine code which is totally awesome but doesn’t support pattern insertion. Still, check out his site for a lot of detailed information.
Download the file and unzip it into a directory that is easy for you to get to. For windows, we’re going to stick the folder in My Documents in a folder called brother but if you are comfortable with command lines put it where-ever you’d like!
We’ve had good luck running this software on Linux and Mac (OS X) systems, but it supposedly works on Windows now too, thanks to Steve’s PDDEmulate.py bug fix. Try it and let us know!
You will need Python installed to run the code. To see if you have Python installed, open up a command line and type in python. If you’re running Windows you probably don’t have it, so download it from the official Python site . You’ll also need PySerial (serial interface for python) from http://sourceforge.net/projects/pyserial/
Open up a command line (windows) or Terminal (mac) or xterm (linux) and cd to the brother directory and then type in ls (or dir if ls doesnt work) to list all the files.
Determining the serial port
Now we need to figure out what the name of the FTDI cable is. This process differs a little for Mac, Linux and Windows people.
Under Mac, in the Terminal window, type in ls /dev/cu.* which should give the following responses or so.
The name we are looking for is /dev/cu.usbserial-XXXX where the X’s are going to be unique for each cable. Copy and paste the name into a text file so you’ll remember it for later.
For Linux/Unix type ls /dev/ttyUSB* into a terminal window, you should see a device file called something like ttyUSB0.
If you are using Windows, go to the Device Manager (From the Start Menu, select Settings→Control Panel. Double click on System and select the Hardware tab. Then click on the Device Manager button).
This step will show how to download the custom patterns from the knitting machine memory to your computer. This is just for the ‘custom’ patterns, it wont download the ‘built in’ patterns that are shown in the manual.
Plug in the cable into the back of the machine.
There is a ‘key’ on the plug so you should be able to use it without accidentally putting it backwards. Still, check to make sure you have the right colored wires in the right places now, before plugging it in.
Now back to the computer. Start up the disk drive emulator in the command line by typing in python PDDemulate-1.0.py img COMPORT where COMPORT is your serial connection. For example on a mac the command might be python PDDemulate-1.0.py img /dev/tty.usbserial-A7TKMHYD this will make an ‘image’ of the knitting memory in a directory called img.
Now over on your knitting machine… When “ready” lamp is lit, clear display with CE key, then prepare to save pattern data to “disk” by typing 552, then STEP.
Display will go blank and then “ready” and “pattern no” lamps will light up with the “track” number 1 in the display. Press STEP.
Machine will beep when finished, and the track data will now be in the img folder along with your emulator and other scripts. Ignore the .id files.
The emulator also makes a handy file-01.dat file to make it easy to preview the patterns using dumppattern.py (see the next step)
We’ll need that file-01.dat file, so make a backup of it somewhere else for safekeeping! That file contains all your patterns.
The file-01.dat file contains any pattern data that you entered into the machine by hand. You can use the dumppattern.py software to view patterns and see which patterns are in which slot. Not all information is printed, like memo data, just the stitches.
Using it is simple, and you don’t need to be connected to the knitting machine to perform this step. Open up that terminal program and navigate to your directory where the software is. Type in python dumppattern.py img/file-01.dat (that’s assuming that the folder you chose before is called img).
The software will tell you how many patterns are in the memory and their sizes
You can view individual patterns by running python dumppattern.py img/file-01.dat PATTNUMBER where PATTNUMBER is the name of the pattern, usually starting with 901 and going up to 999.
Insert New Patterns
Now we get to the fun part, showing how you can make an image on your computer and then inserting it into the memory file so that we can easily make new patterns without the tedious entering-by-hand part.
The first thing we’ll need to do is make the image. The image must be 1-bit/2-color/monochrome/black&white. You need to make sure that whatever image software can save the file in monochrome. A free program on every windows computer that can do this is MS Paint – its crummy but it does this stuff kinda well.
A nice thing you can do is zoom in and click pixels. Remember that stitches in knitting are not square, so you may want to squish your graphic horizontally just a bit before lowering its resolution.
Again, make sure that its saved as a monochrome 1-bit Bitmap (BMP) file.
Next you’ll need to figure out the pixel dimensions (width and height). You can count the pixels or, at least under windows and some paint programs, they’ll report the image size for you.
Write down or otherwise keep track of the pixel dimensions for the next step.
Creating a container pattern
Our software can’t add new patterns to the memory file (we don’t understand enough of the format to do so) but it can edit existing patterns. So what we’ll do is make a blank ‘container’ pattern on the knitting machine. Then we’ll edit the pattern on the computer and re-upload the file.
In this step, you’re going to create the blank “container” pattern of the appropriate dimensions using the knitting machine control panel. This pattern is going to be 32×32 and will have pattern ID #901.
Note the pattern number that appears. User-input patterns get assigned a number in ascending order starting at 901.
Enter your pattern’s width (number of stitches), then press STEP
The number of available rows in the machine’s memory will appear on the display. Press CE to clear the display.
Enter the pattern’s height (number of rows) and press STEP.
Press INPUT once more to exit input mode.
Repeat for as many patterns as you’d like to create (and for which you have space).
Inserting the pattern
Follow the backup tutorial to transfer the knitting machine memory to your computer
Now you’ll run insertpattern.py by typing in python insertpattern.py img/file-01.dat PATTERNNUM BMPFILE myfile.dat which will insert the BMPFILE You made in part 1 into the pattern # location PATTERNNUM and when done, save the new data file tomyfile.dat (so you don’t overwrite the old file).
If the pattern size doesn’t match the image size it won’t continue.
Split the file
Now that we have the myfile.dat, we’ll need to split the file into tracks. This lets the emulator load the files back like it was a diskette. We’ve included a simple program to do this, its called splitfile2trakc.py and you can run it by typing in splitfile2track.py myfile.dat it will create two files, track0.dat and track1.dat.
Rename the files 00.dat and 01.dat respectively.
And drag them into your img folder.
If you’re looking for a simple way to accomplish all that file-wrangling, check out Davi Post’s img2track software that combines many of the above steps into one handy program.
Lastly, we’ll reupload the files to the knitting machine, see the next section!
Upload Custom Patterns
This step will show how to upload the custom patterns to the knitting machine memory from your computer. This is just for the ‘custom’ patterns, it wont overwrite the ‘built in’ patterns that are shown in the manual (those are built into the “ROM”).
Start up the disk drive emulator in the command line.
When “ready” lamp is lit, reset the machine’s memory by pressing CE key, then type in 888, then press STEP key. This deletes all stored patterns, so be sure to back up first if you have patterns on the machine you want to save! (The patterns included with the machine are stored on non-rewritable chips and can never be deleted through this method).
Clear display with CE key, then prepare to load new data into memory by typing 551, then STEP.
Display should go blank, then “ready” and “pattern no” lamps should illuminate.
Press 1 to indicate which “track” to load from the disk drive emulator, then press STEP.
Machine will beep when finished. Pick a pattern and knit as normal, according to the machine manual for knitting a pattern from memory.
We only tried this project with a Brother 930. Other machines may have different cable pin configurations and different data formatting on their on-board memory. We don’t have another machine so for now this guide is “AS IS” for the 930.
Check out these two Adafruit forum threads, where you can also find out about the Yahoo mailing list (not managed by Adafruit).
Valley Yarns 8/2 Cotton and Valley Yarns 2/10 Merino Tencel (Coltrain Lace), both from Yarn.com
If you like this project, try these others!
3 thoughts on “Hacking the Brother KH-930e knitting machine”
tell your friend andrew that his face is way too lovely to be covered up with a mask.
Becky, this seriously rocks! Love your work and innovation, thanks for sharing!
now I really want to make some generative one of a kind knit products
Comments are closed.