Sunday, September 16, 2012

Drawing Machine

So I've built my first CNC bot, a drawing machine. Because that wasn't quite difficult enough on its own I decided to make one that uses polar coordinates. That is, one with an arm that can spin on a base, and move in and out relative to the centre. It gives you a very large drawing surface with a minimum of moving parts compared to a standard x,y Cartesian plotter. I was inspired by similar projects online, like the eggbot and the polargraph which uses a dual polar coordinates system; mines a single.

The general setup is a pair of nema-17 motors, being run by dSpin motor drivers. Nice chips, you can set them up with your parameters in terms of what acceleration and max speed you want as well as the micro-step mode and after that you just tell it to move forward X steps. It handles all the movement profile and it also has a full suite of protection systems built in. They communicate over SPI to an Arduino, which is then hooked up over USB/serial to a laptop running Processing. Yup its definitely convoluted but oddly functional. The laptop is used to convert and process an image, and send the required movements line by line to the Arduino which just relays it to the dSpin boards. I will be posting code a bit later once I make it slightly more friendly than the convoluted mess it is in now. You can see the set up to the left.

One important note, if you use a solenoid for the pen lifter you need a really good diode to drain the current when you depower it otherwise the back EMF does bad things. I blew up the pull up resistor on two output pins on my arduino before I figured out that my 1N4004 diode just wasn't working. In the interests of overkill I added an optical isolator and a schottky diode rated at 600v and 4amps with a 4ns response time. Over-specced, but only $1.20 delivered.

Here are some videos, first the movement test:

First drawing:

After that first test, and showing the project off at my first makers faire, I rewrote the code so it automatically converts the coordinates from polar to cartesian so it gets rid of the distortion. I still get a few rounding errors as you can tell by the slightly wavy baseline, it also now skips over white space and goes a whole heck of a lot faster.

As for the build. I will start with the easy part, carpentry. Because my pen holder design has limited travel I needed a fairly flat and true surface or else I would end up with gaps and extra lines in my drawing. I decided to go with a torsion box design build out of a bunch of scrap 1/4" baltic birch I had in my shop. Its slightly overkill.

Once I got it glued up and assembled using every clamp in the shop, plus an anvil, blower, forge, and anything else heavy on top. I needed to cut it into an arc. So, one nail, a piece of wood, a workmate and a bit of creative stacking I got it set up next to my bandsaw.

I should note around this point that I wasn't really working from plans, or a design, my process for prototypes like this is more.. I don't know.. industrial jazz? Winging it while machining? Something like that. The goal was to get it working and then worry about making it pretty, which I will get to eventually.

You can see the rotation axis in the image on the right. General plan is that I have a large lazy susan bearing attached to the base. Also attached and stationary is a 52 tooth gear off a 1970's bike. The gear and chain are basically stationary while the motor runs around on the inside of the chain. I built my own jackshaft assembly that lets me hook up the 11 toothed sprocket off a rear derailer to a 60 tooth timing belt pulley, this is in turn hooked up to a belt and an 18 tooth pulley on the motor. Simple right? The reason for the arrangement was to gear down the motor and get a bit more resolution on the arm. Trade off is that I have about an inch of backlash. I need to build in an idler tensioner so I can tighten the chain without it binding and that should cut it down some. If that doesn't I will just measure the error and write it into the code.

That is the process for the jackshaft build. I couldn't fit the bearing holder plates on my small lathe so I cut the bearing seats using a rotary table on my mill. You need to get the holes about 4 thousandths of an inch undersized for the bearings to press fit in securely. The shaft is steel, and from personal experience the set screws and flats are mandatory, I spent about an hour debugging my code till I figured out that the timing pulley was slipping. The holder for the 11 tooth sprocket is pretty easy and straight forward, a piece of aluminum bored for the shaft diameter and then a seat was cut slightly over 1cm (the size of the inner bore of the sprocket) the whole shebang was press fit together and a hole was drilled and tapped for the set screw. Come to think of it, its amazing on projects like this how the definition of easy changes over time.

