Tuesday, July 22, 2014

Homemade CNC2 (Electronics - Part 1)

I needed the electronics to run the CNC. When I started out (and with my last CNC build) I have been running it with Arduino Mega 2560 with a RAMPS shield. You can immediately recognize that this is a 3D printer electronics setup. Indeed, I have converted my last CNC into a 3D printer to learn the in and out of it. So with this CNC2 build, I have also started with the same setup, which I happened to have laying around.

For the firmware, I have been using Marlin. In order for it to run CNC, I have to modify the configuration file to disable temperature sensing otherwise it would not move (this is a safety feature for 3D printer to prevent extruding before the hot end is hot enough). For the host software, I have been using Printrun.

This setup works out fine for a while, but then I felt that I will need more. First of all, the Marlin firmware does not work with inch as unit. In this part of world where I am living, the English system is still commonly in use. It is a lot easier to go down to my local hardware store to buy stuff in English then mail order then on Internet and wait for them to arrive. The second thought is that I know there are CNC specific firmware out there, such as GRBL. If I can have a firmware that not wasting the processing power on checking the temperature, why not go for it? GRBL has been proven working by years of experience in the community and it has a few neat features from what I read (such as command to change steps per distance). The third things is that while using Marlin, I for a few times have the firmware paused in the middle of a long run. I somehow suspect there might be un-found bugs in the Marlin firmware, at the same time GRBL is simpler (thus less chance of bugs), better tested (it is there longer than any 3D printer firmware), and I especially like its soft reset that retains machine coordinate while resets the processor state. So I have set to move to GRBL.

GRBL is very simple and easy to use. It is small enough (I have always loved simpler solution) that fits into the 32K memory of ATmega328P. I happened to have a few Arduino Pro Mini 328 (which I bought for a few bucks on eBay thanks to China). So I pulled out my AVR compiler and build the GRBL. After some struggle with the Arduino bootloader, I am able to load GRBL onto my Arduino (which I essentially used as a ATmega328P breakout board).

Onto my breadboard in a spare box, I have built a test CNC controller running GRBL. And I have added the GRBL soft reset switch to the front panel, as I really needed that "Panic Switch". I will find out why soon.

Thursday, July 17, 2014

Homemade CNC2 (Enclosure)

I have been playing with my new CNC, and have machined some pieces for the Y-axis extension modification. While I am machining the pieces in ABS (which is harder and more brittle compared to HDPE), I noticed that the dust from cutting is getting in the air and making me coughing. Since part of my use of the CNC will be to do circuit board routing, it may produce some other harmful dusts as well (circuit boards are made of fiber glasses, which is really nasty if inhaled). So I decided that it is time to make an enclosure for the CNC to contain the dust from cutting inside. In additional, an enclosure will be very helpful for the safety in case some thing goes wrong or some pieces flying around. (This proved to be very useful in an event happened lately).

So with some quick scratch and using the scrap wood I have laying around in my garage, I spent a couple of days to put together a quick enclosure. In order to leave me with un-obstructed access to my working area, I used a cantilever design so the front of the enclosure is without any supporting column. I am not going to put my weight on the shelves besides my controlling electronics, so this should work pretty well. The only problem with that is from the think Plexiglas sheet I have bought. Since the sheets are the most expensive piece of the enclosure, I went for the thinnest I can get. It still cost me almost $30, but the sheet is so thin that it warps. Without the front columns for it to be fixed on, it leaves some gaps between the front and side shields. Oh well, as we know, a perfect solution is a luxury that a home shop does not have. And that is part of where the fun comes from. I used some tape to keep the pieces straight and together.

So here is my CNC enclosure in place. It is not too bad considering how much it costs me.

Sunday, July 6, 2014

Using AVRDUDE with Arduino bootloader

I am working on a home built CNC project that uses Atmel processors as controller. In the process, I had gone through much trouble to load the firmware using the AVRDUDE through the Arduino bootloader on the chip. Here is to share my finding since I have a little trouble finding this information on the internet.

