RepRap building

07/03/09

I am currently doing a residency at SPACE in London. I am building a part of the project I am building a RepRap.

http://reprap.org/

I wrote a simple Arduino program that sends both of the motors to there home points and then drives them up and down. It works pretty well but actually getting them to do something useful with code like this would be a complete headache. Thankfully most of the problems of plotting x y z co-ordinates have been solved by manufacturing. So at the moment I am looking into using G-Code, which seems to be a standard protocol for CNC Routers.

The biggest problem with building this thing is getting everything nicely aligned. I seem to have broken many bits by things not being square. Its running ok now but I have a feeling the y-axis is bent causing the motor to wobble.

Here is the Arduino code anyway

// set up what pins do what
 
// define x axis pins
#define stepPin_x 7
#define dirPin_x 6
#define ENDSTOP_PIN_x 3
// define y axis pins
#define stepPin_y 4
#define dirPin_y 5
#define ENDSTOP_PIN_y 2
 
// a switch variable to remember we have reached the home point
boolean initialised_x = false;
boolean initialised_y = false;
 
void setup()
{
  Serial.begin(9600);
  Serial.println("Starting stepper exerciser.");
 
  // set up x axis
  pinMode(stepPin_x, OUTPUT);
  pinMode(dirPin_x, OUTPUT);
  pinMode(ENDSTOP_PIN_x, INPUT);
  digitalWrite(dirPin_x, HIGH);
  digitalWrite(stepPin_x, LOW);
 
  // set up y axis
  pinMode(stepPin_y, OUTPUT);
  pinMode(dirPin_y, OUTPUT);
  pinMode(ENDSTOP_PIN_y, INPUT);
  digitalWrite(dirPin_y, HIGH);
  digitalWrite(stepPin_y, LOW);
 
}
 
 
 
 
void loop()
{
  // find the home for x
   if (initialised_x == false)
   {
        digitalWrite(stepPin_x, HIGH);
        delayMicroseconds(2);
        digitalWrite(stepPin_x, LOW);
        delayMicroseconds(1650);
   if (digitalRead(ENDSTOP_PIN_x) == LOW)
  { initialised_x = true;
    digitalWrite(dirPin_x, !digitalRead(dirPin_x));
    delay(500);
  } 
   }
 
  else 
        {
          // now find home for y
           if (initialised_y == false)
   {
        digitalWrite(stepPin_y, HIGH);
        delayMicroseconds(2);
        digitalWrite(stepPin_y, LOW);
        delayMicroseconds(1650);
   if (digitalRead(ENDSTOP_PIN_y) == LOW)
  { initialised_y = true;
    digitalWrite(dirPin_y, !digitalRead(dirPin_y));
    delay(500);
  } 
   }
        else
        {
      // now move up and down
 
        int i, j;
 
 
      for (j=0; j<2000; j++)
      {
        digitalWrite(stepPin_x, HIGH);
        digitalWrite(stepPin_y, HIGH);
        delayMicroseconds(2);
        digitalWrite(stepPin_x, LOW);
        digitalWrite(stepPin_y, LOW);
        delayMicroseconds(1650);
      }
 
      delay(500);
      Serial.println("Switching directions.");
      digitalWrite(dirPin_x, !digitalRead(dirPin_x));
      digitalWrite(dirPin_y, !digitalRead(dirPin_y));
 
      for (j=0; j<2000; j++)
      {
        digitalWrite(stepPin_x, HIGH);
        digitalWrite(stepPin_y, HIGH);
        delayMicroseconds(2);
        digitalWrite(stepPin_x, LOW);
        digitalWrite(stepPin_y, LOW);
        delayMicroseconds(1650);
      }
 
      delay(1000);
      Serial.println("Switching directions."); 
      digitalWrite(dirPin_x, !digitalRead(dirPin_x));
      digitalWrite(dirPin_y, !digitalRead(dirPin_y));
  }
   }
}
 
 
 
reprap_building.txt · Last modified: 2009/03/18 17:05 by simon
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki