int PinA = 12;
int PinB = 2;
int val = 0;
int val2 = 0;
void setup(void) {
Serial.begin(9600);
pinMode(PinA, INPUT_PULLUP);
pinMode(PinB, INPUT_PULLUP);
}
void loop(void) {
val = digitalRead(PinA);
val2 = digitalRead(PinB);
Serial.print("A value: ");
Serial.print(val);
Serial.print("\tB value: ");
Serial.println(val2);
}
I get the following result
Channel B reacts to changes and changes 1 to 0 when touched by the laser. Channel A does not react to anything, it constantly hangs at 0. I think maybe I screwed up somewhere in the connection diagram. Does anyone have an idea why channel A does not work? And what is this 5 channel that says that it is a reference channel, no matter how I connect it to + and -, it does not affect anything.
Please post a link to the encoder data sheet or product page, and a new schematic diagram, clearly showing all the relevant pin numbers. Hand drawn is fine.
I'm not sure whether you should be grounding the A- and B- outputs, they look like they are complementary to the A+ and B+ outputs, for connecting to RS485 - TTL converters.
Most possibly not, as when the output BJTs would be turned ON, they would short the relevant output to gnd anyway, otherwise the equivalent of open circuit.
It was definitely a mistake to connect the A-, B- differential signals to ground, but whether that damaged the outputs depends on their internal structure.
For example, if the outputs are open collector/drain and are intended to be used with external pullup resistors, then no problem. If the outputs are totem pole, then they could well be damaged.
The documentation is nearly hopeless, which I do not expect for such an expensive item, so your best option is to test the encoder on the bench, using an oscilloscope and other test equipment to examine the output signals.