Mike, On Sun, 22 Feb 2004 08:28:07 -0000, Mike W wrote: > I'm still very new to Pic'n and I'm trying to write a 508A routine that > will take two input switches, UP and DOWN, to emulate a > Quadrature encoder on two output pins.. Some pointers: You need to think of what you're trying to achieve - as I understand what you've said, you want the two outputs to produce a series like: 00 01 11 10 (then 00 again) changing from one to the next in the "Up" direction, and to the previous one in the "Down" direction. Do you want one transition at each button-press, or do you want it to step on repeatedly while the button is held down at a particular rate? Break it down into units - I'd say: Startup (set the condition you want on all the pins), Button-press detection with debounce and validation (pressing both or neither does nothing, I'd suggest), Step-up, Step-down, output of result, possibly a repeat timer. Then you may want handling of exception conditions like loss of power, although it may have no significance here. But think whether this lot fits what you want - don't take my word for it! Draw it out in some way (flowchart, state diagram, whatever you're happy with) and see if it makes sense. As for the stepping process, I notice that rotating the pattern "00110011" would produce the sequence you want in any adjacent pair of bits, but you need to take care of "Carry", unfortunately. Or you might be able to use a 4-entry table and just run through that in either direction, or two of them, one for upwards, one for downwards and use the previous value as an index into them. Now the 508(A) is an EPROM (rather than Flash) device, so unless you have the quartz-windowed /JW version you'll want to get this working in a simulator before you start committing it to silicon, of course, otherwise each try costs a chip! Hope this helps a bit - Have fun! Howard Winter St.Albans, England -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics