Hello all,
I’m having trouble connecting a step motor controller (with STEP/DIR outputs) to a motor driver (with CW/CCW inputs) using an Arduino-bootloaded ATMega328P, and the root of the problem seems to be that I am also attempting to use an optoisolator to keep this particular motor/driver separate from three others one the same controller. (They use STEP/DIR input drivers so they’re all set…)
Here’s the test code I’m using:
void setup() {
pinMode(10, INPUT); //direction input
pinMode(0, OUTPUT); //indicate CW direction
pinmode(13, OUTPUT); //indicate CCW direction
}
void loop() {
if (digitalRead(10)) { //controller output = CW
digitalWrite(0, LOW);
digitalWite(13, HIGH);
}
else { //controller output = CCW
digitalWrite(0, HIGH);
digitalWite(13, LOW);
}
}
}
Here is my circuit:
http://i46.tinypic.com/zu2ogy.jpg
I have tried several permutations of the NPN phototransistor section, like pulling the Ardiuno pin down instead of up, reversing the connections to pins 4 and 5, and probably others, but I’m obviously not understanding something important because I am consistently unable to change the state of digital input 10.
Any hints would be greatly appreciated!
Thanks,
Patrick