====== Gripper ====== Gripper files {{ :bdev:gripper_files.zip |}} More files {{ :bdev:gripper.zip |}} |{{ :bdev:gripper_track_12.8.stl |}}|{{ :bdev:gripper_track_12.8.png?200 |}}| |{{ :bdev:gripper_paddles.stl |}}|{{ :bdev:gripper_paddles.png?200 |}}| |{{ :bdev:gripperarm.stl |}}|{{ :bdev:gripperarm.png?200 |}}| |{{ :bdev:gripper_pulley_display_prep.stl |}}|{{ :bdev:gripper_pulley_display_prep.png?200 |}}| |{{ :bdev:gripper_nema_motormount.stl |}}|{{ :bdev:gripper_nema_motormount.png?200 |}}| |{{ :bdev:left_gripper_pusher_longer.stl |}}{{ :bdev:right_gripper_pusher_longer.stl |}}|{{ :bdev:gripper_pusher_longer.png?200 |}}| {{ :bdev:gripper_pic1.png?200 |}} {{ :bdev:gripper_pic2.png?200 |}} {{ :bdev:gripper_pic3.png?200 |}} {{ :bdev:gripper_pic4.png?200 |}} {{ :bdev:gripper_pic5.png?200 |}} {{ :bdev:gripper_pcb.png?200 |}} #include #include #include #define dirPin 4 #define stepPin 3 #define motorInterfaceType 1 AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin); const float stepsperul = 131.53; //resolution of 1ml disposable syringes //const float stepsperul = 272.12; //resolution of 250ul glass syringe int enablePin = 5; int directionPin = 4; int elimitPin = A1; int estepsPin = 3; int esteps = 1000; int esteprate = 500; int estepsincrement = 0; int estepcount = 0; int acc = 30; String command; long int currpos; long int pos; void setup() { stepper.setMaxSpeed(1000*16); Serial.begin(115200); pinMode(elimitPin, INPUT); // set pin to input digitalWrite(elimitPin, LOW); pinMode(enablePin, OUTPUT); pinMode(directionPin, OUTPUT); pinMode(estepsPin, OUTPUT); digitalWrite(enablePin,LOW); digitalWrite(directionPin,LOW); digitalWrite(estepsPin, LOW); currpos = 0; stepper.setAcceleration(acc); } void loop() { // put your main code here, to run repeatedly: if(Serial.available()) { char c = Serial.read(); if (c== '\n') { currpos = parseCommand(command, currpos); command = ""; } else { command +=c; } } delay(30); } long int parseCommand(String com, long int currpos) { Serial.print("Your command: "); Serial.println(com); //"G1E10F200"; String part1 = com.substring(0,com.indexOf("e")); if (part1.equalsIgnoreCase("g1")){ String part2 = com.substring(com.indexOf("e")+1,com.indexOf("s")); String part3 = com.substring(com.indexOf("s")+1,com.indexOf("a")); String part4 = com.substring(com.indexOf("a")+1); int vpos = part2.toInt(); pos = vpos * stepsperul; int vfeed = part3.toInt(); int feed = vfeed * stepsperul; int acc = part4.toInt(); if ((pos-currpos) < 0) { feed = feed * -1; } moveacc((pos-currpos), feed, acc); currpos = pos; } else if(com.equalsIgnoreCase("m114")){ Serial.print("Step Position: "); Serial.println(pos); } else if(com.equalsIgnoreCase("g28e0")){ currpos = homing(estepsPin,directionPin,elimitPin); currpos = 0; pos = 0; } else if(com.equalsIgnoreCase("readinput")){ Serial.print("Read pin: "); Serial.println(digitalRead(elimitPin)); } else if(com.equalsIgnoreCase("info")){ Serial.println("solostepper"); } else { Serial.print("Did not recognize "); Serial.println(com); } return currpos; } void moveacc(long int inc, int spd, int acc){ //speed is in steps per second stepper.setCurrentPosition(0); stepper.setAcceleration(acc); while(stepper.currentPosition() != inc){ stepper.setSpeed(spd); stepper.runSpeed(); } } int homing(int stepsPin, int directionPin, int limitPin){ digitalWrite(directionPin,LOW); // Set Dir high int checker = 1; int cnter = 0; int stpper = 1; while(stpper > 0){ checker = digitalRead(limitPin); if (checker == 1){ cnter = cnter + 1; } else { cnter = 0; } if (cnter > 4){ stpper = 0; } digitalWrite(stepsPin,HIGH); // Output high delayMicroseconds(800); // Wait 1/2 a ms digitalWrite(stepsPin,LOW); // Output low delayMicroseconds(800); // Wait 1/2 a ms } digitalWrite(directionPin,HIGH); // Set Dir high for(int x = 0; x < 200; x++){ // Loop 200 times digitalWrite(stepsPin,HIGH); // Output high delayMicroseconds(1000); // Wait 1/2 a ms digitalWrite(stepsPin,LOW); // Output low delayMicroseconds(1000); // Wait 1/2 a ms } int stepcount = 0; return stepcount; }