Search This Blog

Friday, November 19, 2010

Arduino based XYZ CNC Pumpkin & Foam Carver

Project in progress....

I'd been looking for something cool to do with a numerical controlled milling machine and an Arduino.
Using a router bit or dremel, and stepper motor stage, very cool greyscale pumpkin art could be carved.
Carving to different depths yields different light intensity.   Compensating for the curve of the pumpkin sounds like a math tour de force that can't be resisted.

Previously when into miniature Wargaming,  I build some landscape elements out of carved foam blocks and paint mixed with sand.  Very nice looking and easy to make.  Using this machine really would take this to a whole new level.

A 3D printer is not far away, if I could find a material to squirt out.  But that is a pipe dream for now.

In college I worked in a machine shop, and let me tell you, once you have used a CNC to make something you are changed forever.

Couldn't resist starting some research and a prototype to get this off the ground.

XYZ stages of high precision are insanely expensive.  This was the cheapest/best I could find, but I'm not ready to shell out this kind of dough yet.  Maybe if this turns into something cool and I need something more precise and heavy duty:   This is $325 and has the stepper motors.

Zen Toolworks CNC Carving Machine DIY Kit 7x7

Zen Toolworks CNC Carving Machine DIY Kit 7x7

Since I'm not buying that to start, here is the plan.
We are going to stick to carving soft materials for now, so we don't need a heavy duty stage and large motors.  A Dremel will serve as the carving tool to start.

An arduino will serve as the controller, with H-bridge motor driver chips driving stepper motors.
Likely I will have some method to calibrate the machine, either pots, encoders, or limit switches.  That will be in phase 2.    Keeping the carver in a calibrated control loop will increase precision.

For the initial lash up, since I'm diving in with two feet, I'm going to blow some $ and buy some premade kits just so I can get something to work out the bugs.

Adafruit Motor/Stepper/Servo Shield for Arduino kit - v1.0  $19.50

Small stepper motor - PF35T-48  $6.00
To use with the Motor Shield, connect green and red together to ground (middle), brown and black to one motor port (say M1) and orange and yellow to the other motor port (say M2). So in order, thats: brown - black - red&green - yellow - orange.

These motors are pretty small, so I'm going to start with a small machine on the first try.  They may not have the torque to move a big stage or fight against harder materials during carving.
I read on one blog that drawer slides from Home depot can be used to make a movable platform.

I need to find a source of gears, belts, etc that don't break the bank.  May go with the Lego collection on the lash up version, or rubber wheels moving the stage.

Down the road I will need bigger stepper motors and a higher voltage H bridge driver.
I have some of these chips around from automotive projects


I also found bigger stepper motors at
But datasheets are sparse, color codes, voltages etc are hard to find.  Eventually i'll have to dive in and order something, but I'm starting with some little ones that I know will work until my code is running.

Motor control software is all over the place on Arduino pages.    
I may make the Arduino stand alone, or simply make it the interface between the computer and the motors.

One low budget idea is to add an sd card slot, and create windows bitmaps.  The arduino could run in raster mode.  In the past I did a lot of work with windows bitmaps.  They have a simple file structure with the first few bytes showing the picture size, a byte per pixel and a simple greyscale or color scale.    The greyscale could indicate depth.  It would be easy to use gimp to edit pictures to the size and color depth i want, and then just plot them out with the XYZ machine.  Or I may use more conventional vector software, and HPGL or some such.

Built up one of the adafruit motor shields, hooked up two stepper motors and downloaded the adafruit motor library, according to the  pages.  No problems.
Edited the code to control two steppers, like this:

#include <AFMotor.h>

AF_Stepper motorX(48, 1);
AF_Stepper motorY(48, 2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  motorX.setSpeed(10);  // 10 rpm
  motorY.setSpeed(10);  // 10 rpm

  //step motors one step to power the coils
  motorX.step(1, FORWARD, DOUBLE);
  motorY.step(1, FORWARD, DOUBLE);
  motorX.step(1, BACKWARD, DOUBLE);
  motorY.step(1, BACKWARD, DOUBLE);

void loop() {
//  Serial.println("Single coil steps");
//  motor.step(100, FORWARD, SINGLE);
//  motor.step(100, BACKWARD, SINGLE);

  Serial.println("Double coil steps");
  motorX.step(48, FORWARD, DOUBLE);
  motorY.step(48, FORWARD, DOUBLE);
  motorX.step(48, BACKWARD, DOUBLE);
  motorY.step(48, BACKWARD, DOUBLE);


Talked to a friend today and it was depressing.  He told me my steppers would need high torque, that gears are hard to buy, lead screw designs are really inefficient, and it is hard to couple to a shaft.  He said steppers can slip and get off, so relying on counting steps was bad.  He suggested using drill motors and optical encoders instead of steppers.  All possible, but I'm looking for a build that uses components that anyone can get cheap.

Pressing forward with the basic prototype, I'm an EE not an ME so this may fail horribly.

Found a cheap XY table, making note.  Looks like it has very small (like <2") range in one direction, so probably not big enough

Proxxon 27100 Micro Compound Table KT 70

Found some cheapo rotary encoders, bought a few just in case.  May be too flimsy to hold up but good for getting the software going.
I may just use the encoders for calibration, or monitoring.  A feedback loop solution may be overkill.  It depends on the torque and backlash of the motors.  TBD.

Looks like the best system may be to use multiple arduinos to control the motors, since one arduino can't really handle more than 2 steppers.  A PC interface will be needed to control the arduinos.  This is probably the most sane solution, since the Arduino has such limited memory, downloading a big drawing to an Arduino that is also controlling steppers, reading encoders and talking to another Arduino will likely be too much.
Depending on my initial results with the encoders, I think the plan will be one Arduino per motor/encoder pair and a simple communication with the PC.  The PC will do all the work.   One Arduino might be able to handle both X and Y motors which might make some of the timing between motors easier.  I have to decide if I will pixelate the instructions, raster or vector.
Friend suggested Java or Elcipse on the PC to run the whole thing.  Looks like I will be learning how to code for the PC next!

Starting a new post now that I have some direction on this project....
Look for the story to continue in the later post