CNC Update 1 “We Have Motion!”

NOTICE: I CORRECTED ERRORS IN THE CODE AND DESCRIPTION ABOUT MICROSTEPPING AN PULSE DELAY!

Videos at the bottom.

Ok, a lot has happen this week. I started out with a general ideal of how I wanted to accomplish the X and Y axis movements. I was going to go with the sliding table design rather than the Gantry. No real good reason why I have this method in mind it just seems simpler to me. Anyway I go scrounging around through some surplus junk I have picked up from an industrial auction and I came across a couple of pneumatic cylinders with a linear motion mount. This caught my eye right away. The design is quite nice but it only gives me about 10.5″ of travel. This should be fine for my first build and it should be plenty for routing printed circuit boards. Here is a picture of what one of these mounts looks like.

Linear Motion assembly

Today the Stepper motors and EasyDriver boards came in from SparkFun. This is the new version 4.2 driver boards. There isn’t much out there in the ways of tutorials for using this board yet so I hope I can help someone. 

The first order of business was to get some mounting pins soldered onto the driver board so I could plug it into a breadboard for testing. Here is a picture of the module with the pins soldered. 

EasyDriver v4.2 with Pins soldered on

Hint: it’s easier to solder the pins in if you lay the circuit board on the breadboard and stick the pins through the holes into the breadboard then when you have all the pins inserted solder them while its still on the breadboard to hold them straight)

Next I started laying out the jumpers and terminals on the breadboard. I know I could just stick the wires in the breadboard, but I find using these screw terminals work much better. The terminals I have are something like 5 mm pitch so they only pickup every other rail on the breadboard. So it takes a little thought on how to lay the jumpers out.

Jumpers

Terminals

Here is what it looks like when I finished placing all jumpers and terminals.

Completed test board

Wired up

Wired test board

In case you are trying to follow my wiring here, notice the color coding on the stepper motors. On the circuit board there are 4 terminals to hook to the stepper motor. Coil A and Coil B. Coil A terminals are next to each other and Coil B terminals are as well. However due to my use of the 5mm blocks I had to stagger the connections so what you see here  is ABAB, so Blue and Yellow are A coil and Red and Green are B coil.

The wiring of these units is pretty much straight forward. You have a direction Pin, that is held high for one direction and low for the other. A step pin that is pulsed high then low for 1 step. You have 2 other pins that enable micro stepping, ms1 and ms2. Tie them both low if you don’t want to micro step. ( I recommend tying them HIGH until you have tested for successful operation). You have two sources of power, one for the motor and one for the logic. If you are using an external power supply for your motor, which is almost always required, then the board will supply power back to the Arduino through the 5v logic connection. (However I had some issues getting my sketch to upload properly without my normal external supply hooked to the arduino). You have an enable pin that must be held low for the board to operate. The last connection that I used is the Sleep pin. If you tie it low then your motor will not be powered even though the arduino and the easydriver boards are still supplied. This also allows the motor to free wheel. I haven’t used the RST and PFD pins so I can’t speak to them just yet.

Here is the code to get the test running

NOTICE SEVERAL ERRORS WERE CORRECTED SINCE MY ORIGINAL POST!

// Some of this code was scavenged from different places on the Internet but I have changed a few things to get it working.

int dirpin = 8;
int steppin = 9;
int ms2pin = 10;
int enablepin = 11;
int ms1pin = 12;
int sleeppin = 13;
void setup() {
Serial.begin(9600);

pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
pinMode(ms2pin, OUTPUT);
pinMode(enablepin, OUTPUT);
pinMode(ms1pin, OUTPUT);
pinMode(sleeppin, OUTPUT);

digitalWrite(enablepin, LOW);    // enable easy driver
digitalWrite(sleeppin, HIGH);    // easy driver operating
digitalWrite(ms1pin, HIGH);    // microstepping disabled
digitalWrite(ms2pin, HIGH);    // microstepping disabled
}
void loop()
{

int i;

digitalWrite(dirpin, LOW);    // Set the direction pin to move forward

delay(1000);                  //Give it some time

Serial.println(“Forward”);    // Print Forward to the terminal window
for (i = 0; i<31000; i++)    // Step Forward 31000 steps
{
digitalWrite(steppin, LOW);   // Start out with step pin low
delayMicroseconds(500);    // Delay controls speed and Torque I originally had these at 100 that was too short
digitalWrite(steppin, HIGH);    // Now switch it high
delayMicroseconds(500);    // Delay controls speed and Torque you need at least a 500 delay
}             //

digitalWrite(dirpin, HIGH);    // Change direction to reverse
delay(100);                     // Give it some time

Serial.println(“Reverse”);     // Print Reverse to terminal window
for (i = 0; i<31000; i++)    // Step in Reverse 31000 steps
{
digitalWrite(steppin, LOW);   //  Start out with step pin low
delayMicroseconds(500);    // Delay controls speed and Torque you need at least a 500 delay  
digitalWrite(steppin, HIGH);    // Now switch it high
delayMicroseconds(500);    // Delay controls speed and Torque you need at least a 500 delay
}            

}

OK, now time for a couple of videos. Note the wire ties holding the stepper motor on, I couldn’t find any m3.5 screws today so I just used the wire ties for now.

CNC 040 6.5 Meg

CNC 044 5.5 Meg

I am not impressed with the torque of these small steppers I will most likely need to size up but more testing is required. This was because I had my pulse width too narrow. After increasing the delays to 500, I have plenty of torque!

I was the happy recipient of some really cool parts today (Thanks Brian). I now have some 20mm rails and 2 20mm ball screws. These will be the DADDY project after I flush all of the software and driver issues out with this junior unit. (insert smile).

I guess that’s enough for today. More to come…

This entry was posted in Arduino, CNC. Bookmark the permalink.

60 Responses to CNC Update 1 “We Have Motion!”