Pages: [1]   Go Down
Author Topic: Multiplexed Stepper Control  (Read 416 times)
0 Members and 1 Guest are viewing this topic.
Newcastle upon Tyne
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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);
}
« Last Edit: October 06, 2008, 11:26:26 am by will_schrimshaw » Logged

Newcastle upon Tyne
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 06, 2008, 11:28:52 am by will_schrimshaw » Logged

Pages: [1]   Go Up
Jump to: