reading 2 phase encoder
robertz
Posts: 1
in BASIC Stamp
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
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
Also, by just counting pulses, you cannot tell what direction the shaft is turning. Try a search of quadrature in this forum.
https://www.mikroe.com/counter-click
You can obtain the 7366 chip from Anaheim Automation but there is a minimum order quantity.
Welcome to Parallax forums.
Omni Pro has them, starting from $3,95/ea, no MOQ.
omnipro.net/lsi-csi/LS7366R
Henrique