The linear movement is shown to the right. I cheated and used a commercial linear slide due to its higher strength, accuracy, and durability compared to anything I could fabricate at home. Also, it was only 40 bucks. I couldn't make it for cheaper. To drive it I put a jackshaft at the end with an idler pulley, and mounted the motor behind the slide. I ended up building a small clamp to hold onto the belt using friction. Its pretty bodgy but it works.

The photos above show the construction of the most important part of the build, the pen holder. Made out of scraps on the lathe and mill, for a prototype I am pretty happy with it. Actuation is achieved with a 12v solenoid coil and return spring. This is version two. Version one was an attempt to move the pen linearly, straight up and down. It jammed a lot. Rigging the pen on a pivot like this is way more rigid and reliable. I am already starting to design version three. The problem with this one is that its hard to get set up correctly. The pen has to be adjusted till its in the exact right position, too low and it will dig into the paper, too high and it wont write correctly. Adjustments are fortunately easy, one set screw holds the pen in place inside the tube. This design allows the machine to hold everything from a pencil to a fat sharpie. The mount point is also rigged so that no matter what size pen it always centres to the same point relative to the linear slide. Oh, one other important modification, I packed foam between the solenoid driving rod and the pen pivot, this allows the system to have a bit of give to account for variations in the surface. My next plan is to set it up so the solenoid lifts the pen, this will mean I have to add a parking brake so the pen doesn't constantly sit on the paper when its depowered, but should make the whole thing a little faster and allow me to set the pen tension with a spring rather than uneven coil pressure.

The image to the left gives you an idea on the resolution I am getting, the scale is in centimeters. This is with me running the motors at 1/16 microstepping, the dSpin drivers let me go up to 1/128th so its possible to get really really fine resolution out of it.

Oh, and as for suppliers (I have no connection to any of these companies but I am posting links so it might help you chase down some of the more obscure parts).
Sparkfun for the dspin driver breakout boards
Solarbotics motors electronics etc - also carries the sparkfun dspin breakout boards, based in Calgary.
Misumi - Motion control components so all the pulleys, belts, linear slides, bearings etc.
Lee valley carries the big lazy susan bearings.
Digikey canda - the old standby, now has a Canadian warehouse. Their catalog and inventory is the most overwhelming thing I have ever seen but they carry everything. I got most of my electronic components, and a big 12v 6a power transformer from them.


Unknown said...



Rohane's blog said...

I love this design. Excellent work. Is there anyway you can comment on the software and methods used to control the movements?

russ holt said...

I am trying to figure out how to get the stepper motors programmed to work independently in Arduino via dSPIN commands. I know the post is old - but I hope many find it - this is (to me) a FASCINATING and well done project!!!
Russ from Coral Springs, Florida, USA

ifree said...

G-code support? It would be great to extend the applications for this bot.

nancy said...

Hello everybody, I just want to give this great testimony to the whole public about a great man who helped me out of a serious illness. I have had HSV-1 AND HSV-2 VIRUS for good 2 years now and I was almost going to the end of my life due to the illness. All I have in my mind is, let me just give up because life is not interesting for me any longer and i also pray that God should accept my soul when ever I’m gone luckily for me, my kid sister run to me that she found a doctor in the INTERNET who can cure HSV-1 AND HSV-2 VIRUS. She helped me out with everything, the man asked for my details so he can prepare herbal medicine for me. After he was done consulting on my details he told me how my medicine will be prepare, after he was done preparing my medicine he sent me my medication and after using it for 7 days i later started noticing something different in my blood so I went for my HSV-1 AND HSV-2 VIRUS test and I was tested Negative, I’m so happy that I can say I’m not patient of HSV-1 AND HSV-2 anymore. If you have HSV-1 AND HSV-2 or any sickness,HIV/AID,HPV,CANCER,HEPATITIS B DIABETICS ALS,PENIS ENLARGEMENT please for your safety, contact DR.OLUTA VIA email address ( or whats APP number +2349065326267