> -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Spehro Pefhany > Sent: Sunday, October 21, 2001 1:17 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: Rotary Encoders > You can certainly isolate them with diodes. Using TTL threshold inputs, > you can use two diodes per encoder (6 total). Then two inputs > (with resistors > to ground) are dedicated to the encoders, and you have 3 output > pins connected > to the encoder commons (let's assume the shells are nicely grounded). > If you don't follow this, e-mail me. > > Now, you've mentioned 21 keys, so I'll assume you have at least > 10 port pins > already dedicated to the keyboard. (6 x 4 or 5 x 5 or 7 x 3). If you use > 3 pins to drive the encoders and the remaining 7 as inputs, 2 for the > encoders, > that allows you to have 15 more keys (including the momentary ones in the > encoders, which don't require diodes). Or, if you use the 6 x 4 method, > you can have a 4 resistor pulldown network, 6 diodes or (3 SMT duals), > 3 encoders, and up to 12 keys without any additional components (including > the encoder switches). If you want the full complement of switches, as > implied by the x-y matrix, you'll have to isolate at least some of the > switches from the encoder inputs with diodes, but that may not be > necesssary. Many thanks for the suggestions Spehro. I think you have just confirmed my original thoughts. A 7 column x 3 row matrix was originally considered for just the keys. The intention was to sequentially pulse the columns at a rate generated via a timer driven ISR (50-100Hz scan). The scan result would then be available in row registers for further processing in the body of the program. The reason for scanning the columns was that I need to use at least 6 of the 7 outputs as inputs for other functions. Most I/O on this PIC is doing double duty and sometimes more! I know I have to isolate the various lines with diodes and pulldown resistors to avoid conflicts as well as worrying about the capacitance on the lines. To add the encoders I was going to decrease the columns to 6 and increase the rows to 4. This would allow me to dedicate row 4 to a common point on the 3 encoders with the 6 columns connected to A & B and still allow me to have up to 18 keys. AFAIK the contacting encoder can have A & B as inputs as well as outputs since they are just switches. I think this is similar to what you are suggesting, although the rows and columns are swapped. Despite my initial doubts and some negative feedback on using scanning I now believe it can be done successfully providing the scan is fast enough and the contacts are properly debounced in software. What scan rate and debouncing period to use will have to be determined in practice. Some slippage is acceptable but jumps or change in direction are obviously not. The only killer now will be when I announce the increased cost! Regards David -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.