 I'm Stuart Childs, and I have no notes for my talk, so this is going to be freestyle. I'm going to talk to you today about controlling a CNC milling machine with Bealbone Bucking Machine Kit. To start off with, I'm going to tell you a bit about myself. I like laser cutting quite a bit. That's something I do a lot. That was my first foray into CNC-ing, I guess, and sort of going from computer to controlling a machine and moving things around. So, I enjoy laser cutting quite a bit. I also, after having done that for a while, and laser cutting a lot of acrylic and wood, got drawn in to milling. I mean, just look at those metal chips flying off there. Look how cool. So, this thing for me was like metal is so real. It's a real solid thing. Acrylic is quite brittle and wood can burn, and that's kind of acrylic, but metal was quite a draw for me. So, this idea of CNC milling, CNC machining, that's great, and I really wish I could see my notes. This is the mill slightly less cool than the other one. I mean, that one looks pretty cool. It's got a massive bit there. It's got maybe that could be squaring some lubricant out or blowing those chips away with some compressed air. That's a really nice machine. It's probably a fairly expensive machine. This is the one that we got hold of. I'm going to say we quite a lot in this talk, and it's not the royal we. It's the we as in my friends and I, so Matthew Venn, who was at the previous talk in the slide before. Some of you may have heard of something I called Andrew Back. He's the owner of this machine, and he's the one that's responsible for me, well, letting me adapt it. Now, handily, the axes on these machines are labelled. That's the x-axis. This is a three-axis milling machine. There we go. Which is great because that makes it easy to see what you're doing. If you're going from an on-screen design to controlling a machine, it's just really nice to have those labels. There's some machines that don't, and it makes it really annoying. With milling, this milling machine, we have this bed moves in the x and y, like that. The z, the spindle or the head moves up and down. We have a sacrificial bed on this machine. This is a piece of MDF. We have this here in case we want to cut something out. We would clamp our work piece onto this bed. These clamps here would allow us to maybe clamp a big lump of metal or a big lump of wood onto the bed. The head will move around and the head moves up and down. That's the head there. We've got this big green part on the top that moves up and down. The thing that says easy change on, that's a tool holder. That allows you to easily remove the milling bits. The milling bit on this is there, just about there. It's about 2mm diameter, so it's not the biggest milling bit in the world. We do have slightly larger ones for this machine, but when we started out, we thought, let's just go for a nice small one. Incidentally, using a small milling bit like that can lead to breakages. If you're too forceful with it, if you start moving your lump of metal around too quickly, with your very small 2mm milling bit in it, it can snap, which gets annoying rather quickly. This is a slightly fancier CNC milling machine. I think this probably has six or seven axes and it looks a bit more like a robotic arm than a traditional mill. This allows for some really quite funky, I guess that's maybe prototype. Maybe that's doing it out of a foam or it might be being used to then make the mould for casting so that's just kind of for prototyping. That gives you an idea of the stuff you can make with a multi-axis machine when you get to sort of four, five, six axes, that kind of thing. Now milling machines used to look a bit like this. I really like this picture, it just looks so dangerous. Can you imagine this going on today? So big handles, these handles would move the axes. This is the mill operator, that's the guy that knows what he's doing. Presumably he's working from a drawing or from memory perhaps, but I really like the look of that machine, it just looks dangerous. It looks like a mean business. That's what these used to look like. You can retrofit these old machines. This was put together yesterday. This was utilising the internet to find lovely pictures. I really like the way that this guy, presumably Guy, the person that changed this, has left the handles on. That's really nice, he's got some really quite serious motors. It's a big machine. I kind of like the idea that when this machine is working the handles also spin round. I don't know if maybe there's a decoupling mechanism going on but it might be quite dangerous to be near when it's running. What I wanted to get at with this is taking the manual milling machine. We've got a bed here again, we can move the bed in X and Y and it looks like the bed lifts up on this one rather than the head going up and down. You can take an old machine and you can retrofit it with motors. So that's great. The machine that we worked on was built as a CNC machine from the start. So there's no handles and we've got, compared to the last one, relatively small motors. There's just that one there compared to the size of the other guys, the other person's one. He's got some fairly serious motors on there. Now, to control these motors, we don't have a mill operator like in the Black and White photograph. We have computers and this is a wonderfully modern example with paper tape reading down here. So you'd feed your instructions, which most CNC machines run off the programming languages that is known as G-code and it is widely used. It was standardised a long time ago, I think maybe until the 50s and 60s and it's evolved and there are some slight variations. But most machines will run on some form of G-code. That's like an early example of a computer that would be used to control a CNC milling machine. You've got presumably a green screen and there'll be a bit of information on there and you'll be able to position the bed and move the bed around where the interface will have been. You'll know your machine before you use it. Now in the era of single board computers, we can do the computer control of a CNC milling machine much more easily. This is a Beaglebone Black for those that don't know. It's a single board computer. It will run Linux. It's got HDMI out. It's got a load of GPIO. The really interesting thing about the Beaglebone Black is it has on board two things called PRUs, which I think stands for Programmable Real Time Unit. The great thing about those is if we want to use a computer to control motors for a CNC milling machine or a CNC machine of any sort, those motors require quite strict timings. If you want to control those without missing steps on your stepper motors and losing position, you want to have rock solid timing and you can't do that with a standard Linux kernel. You either have to patch a custom Linux kernel and build one which is like a real-time flavour or you can use a custom image for this arm chip which makes use of the PRUs, the Programmable Real Time Units and they'll deal with all the complicated and solid timing stuff. Just as a disclaimer in a room full of, well, more than average Linux enthusiasts and hard cores, I am not a programmer and not an electronics engineer so just kind of a disclaimer on the talk and it was also a few months ago that I did this project so it's kind of digging it up. The cool thing about the Beaglebone is it's a single board computer. It's tiny. We can fit it in the control box for the milling machine. It has the real-time stuff on board and it also comes with a series of capes which I can't see. It comes with a series of things they call capes which if people are familiar with Arduino's they have this thing called shields, like an add-on board basically which gives you different inputs and outputs. We've got the Beaglebone black here and this is the braincap board or the cape a company called Probotix. What this does is it first of all gives you protection between the Beaglebone black, the sort of sensitive electronics on the Beaglebone black and then the big dirty motors that we've got on the CNC machine. It also gives you a range of nice terminals that you can use. The really nice thing about that is again you can get it and you don't have to do any soldering you just plug in together and you know it's going to work and it's designed for CNC control so that it makes it really easy. In our system we've got let's take a bit of an overview we've got the computer here and we've got our milling machine and we want to connect our computer to the milling machine and we want to get it to be driving the axes around. Originally the milling machine came with a rusty old RM box I think it was out of a school it had proprietary software controlling it and the PC looked like it had been stored out it was rusty it didn't power on and it was to the point where like right let's get rid of the old control PC let's not bother trying to find out the software that should control the machine let's rip all that out and then go with the Beaglebone Black so we've got the Beaglebone Black but we can't connect it directly to the machine so the first thing we want in the chain is this cape or breakout board the next thing we need to go in between the breakout board and the machine are stepper drivers so the most common motors for CNC machines are stepper motors some use servos as well but steppers seem to be more commonly used they're cheaper, they're more reliable we did have stepper drivers in the control cabinet of the milling machine when it came but they were very they were on a board that was quite intertwined with the proprietary interface with the old computer so we ditched all that and we got these fancy new stepper drivers from RS which were very nice to work with again lovely terminals lots of documentation available so they were super simple to connect up and we had three of those so that was RXYZ so now we've got the computer the computer is protected it connects to the stepper drivers the stepper drivers connect to the motors now we can move the axes around that's great the next thing we had to do was spin the spindle so we've got our computer we can move the axes around, that's fine we want to spin the spindle as well the bit that holds the milling bit down here is the existing spindle drive board that was in the control box now that expects 0 to 10 volts as the control for the speed of the milling bit but we were getting 0 to 5 volts out from the computer the beagle bone so we've got this thing in the top left the spindle v5 board there's a guy in the UK somewhere making those and that will take the 0 to 5 volts in it will opt to isolate it and give you 0 to 10 volts out we've got about 100 odd 100 odd volts on here to control the motor and we don't want that to go back into the beagle bone I did that a while ago on an old board and we broke it so the opt to isolation fixes there so that's what allows us to control the spindle so if we now get back to our lovely simple system diagram that's kind of what we had to do to give us control from the beagle bone to the CNC mill so let's have a look at the hardware that's the rusty old PC unit that came with it and that's the machine we had to take this cover off and we never really got round to putting it back on yet it was a big lump of plastic and it made it really difficult to access any of the bits you can't really see but down here this is the original control cabinet that housed the electronics for the machine as well we'll take a quick look inside there but that's what had the original stepper drivers and the interface between the computer and those there we go it was a really nice box to work in it was great I think it's 1995 it was made by a company called Denford who were based in Brickhouse which is not very far in our direction and opening up the cabinet was great and there was space to add extra stuff so we could put something in here we had a bit of room there all of the wires were labelled which was fab not only were they all labelled but we had schematics and we had documentation provided by Denford online and they also have a forum which is great they have their staff advising you how to hack and modify their machines that are 20 years old and they have no qualms in doing that and I think that's great that's really they're aware that people might not want to use their old software or their old computers they're aware people are going to get hold of these machines these machines you can get for 700 quid, 800 quid online on everyone's favourite auction site and they're really good quality it was a bit of pressure working on something this nicely laid out it made me up my game in terms of wiring things and everything in the right place because I wanted it so and making notes so if people went back to what I'd done they could maybe see what bits I'd changed and make sense of it rather than what quite often happens is just wires everywhere 50 of the same coloured wire attached to the same circuit board this was the original motor control so this is a nice big lump of aluminium that was mounted into the board it's all labelled nicely lots of inputs and outputs this dealt with the commands from the computer to the driving of the stepper motors and things like limit switches and home switches on the axes this board is sat on this on top of this board on this row of pins here now I have modified another one of these machines and what I did was retained this board and flew wires directly from a parallel port onto here to get to you I think these are the stepper drivers here so I kept this board because it had power on it and it had the stepper drivers which allow you to drive the motors but it wasn't that elegant really I mean it kind of worked but it wasn't super super elegant and I couldn't really afford the fancy stepper drivers that we could buy for this project so it's quite nice to see all that stuff but I got rid of those two boards but what I did keep is this nice lump of aluminium because it was already cut it fit into the control cabinet and it also acted as a bit of a heatsink for these drivers now I think these are rated up to about 7 amps and we ended up only setting them at about 1.6 or 2 or something like that so they haven't got warm yet but it was nice to just mount them on that big lump of aluminium there so that was ready to go in is it in? so yeah so I also discovered for the first time these I'm going to call them ferrules that was a really nice way of you crimp them on to the end of wires that you've chopped and then they're really nice and tidy and they'll just go into these into the screw terminals and make it neat so that's the stepper drivers there and then this is the the breakout board from the Beaglebone so these are all going so that's x, y and z axis going into here because the Beaglebone Black has the HDMI out Cat5 and USB we made this plate to go on the outside of the cabinet that just meant that we could access the ports easily without having to open it when the machine's running which meant we got to bop massive big holes in the side of this metal cabinet which again was quite fun sadly don't have any pictures of it but that was just marking it out so the nice thing about this project was there was a mixture of the hardware and the hardware and then you get hands dirty and putting holes in big lumps of metal and then wiring things up and hoping they don't go bang incidentally that's lots of notes taken along the way and calculations made and checks and double checks I said before, Denford provided lots of schematics and sort of diagrams of the cabinet which is great it really helped apart from there's about five or six different configurations of this particular machine and control cabinet so sometimes it was detective work it wasn't just reference and that slowed things down but you can't fault them for providing enough information now this shows us the spindle control in place so that's the existing board there that's the board that goes in between the big over the 0-5 conversion to 0-10 so it's there it's wired down to there we also had once we'd got the sort of motors wired in and we could move the machine around which was great nothing had started smoking yet this is a limit actually a homing switch so it has a homing switch on each axis this is just in there and what this allowed you to do is once you turn the machine on you can tell it to go to it's datum point which is kind of it's 0-0-0 and these homing switches if they're wired in back into the beagle boners inputs that will allow you to do that and the machine will go to a known homing point it doesn't have limit switches on the other end of the axis but you can set the dimensions of the machine in software so you can say I'm 200mm wide if I know where home is you're not going to go past the end so let's quick look at the software then this machine kit machine kit is a fork of linux cnc linux cnc's been around for quite a while machine kit I don't know I think it's quite young 2014 maybe cool thing is it will run on arm as well as x86 they say here you can control not just the machine tool but quadrotors robots I really hope that no one does that and I mean I haven't seen them do anything but being used for cnc machines but it's pretty cool they have a really nice community that's active there's regular commits to their github and their mailing list or their google group is responsive they'll get back to you it's based on Debian and that's it's quite confusing because I've done stuff with linux cnc before this is a machine kit and it still has linux cnc as this or default thing so it's slowly being all moved over machine kit linux cnc is quite awkward I have sometimes referred to it as linux cnc rather than machine kit but that's the sort of interface you get in software once you've got it all working it wasn't super simple plug and play though we did have some issues and we had to get some help from the HAL but in this sense it's the hardware abstraction layer which is great wow so we've done all the wiring physically we've wired our outputs from our breakout board to our stepper drivers and then into the motors but we need to do all the wiring in software as well and tell the software what to expect and what GPIOs to use and that's what the HAL file does it's text file you edit the text file and then you get a machine kit or linux cnc and completely tailor it to your hardware which is fab that's one of the things that makes machine kit or linux cnc so usable I mean you go in you edit a text file and then you can get it working so we got it working you get a readout and x, y, z you can move a machine round that was great it's such a to go from a dead machine with a rusty computer and a few circuit boards and then having to connect them all up and trying to mash it all together and then get into the point where you've got software running and you can use your arrow keys to move this dangerous looking spinning metal thing around and then you get to that point and you're like really excited and I've finished all this stuff and then you get into what I'm going to call linux cnc which is you can speak to people who used to work as production manufacturers and they know how to use a machine and they know what to listen for and they know what to expect and they know how to use things like this which is a dial gauge which is a very it measures things I think it's hundreds of a millimeter which is quite small to calibrate the machine so we use this once you've got your hardware and software setup and you say right I want the software to move the bed half a millimeter this way and then half a millimeter that way you can use the dial gauge to make sure that it's doing what it's saying and quite often there'll be small tweaks you'll need to make to make sure it's giving you an accurate representation of what you're expecting from the software and part of the joy of cnc control and machining is it's not just you get your machine, you plug it in, you press go it works that's cool that lots of people are familiar with laser cutting or 3D printing not so much but it's relatively easy you could teach someone laser cutting in a day and they'd happily do it cnc machining is this there's so much to learn about milling bits you need to cut different materials how quickly you'd like to do that what materials are suitable what to look out for, what lubricants to use but it's popular it's getting trendy now this it's called Pocket NC I challenge anybody I have it it's as pocket sized as the Raspberry Pi is credit card sized I think I'm going to say but it's lovely though it was kick started it's a pricey bit of kit it'll set you back 3,500 US dollars but it's pretty cool and they have a YouTube video of it milling a small v8 block out of aluminium which looks pretty cool lovely machine, I believe it's five axis control with machine kit with a beagle bone beagle bone black and yeah, lovely that's kind of one end of the scale of what I'd still call hobbyist I guess the other end are these sorts of things there's loads of projects making your own DIY CNC mill key things about mills really it needs to be solid and sturdy it needs to be sturdier than the stuff you're machining for this one I guess the build for this would be probably a couple of hundred quid maybe unless you can, if you get the motors out of a photocopier or something you can find bits often they have dremels as the head but this one's got a motor there and it's coupled to a bit and presumably a bit somewhere down there again he's got a dial gauge so at least he looks like he knows what he's doing I thought I'd best prove that we had actually milled some aluminium on our machine and it was working again this is part of my transition from laser cutting and lots of things to cutting things out of metal I haven't designed a lot in 3D CAD and this is a whole other world of things it's like ok you need to design things in 3D and go from a 3D model into something which will move your machine around so I'm taking it slowly started cutting things out of sheet as you know still relatively 2D and that's one of the first things we did which is a mounting plate for a d-sub connector but it's out of aluminium and it's there and it's solid and it all came out the right size and the right scale so there's loads to learn and we'd love to talk to you more about that as we go on I wrote this project up as a series of 3 posts which will probably have a lot more detail than I squeezed in today if you go on to the information superhighway and search for DesignSpark CNC milling they're the first 3 hits on it and that's the end of the talk and ask me some questions if you have any