Thursday, January 31, 2013

CNC update

I hit a milestone with my CNC project tonight, I made my first cut!

Here's the current state of it configured for milling:

I'm using the Zen Toolworks 12x12 , F8 edition. The F8 edition has an extended Z-axis travel on the gantry, which is needed to be able to use the device for 3D printing. One thing I didn't realize initially were that: 1) configured as a milling machine, the spindle will not reach down to the bed, and 2) the extra Z axis travel does not benefit milling as much, because the gantry clearance is one of the limiting factors. The two possible approaches to address the first issues are to either re-work(ie invent your own) the spindle mount to lower it close to the bed, or to build an elevated platform as your new work area. I decided to do that because it reportedly reduces error due to frame torsional forces. I could always build a new mount and remove the table. The Zen is pretty flexible in that way, a good deal of the design can be up to you.

I should take a moment to add how decent Zen Toolworks customer service has been. When I originally ordered the kit, they turned out to be back ordered, so they cut me a break on my shipping. When I finally got my kit, the first thing I noticed was that one of my power supplies was missing from the order. I emailed Zen support, and was sent a tracking number within minutes, and I got my power supply in the mail 2 days later. Everyone makes mistakes, it's how one deals with them that differentiates us. Goodonya, Zen.

So back to the build, this past weekend, despite recovering from the worst cold I've had in years, I spent most of Saturday in my garage building the raised bed. I used a couple 2x4's and a 1/2 inch piece of MDF. I didn't come up with that idea, I got it from scouring Google, I don't remember the exact place I read about it. I did not have the tools to counter sink the bed-mount bolts, so I figured that I will postpone that, and use the CNC itself to countersink. I'm waiting until I get some practice in using it, so for now, I'll just work with a reduced work area, and avoid the mounting bolts.

This bolt will be countersunk eventually. Also, I got lazy
on the platform wood-screw spacing, I eyeballed the spacing, and I was
pretty fatigued at that point, so they look pretty amateur. Oh well.

I decided to drive the system with a Sanguinololu, Arduino based board. That's not typical for CNC work, and the Sanguinololu is slanted to 3D printing work. I mentioned in an earlier post that a CNC mill contains a subset of the programming language used for 3D printing, but that's not entirely true. There are some G-codes that are specific to milling and "Subtractive manufacturing".

One of the missing features in Marlin are the "G54-G59" work coordinate system codes, that let you work in alternate reference coordinates while still maintaining the true, machine coordinate system. Without those, you have to use the "G92" (set position) command to reset where the machine thinks it is. The problem with that is that it's very easy to make a mistake that sends the tool somewhere it shouldn't be:
My first "heart stopping" moment with my CNC, I had not set the
coordinates up correctly, and when I ran my program, the mill plunged into
my sacrificial surface.

I'm using an AtMega 1284p in my Sanguinololu, the big daddy of the dip-form factor AVR chips. So far, my build of Marlin is taking up about 75% of that space, with most of it's bells and whistles enabled and with my additions. I think it will be a challenge to fit everything else I want to add in that last 25% (less than that since the bootloader takes up part of it).

Things I still want to add to the code:

  • aforementioned WCS support
  • LCD UI code for working with WCS (selecting/setting/storing)
  • possible software de-bouncing to the input encoder. I know from my power-supply project that encoder debouncing sucks, I hope to be able to use lessons learned.
  • Use for the one-free pin I have left, I'm thinking of adding touch probe support
  • Drilling cycle (G80-G83) support. I have that partially implemented, but I have to research Marlin's architecture more to do it properly.
  • Modify my backlight timeout feature to be run-time configurable.
  • try to merge in any Marlin updates/bugfixes

Another thing I changed was the bootloader. The bootloader that came on board was probably close to a standard Arduino bootloader (It did support Arduino 1.X. which a lot of people on the web had problems with). One problem is that it leaves all the pins on the AVR floating, which the stepper drivers interprete to mean "enable me". (Or at least on the Sanguinololu they do). I wanted the bootloader to drive the enalbe lines high, which disables the stepper driver. I also connected an LED to the /CS pin used by the SD card, under normal operation that line is held high, so it's a good "power on" indicator, but I also have the ability in code to blink it, so long as I'm not using trying to talk to the SD card at the same time. I was hoping SD card access would blink it, but it's too fast for the human eye to notice. 

I had some pain points trying to get the new bootloader working. The version of avrdude I was using was the one packaged with the Arduino 1.01 IDE. It worked with the shipped bootloader, but did not like the one I compiled. All the Google hits for my problems offered the advice: "Check your cables", "reboot your machine", etc. Hogwash. It would have taken me a lot longer to figure it out had it not been for my beloved AVR Dragon/Dragon Rider combo. I could debug the bootloader and found that the version of the source I had was not compatible with newer avrdude using the "stk" protocol.

Sanguinololu in the Dragon rider, this let me watch the
bootloader in the debugger.

Which brings us to today. I finally did a test run of a profile job for a nonsense part I made in FreeCad:
Ok, I fudged it a little, to be exact. You can't really measure Styrofoam
to sub-millimeter accuracy.

Here's the back of the machine:
I still have some clean up to do on the routing of the wires. 
There are two relays, on the left, there is a solid-state relay that drives the dual heat bed. In the upper right, this relay controls the spindle (in series with a manual switch for extra safety).

There is a custom board that breaks out the Sanguinolou extension header, and still allows me to "pass through" the ribbon cable to the LCD/encoder/ SD card read combo. I should do a separate blog post on the custom adapter I made, I thought it was pretty clever, and the result of a 100 idea iterations. The smaller ribbon cable runs to a custom board that has connections for the spindle relay control, the 3D printing fan controller (PWM'ed), the emergency stop button (not built yet, but I needed it today), and the one free I/O that I haven't figured out what to do with yet.

Building this thing has been a blast, but I'm thinking that the most rocking good times are ahead of me.


No comments:

Post a Comment

I welcome you're thoughts. Keep it classy, think of the children.