diff --git a/testjig/README.md b/testjig/README.md index bc6c0cf422b0aa983c31f937cf2e37fb76681166..a8a00584f5d4fb983ebee6f594330846bc936e32 100644 --- a/testjig/README.md +++ b/testjig/README.md @@ -37,6 +37,15 @@ Vin | +5V power for testjig itself 2 | To ground via green button 3 | Fadecandy TCLK (SWCLK) 4 | Fadecandy TMS (SWDIO) +5 | Fadecandy USB D- (white wire) +6 | Fadecandy USB D+ (green wire) +7 | Fadecandy USB shield ground +8 | Fadecandy USB signal ground +9 | (No connection) +10 | PWM out for power supply control +11 | (No connection) +12 | DOUT of second WS2811 LED, via 3.3K current limiting resistor +13 | (Teensy built-in LED) 14 (A0) | Fadecandy output 0 (via resistor divider) 15 (A1) | Fadecandy output 1 (via resistor divider) 16 (A2) | Fadecandy output 2 (via resistor divider) @@ -49,10 +58,27 @@ Vin | +5V power for testjig itself 23 (A9) | Fadecandy VUSB (via resistor divider) All analog inputs connect via the same resistor divider: + * 1K between analog input and ground * 6.8K between analog input and Fadecandy signal * Use 5% tolerance resistors or better +Target power supply (micro-USB cable) is driven at a variable voltage. This is achieved by buffering a PWM output with an RC filter and op-amp. + +* Op-amp should be able to drive ~20mA. I used half an OPA2350, since it was handy. +* Op-amp supply voltage driven by Teensy VUSB (~5V), bypassed with 0.1uF cap +* Configured as a non-inverting amplifier with gain=2 + * Feedback resistor, - to out, 68K + * Feedback resistor, - to ground, 68K +* Low-pass filter on + input + * 68K between + and PWM input + * 0.1uF capacitor between + and ground +* Unused op-amps configured as followers + * 33K from - to out + * 33K from + to ground + +The Teensy isn't capable of communicating over USB with the Fadecandy board when wired this way, but the USB pins are electrically tested in a minimal way. Note that the USB signal ground and shield ground are set up this way only for electrical testing. During testing and programming, the actual power and signal ground is achieved through the test clip's connection to the output port. Except for VUSB, all signals on the USB connector are used only to electrically test the USB connector itself. + Testjig Firmwares ----------------- diff --git a/testjig/production/electrical_test.cpp b/testjig/production/electrical_test.cpp index 5ed274912fac50c36edb55fdc10733e3573aa8ed..6ad8813f9e440705b489575de39a1218813a1ab2 100644 --- a/testjig/production/electrical_test.cpp +++ b/testjig/production/electrical_test.cpp @@ -114,6 +114,30 @@ bool ElectricalTest::initTarget() return true; } +void ElectricalTest::setPowerSupplyVoltage(float volts) +{ + // Set the variable power supply voltage. Usable range is from 0V to system VUSB. + + const float fullScaleVoltage = 6.42; + int pwm = constrain(volts * (255 / fullScaleVoltage), 0, 255); + pinMode(10, OUTPUT); + analogWriteFrequency(10, 1000000); + analogWrite(10, pwm); + + delay(5); +} + +void ElectricalTest::powerOff() +{ + setPowerSupplyVoltage(0); +} + +void ElectricalTest::powerOn() +{ + target.log(logLevel, "ETEST: Enabling power supply"); + setPowerSupplyVoltage(5.0); +} + bool ElectricalTest::runAll() { target.log(logLevel, "ETEST: Beginning electrical test"); diff --git a/testjig/production/electrical_test.h b/testjig/production/electrical_test.h index 73879785abfdd164b88ae3490c26a9d99cd22955..63301e69ab09f77b96426167dd205576659be8ac 100644 --- a/testjig/production/electrical_test.h +++ b/testjig/production/electrical_test.h @@ -30,7 +30,10 @@ public: ElectricalTest(ARMKinetisDebug &target, int logLevel = ARMDebug::LOG_NORMAL) : target(target), logLevel(logLevel) {} - bool runAll(); + void powerOff(); // Turn off target power supply + void powerOn(); // Set target power supply to default voltage + + bool runAll(); // All normal electrical tests private: ARMKinetisDebug ⌖ @@ -41,6 +44,7 @@ private: return target.pin(target.PTD, index); } + void setPowerSupplyVoltage(float volts); float analogVolts(int pin); bool analogThreshold(int pin, float nominal, float tolerance = 0.20); bool testOutputPattern(uint8_t bits); diff --git a/testjig/production/production.ino b/testjig/production/production.ino index 99cbbf953c680cb6f2ed23b7eb4e006b4b57438b..d4bb459bdd2fb61b63a16aebb080e50baa320d76 100644 --- a/testjig/production/production.ino +++ b/testjig/production/production.ino @@ -32,6 +32,9 @@ void loop() Serial.println("--------------------------------------------"); Serial.println(""); + // Keep target power supply off when we're not using it + etest.powerOff(); + while (digitalRead(buttonPin) == LOW); delay(20); // Debounce delay while (digitalRead(buttonPin) == HIGH) { @@ -40,6 +43,8 @@ void loop() } digitalWrite(ledPin, HIGH); + etest.powerOn(); + // Start debugging the target if (!target.begin(swclkPin, swdioPin)) return;