Compare commits

...

2 Commits

3 changed files with 200 additions and 16 deletions

View File

@ -0,0 +1,75 @@
#include <AccelStepper.h>
#include <Adafruit_MotorShield.h>
volatile boolean DEBUG = true;
Adafruit_MotorShield AFMStop(0x60);
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
//Set up for a 200step motor (NEMA 17)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 1);
void forwardstep() {
myMotor->onestep(FORWARD, DOUBLE);
}
void backwardstep() {
myMotor->onestep(BACKWARD, DOUBLE);
}
//Set up AccelStepper
AccelStepper stepper(forwardstep, backwardstep);
void setupMotor () {
TWBR = ((F_CPU /400000l) - 16) / 2; // Change the i2c clock to 400KHz
if (!AFMS.begin()) { // default frequency 1.6KHz
Serial.println("Could not find Motor Shield. Check wiring.");
while (1);
}
Serial.println("Motor Shield found.");
//myMotor->setSpeed(600);
//stepper.setMaxSpeed(600.0);
//stepper.setSpeed(600.0);
//stepper.setAcceleration(500.0);
}
void setup() {
Serial.begin(57600);
setupMotor();
//stepper.setMaxSpeed(600.0);
//stepper.move(600);
}
void loop() {
// put your main code here, to run repeatedly:
//Serial.println("Microstep steps");
//myMotor->step(200, FORWARD, MICROSTEP);
//myMotor->step(round(200 / 8), FORWARD, SINGLE); //109ms @ speed 600
//myMotor->step(round(200 / 8), FORWARD, SINGLE); //172ms @ speed 100
//myMotor->step(round(200 / 8), FORWARD, MICROSTEP); //1557ms @ speed 600
//myMotor->step(round(200 / 8), FORWARD, MICROSTEP); //1621ms @ speed 100
//myMotor->step(200, FORWARD, SINGLE); //873ms @ speed 600
//myMotor->step(200, FORWARD, SINGLE); //1377ms @ speed 100
//myMotor->step(200, FORWARD, MICROSTEP); //12466ms @ speed 600
//myMotor->step(200, FORWARD, MICROSTEP); //12967ms @ speed 100
//if (stepper.distanceToGo() != 0) {
long startTime = millis();
//stepper.runToNewPosition(0);
//stepper.runToNewPosition(600);
myMotor->step(600, FORWARD, DOUBLE);
//myMotor->step(600, FORWARD, SINGLE);
stepper.run();
long stopTime = millis();
Serial.print(stopTime - startTime);
Serial.println("ms");
delay(1000);
//}
}

View File

