Thursday, 23 February 2017

3020T CNC "Engraving Machine"


I bought a light CNC milling/engraving machine off eBay to mill PCBs and other parts in future. I'd have liked to try building my own, but that will have to be a project for the future, if I need a sturdier or larger machine.

The machine, of model "CNC 3020T" (which refers to its travel area of 30 x 20 x ~7cm), came pre-assembled in a large box. There are a lot of similar CNC machines on eBay/Aliexpress in terms of size and style of construction, and there appears to be the option of a model with ball screws, as opposed to the trapezoidal lead screws in the "T" model. I haven't had any issues with backlash yet, but I imagine that depends on loading and how worn the nuts are.

The spindle takes ER11 collets, so I also bought a set of them separately, as well as some PCB drills and V-bits. Some of the collets are sized for bits large enough that I doubt the spindle would have enough torque be able to mill with them, nor the machine have enough rigidity, but I shall see.

All I had to do after pulling the machine out of the box was fit the stepper motors and wire them into the control box that accompanied it - well not quite... The control box that came with the machine had a parallel port for interfacing with the controlling computer; I do not have any computers with a parallel port, and USB to parallel port converters are not suitable for controlling CNCs due to the tight timing which the step pulses must be adhere to for motion to be accurate and smooth.


Arduino-based control with Grbl: 


But there was an easy solution that brought the CNC into the modern era of USB - that was via inserting an Arduino, and making use of the fact that the original control box is fairly basic. It has three stepper motor drivers (one for each axis), a linear power supply (presumably with three rails to supply the logic, stepper motors and the spindle motor), and a PWM controller for adjusting the speed of the spindle. The parallel port on the back has two control pins per axis, which feed straight into the motor drivers via opto-couplers. The control pins are the "step" pin, which causes the corresponding stepper motor to move one step when it is driven high; and the direction pin, where high or low indicates the desired direction of movement. "Step/direction" is the exact scheme Grbl uses and is something of a standard in CNC. Some searching provided guidance on how the parallel port was likely laid out, but I tested the pinout by connecting an Arduino running a sketch which sent 100 pulses over a second, then reversed the direction before sending another 100 pulses, and so on, which confirmed that the pins were correct as one motor at a time started moving. This was after verifying ground with a multimeter and that nothing would obviously blow up my Arduino if I connected it. The pinout was as follows:

DB-25 Pin   | Function
2                 | X step
3                 | X direction
4                 | Y step
5                 | Y direction
6                 | Z step
7                 | Z direction
18 - 25         | Ground

The rest of the pins on the parallel port I left unconnected, as they are unused on my machine because it has no endstops nor extra axes, etc.

After that, I uploaded the Grbl CNC software onto the Arduino, then configured the steps per mm (400) and "inverted" the appropriate axes so that the machine follows the right hand rule and the back right corner is 0,0 (the back-right corner is just personal preference, as opposed to the front-left corner, which also works). This configuration was done via some Grbl serial commands which store these settings to EEPROM so that I don't have to re-send the commands every time on startup nor change a config file and then re-compile and re-upload Grbl. Here is Grbl running the CNC according to G code commands I sent manually over serial:





A dedicated control server:

Note: no USB hub is installed yet, so I just plug in either the CNC or the 3D printer
To avoid a big PC sitting in the garage alongside the CNC and 3D printer, I hoped to make use of a BeagleBone running OctoPrint to control both my CNC and 3D printer - it should be possible after all, what with both machines running on G code sent over serial. OctoPrint is a fancy webserver and G code sender written for controlling 3D printers via a browser interface; so any computer on your home network can simply connect up to the webserver on the BeagleBone to control/monitor the printer and upload jobs to it - no more tethering a dedicated laptop!

Well in theory - and indeed 99% of it is there, but OctoPrint wouldn't "connect" with Grbl and so let me send G code, likely because Grbl doesn't support some of the custom commands which RepRap firmware has for reporting temperature, version number, etc. rather than because Grbl lacks any basic G code commands. OctoPrint, as of my admittedly dated install, finds these custom commands crucial. All very frustrating given OctoPrint picked up the serial port fine and both ends supported the same baud rate and were communicating in plain ASCII.

So when controlling the CNC, instead of using OctoPrint, I use the stream.py script that comes in the Grbl repository. At present, this means that I have to SSH into the BeagleBone and transfer G code to it using SFTP, then start jobs over the command line instead of a nice, easy web interface - gah!

Some other hiccups along the way:

  • Ubuntu on the BeagleBone wouldn't detect hot-plugged USBs (restart needed every time the USB port was plugged/unplugged) - solved this by installing Arch Linux, which must've had a less-funky kernel, because hot-plugging works now (and more free space - didn't want a GUI anyway)!
  • The USB port on the BeagleBone would get disabled when I turned the power to the CNC controller off while the Arduino was connected to the BeagleBone's USB port. But how?! The Arduino was connected to the stepper drivers through opto-couplers (inside the control box). Even more puzzling, the solution was to change the USB cable to a higher quality one. One where the shielding was actually grounded on both ends. I don't think the BeagleBone was acting as a ground path, because it was on a floating power supply, and the control box, which does have a ground-referenced power supply, also has a grounded case which should stop EM emissions, so I can't really make sense of it. My laptop, also floating, had no issues with either cable.


Conclusion:


All in all, I'm happy with the purchase - nothing was broken or missing, and postage was quick. The control box is useful and easily interfaced with Grbl. I've got a post on isolation routing PCBs coming (and then also a post on the project that I made the PCB for), spoilers: this CNC is more than capable of making a good job of PCBs.