One shield to fit them all, and in the darkness bind them

I’m working on a project which involves mechanizing some machining tables. I decided to use some surplus stepper motors and A4983 stepper motor breakout boards from Pololu to control them. Getting them to work on a protoboard was no problem, so I decided to see if I could design and build a PCB to connect them in a more organized and robust fashion. Well, some hours and some chemical sniffing later, I had a board!

It has space to populate up to 4 of the Pololu stepper carriers, with a few pins left over. It’s in need of some bypass caps and input filtering, but there should be ample room between the power and ground circuit rails to add them.

Want to make one yourself? Grab the board artwork and design files, and the software from after the break.

Arduino board layout thanks to Garrett at Macetech.

UPDATE: Fixed a small bug in the code (can’t call delay() from an initialization function)

class stepper {
  uint8_t resetPin;
  uint8_t stepPin;
  uint8_t directionPin;
  
  long position;

 public:
  stepper(uint8_t resetPin_, uint8_t stepPin_, uint8_t directionPin_)
    {
      resetPin = resetPin_;
      stepPin = stepPin_;
      directionPin = directionPin_;
      
      pinMode(resetPin, OUTPUT);
      pinMode(stepPin, OUTPUT);
      pinMode(directionPin, OUTPUT);
     
      doReset();
    }
    
    void doReset() {
      position = 0;

      digitalWrite(directionPin, LOW);
      digitalWrite(stepPin, LOW);

      digitalWrite(resetPin, LOW);
      digitalWrite(resetPin, HIGH);
    }
    
    void moveAbsolute(long newPosition) {
      moveRelative(newPosition - position);
    }

    void moveRelative(long counts) {
      if ( counts > 0) {
        digitalWrite(directionPin, HIGH);
      }
      else {
        digitalWrite(directionPin, LOW);
      }
      
      unsigned long absCounts = abs(counts);
     
      for ( unsigned long absCounts = abs(counts); absCounts > 0; absCounts--) {
        digitalWrite(stepPin, HIGH);
        digitalWrite(stepPin, LOW);
        delayMicroseconds(1000);
      }
      
      position += counts;
    }

    long getPosition() {return position;}
};

stepper stepperA(10, 11, 12);
stepper stepperB(14, 15, 16);
stepper stepperC(7, 8, 9);
stepper stepperD(17, 18, 19);

void setup() {
}

void loop() {
  // Move one whole rotation and back
  stepperA.moveRelative((long)-200*16*36);
  delay(200);
  stepperA.moveRelative((long)200*16*36);
  delay(200);
}
This entry was posted in tech. Bookmark the permalink.

One Response to One shield to fit them all, and in the darkness bind them

  1. Pingback: C i b o M a h t o . c o m » Rotation test

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>