Basically the Arduino bootloader is default to 57600 baud 8-N-1 (circa 2014). Everywhere I searched on Internet (including the official Arduino bootloader page) has dated information, and specified as 17600.

The other information is that the programmer protocol must be set to "arduino" for AVRDUDE. So here is the correct commandline options for it:

avrdude -v -v -c arduino -b 57600 -P com9 -p atmega328p ....

Note that the baud rate (57600) has to be explicitly specified for this to work. I also found this information mentioned in this Sparkfun forum post, which is where I got the idea originally.

One more small caution with loading with AVRDUDE instead of Arduino IDE is that one will need to make sure that the chips is in bootload mode when AVRDUDE attempts to write to it. One way to do it is to perform a board reset (through a switch or short the right pin). But the modern Arduino bootloaders stays in the bootload mode in a very short time (mine is half a second), so you will have to reset it in a relatively short time window. But if the code is load through Arduino IDE (and proper Arduino hardware setup) there is no such reset needed. The way that Arduino IDE does it without using the reset is to use the DTR line (of the serial communication) to trigger the reset. On my setup I just connect the DTR of my FT232R module to a line marked GRN on my Arduino Mini Pro, and it works well without needing me to press the reset button any more for loading.

A few more words, I am using these Arduino boards essentially as a AVR processor board. The Arduinoo boards are cheap and readily available (thanks to industry scale and China), and it helps me to avoid soldering the tiny surface mount chips.


Thursday, July 3, 2014

Homemade CNC2 (Y Extension - Part 1)

Now I got the CNC working and made some test cuts on wood, plastic, and aluminum. Everything works beautifully. It is tight and precise after calibration. And what I like most about the traditional compound table and fixed head design is that I can change the tool bits between different cuts without losing the X/Y coordinates. This was not possible with my previous ShapeOko build.

While I am continuing back to build things useful, I quickly run into a limitation of this CNC. The Y travel of the compound table is only 43 mm (a bout 1-3/4 inches). That limits the parts machined to a very small size. I have mentioned in my previous blogs that there are a couple of ways to extend the Y range (such as Retromaster and 0xFRED). Personally, I think the method by Fred is a much better solution.

First, I went out and bought some small ball bearings from eBay for a few bucks (thanks to China). The bearing is of the size 6mm ID x 12mm OD x 6mm thick. It is small and fits well into the limited space there. The stock Y axis threaded rod is just a bit short, so I also got M6 threaded rod from McMaster-Carr (a great place to source parts, material, and tools). Note that by convention, the Y axis rod is always left handed, although it does not matter if you don't plan to hand crank it. I may replace it later, but for now the center driving nut is left handed, so to make things simpler, I got a left handed rod.

Since I have a lathe, I decided to turn down the end of the rod. I have also turned a small collar to go on the rod. Since I don't like the holding pin Proxxon originally used, I decided to use a die to thread the end that I have just turned down, and to hold the collar in place with a small nut. This has proven to be a bad idea (which I plan to fix later with a different design). As one can see from the picture here. The rod is made with soft steel, which is very difficult to machine. So the thread I made on it looks terrible. Further more, I found that the holding nut will get loosen after some time. But for now, that has to be it. I will have to make it work so I can use it. Proper solution sometimes is a luxury a home shop could not have.

So after measuring the sizes, I got the CNC to cut a part for itself. (A machine that can be used to build itself - sounds like a neat line) Anyway, I made the pieces with some 1/8 inch ABS plastic I have laying around. ABS is just strong enough for a temporary piece, and if my measurement is off I can make things fit with a utility knife (as shown in the picture above).

In another picture, the moving part of the compound table is sliding beyond the end plate of the Y axis. After everything is assembled together, I got to measure the travel of my new Y axis. It is now a whooping 100mm (just under 4 inches). Now I can finally cut pieces that are wider than 2 inches.

Here is how the new extended Y axis look like now. I will come back to fix the rod with a better design and remake the end plate in aluminum. But for now, it works.