Showing posts with label stepper motors. Show all posts
Showing posts with label stepper motors. Show all posts

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.

Monday, 2 September 2013

Building a CNC Router/Milling Machine

As my next big project, I am going to be designing and building a CNC milling machine. I am aiming for something that will have a working area of at least 700x700mm, be able to cut steel and still maintain accuracy on small scale objects such as is needed for PCB milling.

For the machine's electronics I am going to use four, possibly three NEMA 17 stepper motors driven using StepSticks on a Sanguinololu. I decided on a Sanguinololu over an arduino and GRBL shield because the Sanguinololu has more memory and came out at the same price (self-assembled) as an arduino and GRBL shield. The Sanguinololu also has a lot of expansion capability with four motor drivers and two fairly high power MOSFETs to name a few. This will all be powered at 12V using an ATX power supply. I wouldn't use an ATX on a 3D printer due to the high-current heated bed which needs a very large 5V ballast to get an acceptable 12V line, but since this one will just be driving some motors which don't need much torque, it won't matter if the voltage dips a volt or two.

I am going to go with a gantry design which moves the X axis to allow Y positioning while having a stationary bed, unlike a 3D printer. As for movement, I am going to use ACME leadscrews, probably only single start to save money at the cost of speed and I will definitely be using some anti-backlash nuts. Once again, single-start nuts are much cheaper and more widely available than multiple start ones. Also, there is a place locally which can supply ACME threaded rods.

The frame will be made of MDF, but once the machine is up and running I will use it to re-create some parts in aluminium if I'm not happy with them. 

The ways will have to be very sturdy to meet the requirements, but linear rails and bearings get very expensive, especially when they have to be thick, so I will create my own linear rail system using 608 size bearings (sometimes known as skateboard bearings) and steel which can be had from local steel suppliers. There is a local supplier in mind that sells in qualities ranging from structural-use to precision-ground engineering metals. The idea will be to get the sturdiness in the rails from  much cheaper, slightly less accurate square tube steel which may not have the best surface finish. Then mounted to this less well-finished square steel tube will be some much more precisely finished flat steel bars which don't have to be all that substantial as they will just act as a good quality surface for the bearings to roll on. Obviously the supporting steel tube cannot be absolute garbage which varies a whole lot over its length (unless I look into a shimming system which can still keep the rigidity). I am hoping that this approach will both save some money and also allow the contact surfaces to be replaceable if they wear out.

As a spindle, I will start off using a rotary tool/Dremel. Later on I will use my lathe to create a much better spindle with a good quality collet and bearings and be powered by a brushless motor and ESC, perhaps an RC car one if I can get away with it not overheating. This may require a power supply upgrade depending on the size of the motor I choose, but regardless has an extra advantage of being able to control the ESC using a spare Sanguinololu pin.

Will I be using the Mendel90 to create any parts for this machine? Probably not anything critical, as the machine has to be as rigid as possible. Perhaps I will use it make some vacuum attachments and an electronics enclosure.

Here is some of my progress so far:
I bought 5 low resistance NEMA 17 motors for about $60 off AliExpress from Wantai motors, shipping was quick (about a week because I chose Fedex IE) and communication was pretty good, but be very vigilant when shopping on AliExpress. For example, always try to make sure, by choosing fast shipping and taking into account a seller's dispatch time, that the item will arrive well before your credit card dispute window closes. If the seller charges an exorbitant fee for anything but default, slow shipping (which can take over a month), don't buy from them. This was one reason I didn't buy a cheap Sanguinololu from some other seller on the site.

A close-up of some StepSticks off eBay, all soldered up and ready for testing. It cost about $30 - 40 for four of them. In the previous photos you could see five, as I had a spare one from a previous purchase.  I will now have two spares for the CNC and 3D printer once done as the CNC will only use three.

The stepper motor and StepStick testing and calibration set up. Every motor and driver worked and there were no problems.

A Sanguinololu from Think3DPrint3D on eBay. I bought it un-assembled to save money and because I wanted to play with a new (budget) soldering station I had bought. I replaced the 2.54mm pitch molex connectors which are supplied for the motors, hot end and bed connections with 2.54mm screw terminals. These screw terminals have the advantage of being able to carry more current (good for a heated bed) and also of removing the need to assemble a connector onto the wires you want to connect. Due to the need of crimping to assemble these connectors properly, which requires an expensive tool, or a painful and slow hand-assembly method, I do not like them. The end-stops were the only ones on which I kept the molex connectors. For the thermistor connections I put headers instead of the 90 degree molex connectors in case I ever have to use this board for my Mendel90 where there is not enough space when mounted for the 90 degree connectors.

The board went together fine in a few hours of soldering (split up over bits of my free time), and I managed to solder the whole thing with no bad joints (yay!), although I soldered a MOSFET a bit wonkily.
I haven't fully tested the board yet, other than having tested the USB and FTDI chip early on during assembly, then later checking for shorts with a multimeter after which I looked for solder bridges, all I have to do now is bite the bullet and plug it in.
Well, that's it so far! As I progress with the design I will post updates.