Add dongle detection and OhmMeter utility

This commit is contained in:
Travis Burtrum 2020-12-29 01:28:00 -05:00
parent 78db2a74c7
commit 58a4b7ff79
3 changed files with 80 additions and 2 deletions

View File

@ -369,3 +369,16 @@ build_flags = ${in-debug.build_flags} ${out-usbradio.build_flags}
extends = micro, in-debug, out-switchusb extends = micro, in-debug, out-switchusb
src_filter = ${in-debug.src_filter} ${out-switchusb.src_filter} src_filter = ${in-debug.src_filter} ${out-switchusb.src_filter}
build_flags = ${in-debug.build_flags} ${out-switchusb.build_flags} build_flags = ${in-debug.build_flags} ${out-switchusb.build_flags}
# OhmMeter utility
[ohm]
src_filter = -<*> +<OhmMeter.cpp>
[env:esp32-ohm]
extends = esp32, ohm
src_filter = ${ohm.src_filter}
[env:micro-ohm]
extends = micro, ohm
src_filter = ${ohm.src_filter}

View File

@ -33,7 +33,7 @@ Wiring
| 6 | 6 | 5 | - | - | - | - | - | P1-9 | | 6 | 6 | 5 | - | - | - | - | - | P1-9 |
| 7 | 7 | 18 | CE | - | - | - | - | P2-7* | | 7 | 7 | 18 | CE | - | - | - | - | P2-7* |
| 8 | 8 | 19 | CSN | - | - | - | - | - | | 8 | 8 | 19 | CSN | - | - | - | - | - |
| 9 | 9 | 21 | - | - | - | - | - | - | | 9 | 9 > 1k Ω | 35 > 1k Ω | - | 330 Ω | 100 Ω | 220 Ω | 680 Ω | 470 Ω |
| 10 | 10 | 3 | - | - | - | - | - | - | | 10 | 10 | 3 | - | - | - | - | - | - |
| 11 | 0 | 1 | - | - | - | - | - | P1-2 | | 11 | 0 | 1 | - | - | - | - | - | P1-2 |
| 12 | - | 22 | - | - | - | - | - | - | | 12 | - | 22 | - | - | - | - | - | - |
@ -46,12 +46,13 @@ Wiring
| 19 | 19 | 25 | - | DATA2 | - | - | - | P2-2 | | 19 | 19 | 25 | - | DATA2 | - | - | - | P2-2 |
| 20 | 20 | 33 | - | DATA3 | - | - | - | P2-3 | | 20 | 20 | 33 | - | DATA3 | - | - | - | P2-3 |
| 21 | 21 | 32 | - | DATA4 | - | - | - | P2-4 | | 21 | 21 | 32 | - | DATA4 | - | - | - | P2-4 |
| 22 | - | 35 | - | - | - | - | - | - | | 22 | - | - | - | - | - | - | - | - |
| 23 | - | 3.3V VCC | 3.3V VCC | - | - | 3.3V VCC | 3.3V VCC | - | | 23 | - | 3.3V VCC | 3.3V VCC | - | - | 3.3V VCC | 3.3V VCC | - |
| 24 | 5V VCC OUT | 5V VCC | 5V VCC | 5V VCC | 5V VCC | - | 5V VCC | PX-5 5V VCC | | 24 | 5V VCC OUT | 5V VCC | 5V VCC | 5V VCC | 5V VCC | - | 5V VCC | PX-5 5V VCC |
| 25 | GND | GND | GND | GND | - | GND | GND | PX-8 GND | | 25 | GND | GND | GND | GND | - | GND | GND | PX-8 GND |
* 2nd player Genesis is incompatible with Radio because it uses the same pins, 1 player Genesis is compatible * 2nd player Genesis is incompatible with Radio because it uses the same pins, 1 player Genesis is compatible
Ω This is optional and only used for dongle detection. For DB-25 pin 9: On the micro, run to pin 9 to 5V VCC with a 1k resistor. On ESP32, run to pin 35 to 3.3V VCC with a 1k resistor. On each dongle, run a resistor of the given value between DB-25 pin 9 and GND.
Credits / Links Credits / Links
--------------- ---------------

64
src/OhmMeter.cpp Normal file
View File

@ -0,0 +1,64 @@
/*
https://www.circuitbasics.com/arduino-ohm-meter/
micro values:
82: 81.31
100: 98.71-99.89
*/
#if defined(ARDUINO_ARCH_ESP32)
int analogPin = 35;
int Vin = 3.3;
auto steps = 4095.0;
#else
int analogPin = 9;
int Vin = 5;
auto steps = 1024.0;
#endif // ARDUINO_ARCH_ESP32
// value of the known resistor
float R1 = 1000;
#include "Arduino.h"
int raw = 0;
float Vout = 0;
float R2 = 0;
float buffer = 0;
void setup() {
Serial.begin(115200);
}
void loop() {
raw = analogRead(analogPin);
if (raw) {
buffer = raw * Vin;
Vout = (buffer) / steps;
buffer = (Vin / Vout) - 1;
Serial.print("raw: ");
Serial.print(raw);
Serial.print(" Vout: ");
Serial.print(Vout);
// this is R2 when it's connected to + and R1 is connected to ground
R2 = R1 * buffer;
Serial.print(" R2: ");
Serial.print(R2);
// this is R2 when it's connected to ground, and R1 is connected to +
R2 = R1 / buffer;
Serial.print(" R2: ");
Serial.println(R2);
} else {
Serial.println("disconnected");
}
delay(1000);
}