Using Photo-transistors to detect motor position.

Hello, First time posting to these forums for some help i just couldn't find the right answer for. I am currently working on a senior project for school that involves making an old robot arm work again since the school lost the original controller. The Robot arm uses normal DC motors (Not steppers) to move and actuate. But each motor has a photo-transistor encoder that the original controller used to determine the location of the appendage. Unfortunately, I do not know how to interface these with the arduino to have it determine where each motor is. I had an idea to use counts (Like 0 being the home position and 50,000 being fully extended) to tell the arduino where it is.I know how I could count how many passes the encoder makes however, I do not know how I can make the counts move backward. My theory would cause the counts to continuously go up until the counter overflows.

Could someone tell me how to achieve this? Thank you very much

For anyone interested this is the .pdf on the robot. The encoders are in appendix E. pg. 147

Thanks again.

The encoders are two channel quadrature encoders that allow you to keep track of the relative position of the arm motors, but not the absolute position. That simply means that you have to have some way of setting the zero position of each arm motor when the robot is turned on and initialized, then you can keep track of each motor's position afterwards.

The encoder outputs are called P0 and P1, nowadays they would be called A and B. There are libraries and plenty of examples on how to use these with Arduino, but for direct connection to the Arduino, make sure that the P0 and P1 output voltages are within the allowed 0-5 V range. Google "Arduino encoder" for lots of info.

It is very nice that you found such complete documentation.

Oh, Cool, I didn't even think to check the libraries. And yeah, I know it wont be that accurate,but that shouldnt be much of an issue since it will only run some very simple programs to simply display it works. Thank you for your reply. You have helped me tremendously.

And yeah, I know it wont be that accurate

There is no reason to believe that the encoder output will be inaccurate.

The thing to know about these encoders, is that you can tell which way the motor is running, depending on whether the A pulse comes before or after the B pulse.

A photo of the encoder boards could be useful - the boards may or may not include
pull-up or pull-down resistors on the outputs of the phototransistors, and if not you'll
need to experiment to find what value load resistors work reliably.

The PDF shows 4 pins to the encoder boards, 2 will be power for the LEDs, the other
two are the outputs which will probably share GND (or maybe Vcc) - again a little
delving around is needed, but a photo of the board(s) if they are accessible would be
great to check.

You actually know in which direction it will be moving. It's a DC motor. So it means you'll need to change the polarity to make it move in a different direction.