reading 2 phase encoder

hello everyone

I am having a problem trying to read an encoder. The encoder is a 600 pulses per revolution type and needs 3 to 24 volts to operate. It has 4 wires, 2 are for phase A and B and two are gnd and v+. I have connected the phase A and B outputs to 10k pull up resistors and on to a 12 volt supply and connected this to pins 0 and 1 on my BS2.
On the stamp side I have tried several methods for counting the pulses. As an example, I tried the following code:

' {$STAMP BS2}
' {$PBASIC 2.5}

count0 VAR Word
count1 VAR Word
total0 VAR Word
total1 VAR Word
INPUT 0
INPUT 1
total0 = 0
total1 = 0
DO
COUNT 0, 200, count0
COUNT 1, 200, count1

DEBUG "count0 = ", DEC count0, CR
total0 = total0+count0
DEBUG "total0 = ", DEC total0, CR
DEBUG "count1 = ", DEC count1, CR
total1=total1+count1
DEBUG "total1 = ", DEC total1, CR
DEBUG HOME


'DEBUG CLS
LOOP
END

The problem is that I don't see the expected number of counts. For example, if I turn the encoder 90 degrees, I would expect to see roughly 150 pulses or counts. I don't see this many and usually ends up in the 10s or 20s at most. I am thinking that perhaps the BS2 doesn't record fast enough to see all the pulses. Is this true? Also, I don't have a scope and I attempted to connect the encoder to a DVM. If I slowly rotate the encoder, I think I am able to get a 7V pulse from one of the phases.

The project is for a PID control system using a stepper motor for a robotic arm right now. If I can get the system to work, I may move on to other robotic uses.

Any suggestions are welcome.

Robertz

Comments

  • 4 Comments sorted by Date Added Votes
  • You are counting pulses for only 80 millisec.
    COUNT 0, 200, count0
    COUNT 1, 200, count1
    
    (200 times 400 microsec) Try bumping that up to, say, one full second.

    Also, by just counting pulses, you cannot tell what direction the shaft is turning. Try a search of quadrature in this forum.

    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Usually phases A and B are both considered in order to resolve the direction of motion, and I'm guessing that is what you want to do for a robot arm. I have some information using the Stamp at this link, and you'll find more discussions on this forum by searching as Tom suggested. That said, the Stamp is relatively slow and single-minded, and will have trouble if the arm moves too fast, something on the order of 10 seconds for 90 degrees.
  • I use:

    https://www.mikroe.com/counter-click

    You can obtain the 7366 chip from Anaheim Automation but there is a minimum order quantity.


    PropBASIC ROCKS!
  • @robertz

    Welcome to Parallax forums.

    Omni Pro has them, starting from $3,95/ea, no MOQ.

    omnipro.net/lsi-csi/LS7366R

    Henrique
Sign In or Register to comment.