Sunday, October 22, 2017

Controller configuration

For initial testing, I would take my laptop out to the garage and use Grbl-Panel.


Slick as Grbl-Panel is, I don't relish ingesting a chip into my laptops' keyboard. So I am going to use an Orange Pi Lite as a grbl server. Prior to the advent of the Raspberry Pi 3, the Orange Pi devices were half the cost and came with integrated wifi, and had more powerful processing power - while the latter is no longer true they are still cheap, nearly expendable computers. I'm not sure the exact configuration I'll end up with but I have had 3 ideas

1. Get a Raspberry Pi touchscreen and go full touch interface.
2. Get cheap used DVI monitor/keyboard/mouse and use the OrangePi as a computer interface
3. Use server software and jog via tablet/upload gcode for production

I'm going to go with (3), with (2) as a backup. During testing I can use my cheap windows tablet as a pendant and during production runs I dont need to have any computer there except the Orange Pi. If this is limiting I'll add a monitor/keyboard from the thrift shop.

Orange Pi Configuration

I installed a fresh Armbian image, added my user acoount and enabled wifi (nmcli c up id <router name>).


First things first: perform an apt-get update, apt-get dist-upgrade to ensure the latest packages. Reboot and make sure your wifi configuration sticks.

First program I tried was grblweb. This is a nodejs-based program that allows you to control your mill remotely through a web browser. It looks fairly simple and well thought-out, the only downside to the naked eye is that github hasn't been updated in 2+ years.

Clone it from github:
 git clone https://github.com/andrewhodel/grblweb

grblweb is built on nodejs, so we need to install nodejs/npm and various dependencies:
 sudo apt-get install nodejs npm
 sudo ln -s /usr/bin/nodejs /usr/bin/node
 npm install serialport
 npm install socket.io
 npm install node-static

now you should be able to cd into grblweb and execute
 node server.js

Load up a web browser to the IP of the machine, port 8000 and you should see the GUI.

If you want to run it as a service (start on boot) you can use forever and crontab. First install forever
sudo npm install forever -g (g=all users) Then follow the instructions from the top answer at stackoverflow.

I went out in the garage to test. I was able to jog the mill with the graphical joystick on my laptop but this was problematic on my tablet - sometimes it would be interpreted as moving the screen, other times as a joystick jog. Additionally there weren't a whole lot of features to do interactive positioning or gcode playback. I was a bit disappointed - this is probably great for production use but I needed something more oriented towards diagnostics.

So I went to the backup plan - ChiliPeppr. The concept is that ChiliPeppr is a "hardware fiddle", a more-or-less generic gui for various hardware devices. By forking the code and creating workspaces, you can create interfaces for new devices. Among these devices are grbl devices. NOTE: if you are using Grbl 1.1 (ie: the latest release) you want to use this workspace, not the grbl one which supports 0.9. In order to talk to your mill you need to download the JSON server for your computer (arm in our case) (download link bottom-right part of screen) and start the service on the Orange Pi. Now with any other device on your network you can connect to your device (bottom-right) using a URL that looks like ws://192.168.1.10:8989/ws. Your device will show up. Before connecting, you must change the connection type dropbox to GRBL! This will cause confusion if you do not. Click the checkbox next to the arduino and you're connected. You can jog by clicking the "jog" button and clicking on the screen. You can play back the test gcode by clicking "play". The code will pause at tool changes, hit the pause button to un-pause. I chucked up a pencil and pressed it against a notebook on my bed... and it worked !  more or less. I lost a few steps in the x-axis at one point.

TL;DR: suggest using Grbl-Panel for diagnostics, ChiliPeppr for gcode testing.

Tuesday, October 17, 2017

y axis

With the x-axis working (at least, without load) on to the y-axis. Having two working axes is a big deal as you can then use it as a point locator. So you can zero to a known reference point, translate to the desired location then perform an operation (for instance, drill a hole) and get well-dimensioned parts even if not fully automated. 

The y axis is slightly more involved than the x axis. The motor is cantilevered ~100mm away from the mill requiring a solid print (with reinforcement). The x-axis has built in thrust bearings, whereas the y axis does not (the handwheel has a rubbing surface). Finally there's a keyway involved! 

The design will be similar to the x-axis in that we will be using an oldham coupler to link the motor to the leadscrew. A printed part will suspend the motor out ~100mm, leaving ~10mm gap between the motor shaft and the leadscrew shaft. 

