Merge in 9 months of work on capper branch #71
|
@ -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);
|
||||||
|
//}
|
||||||
|
}
|
|
@ -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,85 @@ 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
** DC Motor Design
|
||||||
|
**/
|
||||||
|
|
||||||
module animationMotorDCBodyPositive () {
|
module animationMotorDCBodyPositive () {
|
||||||
rimH = 10 + 3.5;
|
rimH = 10 + 3.5;
|
||||||
difference () {
|
difference () {
|
||||||
|
@ -368,11 +437,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();
|
||||||
|
@ -394,9 +466,11 @@ 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") NEMA17();
|
||||||
|
|
||||||
|
//color("blue") translate([0, 0, 19.5]) animationMotorCap();
|
||||||
|
|
||||||
PART2 = "drive_coupling_DC";
|
PART2 = "animation_motor";
|
||||||
|
|
||||||
if (PART2 == "drive_coupling_DC_connector") {
|
if (PART2 == "drive_coupling_DC_connector") {
|
||||||
driveCouplingDCConnector();
|
driveCouplingDCConnector();
|
||||||
|
@ -406,4 +480,6 @@ if (PART2 == "drive_coupling_DC_connector") {
|
||||||
animationMotorDCCap();
|
animationMotorDCCap();
|
||||||
} else if (PART2 == "animation_motor_DC") {
|
} else if (PART2 == "animation_motor_DC") {
|
||||||
animationMotorDCBody();
|
animationMotorDCBody();
|
||||||
|
} else if (PART2 == "animation_motor") {
|
||||||
|
animationMotorBody();
|
||||||
}
|
}
|
Loading…
Reference in New Issue