Compare commits

..

No commits in common. "9d3bf24627c4830ca0fa5ff9f0fe36af2cda738f" and "f585aa2a5a7e5e1e36830e5d0205b3a3afe53130" have entirely different histories.

4 changed files with 2 additions and 217 deletions

View File

@ -179,12 +179,9 @@
"camera_projectors_identifier": "5",
"cameras_projector_identifier": "6",
"cameras_projectors_identifier": "7",
"capper_identifier" : "C",
"camera_capper_identifier" : "8",
"camera_capper_projector_identifier" : "9",
"camera_capper_projectors_identifier" : "0",
"cap_on" : "A",
"cap_off" : "B"
"camera_capper_projectors_identifier" : "0"
}
}
}

View File

@ -1,161 +0,0 @@
#include <Servo.h>
boolean debug_state = false;
/*
----------------------------------------------------
Servo - Arduino
-
Red - 5V
Black - GND
Yellow - PWM Pin (9 in example)
Optical Endstop
-
Red - 5V
Black - GND
Yellow - Pin 10
----------------------------------------------------
*/
/* ------------------------------------------------
* pins
* ------------------------------------------------*/
//Arduino Duemilanove
const int PIN_SERVO = 9;
const int PIN_ENDSTOP = 10;
volatile boolean running = false;
volatile boolean cap_state = false;
volatile boolean endstop_state = false;
volatile int angle = 0;
const int cap_on_angle = 0;
const int cap_off_angle = 60;
volatile long timer = 0;
const char cmd_cap_on = 'A';
const char cmd_cap_off = 'B';
const char cmd_debug = 'd';
const char cmd_connect = 'i';
volatile char cmd_char = 'z';
const char cmd_mcopy_identifier = 'm';
const char cmd_capper_identifier = 'C';
const int serialDelay = 5;
Servo servo;
//SG-5010 speed 0.18s / 60 degree
//converted to milliseconds/angle
const float servoSpeed = 180.0 / 60.0;
void setup() {
Serial.begin(57600);
Serial.flush();
Serial.setTimeout(serialDelay);
Pins_init();
}
void loop() {
if (Serial.available()) {
/* read the most recent byte */
cmd_char = (char)Serial.read();
}
if (cmd_char != 'z') {
cmd(cmd_char);
cmd_char = 'z';
}
timer = millis();
}
void cmd (char val) {
if (val == cmd_debug) {
debug();
} else if (val == cmd_connect) {
connect();
} else if (val == cmd_mcopy_identifier) {
identify();
} else if (val == cmd_cap_on) {
Cap_on(false);
} else if (val == cmd_cap_off) {
Cap_off(false);
}
}
void debug () {
debug_state = true;
Serial.println(cmd_debug);
log("debugging enabled");
}
void connect () {
Serial.println(cmd_connect);
log("connect()");
}
void identify () {
Serial.println(cmd_capper_identifier);
log("identify()");
}
void Pins_init () {
pinMode(PIN_ENDSTOP, INPUT_PULLUP);
}
void Servo_init () {
servo.attach(PIN_SERVO);
delay(100);
if (!Read_endstop()) {
Cap_off(true);
}
}
boolean Read_endstop () {
return digitalRead(PIN_ENDSTOP) != LOW;
}
void Servo_angle (int newAngle) {
servo.write(newAngle);
delay(Servo_delay(newAngle, angle));
angle = newAngle;
}
int Servo_delay (int angleA, int angleB) {
int angle = abs(angleA - angleB);
return (int) ceil((float) angle * servoSpeed);
}
void Cap_off (boolean suppress) {
if (cap_state) {
Servo_angle(cap_off_angle);
cap_state = false;
} else {
log("Cap already off");
}
log("Cap_off()");
if (!suppress) {
Serial.println(cmd_cap_off);
}
}
void Cap_on (boolean suppress) {
if (!cap_state) {
Servo_angle(cap_on_angle);
cap_state = true;
} else {
log("Cap already on");
}
log("Cap_on()");
if (!suppress) {
Serial.println(cmd_cap_on);
}
}
void log (String msg) {
if (debug_state) {
Serial.println(msg);
}
}

View File

@ -1,48 +0,0 @@
include <common.scad>;
// Using a Tower Pro SG-5010 servo
// https://www.thingiverse.com/thing:83806 - Lego mount (has dimensions of servo body)
// https://www.thingiverse.com/thing:5241574 - Robot arm (just cool)
LensVoidDiameter = 40; //mm
LensZ = 80;
LensY = 20;
CapOffsetX = -50;
CapOffsetY = -11;
module Mount () {
$fn = 200;
difference(){
union(){
difference(){
cylinder(r=R(LensVoidDiameter)+15, h=LensY, center=true);
cylinder(r=R(LensVoidDiameter)+5, h=LensY+1, center=true);
}
translate([0,0,-(LensY/4)-(5/4)]) difference(){
cylinder(r=R(LensVoidDiameter)+5, h=R(LensY)-R(5), center=true);
cylinder(r=R(LensVoidDiameter), h=LensY+1, center=true);
}
}
translate([0,R(LensVoidDiameter),0])cube([LensVoidDiameter*2, LensVoidDiameter, 5], center=true);
}
}
module Cap () {
$fn = 200;
difference(){
union(){
translate([CapOffsetX,CapOffsetY,0]){
cylinder(r=R(LensVoidDiameter) + 4, h=4, center = true);
translate([35,(LensVoidDiameter/4)+1,0]) cube([50,R(LensVoidDiameter),4], center=true);
}
cylinder(r=5,h=10,center=true);
}
cylinder(r=2,h=10+1,center=true);
}
}
Mount();
translate([-CapOffsetX,-CapOffsetY,0]) rotate([0,0,-60]) Cap();

View File

@ -29,7 +29,4 @@ module trap_cube(height = 19, top_x = 30, top_y = 34, bottom_x = 45, bottom_y =
cube([bottom_x - wall_thickness, bottom_y - wall_thickness, 0.1], center=true);
}
}
}
echo("common.scad - R()");
function R (diameter) = diameter / 2.0;
}