First I designed the print. I cribbed off of this design. Reyer was nice enough to tweak that model for my x-axis (his mill had a different bolt pattern), but I decided to do the x-axis on the opposite side. I borrowed the idea for the y-axis but made several improvements, the biggest being I ran 4 M5x100mm bolts through the print to provide compressive force to the print. My issue with Reyer's design is he had about 15mm of bite on the nuts, and then the nuts ate up a good chunk of the cross-sectional area of the print - and I'd hate to see my stepper fall to the floor mid-print! 

You can see the model on thingiverse. It wraps around the y axis pedistal and bolts it to the mill, while bolting the stepper through the print. 100% infill, layers normal to the bolt direction. 15 hour print! 



Next: I bought a cheap thrust bearing off Amazon.  Pack of 3, I'll need the other 2 for the Z conversion. This allows me to tighten the print down to the Y axis and reduce the drag between the print and the pedistal.

I have two printed parts for the coupler, but only used the stepper side print. Clean it up and use a mallet to tap it onto the axis nice and tight, then tighten down with a washer and two nuts. 

I had to machine the inner coupler and the motor side. I don't have a drawing I more or less eyeball and test-fitted it. Kind of frusturating without the handwheel in place - I need to come up with drawings so other people can make the parts a priori. 



Here's the print bolted to the stepper with the motor-side coupler. The coupler is basically a 1" aluminum rod 25mm long with a slot and a hole in it, and 3 tapped holes to secure it to the shaft.


All mounted up. this took several iterations as the middle part to the oldham coupler was too long. Better than too short (easier to remove material than it is to add it) but still frustrating.


It looks a little funky because the top side and bottom angles are all different but the motor is flat relative to the mill. There is almost no play in the coupler - I put a dial indicator on the y axis and I could move it +/-10mm within 0.01mm after getting the steps per mm put in correctly.

Here's a look at that inner coupler. the other side looks the same except I didn't have to core out the middle. This side needed clearance for the nuts, the other side needs no clearance as it fits in the slot on the motor side coupler.



All assembled. Here's a video of jogging both the x and y axes. Very pleased to be here in 2 weeks of effort.



Saturday, October 14, 2017

x axis


I got the x axis done, last weekend actually! The X axis is by far the easiest and only needs 3 parts: the stepper motor, the mounting hardware, and the coupler to join the motor shaft to the leadscrew. 

Going backwards, I decided to use an oldham coupler to link the motor to the leadscrew. An animation of an exaggerated use case is below. The oldham coupler consists of 3 pieces aligned with two tongue-and-groove interfaces This allows play normal to the axis plane. TL;DR: offset shafts are not a problem. In my case I know the shafts are within a mm or two, but directly coupling shafts that are almost-but-not-quite aligned puts loads on bearings and lead nuts and whatnot that lead to wear an tear. By decoupling the axial torque from bending in other directions you keep the force you want and eliminate the remaining forces. 



I uploaded my x-axis oldham coupler to thingiverse. Here is the leadscrew-side press fit onto the end. You'll notice on thingiverse there are two parts to this print, the outside print and a thin print that fits in the fork of the leadscrew with holes. Several screws pass through the outer print into the inner print to transfer the torque from the coupling to the shaft. The print fits tightly eliminating slop. The other advantage (not realized until I printed it, but I'll take credit!) is that you can trim the inner print to get the alignment you want with the stepper, then bolt in place. 


