Electronics - Hacking the SX2 Mini Mill - (Adding a reverse switch and reverse engineering the tachometer port protocol)
Despite living in an apartment, I have given serious thought over the years to purchasing an X2 milling machine to CNC-ify. When I learned that Little Machine Shop had begun selling the SX2 mill which sports more travel, a better motor (500w brushless), and a belt drive compared to the standard X2, I caved and purchased it.
I knew before purchasing this mill that it had a tachometer display port on it much like the SC2 Lathe has. I also knew there was no way in hell I was going to pay 125$ for what amounts to an lcd and simple uC. So what's the logical thing to do in a situation like this? Hack it!
Step 1 - Trace the wires:
I pulled the side panel off to see where the tachometer wires were going and found they connected to the Potentiometer board which is used to control the speed of the SX2 mill. This board has 4 unmarked jst xh series connectors (thanks for finding the connector types Don) on it that include:
- 10 pin header that connects to the circuitry on the back of the unit.
- 7 pin header that connects to the tachometer plug
- 2 pin header for the fault led
- 3 pin mystery header
Step 2 - Become sidetracked:
What could this unmarked 3 pin mystery header be for? The center pin is connected to ground and the other two pins appear to be i/o lines that are pulled up to 5v via 4.7k resistors. Hey wait, doesn't the SC2 lathe which uses the same 500w brushless motor have a forwards/reverse switch? Hmm, and Little Machine Shop sells the SX2 and CN2 potentiometer and motor controller boards as the same product!
As it turns out, you can easily make the SX2 mill run in forwards or reverse just by grounding one of these pulled up i/o lines. Connecting the i/o line towards the inside of the case to ground (center pin) will cause the machine to run in reverse. Connecting the i/o line towards the outside of the case to ground (center pin) will cause the machine to run normally.
I wonder why they left this feature out? All that needs to be done to gain the functionality is to wire up a dirt-cheap two position three prong switch to the 3 pin connector.
Step 3 - Back on track:
With that distraction gone, I finished up tracing the wires and identifying what voltages (and signals) were present on the lines using a
DS1052E DS1102E (he he he) scope:
Upon completing this, I knew the tachometer port offered two ground lines, a 5v line, and three 5v digital lines (LCDCS, LCDCL, LCDDI) which would need to be decoded to display readings. To analyze these lines, I made a custom tachometer cable using a mating "7 pin mic connector" that I purchased off ebay. I believe the official name of this connector is an XLR 7-pin mic connector.
A quick look at the digital lines using a Saleae logic analyzer indicated that a burst of data is sent every 0.75 seconds as soon as the machines turn on. I'll call these bursts "packets" from here on out.
Zooming in a bit further revealed that LCDCS appeared to be some sort of frame line and that each packet consists of 4 frames. LCDCL, being the fastest toggling line, seemed like a likely clock line candidate and the sporadic nature of LCDDI made it a good data line condendor.
To give some sort of validations to these educated guesses, I tried decoding a few of the packets sampled when the spindel was at rest and then again when the spindel was rotating.
On a positive note, I found that by reading the data line (LCDDI) on every falling edge of the clock line (LCDCL), I was able to consistently read out the 4 19 bit frames. Thankfully, while the spindle was stopped, these values did not change.
10100000011111010, 10100001011111010, 10100010011111011, 10100011000100000
Looking at this data closer, I noticed the first 8 bits increment by one. This made me guess they were addresses and the last 9 bits were data. To confirm this I ran the spindle at different speeds and found that while the last 9 bits of each frame changed, the first 8 always stayed the same.
10100000:011111010, 10100001:011111010, 10100010:011111011, 10100011:000100000
Step 4 - Decoding the data:
It was at this point I wrote a simple atmega168 program to read the frames and dump them to the terminal so I could observe how the data changed as I adjusted the spindle speed.
From pictures and data gathered around the web, I was under the impression that:
- The tachometer display rpms increment by 20 (according to LMS)
- The display had 4 7-segments to represent the rpms
- The display could show a forwards, reverse, and stop symbol
- The tachometer display rpms actually increment by 10
- The display does indeed have 4 7-segments to represent rpms
- The display does display a separate STOP symbol when the spindle is at rest but it DOES NOT display forwards/reverse.
- The display updates at least 1 time a second.
Armed with this new information and a tachometer a buddy offered to lend me, I was able to quickly figure the rest out. The first 3 frames turned out to represent the 1000's, 100's, and 10's display digits. The final frame value never seems to change so I'm going to guess this is a "write to screen" control frame.
The first bit of digit frame data is always 0. The next 7 bits toggle the 7 segments of the digit on/off. To figure out what bits controlled what segments, I incremented my spindel speed by 50 rpms up to 950 rpms and recorded what the 100's place digit displayed.
The last bit of digit frame data is always 0 EXCEPT for the 10's place frame. When the spindel is rotating, this bit is 0 but when stopped, the bit is set to 1.
Step 5 - Test findings:
I wrote a quick and dirty arduino app (click for code) that connects to the port, processes the packets, then displays the data.
Here's what it looks like with the spindle at rest and while running (click on the images for larger versions):
Step 6 - Document the pinout and protocol
I figured it would be better to keep the "journey" log separate from the pinout/protocol data so I wrote this up on the pinout_and_protocol page.
I plan on designing and fabricating my own tachometer display which should cost nowhere near the ~125$ LMS wants for these. It would be nice if I could sell these in order to pay for this mill and fund my cnc build.
Kits are in! email me for info.
In addition, I plan on exploring the controller board of this machine some more. It is designed in a very practical manner where the motor driving circuit is on a main board and the brains of the operation (an Atmega8) is placed on an easily removed daughterboard. Surely some interesting hacks will arise from this design! :)
If you found this project interesting or helpful and have the means feel free to donate! CNC equipment is expensive!
Comments to date: 8. Page 1 of 1.
10:08pm on Friday, September 14th, 2012
I love the variable speed, but the low speed is too fast and geitntg faster. It started at around 600 rpm, but now does not get below 1000. Ordered a new belt to get the speed down (as the belt wears and gets narrower, the speed goes up. The motor seems to have the power it needs, so stalling is minimal. I don't have a big band saw, so my bowl planks are very out of round and chunky from the chain saw when I start, but I only had one (so far) that caused the lathe to walk across the floor. Probably would help to add some weight The main issue I have found so far is the the levers that hold the tool rest strip out very easily especially if you use the articulated arm. Shop Fox has sent me 4 sets of replacement, and I just stopped using the arm so I could keep turning. The banjo foot is a little short, and is hard to work around the larger bowls without the arm. (but possible) Customer Service has been great sending replacement parts when I need them. They even sent a replacement belt at no charge. The tail stock does not tighten into the correct position always, I have to put a twist on it when I secure it or it will line up a little to the left. With the twist it is spot on. It has no reverse, no hand wheel, and no way to lock the spindle in the headstock. All in all, it gets the job done, but does not have the polish and the craftsmanship of the bigger lathes. I have been able to turn 14 bowls, candle holders, lidded boxes, and most anything I have tried. Sometimes the pucker factor is high due to the speed, but I have managed.
Mark B guest
6:33pm on Sunday, March 18th, 2012
Excellent product at a fraction of the price of the orginal. Have them on my mini mill and mini lathe.
Andrew H. guest
10:55pm on Tuesday, February 14th, 2012
Love my tach. ran down to "the shack" and picked up a project box. took the project box apart, cut it down with my bandsaw and than milled it so the top would fit back on. Came out great!
L Davis guest
10:14am on Tuesday, February 7th, 2012
Service form Jeff was fantastic. Kit fitted and functions perfectly.
Mr T guest
1:02am on Sunday, November 13th, 2011
Love mine, if you have it built it or build it yourself , you may want to put the main 7 pin connector on the back of the board, this will give you better mounting and case options
Simon Foley guest
5:11am on Tuesday, August 9th, 2011
9:08am on Monday, July 11th, 2011
You raelly saved my skin with this information. Thanks!
4:24pm on Sunday, May 22nd, 2011
Very nice. Got to wonder why you didn't just attach the microproc straight to the sensor output though?