亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? use of a pc printer port for control and data acquisition.htm

?? Parallel Port description of the communication port
?? HTM
?? 第 1 頁 / 共 3 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0061)http://et.nmsu.edu/~etti/fall96/computer/printer/printer.html -->
<!  
REQUEST: REVIEW

TITLE: Use of a PC Printer Port for Control and Data Acquisition

AUTHOR: Peter H. Anderson

EMAIL ADDRESS: pha@eng.morgan.edu

INDEX: 

ORGANIZATION:  Morgan State University

<HTML><HTML><HEAD><TITLE>Use of a PC Printer Port for Control and Data Acquisition</TITLE>
<META content="text/html; charset=windows-1252" http-equiv=Content-Type>
<META content="MSHTML 5.00.3315.2870" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<CENTER>link to <A href="http://et.nmsu.edu/~etti"><I>the <B>Technology 
Interface </I></B></A><BR><B>the Electronic Journal for Engineering 
Technology</B> </CENTER>
<P><FONT size=2><A href="http://et.nmsu.edu/~etti"><I>the <B>Technology 
Interface</B></A> /Fall 96</I></FONT> 
<CENTER>
<HR>

<H1>Use of a PC Printer Port for Control and Data Acquisition</H1></CENTER>
<HR>

<CENTER>
<H4>by</H4>
<P><B>Peter H. Anderson<BR><I><A 
href="mailto:pha@eng.morgan.edu">pha@eng.morgan.edu</A></I><BR>Department of 
Electrical Engineering<BR>Morgan State University</B><BR></CENTER>
<P>
<P><B>Abstract:</B> <I>A PC printer port is an inexpensive and yet powerful 
platform for implementing projects dealing with the control of real world 
peripherals. The printer port provides eight TTL outputs, five inputs and four 
bidirectional leads and it provides a very simple means to use the PC interrupt 
structure. 
<P>This article discusses how to use program the printer port. A larger manual 
which deals with such topics as driver circuits, optoisolators, control of DC 
and stepping motors, infrared and radio remote control, digital and analog 
multiplexing, D/A and A/D is avaialable. See 
<P>http://www.access.digex.net/~pha 
<P>A special thanks to Morgan State University students Towanda Malone, 
Christine Samuels and H. Paul Roach for their technical contributions and to New 
Mexico State University student Kyle Quinnell for preparing the html file.</I> 
<P>
<CENTER>
<H2>I. Printer Port Basics</H2></CENTER>
<P>
<CENTER>
<H3>A. Port Assignments</H3></CENTER>
<P>Each printer port consists of three port addresses; data, status and control 
port. These addresses are in sequential order. That is, if the data port is at 
address 0x0378, the corresponding status port is at 0x0379 and the control port 
is at 0x037a. 
<P>The following is typical. 
<P><PRE><B> 
       Printer         Data Port        Status          Control</B>      
	LPT1            0x03bc          0x03bd          0x03be      
	LPT2            0x0378          0x0379          0x037a      
	LPT3            0x0278          0x0279          0x027a 
</PRE>
<P>My experience has been that machines are assigned a base address for LPT1 of 
either 0x0378 or 0x03bc. 
<P>To definitively identify the assignments for a particular machine, use the 
DOS debug program to display memory locations 0040:0008. For example: 
<P><PRE>    
	&gt;debug      
	-d 0040:0008 L8      
	0040:0008       78 03 78 02 00 00 00 00    
</PRE>
<P>Note in the example that LPT1 is at 0x0378, LPT2 at 0x0278 and LPT3 and LPT4 
are not assigned. 
<P>Thus, for this hypothetical machine; 
<P><PRE><B>    
       Printer         Data Port        Status          Control</B>      
	LPT1            0x0378          0x0379          0x037a      
	LPT2            0x0278          0x0279          0x027a      
	LPT3            NONE      
	LPT4            NONE    
