# Figuring out wiring of optical encoder

I have a linear peristaltic pump (salvaged from medical equip. - likely used for dosing, etc). It uses a stepper motor and an optical shaft encoder. I have the motor working but I am confused about getting the wiring for the encoder sorted out. I've already done a search on the number appearing on the part and got no hits.

This is probably very simple - there are 4 wires: red, black, green and white. I don't want to blow the encoder out so I thought I would ask here. Can I assume that:

• red Vcc 5v
• black: gnd
• green: channel A
• white: channel B

I'll be using this with an arduino - so would I need pull up (or down) resistors on the signal lines? And if I can't assume the above, is there a way I can determine how to wire this up?

And finally, the encoder wheel has two slots in it - and I am trying to figure out what they mean in terms of pump state. Finding initial position at start? Or pump compression state.

• It is odd that some of the fingers are missing, is this by design? If it is by design it may be to allow you to stop the pump in a position to open the line and let it purge under gravity. At least one slot is needed to check that the Stepper is turning a full revolution so the dosing is accurate, not sure of the reason for the second slot unless it is to avoid the line remaining open while it steps over that problem area.. May 2, 2017 at 20:30

The other pair of wires is most likely two sides (emitter and collector) of a phototransistor, and it's not easy to tell which is which. The gain will be greater when biased correctly, but it may still work backwards (reverse-active mode of the phototransistor). Once you have worked out the LED side, you can find the correct polarity for the transistor by measuring the current transfer ratio: $\frac{\text{current passed by transistor}}{\text{current through LED}}$. Whichever way around gives the highest CTR is the right way. Keep in mind that enough light from the LED, or stray light in the environment, may saturate the transistor so that it is no longer limiting the current. Once again, make sure that you limit the short circuit current through the transistor.