Go Down

Topic: Multiplexed Stepper Control (Read 435 times) previous topic - next topic

poportis

Oct 06, 2008, 02:39 pm Last Edit: Oct 06, 2008, 06:26 pm by will_schrimshaw Reason: 1
I'm trying to control a couple of steppers via a 74HC595 shift register and a ULN2004 transistor array. I'm currently testing the setup with a single stepper but want to attach between 5 and 8, which is reason for the multiplexing.

The result I'm currently getting is as if the steppers were wired up incorrectly, i.e. they seem to take one large step CW and then three smaller steps CCW. As far as I can tell, the wiring is correct, so for now I'm inclined to think it's a code problem.

Here is what I have so far. Any suggestions are greatly appreciated.

Code: [Select]
#define latchPin 8
#define clockPin 12
#define dataPin  11
#define ledPin 13
#define numOfSteps 100
#define rate 60
#define input 0
int amp  = 0;
int motorSpeed = 20;
byte dataArray[4];
byte data;


void setup() {
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);

// step orders:
 dataArray[0] = 0xAA; // 1010
 dataArray[1] = 0x66; // 0110
 dataArray[2] = 0x55; // 0101
 dataArray[3] = 0x99; // 1001

}

void loop() {

// do numOfSteps steps and then wait for a second:
for (int i = 0; i < numOfSteps; i++) {
 for (int j = 0; j < 4; j++) {
   


   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, MSBFIRST, dataArray[j]);
   digitalWrite(latchPin, HIGH);
   delay(200);
   

   }
 }
delay(1000);
}

poportis

#1
Oct 06, 2008, 06:26 pm Last Edit: Oct 06, 2008, 06:28 pm by will_schrimshaw Reason: 1
okay forget this, my brain is full of pine nuts.
This code does work, with two motors, it was just that I had forgotten that Q0 was on the right hand side of the 595...

Bone Head.

Go Up