0

I'm trying to switch a ATX PSU on and off by serial command. My code is as follows:

#include <Arduino.h>
#define PIN_LOW_FOR_POWER PIN_F0

void setup() {
  Serial.begin(115200);
}

void loop() {
  String sCode = Serial.readStringUntil('\n');
  if (sCode == "M80"){
    digitalWrite(PIN_LOW_FOR_POWER, LOW);
  }
  else if (sCode == "M81"){
    digitalWrite(PIN_LOW_FOR_POWER, HIGH);
  }
  else{
    Serial.println("Unknown command");
    return;
  }
  Serial.println("OK");
}

I'm getting "OK" back, and the power switches. After sending M81 I read 5V across the pin and ground, but after sending M80 for some reason I read 2.37V and not 0V. If I switch to "F1" (keep the wire connected to F0) I do read 0V.

The ATX PSU needs F0 to be pulled down in order to turn on. I soldered the ground of the ATX PSU to the Teensy ground, and the wire to be pulled down (green) to F0. I supply the 5V to the Teensy through USB, so the VCC pin is left unconnected.

The PSU does turn on if I manually create a short between F0 and ground.

Why doesn't the Teensy pull F0 down, and how do I resolve this? (All I could come up with is something of internal resistance within the Teensy being too high, which seems unlikely to me. (If the resistance within the PSU and wires between "green" and ground is equal to the resistance within the Teensy this would happen, right?))

PS: It turns out I bought a fake Teensy from China, if it's related. Ordered a new one for a different project, but still had this one laying around.

0

You forgot to set the IO pin to OUTPUT. Unless you do so all you are doing (if the Teensy core follows the Arduino API to the letter) is controlling the internal pullup.

pinMode(PIN_LOW_FOR_POWER, OUTPUT);
  • Okay, that was stupid... I'll accept your answer in 3 minutes. – Daniël van den Berg Dec 29 '18 at 21:22
  • Easilly done. It's called "code blindless" and we all suffer from it at some time or other. You have been looking at the code so long that you stop being able to see the code. A fresh pair of eyes always helps. – Majenko Dec 29 '18 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.