Here's the stepper side. 2 sets of 2 M3 bolts grip the shaft. They are held in place by hot melt inserts like these:
The hot melts are inserted into the print from the inside. By screwing the M3 bolt into the print, once the bolt hits the leadscrew it will drive the hot melts up into the print and provide tension on the shaft (limited by the ability of the plastic to keep it all together - admitteldy this print is a bit light around the bolts(


These two parts are interfaced by the middle part of the oldham coupler (not shown - check out thingiverse). I had to fiddle a bit till I was happy with it: sand it down so the parts move smoothly but aren't loose and then coat interfaces with some white lithium grease. Finally, I dragged the laptop out to the garage


And it was time for a test:


Which was pretty awesome! When I tightened up the dovetails to eliminate backlash/play, though, the motor started slipping in its coupling. I will need to make this part out of aluminum and tap holes for the set screws. I'm pretty confident the other parts can remain plastic as long as I need them to.

Next up... y-axis!

Saturday, October 7, 2017

Electronics

I bought electronics for the conversion this summer. But of course other things got in the way. Assuming you have a little experience with Arduino and electronics this is more or less childs' play but even if you are a novice it is not all that hard to learn.

The first thing I had to decide on was how I wanted to talk to the CNC mill once it was built. There are two major ways that I know of. The first is LinuxCNC, which is comprehensive and has lots of features. Essentially it is a layer of software you install on top of your Linux OS. It is built to utilize high end controllers (like PCI/ISA cards, parallel port and ethernet interfaced industrial controllers, etc.) Having direct access to the hardware like this means they can do a lot of cool things, but the price barrier was higher than I liked. Cheap mill, cheap electronics! 

I decided to go with an Arduino based GRBL board. This board is an Arduino shield which interfaces four stepper motors along with end stop switches to the computer via USB. The firmware you compile and upload to the Arduino accepts gcode and then actuates the steppers per the gcode. The paradigm is exactly like that of a 3D printer. Definitely get one with the DRV8825 chip that is rated to a higher voltage/amperage.

For a power supply I picked this one which is variable 0-48v with a built in potentiometer. It also includes a second potentiometer and header so you can use an arbitrary length of wire to mount the pot wherever you like. The integrated display is a neat feature, it lags and is off by a few tenths of a volt but handy nonetheless. Nice thing about a variable supply is you can test at a lower voltage and then when you work with materials increase the voltage as high as you need. 

The steppers I picked up off of eBay are NEMA 23's with dual shaft. Do note that not all NEMA steppers are alike: be sure to look at the torque rating! 2.83 Nm (or in God's Units, 400 oz-in) is plenty but you will find many NEMA 23's rated at a fraction of that value. One of my requirements was to find a way to keep the handles on the mill for small manual jobs. Truth be told after some more thinking I really only needed one of these to be dual shaft (the Y axis) so you can potentially save a few bucks buying one dual shaft and two non-dual shaft. But trust me on the torque.

Eventually you will want end stops. These leaf switches are set up to trigger near end of travel and will cause the GRBL board to stop sending signals which would overdrive your machine. But for initial setup and testing, unnecessary. If you don't have them you will need connectors (0.1" header female) to connect the steppers to the board (I had spares aplenty from my 3d printer). And a computer of course. For testing your laptop is just fine. For the permanent install I will either use a Raspbery Pi with Octoprint (there is a GRBL plugin!) Octoprint is a 3D print server which allows you to upload your gcode over the network and it will stream the code to the device. 

So last night I wired up the stepper. Fortunately the auction had a schematic with wire colors but it isn't impossible to figure it out by trial and error. We are interested in "bipolar series" wiring since we have eight wires but only four connectors. On these steppers there are two pairs of two phases, and you wire them in series. 


Then you need to compile and upload grbl to the arduino. It is not as intimidating as it sounds, the step-by-step instructions are very clear. Once the firmware is uploaded put the shield on, connect power at 12v (lowest operating voltage) and connect the motor. Test wiring complete!

Now we need code to drive the steppers. The one I used is grblPanel. Grab the latest release and double-click the executable. Set the port to the COM port where your Arduino is and if all is well click (+X) and watch your stepper step! 

Sunday, October 1, 2017

Mill tear-down

So Robothon was yesterday. My metal combat bots were both 0-2 but neither was demolished; in fact they both still run. The next competition is at the end of January at the Northwest Model Hobby Expo, so I have a solid 3 months and some change to finish the conversion. 

Today I stripped down the table of my mini mill, because the y-axis has always been particularly sloppy ever since I got it. And I figure I should start with a clean, dialed-in machine. After cleaning chips and wiping down the machine I took off the x-axis by spinning the table all the way to the right and then taking off the handle and key. By jamming the table left to right a few times I was able to free the outer bearing and remove the table. The last bearing I took off by placing a crescent wrench against the bearing and then tapping it with a rubber mallet. Now the Y axis is exposed and the culprit became immediately apparent: the nut on the leadscrew is free floating in a slot in the y-axis table and is supposed to be pinned in place by a screw which was loose. Screwing it down and tightening the handle, the slop was instantly gone. Great, but I proceeded to finish stripping it down to clean and oil. Once the table was off I discovered the column was not properly aligned:



I loosened the outer two bolts and took a half-turn off of the center bolt and was able to rotate the column to visual alignment - once I have the table rebuilt I'll use an indicator on a magnetic base to confirm proper alignment. 

I cleaned off all of the packing grease I could find and rubbed everything down with an oily cloth and reassembled the y-axis. I tightened the screw which pins the leadscrew nut and tightened the nut on the handle to a comfortable tension and there was no visible play in the bed - of course once fully assembled I'll verify with an indicator. 


Tomorrow night I'll assemble the x-axis and work on confirming things are nice, smooth and aligned.

more successes

Next thing to do was cut something with multiple depths. Eventually I'd like to make some keychains for gifts and myself and family (wel...