Digital Read Out Quadrature Encode Reader

version 4.0, copyright 1995 1996
Lindsay Engraving Inc.
3714 W. Cedar Hills Drive
Kearney, NE 68847
slindsay@nyx.cs.du.edu

This program will make your computer into a linear DRO or 
rotary indexing reader for up to three 5V quadrature square 
wave encoders.


Description:
DRO.EXE is a DOS based program that will read incoming pulses 
from 5V quadrature square wave encoders through the parallel 
port.  A hardware interface is required that consists of only two 
transistors per encoder.  Text and wiring diagrams are supplied 
to help you make your own. 

Features:
Read up to three encoders simultaneously.
Reads 4 times the resolution of the encoder by counting all 
changes per cycle of the quadrature inputs.
Reset, Preset.
Absolute master mode and four incremental modes.
User selectable between Linear and rotary readouts.
User customizable unit to count by for each encoder.
Six places right of the decimal point resolutions possible.
Linear backlash compensation.
Millimeter to inch and inch to millimeter conversion.
Reads from most 5V encoders with quadrature square wave 
output.

Requirements:
IBM compatible, Dos, VGA or EGA
Bi-directional parallel port


Files found in DRO302.ZIP

DISCLAIM.TXT PLEASE READ
README.TXT   last minute notes
DRO.EXE      the program
ENCODE.CFG   saved configuration information (used by DRO.EXE)
QUAD.HLP     help file (used by DRO.EXE)
DRO.TXT	     this document
NO_IRQ1.GIF  simple interface diagram to use DRO without an IRQ
NO_IRQ2.GIF  diagram of the wire connections to the homemade interface box.
PARTS.TXT    list of parts required to make the interface
BOX1.JPG     photo of the interface box.
BOX2.JPG     "   "
BOX3.JPG     "   "
BOX4.JPG     "   "
BOX5.JPG     "   "
LINEAR.ZIP   photos of homemade encoder housing to read linear movement
WITH_IRQ.ZIP files on making the interface with an IRQ
PARALLEL.ZIP utility shareware program to tell you about your LPT port


Use a gif and jpg viewer to see these types of files.  You may also use a 
Web browser to view these files.  To view them with Netscape, start 
Netscape and click on "File" then "Open location".  Type in your path 
to the DRO directory and hit enter.  When you see the jpg and gif files 
just double click on them.

BUILDING THE HOMEMADE INTERFACE:
You may run DRO.EXE and look at the software without hooking 
up the encoders or interface.  

On the main menu of DRO there is an on/off switch for turning 
the IRQ (hardware interrupt) off and on.  With the IRQ off
the hardware interface you need to build is simpler.  Also it
works better than with the "IRQ on" feature with the more complex
hardware.  Without using an IRQ all three encoders can be
spun quickly at the same time without errors showing up in DRO.
To interface your 5V quadrature encoder to DRO without using an 
IRQ you will need two transistors (PNP) per encoder and a 5V 
power supply.  Look at the NO_IRQ1.GIF and NO_IRQ2.gif.  These 
are diagrams of the wiring for the transistors and the LPT port.  
They show two different sources for the 5V power supply.  One is 
by bringing a 5V wire directly out of the computer's power supply 
and the other is using an outside source for 5V.  They both are 
wired similarly.  If you use a 5V DC outside power supply make 
sure it is a clean TTL 5V DC.  If not, you may damage your encoders 
or LPT communications port.  Be sure to look at NO_IRQ1.GIF and 
notice the orientation of the Transistors.  PARTS.DOC has a list of 
parts and part numbers you will need to build the interface.  The 
part numbers are Mouser Electronics but you should be able to find 
them at your local Radio Shack if you prefer.  In this PARTS.DOC 
it also listed sources for inexpensive Hewlett Packard OEM 
encoders.  The BOX1.JPG through BOX7.JPG files show completed
photos of interface that should help in the construction.


