I'm working on sorting out a conveyor's speed. We have these Photocraft RH-P144AJ/8-30 encoders which I'm trying to get the Arduino to read from. Unfortunately I'm a bit in over my head trying to sort out PNP/NPN/etc.
The encoder is a single pulse encoder. Outputs a square wave and I just need to count pulses to sort out the conveyor speed. I'll be powering the Arduino and encoder from the same 12v source. The encoder supports four methods of output circuit:
PNP, NPN, NPN open collector, and push-pull output.
More detail here: http://www.photocraftencoders.com/Incremental%20Encoder%20Options%20&%20Features.htm#Output Circuits
Four wire interface: Voltage, Common, Output and Ground.
I'm really not sure on the best way of hooking this up.
I've tried a couple samples from the playground but couldn't find anything that would do the trick and I'm a bit worried about wiring this thing up wrong.
The different output circuits are not the problem, it's just a bit more difficult because you have the RH-P144AJ/8-30 and not the RH-P144AJ/5. The later would just work with 5V, the former needs 8 to 30V and puts out the same voltage. The simplest circuit would be a NPN open collector configuration. Then connect Common to GND, Voltage to your 12V Vin and Output to a digital input (you can choose any) and from there a 3k3 resistor to 5V. Don't connect the encoder before you configured NPN open collector, otherwise you may damage your Arduino.
Alright, I think I understand what you are saying.
Just so I have this clear on the wiring (forgive the crude drawing):
Encoder Arduino Power
V --------------------------------- +12v
C ----------\ N
Gnd --------+-- Gnd --------------- Gnd
Output --+----- Digital In
\-3k3- 5v