After several evenings of trying to get this to work I finally figured it out. I had not connected the strips to power that I thought I had. On the periphery of the breadboard are 2 rows top and bottom but they are split in the middle. I hooked the circuit up as though they were connected and of course it didn't work. What made it more confusing was that it partially worked. It would run 1 direction fine but not reverse. I was using a U2 stepper translator from dakeng.com, the author of Turbocnc, a dos based CNC control software.
Tonight it finally dawned on me that maybe it wasn't getting power. This was when I tried hooking up a led on that side in another attempt to troubleshoot and it wouldn't light.
Anyway, success. I ran the stepper back and forward using buttons programmed through the arduino to give the U2 stepper translator Dir input. It will run 2 steppers and takes input for step dir and step. They were meant to be used with a PC parallel port.
The cool thing about the U2 stepper translator is that it is on a PIC 16F84A and the hex and code is available on the dakeng.com page, or you can buy a preprogrammed IC from DK. This is what I did, a while ago. Only just now have I gotten around to trying them. It was at least a year ago, maybe 2. Minus is that it only runs half step.
This is what I ran, I had a funny thing happen that I think I have figured out. The steppers are from a printer and a flatbed scanner. They run ok using the nmb datasheet and arduino stepper function but did 2 step forward, 2 steps back with the U2. The U2 runs half step only and the sequence causes the steppers to run that way, at least these 2. I discovered through some light trial and error that they would run ok with the wires sequenced 1, 3, 2, 4. That is what I am going with.
Other issue with the driver is that I don't have a way to turn down the current. The motor gets hot after a little while.
This is the code I ran.
/* Stepper motor control using the PIC U2 stepper control from dakeng.com
* to run a stepper motor using a direction pin and a step pin.
*
*
* Written by Lee Cavanaugh 01/26/09
* Rev 0.1 - Minimal working version, run at your own risk.
*
*
*/
int directionPin=2; //output pin used to control stepper motor direction
int stepPin=3; //output pin used to step the stepper motor
int forwardButton=4; //input pin for forward button
int reverseButton=5; //input pin for reverse button
int forward = 0; //forward signal
int reverse = 0; //reverse signal
void setup()
{
//pinMode(forwardButton, INPUT); //input button to control forward running of the stepper motor
//pinMode(reverseButton, INPUT); //input button to control reverse running of the stepper motor
pinMode(directionPin,OUTPUT); //output for direction
pinMode(stepPin,OUTPUT); //output to step
pinMode(forwardButton,INPUT); //pushbutton for forward
pinMode(reverseButton,INPUT); //pushbutton for reverse
}
void loop()
{
//Read buttons for forward and reverse
forward = digitalRead(forwardButton);
reverse = digitalRead(reverseButton);
//drives the stepper motor forward or reverse when those buttons are pressed individually
if (forward==1 && reverse==0) digitalWrite(directionPin, HIGH); //Set direction
if (forward==0 && reverse==1) digitalWrite(directionPin, LOW); //Set direction
//if (forward==0 && reverse==0) digitalWrite(directionPin, HIGH); //Set direction
//if (forward==0 && reverse==0) digitalWrite(directionPin, LOW); //Set direction
// One step signal to the step pin
digitalWrite(stepPin, HIGH); //sets pin high, debugging leds stay on unless I do this.
delayMicroseconds(500); //40us pause so PIC u2 has time to see signal, less than 500 motor stalls
//delay(5);
digitalWrite(stepPin, LOW); //
//delay(5);
delayMicroseconds(500); // 40us pause so pic u2 has time to see signal, less than 500 motor stalls
}

No comments:
Post a Comment