Firmware first drafts for MONO NO AWARE optical printer

This commit is contained in:
mmcwilliams 2019-02-28 17:50:39 -05:00
parent b9bd62bb78
commit ac888b1fc4
4 changed files with 432 additions and 3 deletions

View File

@ -1,10 +1,13 @@
boolean debug_state = false; boolean debug_state = false;
//const int proj_pin = 5; //relay 4 const int proj_fwd_pin = 12;
//const int proj_time = {{proj.time}}; const int proj_bwd_pin = 11;
//const int proj_delay = {{proj.delay}}; const int proj_pin = 10;
const int proj_time = 1200;
const int proj_delay = 42;
boolean proj_dir = true; boolean proj_dir = true;
boolean proj_running = false;
const char cmd_projector = 'p'; const char cmd_projector = 'p';
const char cmd_proj_forward = 'g'; const char cmd_proj_forward = 'g';

View File

@ -0,0 +1,152 @@
/**
* This is a specialized version of the mcopy firmware for
* controlling the 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
* Arduino Uno compatible board.
*
* Pins
* 12 - CH1 - FWD LOW, BWD HIGH
* 11 - CH2 - FWD LOW, BWD HIGH
* 10 - CH3 - FWD LOW, nothing HIGH
* - controls the directional relays of the camera.
*
* 07 - CH4 - 4 pronged trigger cable, LOW
* - triggers the camera
*/
boolean debug_state = false;
/* ------------------------------------------------
* pins
* ------------------------------------------------*/
const int cam_dir_pin_1 = 12;
const int cam_dir_pin_2 = 11;
const int cam_dir_pin_3 = 10;
const int cam_pin = 9;
boolean running = false;
boolean cam_dir = true;
const int cam_time = 700;
const int cam_momentary = 120;
const int cam_delay = 42;
const char cmd_camera = 'c';
const char cmd_cam_forward = 'e';
const char cmd_cam_backward = 'f';
const char cmd_debug = 'd';
const char cmd_connect = 'i';
volatile char cmd_char = 'z';
const char cmd_mcopy_identifier = 'm';
const char cmd_cam_identifier = 'k';
const int serialDelay = 5;
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';
}
}
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_camera) {
Frame();
} else if (val == cmd_cam_forward) {
cam_direction(true); //explicit
} else if (val == cmd_cam_backward) {
cam_direction(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_cam_identifier);
log("identify()");
}
void Pins_init () {
pinMode(cam_dir_pin_1, OUTPUT);
pinMode(cam_dir_pin_2, OUTPUT);
pinMode(cam_dir_pin_3, OUTPUT);
pinMode(cam_pin, OUTPUT);
digitalWrite(cam_dir_pin_1, LOW);
digitalWrite(cam_dir_pin_2, LOW);
digitalWrite(cam_dir_pin_3, LOW);
digitalWrite(cam_pin, HIGH);
}
void Frame () {
if (!running) {
running = true;
digitalWrite(cam_pin, LOW);
delay(cam_momentary);
digitalWrite(cam_pin, HIGH);
delay(cam_time - cam_momentary + cam_delay);
Serial.println(cmd_camera);
log("Frame completed");
running = false;
}
}
void cam_direction (boolean state) {
cam_dir = state;
if (state) {
digitalWrite(cam_dir_pin_1, LOW);
digitalWrite(cam_dir_pin_2, LOW);
digitalWrite(cam_dir_pin_3, LOW);
Serial.println(cmd_cam_forward);
log("cam_direction -> true");
} else {
digitalWrite(cam_dir_pin_1, HIGH);
digitalWrite(cam_dir_pin_2, HIGH);
digitalWrite(cam_dir_pin_3, HIGH);
Serial.println(cmd_cam_backward);
log("cam_direction -> false");
}
}
void log (String msg) {
if (debug_state) {
Serial.println(msg);
}
}

View File

@ -0,0 +1,136 @@
/**
* This is a specialized version of the mcopy firmware for
* controlling the projectors of the optical printer
* 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.
*
* 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
*/
boolean debug_state = false;
const int proj_fwd_pin = 12;
const int proj_bwd_pin = 11;
const int proj_pin = 10;
const int proj_momentary = 60;
const int proj_time = 950; //secondary projector speed
const int proj_delay = 42;
boolean proj_dir = true;
boolean proj_running = false;
const char cmd_projector = 'p';
const char cmd_proj_forward = 'g';
const char cmd_proj_backward = 'h';
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 int serialDelay = 5;
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);
}
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';
}
}
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_projector) {
projector();
} else if (val == cmd_proj_forward) {
proj_direction(true);
} else if (val == cmd_proj_backward) {
proj_direction(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_proj_identifier);
log("identify()");
}
void projector () {
if (!proj_running) {
proj_running = true;
digitalWrite(proj_pin, HIGH);
delay(proj_momentary);
digitalWrite(proj_pin, LOW);
delay(proj_time - proj_momentary + proj_delay);
Serial.println(cmd_projector);
log("projector()");
proj_running = false;
}
}
void proj_direction (boolean state) {
proj_dir = state;
digitalWrite(proj_fwd_pin, LOW);
digitalWrite(proj_bwd_pin, LOW);
if (state) {
digitalWrite(proj_fwd_pin, HIGH);
Serial.println(cmd_proj_forward);
log("proj_direction -> true");
} else {
digitalWrite(proj_bwd_pin, HIGH);
Serial.println(cmd_proj_backward);
log("proj_direction -> false");
}
//delay(50); //delay after direction change to account for slippage of the belt
}
void log (String msg) {
if (debug_state) {
Serial.println(msg);
}
}

View File

@ -0,0 +1,138 @@
/**
* TEMPORARY
*
* This is a specialized version of the mcopy firmware for
* controlling the projectors of the optical printer
* 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.
*
* 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
*/
boolean debug_state = false;
const int proj_fwd_pin = 12;
const int proj_bwd_pin = 11;
const int proj_pin = 10;
const int proj_momentary = 60;
const int proj_time = 950; //secondary projector speed
const int proj_delay = 42;
boolean proj_dir = true;
boolean proj_running = false;
const char cmd_projector = 'p';
const char cmd_proj_forward = 'g';
const char cmd_proj_backward = 'h';
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 int serialDelay = 5;
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);
}
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';
}
}
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_projector) {
projector();
} else if (val == cmd_proj_forward) {
proj_direction(true);
} else if (val == cmd_proj_backward) {
proj_direction(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_proj_identifier);
log("identify()");
}
void projector () {
if (!proj_running) {
proj_running = true;
digitalWrite(proj_pin, HIGH);
delay(proj_momentary);
digitalWrite(proj_pin, LOW);
delay(proj_time - proj_momentary + proj_delay);
Serial.println(cmd_projector);
log("projector()");
proj_running = false;
}
}
void proj_direction (boolean state) {
proj_dir = state;
digitalWrite(proj_fwd_pin, LOW);
digitalWrite(proj_bwd_pin, LOW);
if (state) {
digitalWrite(proj_fwd_pin, HIGH);
Serial.println(cmd_proj_forward);
log("proj_direction -> true");
} else {
digitalWrite(proj_bwd_pin, HIGH);
Serial.println(cmd_proj_backward);
log("proj_direction -> false");
}
//delay(50); //delay after direction change to account for slippage of the belt
}
void log (String msg) {
if (debug_state) {
Serial.println(msg);
}
}