Monday, May 16, 2011

CNC Milling Machine

OK, so this milling machine project has gotten pretty out of hand. I know what I want to do with it, but getting it to work with my hardware setup is difficult. This is what I have so far:


And the parts list:
  • 2 EasyDriver motor drivers from Sparkfun
  • 2 12V 4-wire bipolar stepper motors from Sparkfun
  • 1 12V small fan
  • 1 slide switch
  • 2 LEDs with 2 220K resistors
  • 1 small flyback diode
To power the motors and fan, I am using a 12V, 1000mA wall wart transformer that I found in our shop. The EasyDrivers take that power and sink it through the H-bridge circuits to the motors, as well as through a 5V regulator for on-board logic. The H-bridge circuits and voltage regulator get really hot from all that power, so that's the reason I have a fan blowing on both of them. The fan gets good airflow, and I'm able to keep it running indefinitely without anything getting too hot.

To run two motors at a time, I wrote a small sketch that alternates movements between the two motors. The control of a motor is wrapped up in a for loop, so there is no way to run two stepper motors simultaneously. For example:


 for (int j = 0; j<steps1[i]; j++)       
    {
      digitalWrite(steppin1, LOW); 
      digitalWrite(steppin1, HIGH);

      delayMicroseconds(spd1[i]);                                
    }
    for (int k = 0; k<steps2[i]; k++)      
    {
      digitalWrite(steppin2, LOW); 
      digitalWrite(steppin2, HIGH);

      delayMicroseconds(spd2[i]);                         
    }



The steps1, steps2, spd1, and spd2 are just arrays of values that I was using to test the motor movements. As you can see, the program runs through the first loop then the second, not at the same time. The only way to run them at the same time would be if they were moving for the exact same number of steps and speed. I'm not sure how to deal with that at the moment.


Another option aside from writing my own code is to find someone who has written it already. That is the beauty of Arduino: people post their projects on the web and give you access to the code. I found a project that a group of people have been working on called "RepRap." The RepRap is a self-replicating 3D printer, meaning it can print plastic parts that can then be used to build another RepRap. And it runs on an Arduino sketch! The only difference between a RepRap and what I want to do is that the third "axis" on the RepRap is a thermoplastic extruder. All I have to do is modify the RepRap code to run three stepper motor axes. And as it turns out, someone already did that, too. I still have to modify the code though because their hardware is a little different than mine.


Phew, all that and I still have to find a way to draw parts to mill (I'm thinking Google Sketchup), a way to generate a toolpath, a way to generate G-code from the toolpath, and a way for an Arduino sketch to read G-code (probably through serial using another application). Finding a way to do all of that will be very difficult. It might be a while before I actually implement anything for this project, so I'll probably talk about my other project in my next post. What is it? Well, all I will say is that it has to do with the sun.

No comments:

Post a Comment