Reverse Engineering Knitting Machine Data
This page will attempt to describe methods of figuring out the internal data representation of data saved from knitting machines.
Additional information about Brother knitting machines can be found here
So far, all analysis of data formats has been done on the Brother model KH-930e machine. It's known that the Model KH-940 uses a different format, but it hasn't been figured out yet.
All software tools mentioned here are available in this git repository.
You are encouraged to fork this repository and contribute to the tools and to the information about the data formats.
PDDemulate External Disk Drive emulator
This python script (PDDemulate.py) emulates the Brother FB100 external disk drive. The knitting machine connection for the external drive is standard asynchronous serial data, but at non-standard (non-RS-232) voltages. In order to use it, you will need to build a serial adapter, as documented on this page. This emulator saves disk sectors to files on the host file system, for examination and modification.
The only way to get data in and out of these knitting machines is to save the knitting machine data to the emulator, examine and/or modify the emulator data files, then load these back into the knitting machine using the emulator.
Utilities for comparing different saved files
When comparing files, it's important to compare the data that represents one saved state of the knitting machine. For the KH-930 model, a single save writes two sectors of disk data. The PDDemulator script assumes this data structure, and automatically combines two saved sectors into one data file that is the actual saved data from the knitting machine. There is evidence that on the KH-940 model machine, a single save results in writing data to all disk sectors, implying that the saved data format is quite different. When attempting to reverse-engineer the data format, it's important to compare the entire set of data saved from the machine, by combining all the saved sectors into one larger data file.
There are a number of scripts in the file-analysis directory of the repository. Most were written for the KH-930 and will need changes to be used with other models of knitting machine. The following are of general use:
compare.py - compares two files and displays the differences between them side by side. filecombine.py - combines multiple sectors into a data file, probably needs to be copied and modified for different models makecsv.py - creates a csv file that can be imported into a spreadsheet for keeping notes, probably needs file length changed for different models
Documentation for the KH-930 data format
You can find information about the data format for the KH-930 machine in the docs directory in the file file-data.txt
How to reverse engineer the data files
1. You must determine how many sectors are saved each time you save one "file" from the knitting machine. To do this, save files and see which sectors are written by the emulator.
2. You must combine the modified sectors into one file for comparison between different 'saves' from the knitting machine.
3. Study file-data.txt to get an idea of how the data is stored. Most of the data is stored in BCD format, with each nybble (half of a byte) containing data. Pattern data is stored in a bot field, which is padded to the nearest byte or nybble.
The reverse engineering process:
1. Clear the knitting machine memory (on the KH-930, this is code 888)
2. Save this using PDDemulate.py
3. Change one (and only one) thing
4. Save this using PDDemulate.py
5. Compare the two sets of saved data. Document any discoveries.
6. Go to 3 (or goto 1 if needed)
That's basically all there is. This is very tedious work. The basic order I changed things in for the KH-930 is:
1. Change the variations once at a time (reverse, mirror horizontal, etc)
2. Create a small pattern and find the pattern directory entry and pattern data locations
3. Add a second pattern and confirm/extend this information
4. Add memo data to the first pattern
5. Change motif data and figure that out
6. save after moving carriage left or right and find that
7. Work the machine part way through a pattern and find the needle data for current row and next row, and the current row number
Things I know are missing from the KH-930 information
I was able to figure out a lot, including the way patterns are stored, but there is a lot that is unknown. I'm pretty certain that using more than two colors affects the data, but I do not have a four-color carriage for my machine.