On Wed, 26 Jun 2002 15:11:08 -0400 Erik Jacobs writes: > > to position. When in one of its stable positions, both sets of > contacts > > are open, so you can connect multiple encoders in parallel and > adjust any > > one of them and have the PIC read it fine. I managed to do it with > > polling instead of interrupts. On detecting that the first contact > had > > Well, what method did you use to "detect" that the "first" contact > was > closed? > > I'm thinking that if I AND the two outputs from the encoder, that > could give > an interrupt. Then if you just polled until the state changed, > you'd see > which came up next (either 01 or 10) and that would tell you what > direction > you're going... yeah? I'm detecting the first closure using polling, then staying in a tight loop (with a counter limit so I don't get stuck there forever) waiting for the first closure to open. I then check the second set of contacts. Their state tells me which direction the encoder is going. With interrupts, assuming the contacts are set up for a closure to ground, you can just generate a negative interrupt on detecting the first contacts closing, then check to see if the second contacts are open or closed, which will tell you the direction of rotation. Interrupt response time has to be fast enough to get there in time, but this should not be a problem. In the project I'm using the encoder on, I've written the whole thing in C and have not yet used interrupts. We'll see if I need to bring them in a little later. Harold > > -- > http://www.piclist.com hint: PICList Posts must start with ONE > topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: > ->Ads > > FCC Rules Online at http://hallikainen.com/FccRules Lighting control for theatre and television at http://www.dovesystems.com Reach broadcasters, engineers, manufacturers, compliance labs, and attorneys. Advertise at http://www.hallikainen.com/FccRules/ . ________________________________________________________________ GET INTERNET ACCESS FROM JUNO! Juno offers FREE or PREMIUM Internet access for less! Join Juno today! For your FREE software, visit: http://dl.www.juno.com/get/web/. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads