Reading optical encoders with javelin
theoatvecna
Posts: 20
Has anyone read optical encoders using javelin, or have any suggestions.
Here are some of the options I am considering:
-I have a chip (LS7 183) that turns the encoder a&b signals to a simple updown counter signal, which I presume I could read directly on the javelin, but I am a bit concerned about missing counts.
-I could use the above decoder and a simple updown counter chip (74193) to buy some security about not missing counts, and then could regularly read the 4 byte output of the chip using 4 data lines of the javelin.
-I have a chip (LS7 166) that will take care of all the counting (24bit), but has a fairly involved set of registers and an 8bit bus.
-Wondering if there is any IIC enabled encoder counter chip out there (I haven't found it)
Any suggestions or advice would be welcomed.
Thanks,
Daniel
Here are some of the options I am considering:
-I have a chip (LS7 183) that turns the encoder a&b signals to a simple updown counter signal, which I presume I could read directly on the javelin, but I am a bit concerned about missing counts.
-I could use the above decoder and a simple updown counter chip (74193) to buy some security about not missing counts, and then could regularly read the 4 byte output of the chip using 4 data lines of the javelin.
-I have a chip (LS7 166) that will take care of all the counting (24bit), but has a fairly involved set of registers and an 8bit bus.
-Wondering if there is any IIC enabled encoder counter chip out there (I haven't found it)
Any suggestions or advice would be welcomed.
Thanks,
Daniel
Comments
I have interfaced a Bournes ( or was it Grayhill? )· quadrature rotary switch (optical encoder)·to a Javelin using the PCF8574 i2c i/o expander.
PCF8574 has 8 i/o pins (user configurable),·and uses i2c for communication.· The Javelin library already includes a class for using the chip.· In the next day or so, I'll have written a class to read the switch.
The good thing about the PCF8574 is the chip has an output pin,·!INT,·which signals if any change has occured on the input pins. Rather than constantly read the chip via i2c, I just check a single cpu pin to know if the chip needs to be read.
In a tight loop, I could not turn the switch fast enough to "skip" a position.· A skipped position is detectable by reading an illegal count progression.· There was a Circuit Cellar article that was very helpful in learning to decode quadrature patterns.· Basically, the last position AB bits are in bits 3,2.· Current AB bits or'ed in to bits 1,0.· The four bit number is used in·a lookup table, indicating CW, CCW or skipped increment.
Maybe a rotary switch isn't totally related, but I hope this helped.
A) Read new encoder bits
result = new XOR old
C) If result is 0, go back to A
D) old = old << 1
E) old = old XOR new
F) If old.1 is 1 then CW, otherwise CCW
I hope this makes sense and is helpful. Perhaps a timer object could be used to make sure that the ecoder bits are read at a fairly regular rate.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
thanks,
Daniel
I'm using a PCF8574 that reads US Digital LS7166 this setup needs 5 ports.
If you can afford the chip count then go for it beats throwing away CPU cycles and forever wondering if you missed encoder lines.
If you can afford the ports then skip the PCF8574, this takes 11 ports.
http://www.usdigital.com/products/ls7166/ls7166adv.shtml
I also like there encoders very fast delivery and very economical.
Now· if someone would just make a I2C version of this chip!
Jack Hudler
I was just looking for the I2C -> 166 Java and I can't find it anywhere... it was just a prototype.
On the other hand I have some BS2 code that reads the 166 chip, and should be easy to convert.
I attached the BS2 code if you need the schematic for this let me know.
Post Edited (Jack Hudler) : 12/8/2004 7:42:58 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
After a year of not playing with my robot toys, I have ordered a couple SureLink boards and grabed the plastic boxes of parts from the garage. My first priority will be to get the SureLinks going and write a class for them as well as a comm protocol so I can use a host PC to function as a goals processor with the Javelin being the action processor. After that though I plan to get some quadrature encoders going and your SX project sounds like fun. You can just never have enough types of microcontrollers on a bot!
By the way when will we see SX/J? lol
Current bot chassis is: www.shekari.org/wheels.php
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Shawn
Post Edited (Shawn Reed) : 2/3/2005 8:07:47 PM GMT
I spent a little time trying to read the LS7166 directly without success, I am not sure how to handle some of the pins. Is the schematic offer still good? That would help me tremendously. Thanks.
Thanks,
Daniel