Shop OBEX P1 Docs P2 Docs Learn Events
Stringing together multiple quadrature encoders — Parallax Forums

Stringing together multiple quadrature encoders

RoHerman00RoHerman00 Posts: 22
edited 2011-01-27 12:50 in Accessories
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

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-20 11:35
    No, you would not only lose information regarding direction of rotation, you could actually harm the encoder A outputs since they would be in conflict.

    -Phil
  • ercoerco Posts: 20,256
    edited 2011-01-21 08:21
    A little conflict helps things stay in the proper pecking order!
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2011-01-21 09:41
    If the outputs of your encoders happen to be open collector then they could be tied together but a Phil mentions there really isn't any point since you won't really know what encoder channel is the one bring the output low.

    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
  • ercoerco Posts: 20,256
    edited 2011-01-21 12:34
    I got interested in QE's in the following thread and did some experimental speed testing for a BS2, where the motor literally achieved "smoking" speeds as the video links show. The motor blew up before the BS2 & single QE lost count.

    http://forums.parallax.com/showthread.php?121179-Reading-Quadrature-Encoders
  • RoHerman00RoHerman00 Posts: 22
    edited 2011-01-27 12:31
    In reply to phil_pilgrim I tried a while back to connect two motor's a's and b's of the encoder together and I read counts and it didn't lose any counts. The motors weren't run at the same time by the way. But when I added a third motor it would increment on its own because sometimes the motors were positioned in some way that the blacks and whites were on the detector at the same time. I'm just wondering if rather than connecting both wires together if I could just connect the a's together and use the b's as a non directional counter. The encoder is a quadrature type (don't know if it makes a difference) and I could use only one of the detectors to sense motion. And to robotworkshop i'm trying to do what I can without spending more money that i don't have. But I'll keep that in mind in the future. The chip that I'm using to count is a basic atom pro and the BS2 is only used to give it data that tells it where to go.
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2011-01-27 12:50
    If you share the outputs and they are all tied together then you will have problems like you mention since the state of the encoders (high/low) may end interfere.

    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
Sign In or Register to comment.