More mount work and start of endstop logic. Rebuilding the B&H projector unity.

This commit is contained in:
Matt McWilliams 2022-06-17 23:39:19 -04:00
parent 3a435933e3
commit 62a66f5f6d
4 changed files with 55 additions and 33 deletions

View File

@ -145,15 +145,15 @@ int Servo_delay (int angleA, int angleB) {
void Cap_off (boolean suppress, boolean force) { void Cap_off (boolean suppress, boolean force) {
Endstop_on(); Endstop_on();
current_angle = servo.read(); current_angle = servo.read();
if ((Read_endstop() || force) && (cap_state || current_angle != cap_off_angle)) { 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 {
log("Cap already off"); log("Cap already off");
} }
while (Read_endstop()) { /*while (Read_endstop()) {
delay(1); delay(1);
} }*/
Endstop_off(); Endstop_off();
log("Cap_off()"); log("Cap_off()");
if (!suppress) { if (!suppress) {
@ -164,15 +164,15 @@ void Cap_off (boolean suppress, boolean force) {
void Cap_on (boolean suppress, boolean force) { void Cap_on (boolean suppress, boolean force) {
Endstop_on(); Endstop_on();
current_angle = servo.read(); current_angle = servo.read();
if ((!Read_endstop() || force) && (!cap_state || current_angle != cap_on_angle)) { 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 {
log("Cap already on"); log("Cap already on");
} }
while (!Read_endstop()) { /*while (!Read_endstop()) {
delay(1); delay(1);
} }*/
Endstop_off(); Endstop_off();
log("Cap_on()"); log("Cap_on()");
if (!suppress) { if (!suppress) {

View File

@ -1,13 +1,14 @@
boolean debug_state = false; boolean debug_state = false;
const int proj_fwd_pin = 12; const int proj_fwd_pin = 9;
const int proj_bwd_pin = 11; const int proj_bwd_pin = 10;
const int proj_pin = 10; const int proj_micro_pin = 4;
const int proj_time = 1200; const int proj_time = 1200;
const int proj_delay = 42; const int proj_delay = 42;
boolean proj_dir = true; boolean proj_dir = true;
boolean proj_running = false; boolean proj_running = false;
volatile int proj_micro_raw;
const char cmd_projector = 'p'; const char cmd_projector = 'p';
const char cmd_proj_forward = 'g'; const char cmd_proj_forward = 'g';
@ -25,6 +26,16 @@ void setup() {
Serial.begin(57600); Serial.begin(57600);
Serial.flush(); Serial.flush();
Serial.setTimeout(serialDelay); Serial.setTimeout(serialDelay);
pins_init();
}
void pins_init () {
pinMode(proj_fwd_pin, OUTPUT);
pinMode(proj_bwd_pin, OUTPUT);
pinMode(proj_micro_pin, INPUT_PULLUP);
analogWrite(proj_fwd_pin, 0);
analogWrite(proj_bwd_pin, 0);
} }
void loop() { void loop() {
@ -36,6 +47,9 @@ void loop() {
cmd(cmd_char); cmd(cmd_char);
cmd_char = 'z'; cmd_char = 'z';
} }
if (proj_running) {
proj_reading();
}
} }
void cmd (char val) { void cmd (char val) {
@ -72,11 +86,11 @@ void identify () {
void proj_start () { void proj_start () {
if (proj_dir) { if (proj_dir) {
digitalWrite(proj_fwd_pin, HIGH); analogWrite(proj_fwd_pin, 255);
digitalWrite(proj_bwd_pin, LOW); analogWrite(proj_bwd_pin, 0);
} else { } else {
digitalWrite(proj_bwd_pin, HIGH); analogWrite(proj_bwd_pin, 255);
digitalWrite(proj_fwd_pin, LOW); analogWrite(proj_fwd_pin, 0);
} }
proj_running = true; proj_running = true;
delay(500); // Let bump pass out of microswitch delay(500); // Let bump pass out of microswitch
@ -95,8 +109,8 @@ void proj_reading () {
} }
void proj_stop () { void proj_stop () {
digitalWrite(proj_bwd_pin, LOW); analogWrite(proj_bwd_pin, 0);
digitalWrite(proj_fwd_pin, LOW); analogWrite(proj_fwd_pin, 0);
proj_running = false; proj_running = false;

View File

@ -25,7 +25,7 @@ RailSlotsD = 6;
MountBoltSpacingY=40; MountBoltSpacingY=40;
OptoEndstopAdjustZ=2; OptoEndstopAdjustZ=2-9;
module OptoEndstop () { module OptoEndstop () {
$fn=30; $fn=30;
@ -44,6 +44,7 @@ module OptoEndstop () {
translate([0,R(Y)+R(4.15),-R(1.75)-R(10.15)]) cube([6.1, 4.15, 10.15], center=true); translate([0,R(Y)+R(4.15),-R(1.75)-R(10.15)]) cube([6.1, 4.15, 10.15], center=true);
translate([0,-R(Y)-R(4.15),-R(1.75)-R(10.15)]) cube([6.1, 4.15, 10.15], center=true); translate([0,-R(Y)-R(4.15),-R(1.75)-R(10.15)]) cube([6.1, 4.15, 10.15], center=true);
} }
translate([3,4, -R(1.75)-R(.75)]) cube([3.6, 15.7, .75], center=true);
} }
module BoltVoid () { module BoltVoid () {
@ -85,9 +86,12 @@ module Mount () {
translate([80, R(MountBoltSpacingY), 0]) RailSlots(); translate([80, R(MountBoltSpacingY), 0]) RailSlots();
translate([80, -R(MountBoltSpacingY), 0]) RailSlots(); translate([80, -R(MountBoltSpacingY), 0]) RailSlots();
//endstop //endstop
translate([0, -34, 25-2-2]) { translate([0, -34, 25-2-2-10]) {
cube([14, 20, 50], center=true); difference () {
translate([0, 11, -14]) cylinder(r=R(22), h=4, center=true); cube([14, 20, 50], center=true);
translate([0, R(LensVoidDiameter)+10+4.01, 0]) cylinder(r=R(LensVoidDiameter)+5, h=LensY + 29, center=true, $fn=200);
}
translate([0, 11, -14+9]) cylinder(r=R(22), h=4, center=true);
} }
} }
} }
@ -178,29 +182,33 @@ module RailMount () {
module OptoEndstopMount () { module OptoEndstopMount () {
translate([-5,9.5,20]) { translate([-5,9.5,20]) {
difference() {
difference() { translate([0, 0, 1-7.25]) cube([14-0.3-0.3, 14, 32+4], center=true);
translate([0, 0, 4]) cube([14-0.3-0.3, 14, 32], center=true); //lens void
translate([0, R(LensVoidDiameter)+15+4, 0]) cylinder(r=R(LensVoidDiameter)+15, h=LensY + 10, center=true, $fn=200); translate([0, R(LensVoidDiameter)+5+4, 0]) cylinder(r=R(LensVoidDiameter)+5, h=LensY + 29, center=true, $fn=200);
translate([0,-8.3, 12]) cube([9, 8, 5], center=true); //connector void
//translate([0,-5,-9+OptoEndstopAdjustZ]) rotate([90, 0, 0]) cylinder(r=R(2.9),h=10,center=true, $fn=40); translate([0,-8.3, -14.5]) cube([9, 8, 5], center=true);
translate([-2,-5,15+OptoEndstopAdjustZ]) rotate([90, 0, 0]) cylinder(r=R(2.9),h=20,center=true, $fn=40); //bolts
translate([0,1,-3+OptoEndstopAdjustZ]) cube([8,20,15],center=true); translate([2,-5,-13.25+OptoEndstopAdjustZ]) rotate([90, 0, 0]) cylinder(r=R(2.9),h=20,center=true, $fn=40);
//pathway void translate([2,-5,15+OptoEndstopAdjustZ]) rotate([90, 0, 0]) cylinder(r=R(2.9),h=20,center=true, $fn=40);
translate([0,6,-3 +OptoEndstopAdjustZ]) cylinder(r=R(22), h=4, center=true); //main void
translate([1,1,-3]) cube([8,20,15],center=true);
//pathway void
translate([0,6,-2]) cylinder(r=R(22), h=4, center=true);
//smd voids
translate([-5, -6.5, -3]) cube([3.6, 1, 18], center=true);
} }
} }
} }
module Debug () { module Debug () {
Mount(); Mount();
translate([-CapOffsetX,-CapOffsetY,5.71]) rotate([0,0,currentAngle]) Cap(); //translate([-CapOffsetX,-CapOffsetY,5.71]) rotate([0,0,currentAngle]) Cap();
//color("green") RailMount(); //color("green") RailMount();
//translate([5, -38, -11.8+OptoEndstopAdjustZ]) rotate([0, -90, 0]) opto_endstop(); //translate([5, -38, -11.8+OptoEndstopAdjustZ]) rotate([0, -90, 0]) opto_endstop();
//color("green") translate([5, -38, -11.8]) OptoEndstopMount(); //color("green") translate([5, -38, -11.8]) OptoEndstopMount();
translate([-2, -38 + 2, -11.8 + 20 + OptoEndstopAdjustZ+.75]) rotate([90, 180, 0]) OptoEndstop(); //translate([2, -38 + 2, -11.8 + 11 + 2 +.75]) rotate([90, 0, 0]) OptoEndstop();
} }
Render="Debug"; Render="Debug";

Binary file not shown.