Stringing together multiple quadrature encoders
RoHerman00
Posts: 22
This question pertains to encoders (quadrature type) but also somewhat to the basic stamp 2 programming. I have 4 encoders and 4 hbridge circuits i made. Each encoder as an A and B output for measuring the pulses coming from the encoder and thus allowing position to be counted/calculated. To detect these changes i have used part of a program written by another which has a line of code that reads "newbits = INA & %0011" where pins 0 and 1 are connected to the A and B outputs respectively. to check the second encoder i would use INA & %1100 and etc. for the others.
My question is can i tie together all of the A outputs into one wire which plugs into pin 0 and then each B output on the 4 encoders plug into pins 1, 2, 3, 4? To read these encoders could i use the code newBits = INA & %0011 for encoder 1, newbits = INA & %0101 for encoder 2, newBits = INA & %1001 for encoder 3 and so on?
Thank you
My question is can i tie together all of the A outputs into one wire which plugs into pin 0 and then each B output on the 4 encoders plug into pins 1, 2, 3, 4? To read these encoders could i use the code newBits = INA & %0011 for encoder 1, newbits = INA & %0101 for encoder 2, newBits = INA & %1001 for encoder 3 and so on?
Thank you
Comments
-Phil
One possible way to read all 4 encoders (while saving pins) would be to use something like a 74HC165 which has 8 parallel inputs and can shift them out serially using a few pins. You can cascade them for more inputs.
The main concern I have about the whole thing is the resolution of your encoders and how fast they are moving. Keeping track of 4 at once in real time and updating the motors probably isn't an application best suited for the Stamp since you'd have to poll the encoders and if you don't keep reading them fast enough may miss pulses. A Propeller chip (with more I/O than most Stamps) may be a better option for this application.
Robert
http://forums.parallax.com/showthread.php?121179-Reading-Quadrature-Encoders
A better method would be to use some tri-state buffers at the output of each encoder and then use the enable pin on the buffer to select which encoder you want to read. That way the disabled ones will be isolated and won't interfere. You can read more here:
http://www.electronics-tutorials.ws/logic/logic_9.html
http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/CompOrg/tristate.html
A common chip that would work is a 74HC244 (or 74HCT244, 74LS244, etc) It has two sets of 4 buffers. If you used a pair of these chips you could cover all three encoders.
Robert