Add commands for controlling a secondary projector.
This commit is contained in:
parent
200671b1cf
commit
f276d5ce83
|
@ -118,7 +118,12 @@
|
|||
"proj_light_identifier" : "q",
|
||||
"proj_cam_light_identifier" : "r",
|
||||
"proj_cam_identifier" : "s",
|
||||
"proj_second_identifier" : "t"
|
||||
"proj_second_identifier" : "t",
|
||||
"proj_dual_identifier" : "d",
|
||||
"proj_second_forward" : "u",
|
||||
"proj_second_backward" : "v",
|
||||
"projector_second" : "w",
|
||||
"projectors" : "x"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* This is a specialized version of the mcopy firmware for
|
||||
* controlling the camera of the optical printer
|
||||
* controlling the BBOptics Mitchel camera of the optical printer
|
||||
* at MONO NO AWARE. This uses a Sainsmart 4 Relay Module
|
||||
* board wired into the directional switches and "indiv" trigger
|
||||
* switch of a JK104-R camera controller box, and it runs on an
|
||||
|
|
|
@ -4,39 +4,61 @@
|
|||
* at MONO NO AWARE. This uses a Sainsmart 8 Solid State Relay
|
||||
* board wired into the directional switches of a JK104-R projector
|
||||
* controller box, a secondary projector controller box and it
|
||||
* runs on an Arduino Uno compatible board.
|
||||
* runs on an Arduino Mega 1280 compatible board.
|
||||
*
|
||||
* Pins
|
||||
* 12 - CH1 - FWD
|
||||
* 11 - CH2 - BWD (bridged to CH1)
|
||||
* - controls the directional relays of the secondary projector.
|
||||
* 10 - CH3 - 4 pronged trigger cable
|
||||
* - triggers the secondary projector
|
||||
* Pins - 8CH Sainsmart Solid State Relay Board
|
||||
* 12 - CH1 - BWD PROJ 1
|
||||
* 11 - CH2 - FWD PROJ 1 (bridged to CH1)
|
||||
* 10 - CH3 - BWD PROJ 1
|
||||
* 09 - CH4 - FWD PROJ 1 (bridged to CH3)
|
||||
* 08 - CH5 - BWD PROJ 1
|
||||
* - controls the directional relays of the primary projector.
|
||||
* 07 - CH8 - 4 pronged trigger cable
|
||||
* - triggers the primary projectory
|
||||
*/
|
||||
|
||||
|
||||
boolean debug_state = false;
|
||||
|
||||
const int proj_fwd_pin = 12;
|
||||
const int proj_bwd_pin = 11;
|
||||
const int proj_pin = 10;
|
||||
const int proj_bwd_pin_1 = 12;
|
||||
const int proj_fwd_pin_1 = 11;
|
||||
const int proj_bwd_pin_2 = 10;
|
||||
const int proj_fwd_pin_2 = 9;
|
||||
const int proj_bwd_pin_3 = 8;
|
||||
const int proj_pin = 7;
|
||||
|
||||
const int proj_second_fwd_pin = 6;
|
||||
const int proj_second_bwd_pin = 5;
|
||||
const int proj_second_pin = 4;
|
||||
|
||||
const int proj_momentary = 60;
|
||||
const int proj_time = 950; //secondary projector speed
|
||||
const int proj_delay = 42;
|
||||
|
||||
const int proj_second_momentary = 60;
|
||||
const int proj_second_time = 950; //adjust
|
||||
const int proj_second_delay = 42; //use same
|
||||
|
||||
boolean proj_dir = true;
|
||||
boolean proj_running = false;
|
||||
|
||||
boolean proj_second_dir = true;
|
||||
boolean proj_second_running = false;
|
||||
|
||||
const char cmd_projector = 'p';
|
||||
const char cmd_proj_forward = 'g';
|
||||
const char cmd_proj_backward = 'h';
|
||||
|
||||
const char cmd_proj_second_forward = 'u';
|
||||
const char cmd_proj_second_backward = 'v';
|
||||
const char cmd_projector_second = 'w';
|
||||
|
||||
const char cmd_projectors = 'x';
|
||||
|
||||
const char cmd_debug = 'd';
|
||||
const char cmd_connect = 'i';
|
||||
volatile char cmd_char = 'z';
|
||||
const char cmd_mcopy_identifier = 'm';
|
||||
const char cmd_proj_identifier = 'j';
|
||||
const char cmd_proj_identifier = 'j'; //'d'; //dual projector identifier
|
||||
|
||||
const int serialDelay = 5;
|
||||
|
||||
|
@ -44,13 +66,8 @@ void setup() {
|
|||
Serial.begin(57600);
|
||||
Serial.flush();
|
||||
Serial.setTimeout(serialDelay);
|
||||
pinMode(proj_fwd_pin, OUTPUT);
|
||||
pinMode(proj_bwd_pin, OUTPUT);
|
||||
pinMode(proj_pin, OUTPUT);
|
||||
|
||||
digitalWrite(proj_pin, LOW);
|
||||
digitalWrite(proj_fwd_pin, HIGH);
|
||||
digitalWrite(proj_bwd_pin, LOW);
|
||||
Pins_init();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -77,6 +94,14 @@ void cmd (char val) {
|
|||
proj_direction(true);
|
||||
} else if (val == cmd_proj_backward) {
|
||||
proj_direction(false);
|
||||
} else if (val == cmd_proj_second_forward) {
|
||||
proj_second_direction(true);
|
||||
} else if (val == cmd_proj_second_backward) {
|
||||
proj_second_direction(false);
|
||||
} else if (val == cmd_projector_second) {
|
||||
projector_second();
|
||||
} else if (val == cmd_projectors) {
|
||||
projectors();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,22 +138,115 @@ void projector () {
|
|||
}
|
||||
}
|
||||
|
||||
void projector_second () {
|
||||
if (!proj_second_running) {
|
||||
proj_second_running = true;
|
||||
digitalWrite(proj_second_pin, HIGH);
|
||||
|
||||
delay(proj_second_momentary);
|
||||
digitalWrite(proj_second_pin, LOW);
|
||||
|
||||
delay(proj_second_time - proj_second_momentary + proj_second_delay);
|
||||
|
||||
Serial.println(cmd_projector_second);
|
||||
log("projector_second()");
|
||||
proj_second_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void projectors () {
|
||||
int proj_time_highest = proj_time;
|
||||
if (!proj_running && !proj_second_running) {
|
||||
if (proj_second_time > proj_time) {
|
||||
proj_time_highest = proj_second_time;
|
||||
}
|
||||
proj_running = true;
|
||||
proj_second_running = true;
|
||||
|
||||
digitalWrite(proj_pin, HIGH);
|
||||
digitalWrite(proj_second_pin, HIGH);
|
||||
delay(proj_momentary); //highest? they are the same
|
||||
digitalWrite(proj_pin, LOW);
|
||||
digitalWrite(proj_second_pin, LOW);
|
||||
|
||||
delay(proj_time_highest - proj_momentary + proj_delay);
|
||||
|
||||
Serial.println(cmd_projectors); //cmd_projectors
|
||||
log("projectors()");
|
||||
proj_running = false;
|
||||
proj_second_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void proj_direction (boolean state) {
|
||||
proj_dir = state;
|
||||
digitalWrite(proj_fwd_pin, LOW);
|
||||
digitalWrite(proj_bwd_pin, LOW);
|
||||
digitalWrite(proj_fwd_pin_1, LOW);
|
||||
digitalWrite(proj_fwd_pin_2, LOW);
|
||||
|
||||
digitalWrite(proj_bwd_pin_1, LOW);
|
||||
digitalWrite(proj_bwd_pin_2, LOW);
|
||||
digitalWrite(proj_bwd_pin_3, LOW);
|
||||
if (state) {
|
||||
digitalWrite(proj_fwd_pin, HIGH);
|
||||
digitalWrite(proj_fwd_pin_1, HIGH);
|
||||
digitalWrite(proj_fwd_pin_2, HIGH);
|
||||
|
||||
Serial.println(cmd_proj_forward);
|
||||
log("proj_direction -> true");
|
||||
} else {
|
||||
digitalWrite(proj_bwd_pin, HIGH);
|
||||
digitalWrite(proj_bwd_pin_1, HIGH);
|
||||
digitalWrite(proj_bwd_pin_2, HIGH);
|
||||
digitalWrite(proj_bwd_pin_3, HIGH);
|
||||
|
||||
Serial.println(cmd_proj_backward);
|
||||
log("proj_direction -> false");
|
||||
}
|
||||
//delay(50); //delay after direction change to account for slippage of the belt
|
||||
}
|
||||
|
||||
void proj_second_direction (boolean state) {
|
||||
proj_second_dir = state;
|
||||
digitalWrite(proj_second_fwd_pin, LOW);
|
||||
digitalWrite(proj_second_bwd_pin, LOW);
|
||||
if (state) {
|
||||
digitalWrite(proj_second_fwd_pin, HIGH);
|
||||
Serial.println(cmd_proj_second_forward);
|
||||
log("proj_second_direction -> true");
|
||||
} else {
|
||||
digitalWrite(proj_second_bwd_pin, HIGH);
|
||||
Serial.println(cmd_proj_second_backward);
|
||||
log("proj_second_direction -> false");
|
||||
}
|
||||
}
|
||||
|
||||
void Pins_init () {
|
||||
//Declare primary projector pins
|
||||
pinMode(proj_fwd_pin_1, OUTPUT);
|
||||
pinMode(proj_bwd_pin_1, OUTPUT);
|
||||
pinMode(proj_fwd_pin_2, OUTPUT);
|
||||
pinMode(proj_bwd_pin_2, OUTPUT);
|
||||
pinMode(proj_bwd_pin_3, OUTPUT);
|
||||
pinMode(proj_pin, OUTPUT);
|
||||
|
||||
//declare secondary projector pins
|
||||
pinMode(proj_second_fwd_pin, OUTPUT);
|
||||
pinMode(proj_second_bwd_pin, OUTPUT);
|
||||
pinMode(proj_second_pin, OUTPUT);
|
||||
|
||||
//Set primary projector to forward
|
||||
digitalWrite(proj_pin, LOW);
|
||||
digitalWrite(proj_fwd_pin_1, HIGH);
|
||||
digitalWrite(proj_fwd_pin_2, HIGH);
|
||||
digitalWrite(proj_bwd_pin_1, LOW);
|
||||
digitalWrite(proj_bwd_pin_2, LOW);
|
||||
digitalWrite(proj_bwd_pin_3, LOW);
|
||||
|
||||
//Set secondary projector to forward
|
||||
digitalWrite(proj_second_fwd_pin, HIGH);
|
||||
digitalWrite(proj_second_bwd_pin, LOW);
|
||||
digitalWrite(proj_second_pin, LOW);
|
||||
|
||||
}
|
||||
|
||||
void log (String msg) {
|
||||
if (debug_state) {
|
||||
Serial.println(msg);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* TEMPORARY
|
||||
* TEMPORARY PROOF OF CONCEPT
|
||||
*
|
||||
* This is a specialized version of the mcopy firmware for
|
||||
* controlling the projectors of the optical printer
|
||||
|
|
Loading…
Reference in New Issue