</PRE>
<P>An alternate technique is to run Microsoft Diagnostics (MSD.EXE) and review 
the LPT assignments. 
<P>
<CENTER>
<H3>B. Outputs</H3></CENTER>
<P>Please refer to the figures titled Figure #1 - Pin Assignments and Figure #2 
- Port Assignments. These two figures illustrate the pin assignments on the 25 
pin connector and the bit assignments on the three ports. 
<HR>

<CENTER><IMG 
src="Use of a PC Printer Port for Control and Data Acquisition_files/PHAFIG1.gif"> 

<P><B>Fig 1. Pin Assignments</B></CENTER>
<HR>

<CENTER><IMG 
src="Use of a PC Printer Port for Control and Data Acquisition_files/PHAFIG2.gif"> 

<P><B>Fig 2. Port Assignments</B></CENTER>
<HR>

<P>Note that there are eight outputs on the Data Port (Data 7(msb) - Data 0) and 
four additional outputs on the low nibble of the Control Port. /SELECT_IN, INIT, 
/AUTO FEED and /STROBE. 
<P>[Note that with /SELECT_IN, the "in" refers to the printer. For normal 
printer operation, the PC exerts a logic zero to indicate to the printer it is 
selected. The original function of INIT was to initialize the printer, AUTO FEED 
to advance the paper. In normal printing, STROBE is high. The character to be 
printed is output on the Data Port and STROBE is momentarily brought low.] 
<P>All outputs on the Data Port are true logic. That is, writing a logic one to 
a bit causes the corresponding output to go high. However, the /SELECT_IN, 
/AUTOFEED and /STROBE outputs on the Control Port have inverted logic. That is, 
outputting a logic one to a bit causes a logic zero on the corresponding output. 
This adds some complexity in using the printer port, but the fix is to simply 
invert those bits using the exclusive OR function prior to outputting. 
<P>[One might ask why the designers of the printer port designed the port in 
this manner. Assume you have a printer with no cable attached. An open usually 
is read as a logic one. Thus, if a logic one on the SELECT_IN, AUTOFEED and 
STROBE leads meant to take the appropriate action, an unconnected printer would 
assume it was selected, go into the autofeed mode and assume there was data on 
the outputs associated with the Data Port. The printer would be going crazy when 
in fact it wasn't even connected. Thus, the designers used inverted logic. A 
zero forces the appropriate action.] 
<P>Returning to the discussion of the Control Port, assume you have a value val1 
which is to be output on the Data port and a value val2 on the Control port: <PRE>    
	#define DATA 0x03bc      
	#define STATUS DATA+1      
	#define CONTROL DATA+2      
	...      
	int val1, val2;      
	...      
	val1 = 0x81;    /* 1000 0001 */         /* Data bits 7 and 0 at one */      
	   outportb(DATA, val1);      
	val2 = 0x08;    /* 0000 1000 */      
	   outportb(CONTROL, VAL2^0x0b);      
	/* SELECT_IN = 1, INIT = 0, /AUTO_FEED = 0, /STROBE = 0 */    
</PRE>
<P>Note that only the lower nibble of val2 is significant. Note that in the last 
line of code, /SELECT_IN, /AUTO_FEED and /STROBE are output in inverted form by 
using the exclusive-or function so as to compensate for the hardware inversion. 
<P>For example; if I intended to output 1 0 0 0 on the lower nibble and did not 
do the inversion, the hardware would invert bit 3, leave bit 2 as true and 
invert bits 1 and 0. The result, appearing on the output would then be 0 0 1 1 
which is about as far from what was desired as one could get. By using the 
exclusive-or function, 1 0 0 0 is actually sent to the port as 0 0 1 1. The 
hardware then inverts bits 3, 1 and 0 and the output is then the desired 1 0 0 
0. 
<P>
<CENTER>
<H3>C. Inputs</H3></CENTER>
<P>Note that in the diagram showing the Status Port there are five status leads 
from the printer. (BSY, /ACK, PE (paper empty), SELECT, /ERROR). 
<P>[The original intent in the naming of most of these is intuitive. A high on 
SELECT indicates the printer is on line. A high on BSY or PE indicates to the PC 
that the printer is busy or out of paper. A low wink on /ACK indicates the 
printer received something. A low on ERROR indicates the printer is in an error 
condition.] 
<P>These inputs are fetched by reading the five most significant bits of the 
status port. 
<P>However, the original designers of the printer interface circuitry, inverted 
the bit associated with the BSY using hardware. That is, when a zero is present 
on input BSY, the bit will actually be read as a logic one. Normally, you will 
want to use "true" logic, and thus you will want to invert this bit. 
<P>The following fragment illustrates the reading the five most significant bits 
in "true" logic. <PRE>    
	#define DATA 0x03bc      
	#define STATUS DATA+1      
	...      
	unsigned int in_val;      
	...      
	in_val = ((inportb(STATUS)^0x80) &gt;&gt; 3);    