ROTARY TO LINEAR CONVERSION
The seven LINEAR.JPG files show an idea for making a device 
that uses HP rotary encoders read a linear axis.  It consists 
of a HP rotary encoder, HEDS-9000-U00 (2048 pulses).  By the 
time it is quadratured in the software it is 8192 pulses.  To get from 
linear to rotary the housing holds the encoder with two idlers 
on either side.  A wire is strung (.015 fishing leader wire) the full 
length of the axis. The wire comes in over one of the idlers and 
around the encoder shaft and then back around the other idler 
and out of the housing.  The encoder shaft that the wire runs on is 
5/8" dia.  To figure out the resolution to tell DRO the unit to count 
by, you tell DRO to first count by 1.  Move the axis all the way to 
one end and zero DRO then move all the way to the other end of 
the axis and watching your hand crank dial so you know exactly 
how far you moved.   Then divide the distance traveled by the 
count on the DRO.  The unit for a 5/8 dia encoder shaft came out 
to be .00025394328.  This is entered in the program as the unit to 
count by.  If you get lots of cutting oil on the wire it can make it 
slip though.  Possibly a housing for the wire could be made.  If 
the wire is strung too tight the result is that the wire must stretch a 
little when the axis changes direction acting similar to backlash.  
With the wire just snug it will have a backlash of .00025 to .0005.  
It does take some trial and error to get the wire just right.  In the 
worst case it will act like backlash up to .002.  We have heard 
some Kevlar thread may work better and not stretch.  We would 
be interested in hearing from anyone that tries the Kevlar and how it 
works. 

There is a company that will have available soon 
some linear encoders modules and gradient film strips for 
about the price of the HP rotary encoders.  These linear encoders 
are suppose to read a film strip with a gradient of 500 lines per 
inch.  That will be 2000 quadutured (.0005" resolution). The 
company is www.usdigital.com 800 836 0198.  They also sell the 
HP encoders with and without housing and all kinds of encoder 
miscellaneous items.  

INSTALLING THE SOFTWARE:
To install the Digital ReadOut create a directory for it and use 
PKUNZIP to extract DRO302.ZIP to that directory.  To run the 
program change to the directory you made for it and type dro 
followed by enter.  You may run DRO.EXE and look at the software 
without hooking up the encoders or interface.  DRO.EXE will run 
off a floppy disk if you do not have a hard drive on the computer 
you would like to use it with.  Just copy the files DRO.EXE, 
ENCODE.CFG and QUAD.HLP to a floppy.

DESCRIPTION OF THE DIGITAL READOUT MENUS AND 
FUNCTIONS:
All the menus in the program have highlighted letters.  Hitting that 
letter on your keyboard will take you to that function.  At any time 
to return to the previous menu press the ESC key.

When DRO is started the first screen is where the LPT port is 
chosen.  The default port is LPT1.  The setting of the IRQ# is 
unimportant if the IRQ is shut off (IRQ on/off in the lower right 
corner of the screen).  Shut the IRQ off in order to use the 
interface described without an IRQ.  The Time Display value is used 
when the IRQ is shut off.  The program uses the time display 
value while DRO is watching the port and displaying the incoming 
value changes to the screen.  When information begins to come 
in too fast (encoders are spinning fast) the program will stop 
updating to the screen and just concentrate watching the port and 
counting.  When the encoders slow down the display will begin 
updating again.  The time display value determines when the program 
should quit displaying to the screen and only concentrate 
watching the port.  Try to set this value to the smallest number 
without errors coming in.  DRO will tell you if it had an error.  
With our testing a 486-100 computer and DRO setup with the encoders 
as viewed in Linear6.jpg and with a low Time Display setting 
of 6 a hand cranked axis spun as fast as possible DRO will keep 
up without errors.  In testing with the same 486-100 and a HP 
500 CPR encoder the shaft was spun at approx. 900 rpm without
errors.  Please note:  For best results a .1µF capacitor should
be placed between the incoming 5V at the interface and ground.
Also it may help to put one across Pos and Neg right at the 
encoders.  A 286 computer will require a higher setting of the 
Time Display to keep error from occurring.   Pertinent values 
are from 1 to 300.  DRO is a DOS based program and can be ran 
in a Windows 3 or Windows 95 window but DRO seems to get 
more errors from the encoders when Windows is running.  If you 
use Windows exit to DOS and run it from the DOS prompt for a 
faster reaction of the encoders.  To view and/or change the Time 
Display value press the 't' key from the main menu.  Enter a new 
value or press ESC to return back to the main menu.

Press the 'r' key from the main menu to begin reading the port.  
This encoder reader screen uses X, Y and Z to designate the 3 
encoders.  The X axis is hooked to pins 2 and 3 of the LPT port, 
Y is hooked to 4 and 5, and Z is hooked to 6 and 7.   There is a 
quick zero reset for each axis from this screen.  They are F1 for 
X, F2 for Y and F3 for Z.  Encoder Y and Z have been disabled in 
this 3.02 version.  Contact Lindsay Engraving for the latest 
registered version ($79.00) with all encoders enabled.

There are four increment modes and one main Master Mode.  
Press the 'm' key or space key to toggle through them.  Each axis 
(encoder) has it own setup screen and depending if you are in 
Master mode or a increment mode the setup up is different.  The 
increment mode is a more limited setup screen.  Toggle the mode 
by pressing the space bar until you are in Master Mode.  Now 
press the 'x' key.  This takes you to the X axis (encoder1) Master 
setup screen.  The available options in this setup are:

COUNTING UP/DOWN +/-  
To change the direction that encoder is counting.

RESET TO ZERO
To reset the encoder to zero.  Press it again to undo the rezero.  
(F1 will do the same from the reading screen but there is no undo 
from there) 
 
CURRENT VALUE    
Enter in a new current value

UNIT TO COUNT BY 
Enter in a value for this encoder to count by (up to 14 places to 
the right of the decimal).  

BACKLASH ON/OFF   
Use if you are hooking directly to a lead screw that has backlash.

LASH DISTANCE      
The backlash distance of the screw and nut.

LASH TENSION DIR. 
Which way you want the tension of the lash to go from.  (Once
you set this it will keep track of where you are in the backlash.
So if you take the backlash up the opposite of what it once
was and rezero the axis it will automatically switch the "lash
tension dir." for you.)

POSSIBLE ERRORS    
This will show a running count on the encoder reader screen of 
any possible errors.

PLACES SHOWN RIGHT OF DECIMAL 
How many places to the right of the decimal you would like 
displayed on the encoder reader screen.

F2 CONVERSION        
Menu to a inch to mm and mm to inch setup screen.

When you are finished entering in the data press the ESC key to 
return back to the encoder reader screen.

Press the space key to go to any other mode than the Master 
mode.  Now press the 'x' key.  This is the incremental mode setup 
screen.  The options are Reset to zero, Entering in a new current 
value and changing direction of counting +/-.  Press the ESC key 
to return back to the encoder reader screen.  

When you press the F1, F2 or F3, key to rezero from the 
encoder reader screen this will rezero only what mode you are
currently in.  If you press one of these hot keys from the master 
mode it will rezero all the modes however.  

It should be noted that if you are using an interface to your 
encoders without using an IRQ and you are in any other screen 
besides the encoder reader screen and one of the encoders 
moves the program will not see it move.  This is not true with an 
IRQ interface though.

You may set up any three of the encoders to read as a rotary 
readout to use in indexing.  From the encode reader screen press 
the 'r' key.  The program will ask you what axis you would like 
setup as rotary.   In the Rotary Settings screen the options are:

ROTARY COUNTING   ON/OFF
Shut this off to go back to linear counting.

RESET TO ZERO
Reset the encoder to zero.

CURRENT VALUE       
Enter in the current degrees value.  Either decimal or in degrees, 
minutes, secs.

DISPLAY           
Display in degrees, minutes, secs or in decimal degrees.

NUM. IN 360 DEGREES    
Enter in the number of counts per rev. of your encoder times four 
because DRO reads the quadrature.

SHOW REVOLUTIONS   
Toggles between showing how many times 360 or -360 was hit.

COUNT DIRECTION   -/+
Change direction of counting up or down.

After entering in the data press ESC to return to the encode 
reader screen.

There is one other hot key that is not shown on the encoder 
reader screen and that is the 'h' Help key. 



GETTING YOUR LPT PORT TO WORK WITH DRO
Your printer parallel LPT port should be a bi-directional (8 bit
in and out) to work with DRO.  What is called a "compatible mode" 
will not work as it is a 4 bit input only port.  A "EPP" parallel
LPT mode port will work.  If your LPT port is integrated right on 
the motherboard check your BIOS setup to see if you may configure 
your LPT in several type of modes.  After you have the interface 
made and you hook up an encoder for the first time and nothing 
seems to happen make sure that you selected the correct LPT port 
in the main startup screen of DRO.  If this is not the problem it 
may be that the LPT port is not bi-directional.  If after hooking 
the encoder up DRO counts but with lots of errors also coming in 
the problem probably is a noisy 5V power.  Try placing a .1µF 
(microfarad) capacitor across GND and positive at the interface 
box (see NO_IRQ2.GIF) and or a .1µF capacitor across GND and 
positive right at the encoder.  



