On 12/23/2013 11:57 AM, Dwayne Reid wrote: > Comments in-line. > > At 03:02 AM 12/23/2013, CDB wrote: >> I've been asked if I can conjure up a device that will allow 6 incremen= tal >> rotary encoders and 10 ADC inputs. I suspect this is for some sort of >> gaming doodad. >> >> I'm wondering on what the lists thoughts are on saving 12 port pins with >> the following. >> >> Attach channel A of all the encoders to a single interrupt on change pin= .. >> The IOC will look for high to low and then low to high. > This won't work. Assume that the encoders are open-collector (or > mechanical switches) that go to Ground when closed. > > When any one encoder is in a position that channel A is grounded, > none of the other encoders can change that pin. You will see changes > on the individual channel B lines, but without seeing the changes on > the channel A line, you can't tell direction. > > Also note that the method you are proposing, which is treat channel A > as the clock line and channel B as the direction line; can suffer > from false counts because of jitter on the channel A line. That is: > assume that the encoder is right at the transition point for channel > A. You get clock edges but no direction changes. This results in > false counts. > > Been there, done that, learned NOT to do it that way . > > There are a couple of ways to do this. But, honestly, I'd dedicate > either a small PIC (with enough pins for all 12 encoder lines) and > poll the pins at a very fast rate. Then use the standard 4-entry > lookup table for each of the encoders or, if you are feeling > ambitious, the also-standard 4-state state machine for each of the encode= rs. > > dwayne > I'm using a seperate PIC16F1933 as a quad decoder for 4 channels of=20 motors. Firmware de-bouncing is very reliable, with a huge memory for=20 keeping track of the count. During non-motor movement times, the PIC=20 handles RS232 access to a small notebook PC to help us to setup our=20 solar installations. The various counts are stored in EEPROM in=20 triplicate to be sure that the count is always accurate, even during=20 power off situations. The PIC16F1933 officially can be run at 32Mhz but I can run it easily at=20 40Mhz at 5V by using a 10M resonator instead of an 8M. Plenty fast for=20 anything we're doing. These PIC's are cheap, too; about $2 USD. Special quad decoders cost $15=20 or more. --Bob --=20 The only place success comes before work is in the dictionary. VINCE LOMBARDI --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .