Input32 动态库介绍

Introduction(概述)

Parallel port is a simple and inexpensive tool for building computer controlled devices and projects. The simplicity and ease of programming makes parallel port popular in electronics hobbyist world. The parallel port is often used in Computer controlled robots, Atmel/PIC programmers, home automation, …etc… Here a simple tutorial on parallel port interfacing and programming with some examples.

并行口是一种简单而廉价的工具,用于建立计算机控制的设备和项目。程序设计的简单易用性使得并行口在电子爱好者的世界里很受欢迎。并行口经常用于计算机控制的机器人、Atmel/PIC程序员、家庭自动化等……这里是一个简单的关于并行口接口和编程的教程,并举例说明。

Everybody knows what is parallel port, where it can be found, and for what it is being used. the primary use of parallel port is to connect printers to computer and is specifically designed for this purpose. Thus it is often called as printer Port or Centronics port (this name came from a popular printer manufacturing company ‘Centronics’ who devised some standards for parallel port). You can see the parallel port connector in the rear panel of your PC. It is a 25 pin female (DB25) connector (to which printer is connected). On almost all the PCs only one parallel port is present, but you can add more by buying and inserting ISA/PCI parallel port cards.

每个人都知道什么是并行口,在哪里可以找到它,以及它正在使用什么。并行端口的主要用途是将打印机连接到计算机上,并为此目的专门设计。因此,它通常被称为打印机端口或Centronics端口(这个名称来自一家流行的打印机制造公司Centronics,它为并行端口设计了一些标准)。你可以看到平行端口连接器在你的电脑的后面板。它是一个25针女性(DB 25)连接器(打印机连接到)。在几乎所有的PC上,只有一个并行口存在,但是您可以通过购买和插入ISA/PCI并行口卡来添加更多的并行口。

Parallel port modes(并口模式)

The IEEE 1284 Standard which has been published in 1994 defines five modes of data transfer for parallel port. They are,

1) Compatibility Mode
2) Nibble Mode
3) Byte Mode
4) EPP
5) ECP

IEEE 1284 标准1994版定义了并行端口数据传输的五种模式。他们是,

1)兼容模式
2)交互模式
3)字节模式 可能是SPP模式,即Standard Parallel Port,标准并行端口 (Standard Parallel Port),半双工单向传输的,传输速率仅为150KB/s,速度较慢,一般设为默认的工作模式,现在几乎所有的并口外设都支持该模式。
4)EPP,即Enhanced Parallel Port,增强型高速并口。增强型工作模式,EPP采用双向半双工数据传输,其传输速度比SPP高,可达 2MB/s,EPP可细分为EPP 1.7和EPP 1.9两种模式,目前多数外设使用此工作模式。目前市面上的大多数打印机、 扫描仪都能与PC进行双向通讯,都支持EPP模式。
5)ECP,即 Extended Capability Port,扩充功能并口。采用双向全双工数据传输,传输速率比EPP要高。可以算是目前最先进的并口模式,但是该模式需要设置DMA通道,既消耗资源,又容易引起冲突。这可以算是目前最先进的并口模式,但是该模式需要设置DMA通道,既消耗资源,又容易引起冲突。同时,目前支持ECP的外设很少,因此,一般而言不要选择该模式。

The programs, circuits and other information found in this tutorial are compatible to almost all types of parallel ports and can be used without any problems (Not tested, just because of confidence ! ). More information on parallel port operating modes can be found here.

本文中的程序、电路和其他信息几乎兼容所有类型的并行口,并且可以在没有任何问题的情况下使用(没有测试,仅仅是因为信任!)。有关并行口操作模式的更多信息,请参阅此处

Hardware(硬件)

The pin outs of DB25 connector is shown in the picture below

DB25接口定义如下:

这里写图片描述

The lines in DB25 connector are divided in to three groups, they are

1) Data lines (data bus)
2) Control lines
3) Status lines

DB25接线分为三组:

1)数据线
2)控制线
3)状态线

As the name refers , data is transferred over data lines , Control lines are used to control the peripheral and of course , the peripheral returns status signals back computer through Status lines. These lines are connected to Data, Control And Status registers internally . The details of parallel port signal lines are given below

顾名思义,数据通过数据线传输,控制线用于控制外围设备,当然,外围设备通过状态线返回状态信号。这些线路内部连接到数据、控制和状态寄存器。并行口信号线的详细情况如下

Pin No (DB25)Signal nameDirectionRegister - bitInverted
1nStrobeOutControl-0Yes
2Data0In/OutData-0No
3Data1In/OutData-1No
4Data2In/OutData-2No
5Data3In/OutData-3No
6Data4In/OutData-4No
7Data5In/OutData-5No
8Data6In/OutData-6No
9Data7In/OutData-7No
10nAckInStatus-6No
11BusyInStatus-7Yes
12Paper-OutInStatus-5No
13SelectInStatus-4No
14LinefeedOutControl-1Yes
15nErrorInStatus-3No
16nInitializeOutControl-2No
17nSelect-PrinterOutControl-3Yes
18-25Ground---

Parallel port registers(并口寄存器)

As you know, the Data, Control and status lines are connected to there corresponding registers inside the computer. So by manipulating these registers in program , one can easily read or write to parallel port with programming languages like ‘C’ and BASIC.

如您所知,数据、控制和状态线连接到计算机内部的相应寄存器。因此,通过在程序中操作这些寄存器,人们可以轻松地用诸如C和Basic之类的编程语言读写并行口。

The registers found in standard parallel port are ,

1) Data register
2) Status register
3) Control register

标准并口寄存器定义:

1) 数据寄存器
2) 状态寄存器
3) 控制寄存器

As there names specifies, Data register is connected to Data lines, Control register is connected to controll lines and Status lregistyer is connected to Status lines. (Here the word connection does not mean that there is some physical connection between data/control/status lines. The registers are virtually connected to the corresponding lines.). So what ever you write to these registers , will appear in corresponding lines as voltages, Of course, you can measure it with a multimeter. And What ever you give to Parallel port as voltages can be read from these registers(with some restrictions). For example , if we write ‘1’ to Data register , the line Data0 will be driven to +5v. Just like this ,we can programmatically turn on and off any of the data lines and Control lines.

如名称所指定的,数据寄存器连接到数据线,控制寄存器连接到控制线,状态寄存器连接到状态线。(此处,连接一词并不意味着数据/控制/状态线之间存在某种物理连接。寄存器实际上连接到相应的线路。)。因此,无论你写什么到这些寄存器上,都会以电压的形式出现在相应的线路上,当然,你可以用万用表来测量它。当然电压可以从这些寄存器中读取时,你给并行口的是什么(有一些限制)。例如,如果我们将“1”写到数据寄存器,那么数据0行将被驱动到+5v。就像这样,我们可以编程地打开和关闭任何数据线和控制线。

Where these registers are ?(寄存器在哪儿?)

In an IBM PC, these registers are IO mapped and will have unique address. We have to find these addresses to to work with parallel port. For a typical PC , the base address of LPT1 is 0x378 and of LPT2 is 0x278. The data register resides at this base address , status register at baseaddress + 1 and the control register is at baseaddress + 2. So once we have the base address , we can calculate the address of each registers in this manner. The table below shows the register addresses of LPT1 and LPT2

在IBMPC中,这些寄存器被映射为IO,并且具有唯一的地址。我们必须找到这些地址才能让并行口工作。对于典型的PC,LPT 1的基址是0x378,LPT 2的基址是0x278。数据寄存器驻留在该基址,状态寄存器位于基址+1,控制寄存器位于基址+2。因此,一旦我们有了基地址,我们就可以以这种方式计算每个寄存器的地址。下表显示LPT 1和LPT 2的寄存器地址。

RegisterLPT1LPT2
data registar(baseaddress + 0)0x3780x278
status register (baseaddress + 1)0x3790x279
control register (baseaddress + 2)0x37a0x27a0x37a0x27a

download

资源文件地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sdhongjun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值