Newsgroups: comp.robotics
Path: brunix!cat.cis.Brown.EDU!noc.near.net!paperboy.wellfleet.com!news-feed-1.peachnet.edu!news.duke.edu!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!math.ohio-state.edu!jussieu.fr!univ-lyon1.fr!swidir.switch.ch!newsfeed.ACO.net!Austria.EU.net!EU.net!uunet!hobbes!earth.armory.com!rstevew
From: rstevew@armory.com (Richard Steven Walz)
Subject: Re: C and the printer port?
Organization: The Armory
Date: Tue, 19 Jul 1994 19:51:48 GMT
Message-ID: <Ct7Dut.2Fz@armory.com>
References: <1994Jul17.153810.18312@news.vanderbilt.edu>
Sender: news@armory.com (Usenet News)
Nntp-Posting-Host: deeptht.armory.com
Lines: 59

In article <1994Jul17.153810.18312@news.vanderbilt.edu>,
 <HEAGYWS@ctrvax.Vanderbilt.Edu> wrote:
>I am currently using QuickBasic and the OUT 888,xx command to control
>the parallel printer port of a PC.  The port is connected to a 
>stepper motor controller.  The whole setup is pretty simple...all I need
>to do is pulse one or two lines high and low to control the direction
>and stepping of the motor.  It works fairly well using QB, but I am sure
>the stepping speed is being limited by the language I am using.  I'm
>currently running the software on a 386sx, so I'm sure a faster machine
>would also improve the situation...the problem is that after the software
>is finished, it will most likely be run on 286 type machines.
>
>I was considering porting the software to C or assembly and was wondering
>if anyone is aware of the commands used to access the printer port (I
>am particularly interested in the C commands) for this type of work?
>Also, if you have any other ideas how I could increase the stepping speed,
>I would be glad to hear them.
>
>Thanks...Win
>heagyws@ctrvax.vanderbilt.edu
-------------------------------------
Re-Reading your post, I just realized that you didn't write the output
routine in assembly yet. That will cure your ills, *I* use one to output
sound! Up to about 18kHz, and that's with a big delay implemented. I just
use a simple R-2R ladder network to do my D2A, but you don't need to!
Here's the routine in assembly. You can enter it in DEBUG or equivalent:
-Steve Walz   rstevew@armory.com
------------------------

-u100
7BCA:0100 FA            CLI	          ; clear interrupt mask 
7BCA:0101 B90080        MOV	CX,8000   ; number of bytes to send in CX
7BCA:0104 BB2001        MOV	BX,0120   ; start adr of senddata in BX
7BCA:0107 BA7803        MOV	DX,0378   ; output adr in DX 
7BCA:010A 8A07          MOV	AL,[BX]   ; data from start adr to AL 
7BCA:010C EE            OUT	DX,AL     ; output AL to port DX 
7BCA:010D 43            INC	BX        ; increment BX to next data adr 
7BCA:010E 51            PUSH	CX        ; now store CX on stack 
7BCA:010F B92300        MOV	CX,0023   ; put delay count in CX for LOOP 
7BCA:0112 E2FE          LOOP	0112      ; LOOP here till CX decr to zero
7BCA:0114 59            POP	CX        ; get old CX off stack 
7BCA:0115 E2F3          LOOP	010A      ; LOOP to next data load into AL
7BCA:0117 FB            STI	          ; set interrupt mask
7BCA:0118 CD20          INT	20        ; end program and return to DOS 
7BCA:011A 90            NOP               ; NOP means no operation command
7BCA:011B 90            NOP
7BCA:011C 90            NOP 
7BCA:011D 90            NOP
7BCA:011E 90            NOP
7BCA:011F 90            NOP
7BCA:0120 XX?           YYY?              ; first data location with data
-q                                        ; and baloney mnemonic
-----------------------------------------------
Here's the code. You'll want to change that delay number to change speed.
Maybe add a conditional change in the read data address to control
direction. Add a value entry loop to change the delay while running. Cute
project.
-Steve Walz

