EMRFD Message Archive 2312

Message Date From Subject
2312 2008-10-24 15:49:17 kcmuthumani Rotary Encoder interface for serial / lpt port
Hi all,

What would be the best way to interface a rotary encoder to a
computers serial / lpt port. I have a few single board computer,
that's about 2"x4" in size. It has a low end pentium processor at 100mhz.

I am writing a program that will control 2 TenTec RX-320 receivers,
having a nice knob to spin would be great, the SBC has no USB ports
only two serial and LPT port. I know about the Griffin Powermate knob
but thats usb so I am out of luck there.

I am thinking of using a pic 12x chip and program it to read the
rotary encoder and output data 9600 output string that the program can
read or maybe even emulate a keyboard press.

2314 2008-10-24 17:39:14 Nick Kennedy Re: Rotary Encoder interface for serial / lpt port
I've done it by directly reading the A and B inputs on the serial port's
handshaking line, using assembly language. This was a 486 at 50 MHz speed,
no problems. I've also done it with the AVR butterfly and recently with a

Your idea of a dedicated PIC to monitor the encoder and then send info to
the PC doesn't sound bad though. I could send you some source code if
you're interested.
I'm currently working on a receiver using the HYCAS and a few other familiar
components, including an NJQRP AD9851 DDS. I'm writing code for the
PIC16F88 to control the thing.

73--Nick, WA5BDU


[Non-text portions of this message have been removed]
2315 2008-10-25 06:58:27 Archie Lamb Re: Rotary Encoder interface for serial / lpt port
Hi Kevin,
You don't really indicate how much experience you have with the
various pieces
but here are some preliminary suggestions:
(Personally I like the uController way - but If you only want to
interface to an
encoder, not much of this is necessary)

Your serial or parallel port could talk to a uController (PIC/AVR) and
then it
could do all sorts of really cool things (maybe none of which you want)

- there are lots of examples / resources out there on either the PIC
or the AVR
(I use both but prefer the AVR - once you get going, I don't find a
great deal
of difference but the AVR is simpler and much cheaper to set up and
get going).

- The "elmer 160 tutorial" covers the PIC and has example code for
almost all
the hardware IO stuff (including the encoders). The compilers come
with examples
and all(?-I'm thinking of 4 and all of those) have encoder libraries
with examples.

- (I have written assembler (professionally) but agree with the old
saw 'life is
too short for assembler') but if you've tried assembler and like it,
go for it.
There are several compilers out there for both the PIC and AVR (the C/C++
compiler for AVR is free and VERY good); they come in both Basic and
C. The real point
here is that these high level compilers have built in libraries for
encoders and
other useful things like LCDs and one wire devices to give you a good

This "block diagram" of the project that you've sketched out has lots
of (fun)
blocks. I did something similar (but much simpler). Since several of
the blocks
were unfamiliar to me, I designed some and simply inserted some that I
had on
hand to get a starting place (one being the AD9851 daughter card that is
available). I got the transceiver working and then went back and
re-did several
blocks to get to know them better and 'improve' them. (some were
better, some
were not (;-)

There are lots of guys
2320 2008-10-25 16:29:29 Nick Kennedy Re: Rotary Encoder interface for serial / lpt port
Another thing I forgot to mention -- you can do a little "preprocessing" in
hardware if you wish. My original PC (8086/88) based program and circuit
had a couple flip-flops converting the A and B outputs of the encoder to CW
and CCW pulses to be read by my serial port.

I don't know that it's worth the effort, since the logic in software to
handle the "raw" inputs is pretty simple.

Assembler is pretty addictive for us masochists. I agree the AVR is a
little easier to program due to its more capable instruction set.

73-Nick, WA5BDU


[Non-text portions of this message have been removed]