From b529c97b5c0a9ba41f72c09985ad92665982473e Mon Sep 17 00:00:00 2001 From: Micah Elizabeth Scott <micah@scanlime.org> Date: Wed, 16 Oct 2013 12:25:07 -0700 Subject: [PATCH] TestJig: Target power supply control, and finish remaining hardware doc --- testjig/README.md | 26 ++++++++++++++++++++++++++ testjig/production/electrical_test.cpp | 24 ++++++++++++++++++++++++ testjig/production/electrical_test.h | 6 +++++- testjig/production/production.ino | 5 +++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/testjig/README.md b/testjig/README.md index bc6c0cf..a8a0058 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 5ed2749..6ad8813 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 7387978..63301e6 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 99cbbf9..d4bb459 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; -- GitLab