@ -100,15 +100,20 @@ module bodyCapBellowsAdapter () {
} }
} }
/**
** Stepper Motor Design
**/
module animationMotorBodyPositive () { module animationMotorBodyPositive () {
difference () { difference () {
motorBarrel(); motorBarrel();
//hollow out //hollow out
translate([0, 0, 4]) cylinder(r = R(BarrelDiameter) - 5, h = BarrelLength, center = true, $fn = 200); translate([0, 0, 4]) cylinder(r = R(BarrelDiameter) - 5, h = BarrelLength, center = true, $fn = 200);
//cut //cut
translate([0, 0, 20]) cube([100, 100, BarrelLength], center = true); translate([0, 0, 40]) cube([100, 100, BarrelLength], center = true);
cylinder(r = R(23), h = BarrelLength + 1, center = true, $fn = 100); cylinder(r = R(23), h = BarrelLength + 1, center = true, $fn = 100);
translate([0, (BarrelDiameter / 2) - 2, -10]) cube([8, 8, 16], center = true); //window
translate([0, (BarrelDiameter / 2) - 2, -5]) cube([8, 20, 42], center = true);
} }
//rim //rim
@ -145,21 +150,109 @@ module animationMotorBodyPositive () {
} }
module boltSlot () { module boltSlot () {
cylinder(r = R(6), h = 40, center = true, $fn = 40); cylinder(r = R(6), h = 46.5, center = true, $fn = 40);
cylinder(r = R(3.25), h = 50, center = true, $fn = 40); cylinder(r = R(3.25), h = 55, center = true, $fn = 40);
} }
module animationMotorBody () { module animationMotorBody () {
boltZOffset = -6; boltZOffset = -6;
difference () { difference () {
animationMotorBodyPositive(); animationMotorBodyPositive();
//m3 bolts (vertical)
translate([31/2, 31/2, boltZOffset]) boltSlot(); translate([31/2, 31/2, boltZOffset]) boltSlot();
translate([31/2, -31/2, boltZOffset]) boltSlot(); translate([31/2, -31/2, boltZOffset]) boltSlot();
translate([-31/2, 31/2, boltZOffset]) boltSlot(); translate([-31/2, 31/2, boltZOffset]) boltSlot();
translate([-31/2, -31/2, -6]) boltSlot(); translate([-31/2, -31/2, -6]) boltSlot();
// //cap m3s
rotate([0, 0, -60]) translate([14.5, 0, capM3OffsetZ]) {
rotate([0, 90, 0]) {
cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
translate([0, 0, 6.5]) cylinder(r = R(6), h = 3, center = true, $fn = 40);
}
}
rotate([0, 0, 120]) translate([14.5, 0, capM3OffsetZ]) {
rotate([0, 90, 0]) {
cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
translate([0, 0, 6.5]) cylinder(r = R(6), h = 3, center = true, $fn = 40);
}
}
} }
} }
module animationMotorCapPositive () {
difference() {
cylinder(r = R(BarrelDiameter), h = 10, center = true, $fn = 200);
translate([0, 0, -(10 /2) + (7.5/2) - 0.1]) cylinder(r = R(BearingDiameter), h = 7.5, center = true, $fn = 80);
cylinder(r = R(13), h = 10 + 1, center = true, $fn = 80);
}
translate([0, 0, -(10/2)-(5/2)]) difference() {
cylinder(r = R(BarrelDiameter) - 5.3, h = 5, center = true, $fn = 200);
cylinder(r = R(BarrelDiameter) - 7.5, h = 5 + 1, center = true, $fn = 200);
}
translate([0, 0, -(10/2)-(5/2)]) difference() {
union() {
rotate([0, 0, -60]) translate([13, 0, 0]) cube([6, 8, 5], center = true);
rotate([0, 0, 120]) translate([13, 0, 0]) cube([6, 8, 5], center = true);
}
cylinder(r = R(BearingDiameter)+1, h = 5 + 1, center = true, $fn = 200);
}
translate([0, 0, -(10/2)-(5/2)]) intersection() {
cylinder(r = R(BarrelDiameter), h = 5, center = true, $fn = 200);
translate([0, (BarrelDiameter / 2) - 2, 0]) cube([8-0.3, 8, 30], center = true);
}
}
module animationMotorCap () {
difference() {
animationMotorCapPositive();
rotate([0, 0, -60]) translate([14.5, 0, -(10/2)-(5/2)]) {
cube([2.5, 5.7, 6], center = true);
rotate([0, 90, 0]) cylinder(r = R(3.25), h = 10, center = true, $fn = 40);
}
rotate([0, 0, 120]) translate([14.5, 0, -(10/2)-(5/2)]) {
cube([2.5, 5.7, 6], center = true);
rotate([0, 90, 0]) cylinder(r = R(3.25), h = 10, center = true, $fn = 40);
}
//m3 set screw
rotate([0, 0, 180]) translate([14.5, 0, 0]) {
translate([2, 0, -6]) cube([2.5, 5.7, 20], center = true);
rotate([0, 90, 0]) {
cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
translate([0, 0, 6.5]) cylinder(r = R(6), h = 3, center = true, $fn = 40);
}
}
}
}
module driveCoupling () {
D = 15.5;
H = 41;
Divot = 2.75;
difference() {
union() {
cylinder(r = R(D), h = H, center = true, $fn = 80);
translate([0, 0, 2]) cylinder(r = R(BearingInnerDiameter), h = H, center = true, $fn = 80);
}
translate([0, 0, -(H/2)+6.5]) rotate([0, 0, 90]) scale([1.05, 1.05, 1]) NEMA17_motor_shaft();
//bottom M3
translate([-4.5, 0, -(H/2) + 4.9]) cube([2.5, 5.7, 12], center = true);
translate([-10, 0, -(H/2) + 9 - 3]) rotate([90, 0, 90]) cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
//top M3
translate([-4.5, 0, (H/2)-4.9+2]) cube([2.5, 5.7, 10], center = true);
translate([-10, 0, (H/2)-9+5]) rotate([90, 0, 90]) cylinder(r = R(3.25), h = 20, center = true, $fn = 40);
translate([0, 0, (H/2)-3]) difference() {
cylinder(r = R(7.8), h = 10.2, center = true, $fn = 100);
translate([-7.8+2, 0, 0]) cube([7.8, 7.8, 10+1], center = true);
}
}
}
/**
** DC Motor Design
**/
module animationMotorDCBodyPositive () { module animationMotorDCBodyPositive () {
rimH = 10 + 3.5; rimH = 10 + 3.5;
difference () { difference () {
@ -368,11 +461,14 @@ module driveCouplingDCConnector () {
translate([0, 0, (H/2)+H2+(20/2)]) cube([20, 20, 20], center = true); translate([0, 0, (H/2)+H2+(20/2)]) cube([20, 20, 20], center = true);
} }
} }
//translate([0, 20, 0]) color("red") motorOriginal();
//translate([0, -50, 0]) animationMotorDCBody();
//translate([0, -50, 19.5]) animationMotorDCCap();
/* /*
translate([0, 20, 0]) color("red") motorOriginal();
//bodyCapBellowsAdapter(); //bodyCapBellowsAdapter();
//animationMotorBody(); //animationMotorBody();
//translate([0, 0, -49.5]) color("green") NEMA17(); //
//bodyCap(); //bodyCap();
color("red") translate([0, -8.75, -45-4]) rotate([180, 0, -90]) geared_motor(); color("red") translate([0, -8.75, -45-4]) rotate([180, 0, -90]) geared_motor();
//color("blue") translate([-22, -10, -30.5]) microswitch(); //color("blue") translate([-22, -10, -30.5]) microswitch();
@ -393,17 +489,29 @@ translate([0, 0, 13.5]) driveCouplingDCConnector();
translate([0, 0, -12]) color("blue") driveCouplingDC(); translate([0, 0, -12]) color("blue") driveCouplingDC();
//translate([0, 0, 19.5]) animationMotorDCCap(); //translate([0, 0, 19.5]) animationMotorDCCap();
animationMotorDCBody(); animationMotorDCBody();
//translate([0, 0, -49.5]) color("green") rotate([0, 0, 90]) NEMA17();
translate([0, 0, -8])driveCoupling();
color("blue") translate([0, 0, 19.5]) difference() {
animationMotorCap();
translate([0, 50, 0]) cube([100, 100, 100], center = true);
}
*/ */
PART2 = "drive_coupling_DC"; PART2 = "drive_coupling";
if (PART2 == "drive_coupling_DC_connector") { if (PART2 == "drive_coupling_DC_connector") {
driveCouplingDCConnector(); driveCouplingDCConnector();
} else if (PART2 == "drive_coupling_DC") { } else if (PART2 == "drive_coupling_DC") {
driveCouplingDC(); driveCouplingDC();
} else if (PART2 == "animation_motor_DC_cap") { } else if (PART2 == "animation_motor_DC_cap") {
animationMotorDCCap(); rotate([180, 0, 0]) animationMotorDCCap();
} else if (PART2 == "animation_motor_DC") { } else if (PART2 == "animation_motor_DC") {
animationMotorDCBody(); animationMotorDCBody();
} else if (PART2 == "animation_motor") {
animationMotorBody();
} else if (PART2 == "animation_motor_cap") {
rotate([180, 0, 0]) animationMotorCap();
} else if (PART2 == "drive_coupling") {
driveCoupling();
} }

View File

@ -77,6 +77,14 @@ module optoswitch() {
cylinder(r = diag / 2, h = h, center = true, $fn = 6); cylinder(r = diag / 2, h = h, center = true, $fn = 6);
} }
module NEMA17_motor_shaft (L = 22.75) {
//shaft
difference () {
cylinder(r = R(5), h = L, center = true, $fn = 30);
translate([0, 4.5, 4.7]) cube([5, 5, L+1], center = true);
}
}
//NEMA17 Stepper //NEMA17 Stepper
module NEMA17 ( H = 33 ) { //alt = 47.5 module NEMA17 ( H = 33 ) { //alt = 47.5
difference () { difference () {
@ -93,14 +101,7 @@ module NEMA17 ( H = 33 ) { //alt = 47.5
translate([0, 0, (H/2) + (1.9/2)]) { translate([0, 0, (H/2) + (1.9/2)]) {
cylinder(r = R(22), h = 1.9, center = true, $fn = 100); cylinder(r = R(22), h = 1.9, center = true, $fn = 100);
} }
//shaft translate([0, 0, (H/2) + (L/2)]) NEMA17_motor_shaft();
translate([0, 0, (H/2) + (22.75/2)]) {
difference () {
cylinder(r = R(5), h = 22.75, center = true, $fn = 30);
translate([0, 4.5, 4.7]) cube([5, 5, 22.75], center = true);
}
}
} }
//Geartisan Worm Gear Motor - JSX40-370 //Geartisan Worm Gear Motor - JSX40-370