diff --git a/app/data/cfg.json b/app/data/cfg.json index 277ab78..5a92af3 100644 --- a/app/data/cfg.json +++ b/app/data/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.24", + "version": "1.8.25", "ext_port": 1111, "profiles": { "mcopy": { diff --git a/app/package-lock.json b/app/package-lock.json index e9c2e48..0fe8532 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,6 +1,6 @@ { "name": "mcopy-app", - "version": "1.8.24", + "version": "1.8.25", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/app/package.json b/app/package.json index 99d070b..5716a81 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "mcopy-app", - "version": "1.8.24", + "version": "1.8.25", "description": "GUI for the mcopy small gauge film optical printer platform", "main": "main.js", "scripts": { diff --git a/data/cfg.json b/data/cfg.json index 277ab78..5a92af3 100644 --- a/data/cfg.json +++ b/data/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.24", + "version": "1.8.25", "ext_port": 1111, "profiles": { "mcopy": { diff --git a/ino/mcopy_projector_firmware/README.md b/ino/mcopy_projector_firmware/README.md new file mode 100644 index 0000000..e587772 --- /dev/null +++ b/ino/mcopy_projector_firmware/README.md @@ -0,0 +1,13 @@ +# mcopy projector firmware + +The goal of this firmware is to drive a JK-compatible gate +with two (2) NEMA17 stepper motors. Registration will be tracked +by four (4) IR LED emitters and receivers tracking two (2) +double-stage rotary encoders. + + +1. log step index +2. calculate volate +3. analogRead() x 3 +4. average readings +5. populate array with average at index diff --git a/ino/mcopy_projector_firmware/mcopy_projector_firmware.ino b/ino/mcopy_projector_firmware/mcopy_projector_firmware.ino index 5530157..a0abb60 100644 --- a/ino/mcopy_projector_firmware/mcopy_projector_firmware.ino +++ b/ino/mcopy_projector_firmware/mcopy_projector_firmware.ino @@ -141,3 +141,32 @@ void state () { stateString += String(mcopy.STATE); mcopy.print(stateString); } + +long 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 analogReadAccurate (int pin) { + double Vcc = readVcc() / 1000.0; + double ADCValue = analogRead(pin); + return (ADCValue / 1024.0) * Vcc; +} + +long 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; +} diff --git a/package-lock.json b/package-lock.json index f4e81b1..5281c9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mcopy", - "version": "1.8.24", + "version": "1.8.25", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mcopy", - "version": "1.8.24", + "version": "1.8.25", "license": "MIT", "dependencies": { "arduino": "file:app/lib/arduino", diff --git a/package.json b/package.json index 34fabfb..024015d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcopy", - "version": "1.8.24", + "version": "1.8.25", "description": "Small gauge film optical printer platform", "main": "build.js", "directories": { diff --git a/processing/mcopy/cfg.json b/processing/mcopy/cfg.json index 277ab78..5a92af3 100644 --- a/processing/mcopy/cfg.json +++ b/processing/mcopy/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.24", + "version": "1.8.25", "ext_port": 1111, "profiles": { "mcopy": {