</PRE>
<P>Note that the Status Port is read and the most significant bit, corresponding 
to the BSY lead is inverted using the exclusive-or function. The result is then 
shifted such that the upper five bits are in the lower five bit positions. <PRE>    
	0 0 0 BUSY /ACK PE SELECT /ERROR     
</PRE>
<P>Another input, IRQ on the Status Port is not brought to a terminal on the 
DB-25 printer port connector. I have yet to figure out how to use this bit. 
<P>At this point, you should see that, at a minimum, there are 12 outputs; eight 
on the Data Port and four on the lower nibble of the Control Port. There are 
five inputs, on the highest five bits of the Status Port. Three output bits on 
the Control Port and one input on the Status Port are inverted by the hardware, 
but this is easily handled by using the exclusive-or function to selectively 
invert bits. 
<P>
<CENTER>
<H3>D. Simple Example</H3></CENTER>
<P>Refer to the figure titled Figure #3 - Typical Application showing a normally 
open push button switch being read on the BUSY input (Status Port, Bit 7) and an 
LED which is controlled by Bit 0 on the Data Port. A C language program which 
causes the LED to flash when the push-button is depressed appears below. Note 
that an output logic zero causes the LED to light. 
<P><PRE>     
	/* File LED_FLSH.C     
	**     
	** Illustrates simple use of printer port.  When switch is     
	** depressed LED flashes.  When switch is not depressed, LED is     
	** turned off.     
	**     
	** P.H. Anderson, Dec 25, '95     
	*/     
	     
	#include &lt;stdio.h&gt;     
	#include &lt;dos.h&gt;   /* required for delay function */     
	     
	#define DATA 0x03bc     
	#define STATUS DATA+1     
	#define CONTROL DATA+2     
	     
	void main(void)     
	{     
	   int in;     
	   while(1)     
	   {     
	      in = inportb(STATUS);     
	      if (((in^0x80)&amp;0x80)==0)     
	      /* if BUSY bit is at 0 (sw closed) */     
	      {     
	         outportb(DATA,0x00);   /* turn LED on */     
	         delay(100);     
	         outportb(DATA, 0x01);   /* turn it off */     
	         delay(100);     
	      }     
	      else     
	      {     
	         outportb(DATA,0x01);     
	         /* if PB not depressed, turn LED off */     
	      }     
	   }     
	}     
</PRE>
<HR>

<CENTER><IMG 
src="Use of a PC Printer Port for Control and Data Acquisition_files/PHAFIG3.gif"> 

<P><B>Fig 3 Printer Port - Typical Application</B></CENTER>
<P><B>Circuit Description:</B> Logic 1 on output DATA 0 (Data Port - Bit 0) 
causes LED to be off. Logic 0 causes LED to turn on. 
<P>Normally open push-button causes +5V (logic 1) to appear on input BUSY 
(STATUS PORT - Bit 7). When depressed, push-button closes and ground (logic 0) 
is applied to input Busy. 
<P>Note external source of 5V. 
<P><B>Program Description:</B> When idle, push-button is open and LED is off. On 
depressing push-button, LED blinks on and off at nominally 5 pulses per second. 
<HR>

