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) {
Endstop_on();
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);
cap_state = false;
} else {
log("Cap already off");
}
while (Read_endstop()) {
/*while (Read_endstop()) {
delay(1);
}
}*/
Endstop_off();
log("Cap_off()");
if (!suppress) {
@ -164,15 +164,15 @@ void Cap_off (boolean suppress, boolean force) {
void Cap_on (boolean suppress, boolean force) {
Endstop_on();
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);
cap_state = true;
} else {
log("Cap already on");
}
while (!Read_endstop()) {
/*while (!Read_endstop()) {
delay(1);
}
}*/
Endstop_off();
log("Cap_on()");
if (!suppress) {

View File

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

View File

@ -25,7 +25,7 @@ RailSlotsD = 6;
MountBoltSpacingY=40;
OptoEndstopAdjustZ=2;
OptoEndstopAdjustZ=2-9;
module OptoEndstop () {
$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([3,4, -R(1.75)-R(.75)]) cube([3.6, 15.7, .75], center=true);
}
module BoltVoid () {
@ -85,9 +86,12 @@ module Mount () {
translate([80, R(MountBoltSpacingY), 0]) RailSlots();
translate([80, -R(MountBoltSpacingY), 0]) RailSlots();
//endstop
translate([0, -34, 25-2-2]) {
translate([0, -34, 25-2-2-10]) {
difference () {
cube([14, 20, 50], center=true);
translate([0, 11, -14]) cylinder(r=R(22), h=4, 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);
}
}
}
@ -179,28 +183,32 @@ module RailMount () {
module OptoEndstopMount () {
translate([-5,9.5,20]) {
difference() {
translate([0, 0, 4]) cube([14-0.3-0.3, 14, 32], center=true);
translate([0, R(LensVoidDiameter)+15+4, 0]) cylinder(r=R(LensVoidDiameter)+15, h=LensY + 10, center=true, $fn=200);
translate([0,-8.3, 12]) cube([9, 8, 5], center=true);
//translate([0,-5,-9+OptoEndstopAdjustZ]) rotate([90, 0, 0]) cylinder(r=R(2.9),h=10,center=true, $fn=40);
translate([-2,-5,15+OptoEndstopAdjustZ]) rotate([90, 0, 0]) cylinder(r=R(2.9),h=20,center=true, $fn=40);
translate([0,1,-3+OptoEndstopAdjustZ]) cube([8,20,15],center=true);
translate([0, 0, 1-7.25]) cube([14-0.3-0.3, 14, 32+4], center=true);
//lens void
translate([0, R(LensVoidDiameter)+5+4, 0]) cylinder(r=R(LensVoidDiameter)+5, h=LensY + 29, center=true, $fn=200);
//connector void
translate([0,-8.3, -14.5]) cube([9, 8, 5], center=true);
//bolts
translate([2,-5,-13.25+OptoEndstopAdjustZ]) rotate([90, 0, 0]) cylinder(r=R(2.9),h=20,center=true, $fn=40);
translate([2,-5,15+OptoEndstopAdjustZ]) rotate([90, 0, 0]) cylinder(r=R(2.9),h=20,center=true, $fn=40);
//main void
translate([1,1,-3]) cube([8,20,15],center=true);
//pathway void
translate([0,6,-3 +OptoEndstopAdjustZ]) cylinder(r=R(22), h=4, center=true);
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 () {
Mount();
translate([-CapOffsetX,-CapOffsetY,5.71]) rotate([0,0,currentAngle]) Cap();
//translate([-CapOffsetX,-CapOffsetY,5.71]) rotate([0,0,currentAngle]) Cap();
//color("green") RailMount();
//translate([5, -38, -11.8+OptoEndstopAdjustZ]) rotate([0, -90, 0]) opto_endstop();
//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";

Binary file not shown.