Merge in 9 months of work on capper branch #71

Merged
mattmcw merged 95 commits from capper into main 2023-02-19 05:28:46 +00:00
3 changed files with 49 additions and 22 deletions
Showing only changes of commit dae4e65aee - Show all commits

View File

@ -1,6 +1,6 @@
#include <Servo.h> #include <Servo.h>
boolean debug_state = false; boolean debug_state = true;
/* /*
---------------------------------------------------- ----------------------------------------------------
@ -30,9 +30,10 @@ volatile boolean cap_state = false;
volatile boolean endstop_state = false; volatile boolean endstop_state = false;
volatile int angle = 0; volatile int angle = 0;
const int cap_on_angle = 0; const int cap_on_angle = 153;
const int cap_off_angle = 60; const int cap_off_angle = 93;
volatile long timer = 0; volatile long timer = 0;
volatile int current_angle = 0;
const char cmd_cap_on = 'A'; const char cmd_cap_on = 'A';
const char cmd_cap_off = 'B'; const char cmd_cap_off = 'B';
@ -48,7 +49,7 @@ const int serialDelay = 5;
Servo servo; Servo servo;
//SG-5010 speed 0.18s / 60 degree //SG-5010 speed 0.18s / 60 degree
//converted to milliseconds/angle //converted to milliseconds/angle
const float servoSpeed = 180.0 / 60.0; const float servoSpeed = 200.0 / 60.0;
void setup() { void setup() {
Serial.begin(57600); Serial.begin(57600);
@ -108,14 +109,10 @@ void Pins_init () {
void Servo_init () { void Servo_init () {
servo.attach(PIN_SERVO); servo.attach(PIN_SERVO);
delay(100);
servo.write(180);
delay(500);
servo.write(0);
delay(500);
if (!Read_endstop()) {
Cap_off(true); Cap_off(true);
} /*if (!Read_endstop()) {
Cap_off(true);
}*/
} }
boolean Read_endstop () { boolean Read_endstop () {
@ -124,7 +121,7 @@ boolean Read_endstop () {
void Servo_angle (int newAngle) { void Servo_angle (int newAngle) {
servo.write(newAngle); servo.write(newAngle);
delay(Servo_delay(newAngle, angle)); delay(Servo_delay(newAngle, angle) + 50);
angle = newAngle; angle = newAngle;
} }
@ -134,7 +131,8 @@ int Servo_delay (int angleA, int angleB) {
} }
void Cap_off (boolean suppress) { void Cap_off (boolean suppress) {
if (cap_state) { current_angle = servo.read();
if (cap_state || current_angle != cap_off_angle) {
Servo_angle(cap_off_angle); Servo_angle(cap_off_angle);
cap_state = false; cap_state = false;
} else { } else {
@ -147,7 +145,8 @@ void Cap_off (boolean suppress) {
} }
void Cap_on (boolean suppress) { void Cap_on (boolean suppress) {
if (!cap_state) { current_angle = servo.read();
if (!cap_state || current_angle != cap_on_angle) {
Servo_angle(cap_on_angle); Servo_angle(cap_on_angle);
cap_state = true; cap_state = true;
} else { } else {

View File

@ -11,8 +11,12 @@ LensY = 20;
CapOffsetX = -50; CapOffsetX = -50;
CapOffsetY = -11; CapOffsetY = -11;
CapLengthX = 50;
CapWidthZ = 4;
BoltSpacingX = 10;
BoltSpacingY = 49; BoltSpacingY = 49;
BoltD = 5;
module Mount () { module Mount () {
$fn = 200; $fn = 200;
@ -31,7 +35,10 @@ module Mount () {
cylinder(r=R(LensVoidDiameter), h=LensY+1, center=true); cylinder(r=R(LensVoidDiameter), h=LensY+1, center=true);
translate([50, 0, -6]) { translate([50, 0, -6]) {
cube([20, 40.25, 10], center = true); cube([20, 40.25, 10], center = true);
translate([0, BoltSpacingY/2, 0]) translate([BoltSpacingX/2, BoltSpacingY/2, 0])cylinder(r=R(BoltD), h=20, center=true);
translate([-BoltSpacingX/2, BoltSpacingY/2, 0])cylinder(r=R(BoltD), h=20, center=true);
translate([BoltSpacingX/2, -BoltSpacingY/2, 0])cylinder(r=R(BoltD), h=20, center=true);
translate([-BoltSpacingX/2, -BoltSpacingY/2, 0])cylinder(r=R(BoltD), h=20, center=true);
} }
} }
} }
@ -46,13 +53,34 @@ module Cap () {
union(){ union(){
translate([CapOffsetX,CapOffsetY,0]){ translate([CapOffsetX,CapOffsetY,0]){
cylinder(r=R(LensVoidDiameter) + 4, h=4, center = true); cylinder(r=R(LensVoidDiameter) + 4, h=4, center = true);
translate([35,(LensVoidDiameter/4)+1,0]) cube([50,R(LensVoidDiameter),4], center=true); translate([35,(LensVoidDiameter/4)+1,0]) {
} difference () {
cylinder(r=5,h=10,center=true); cube([CapLengthX,R(LensVoidDiameter),CapWidthZ], center=true);
} translate([R(CapLengthX)-(R(LensVoidDiameter)/2), 0, 0]) difference() {
cylinder(r=2,h=10+1,center=true); cube([R(LensVoidDiameter),R(LensVoidDiameter), CapWidthZ+1], center=true);
cylinder(r=R(LensVoidDiameter)/2, h=CapWidthZ+1+1, center=true);
translate([-R(LensVoidDiameter)/2, 0, 0]) cube([R(LensVoidDiameter),R(LensVoidDiameter), CapWidthZ+1], center=true);
} }
} }
}
}
translate([0, 0, -4]) cylinder(r=5,h=4,center=true);
}
translate([0, 0, -4]) cylinder(r1=R(5.5), r2=R(5.4),h=4.01,center=true);
cylinder(r=R(5.4),h=10,center=true);
}
}
module Debug () {
Mount(); Mount();
translate([-CapOffsetX,-CapOffsetY,0]) rotate([0,0,-60]) Cap(); translate([-CapOffsetX,-CapOffsetY,0]) rotate([0,0,-60]) Cap();
}
Render="Debug";
if (Render=="Debug") {
Debug();
} else if (Render=="Cap") {
Cap();
} else if (Render=="Mount") {
Mount();
}

BIN
stl/capper_cap.stl Normal file

Binary file not shown.