<P>
<CENTER>
<H3>E. Test Circuitry</H3></CENTER>
<P>Refer to the figure titled Figure #4 - Printer Port Test Circuitry. This 
illustrates a very simple test fixture to allow you to figure out what 
inversions are taking place in the hardware associated with the printer port. 
Program test_prt.c sequentially turns each of the 12 LED's on and then off and 
then continually loops to display the settings on the five input switches. 
<HR>

<CENTER><IMG 
src="Use of a PC Printer Port for Control and Data Acquisition_files/PHAFIG4.gif"> 

<P><B>Fig 4. Printer Port Test Circuitry</B></CENTER>
<HR>

<P><PRE>   
	/* File TEST_PRT.C   
	**   
	** Program to exercise 12 outputs and five inputs.   
	**   
	** Program sequentially turns off LEDs on Bits 7, 6, 5, ... 0 on the   
	** Data Port, and then Bits #, 2, 1 and 0 on the Control Port.  Each   
	** LED is held off for nominally 1 second.  Note that an LED is turned   
	** off with a logic one.  This process is executed once.   
	**   
	** Program then loops, scanning the highest five bits on the Status Port   
	** and continuously displays the content in hexadecimal.   
	**   
	** P.H. Anderson, Dec 25, '95   

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品日韩av一区二区| 欧美国产亚洲另类动漫| 国产伦精一区二区三区| 国产精品久久久久久久午夜片| 亚洲成人一区在线| 91麻豆国产自产在线观看| 国产裸体歌舞团一区二区| 久久99热99| 91国偷自产一区二区开放时间| 亚洲午夜av在线| 久久精品一级爱片| 大胆欧美人体老妇| 日本一区二区三区dvd视频在线| 91美女片黄在线| 黄页网站大全一区二区| 久久一区二区三区四区| 亚洲va在线va天堂| 欧美一区二区三区视频在线观看| 日韩av高清在线观看| 国产精品网曝门| 成人av片在线观看| 欧美日韩视频专区在线播放| 国产亚洲精品bt天堂精选| 精品成人在线观看| 久久成人18免费观看| 5月丁香婷婷综合| 日韩主播视频在线| 国产日韩成人精品| 欧美日韩二区三区| eeuss鲁片一区二区三区 | 伦理电影国产精品| 欧美激情一区二区三区| 在线视频你懂得一区| 九色porny丨国产精品| 亚洲精品第一国产综合野| 久久精品人人做| 欧美一区二区大片| 欧洲精品一区二区三区在线观看| 久久电影网电视剧免费观看| 亚洲va天堂va国产va久| 一二三区精品福利视频| 91精品欧美一区二区三区综合在| 亚洲国产高清aⅴ视频| 国产精品一级二级三级| 欧美视频日韩视频| 日韩激情在线观看| 久久人人爽人人爽| 欧美午夜精品一区二区三区| 99精品欧美一区| 国产麻豆欧美日韩一区| 国产精品午夜电影| 91蜜桃网址入口| 蓝色福利精品导航| 偷窥国产亚洲免费视频| 一卡二卡欧美日韩| 亚洲精品一区二区在线观看| 精品视频一区 二区 三区| 在线观看av不卡| 在线亚洲免费视频| 欧美欧美欧美欧美| 欧美日韩国产一级| 精品剧情v国产在线观看在线| 欧美一区中文字幕| 久久综合九色综合欧美亚洲| 精品剧情在线观看| 国产精品天天摸av网| 亚洲一区二区不卡免费| 日本sm残虐另类| 国产福利一区二区三区视频在线| 国产一区在线观看视频| 成a人片国产精品| 欧美中文字幕亚洲一区二区va在线| 欧美亚洲综合一区| 日韩美女在线视频| 亚洲精品视频一区二区| 日韩不卡一区二区三区| 粉嫩嫩av羞羞动漫久久久 | 亚洲视频免费观看| 亚洲成人www| 亚洲成人在线网站| 国产精品 日产精品 欧美精品| 波多野结衣中文字幕一区二区三区| 欧美视频一区二区三区四区 | 国产精品99久| 欧美在线观看一二区| 亚洲精品在线观看网站| 亚洲成av人片一区二区| 91丨九色丨尤物| 国产精品自在在线| av一区二区三区在线| 日韩一区二区三区四区 | 91精品国产欧美一区二区| 中文字幕一区二区日韩精品绯色| 日本最新不卡在线| 欧美主播一区二区三区| 国产精品久久久久久久第一福利| 天堂在线亚洲视频| av色综合久久天堂av综合| 日韩精品在线一区| 日韩专区在线视频| 91片在线免费观看| 国产日本一区二区| 精品无人码麻豆乱码1区2区| 欧美三级在线看| 亚洲美女视频在线观看| 成人精品免费看| 精品91自产拍在线观看一区| 亚洲成a天堂v人片| 色噜噜狠狠色综合欧洲selulu| 中文字幕乱码日本亚洲一区二区| 日韩综合在线视频| 欧美精品vⅰdeose4hd| 亚洲一级在线观看| 欧美制服丝袜第一页| 亚洲线精品一区二区三区八戒| 日韩成人dvd| 成人一区在线看| 亚洲一二三四在线观看| 日本国产一区二区| 一区二区理论电影在线观看| 粉嫩av一区二区三区在线播放| 久久久蜜桃精品| 成人免费视频网站在线观看| 亚洲国产精品v| 欧美亚洲国产一区在线观看网站| 一区二区三区av电影| 欧美一区午夜视频在线观看| 亚洲免费在线观看| 欧美一级二级三级蜜桃| 国产精品2024| 亚洲不卡在线观看| 欧美一区二区三区免费视频| 久久精品国产亚洲a| 国产精品的网站| 91精品国产综合久久久蜜臀粉嫩 | 欧美日韩一区高清| 久久99精品久久久久久| 亚洲天堂中文字幕| 欧美成人女星排行榜| 91美女精品福利| 精品在线免费观看| 亚洲在线一区二区三区| 国产精品久久久久永久免费观看| 欧美精品日韩一本| av电影在线观看完整版一区二区 | 欧美猛男超大videosgay| 成人精品在线视频观看| 精品在线观看视频| 亚洲成人资源网| 精品区一区二区| 91精品国产品国语在线不卡 | 午夜视频在线观看一区二区| 国产精品久久久久婷婷| 国产婷婷精品av在线| 日韩精品一区在线观看| 欧美成人video| 日韩精品一区二区在线观看| 欧美精品亚洲二区| 欧美日本一道本在线视频| 色就色 综合激情| 色呦呦日韩精品| 国产成人超碰人人澡人人澡| 国产精品一卡二卡在线观看| 蜜臀a∨国产成人精品| 久久激情五月激情| 美国十次综合导航| 国产99一区视频免费| 丁香六月综合激情| 91在线精品一区二区三区| 色婷婷精品大在线视频| 制服丝袜亚洲色图| 久久综合久色欧美综合狠狠| 国产视频在线观看一区二区三区| 久久久久久久久久久久久夜| 欧美精品一区二区三区在线| 国产精品妹子av| 亚洲激情图片一区| 美女性感视频久久| 成人免费av在线| 精品少妇一区二区三区| 国产精品久久久久影院色老大| 日韩美女视频一区二区| 美国毛片一区二区| 日本高清不卡视频| 精品国产三级a在线观看| 中文字幕第一页久久| 日韩精品一级二级| 91精品1区2区| 久久精品视频一区二区三区| 亚洲午夜在线观看视频在线| 六月丁香婷婷久久| 99精品视频一区二区三区| 久久久久久久久久久99999| 亚洲高清免费一级二级三级| 国产精品99久久久久久有的能看 | 国产精品影音先锋| 欧美三级资源在线| 亚洲精品大片www| 欧美影院一区二区| 亚洲欧美在线视频|