Commit all work in progress

This commit is contained in:
Matt McWilliams 2023-09-21 21:06:31 -04:00
parent 401822a7bb
commit 7f98d6028b
11 changed files with 92 additions and 32 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "1.8.28", "version": "1.8.29",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

2
app/package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.8.28", "version": "1.8.29",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy-app", "name": "mcopy-app",
"version": "1.8.28", "version": "1.8.29",
"description": "GUI for the mcopy small gauge film optical printer platform", "description": "GUI for the mcopy small gauge film optical printer platform",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@ -1,5 +1,5 @@
{ {
"version": "1.8.28", "version": "1.8.29",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -34,6 +34,8 @@ void McopyProjector::setDirection (bool dir) {
} }
void McopyProjector::frame (bool dir) { void McopyProjector::frame (bool dir) {
uint16_t spf = _stepsPerFrame * _mode; //scaled
bool running = true;
if (dir != _dir) { if (dir != _dir) {
setDirection(dir); setDirection(dir);
} }
@ -41,14 +43,28 @@ void McopyProjector::frame (bool dir) {
int64_t takeupGoal = _takeup.currentPosition(); int64_t takeupGoal = _takeup.currentPosition();
int64_t feedGoal = _feed.currentPosition(); int64_t feedGoal = _feed.currentPosition();
takeupGoal += _dir ? _stepsPerFrame : -_stepsPerFrame; takeupGoal += _dir ? spf : -spf;
feedGoal += _dir ? _stepsPerFrame : -_stepsPerFrame; feedGoal += _dir ? spf : -spf;
_takeup.moveTo(takeupGoal); _takeup.moveTo(takeupGoal);
_feed.moveTo(feedGoal); _feed.moveTo(feedGoal);
_running = true; _running = true;
while (running) {
if (_takeup.distanceToGo() == 0 && _feed.distanceToGo() == 0) {
//frame done
running = false;
_posTakeup = takeupGoal;
_posFeed += feedGoal;
} else {
_takeup.run();
_feed.run();
}
}
_running = false;
} }
void McopyProjector::adjust(uint8_t motor, int64_t steps) { void McopyProjector::adjust(uint8_t motor, int64_t steps) {
@ -72,6 +88,7 @@ void McopyProjector::adjustBoth (int64_t steps) {
} }
void McopyProjector::loop () { void McopyProjector::loop () {
/*
if (_running) { if (_running) {
if (_takeup.distanceToGo() == 0 && _feed.distanceToGo() == 0) { if (_takeup.distanceToGo() == 0 && _feed.distanceToGo() == 0) {
//frame done //frame done
@ -90,11 +107,12 @@ void McopyProjector::loop () {
_takeup.run(); _takeup.run();
_feed.run(); _feed.run();
} }
} }*/
} }
//https://wiki.iteadstudio.com/Arduino_Dual_Step_Motor_Driver_Shield //https://wiki.iteadstudio.com/Arduino_Dual_Step_Motor_Driver_Shield
void McopyProjector::setStepperMode (uint8_t mode) { void McopyProjector::setStepperMode (uint8_t mode) {
_mode = mode;
switch (mode) { switch (mode) {
case 1 : case 1 :
digitalWrite(_takeupSettingA, LOW); digitalWrite(_takeupSettingA, LOW);
@ -122,3 +140,32 @@ void McopyProjector::setStepperMode (uint8_t mode) {
break; break;
} }
} }
long McopyProjector::readVcc() {
long result;
// Read 1.1V reference against AVcc
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1125300L / result; // Back-calculate AVcc in mV
return result;
}
long McopyProjector::analogReadAccurate (int pin) {
double Vcc = readVcc() / 1000.0;
double ADCValue = analogRead(pin);
return (ADCValue / 1024.0) * Vcc;
}
long McopyProjector::analogReadAccurateAverage (int pin) {
int count = 3;
double sum = 0.0;
for (int i = 0; i < count; i++) {
sum += analogReadAccurate(pin);
delay(1);
}
return sum / (double) count;
}

View File

@ -28,10 +28,11 @@ class McopyProjector {
AccelStepper _takeup; AccelStepper _takeup;
AccelStepper _feed; AccelStepper _feed;
uint8_t _motorSteps = 1600; //microstepped uint16_t _motorSteps = 1600; //microstepped
uint8_t _frames = 8; uint8_t _frames = 8;
uint8_t _stepsPerFrame = 25; //round(_motorSteps / _frames); uint16_t _stepsPerFrame = 25; //round(_motorSteps / _frames);
float _speed = 500.0; uint8_t _mode = 1;
float _speed = 2000.0;
int64_t _posTakeup = 0; int64_t _posTakeup = 0;
int64_t _posFeed = 0; int64_t _posFeed = 0;
@ -47,6 +48,10 @@ class McopyProjector {
bool _running = false; bool _running = false;
bool _adjusting = false; bool _adjusting = false;
long readVcc();
long analogReadAccurate (int pin);
long analogReadAccurateAverage (int pin);
public: public:
McopyProjector(AccelStepper takeup, AccelStepper feed, uint8_t takeupSettingA, uint8_t takeupSettingB, uint8_t feedSettingA, uint8_t feedSettingB); McopyProjector(AccelStepper takeup, AccelStepper feed, uint8_t takeupSettingA, uint8_t takeupSettingB, uint8_t feedSettingA, uint8_t feedSettingB);
@ -59,6 +64,8 @@ class McopyProjector {
void setDirection(bool dir); void setDirection(bool dir);
void setStepperMode(uint8_t mode); void setStepperMode(uint8_t mode);
void loop(); void loop();
void home();
}; };
#endif #endif

View File

@ -37,6 +37,11 @@
#define FEED_SETTINGS_A 8 #define FEED_SETTINGS_A 8
#define FEED_SETTINGS_B 9 #define FEED_SETTINGS_B 9
#define TAKEUP_EMITTER 17
#define TAKEUP_RECEIVER A8
#define FEED_EMITTER 18
#define FEED_RECEIVER A9
AccelStepper takeup(AccelStepper::DRIVER, TAKEUP_STEP_PIN, TAKEUP_DIR_PIN); AccelStepper takeup(AccelStepper::DRIVER, TAKEUP_STEP_PIN, TAKEUP_DIR_PIN);
AccelStepper feed(AccelStepper::DRIVER, FEED_STEP_PIN, FEED_DIR_PIN); AccelStepper feed(AccelStepper::DRIVER, FEED_STEP_PIN, FEED_DIR_PIN);
@ -76,7 +81,7 @@ void loop () {
if (digitalRead(BUTTON) == LOW) { if (digitalRead(BUTTON) == LOW) {
projector_frame(); projector_frame();
} }
projector.loop(); //projector.loop();
} }
void pins () { void pins () {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.8.28", "version": "1.8.29",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "mcopy", "name": "mcopy",
"version": "1.8.28", "version": "1.8.29",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"arduino": "file:app/lib/arduino", "arduino": "file:app/lib/arduino",

View File

@ -1,6 +1,6 @@
{ {
"name": "mcopy", "name": "mcopy",
"version": "1.8.28", "version": "1.8.29",
"description": "Small gauge film optical printer platform", "description": "Small gauge film optical printer platform",
"main": "build.js", "main": "build.js",
"directories": { "directories": {

View File

@ -1,5 +1,5 @@
{ {
"version": "1.8.28", "version": "1.8.29",
"ext_port": 1111, "ext_port": 1111,
"profiles": { "profiles": {
"mcopy": { "mcopy": {

View File

@ -96,7 +96,7 @@ module LED_void (pos = [0, 0, 0], rot = [0, 0, 0], flip = false) {
EmitterZ = 39.5; EmitterZ = 39.5;
ReceiverZ = 65; ReceiverZ = 65;
translate(pos) rotate(rot) { translate(pos) rotate(rot) {
rotate([0, 90, 0]) { rotate([0, -90, 0]) {
cylinder(r = R(LightVoidD), h = 80, center = true, $fn = 40); cylinder(r = R(LightVoidD), h = 80, center = true, $fn = 40);
if (flip) { if (flip) {
translate([0, 0, -EmitterZ]) cylinder(r = R(LEDVoidD), h = 80, center = true, $fn = 40); translate([0, 0, -EmitterZ]) cylinder(r = R(LEDVoidD), h = 80, center = true, $fn = 40);
@ -169,18 +169,18 @@ module nub_void (pos = [0, 0, 0]) {
} }
} }
module stepper_mount_block (pos = [0, 0, 0]) { module stepper_mount_block (pos = [0, 0, 0], rot = [0, 0, 0]) {
BoltX = NEMA17BoltSpacing / 2; BoltX = NEMA17BoltSpacing / 2;
BoltY = NEMA17BoltSpacing / 2; BoltY = NEMA17BoltSpacing / 2;
H = 30; H = 30;
InnerD = 30; InnerD = 30;
translate(pos) { translate(pos) rotate(rot) {
difference () { difference () {
union () { union () {
translate([0, 0, -5]) cube([NEMA17OuterWidth, NEMA17OuterWidth, H], center = true); translate([0, 0, -5]) cube([NEMA17OuterWidth, NEMA17OuterWidth, H], center = true);
LED_prop([0, 19, -4.5 + 7.5], [0, 0, 45], flip = true); LED_prop([0, -19, -4.5 + 7.5], [0, 0, 45], flip = false);
LED_prop([0, -19, -4.5 + 11.5], [0, 0, 45], H = 9, flip = false); //LED_prop([0, -19, -4.5 + 11.5], [0, 0, 45], H = 9, flip = false);
} }
//corners //corners
for (i = [0 : 3]) { for (i = [0 : 3]) {
@ -197,8 +197,8 @@ module stepper_mount_block (pos = [0, 0, 0]) {
bolt_and_cap_void([BoltX, -BoltY, 10], H, H); bolt_and_cap_void([BoltX, -BoltY, 10], H, H);
bolt_and_cap_void([-BoltX, -BoltY, 10], H, H); bolt_and_cap_void([-BoltX, -BoltY, 10], H, H);
// //
LED_void([0, 17.25, -4.5], [0, 0, 45]); LED_void([0, -17.25, -4.5], [0, 0, 45]);
LED_void([0, -17.25, 2.5], [0, 0, 45], true); //LED_void([0, -17.25, 2.5], [0, 0, 45], true);
} }
} }
} }
@ -206,7 +206,7 @@ module stepper_mount_block (pos = [0, 0, 0]) {
module stepper_mount (pos = [0, 0, 0]) { module stepper_mount (pos = [0, 0, 0]) {
//NEMA17BoltSpacing = 31; //NEMA17BoltSpacing = 31;
translate(pos) { translate(pos) {
stepper_mount_block([0, KeyDistance / 2, 0]); stepper_mount_block([0, KeyDistance / 2, 0], [0, 0, 90]);
stepper_mount_block([0, -KeyDistance / 2, 0]); stepper_mount_block([0, -KeyDistance / 2, 0]);
} }
} }
@ -260,7 +260,7 @@ module gate_key_set_screw_void (pos = [0, 0, 0]) {
} }
} }
module gate_key (pos = [0, 0, 0], rot = [0, 0, 0]) { module gate_key (pos = [0, 0, 0], rot = [0, 0, 0], KeyRot = 0) {
Extension = 8.75; Extension = 8.75;
KeyZ = (13 / 2) + (10 / 2) + 6; KeyZ = (13 / 2) + (10 / 2) + 6;
OctoVoidX = 12; OctoVoidX = 12;
@ -277,7 +277,7 @@ module gate_key (pos = [0, 0, 0], rot = [0, 0, 0]) {
translate([0, 0, -3]) scale([1.07, 1.07, 1]) { translate([0, 0, -3]) scale([1.07, 1.07, 1]) {
NEMA17_motor_shaft([0, 0, -5]); NEMA17_motor_shaft([0, 0, -5]);
} }
octagon_void([0, 0, 3.5], D = 23.5); //octagon_void([0, 0, 3.5], D = 23.5);
//circular_void([0, 0, 3.5], D = 22); //circular_void([0, 0, 3.5], D = 22);
/*translate([0, 0, OctoVoidZ]) { /*translate([0, 0, OctoVoidZ]) {
for (i = [0 : 7]) { for (i = [0 : 7]) {
@ -289,9 +289,9 @@ module gate_key (pos = [0, 0, 0], rot = [0, 0, 0]) {
}*/ }*/
//registration flat //registration flat
translate([0, 26.5, -3.5 - (Extension / 2)]) cube([29, 29, 10 + Extension + 1], center = true); translate([0, 25, -3.5 - (Extension / 2)]) cube([29, 29, 20 + Extension + 1], center = true);
//key //key
rotate ([0, 0, 45]) { rotate ([0, 0, 45 + KeyRot]) {
translate([0, (10 / 2) + (KeyWidth / 2), KeyZ]) cube([10, 10, 10], center = true); translate([0, (10 / 2) + (KeyWidth / 2), KeyZ]) cube([10, 10, 10], center = true);
translate([0, -(10 / 2) - (KeyWidth / 2), KeyZ]) cube([10, 10, 10], center = true); translate([0, -(10 / 2) - (KeyWidth / 2), KeyZ]) cube([10, 10, 10], center = true);
} }
@ -305,6 +305,7 @@ module gate_key (pos = [0, 0, 0], rot = [0, 0, 0]) {
} }
} }
module panel (pos = [0, 0, 0], rot = [0, 0, 0]) { module panel (pos = [0, 0, 0], rot = [0, 0, 0]) {
translate(pos) rotate(rot) { translate(pos) rotate(rot) {
difference () { difference () {
@ -348,19 +349,19 @@ module debug () {
//panel(); //panel();
//NEMA17([0, KeyDistance / 2, -50]); //NEMA17([0, KeyDistance / 2, -50]);
//NEMA17([0, -KeyDistance / 2, -50]); //NEMA17([0, -KeyDistance / 2, -50]);
//gate_key([0, KeyDistance / 2, -14], [0, 0, 45]); gate_key([0, KeyDistance / 2, -14], [0, 0, -90 + 45], KeyRot=90);
//gate_key([0, -KeyDistance / 2, -14], [0, 0, 45]); gate_key([0, -KeyDistance / 2, -14], [0, 0, 180 + 45 ]);
difference () { difference () {
union () { union () {
intersection () { intersection () {
panel(); panel();
translate([0, -50, 0]) cube([60, 100, 150], center = true); //translate([0, -50, 0]) cube([60, 100, 150], center = true);
} }
} }
//translate([50, 0, 0]) rotate([0, 0, 45]) cube([100, 250, 150], center = true); //translate([50, 0, 0]) rotate([0, 0, 45]) cube([100, 250, 150], center = true);
translate([0, 0, -75 - 10]) cube([100, 250, 150], center = true); translate([0, 0, -82.5 - 10]) cube([100, 250, 150], center = true);
} }
} }
@ -368,7 +369,7 @@ module debug () {
PART = "gate_key"; PART = "gate_key";
if (PART == "gate_key") { if (PART == "gate_key") {
gate_key(); gate_key(KeyRot = 90);
} else if (PART == "panel") { } else if (PART == "panel") {
rotate([180, 0, 0]) panel(); rotate([180, 0, 0]) panel();
} else { } else {