Paralllel Port(DB25) Comnector

关于并口的一些东西。

 

This is About Paralllel Port(DB25) Comnector.

 

Introduction

Hi there, I was searching the web for a way to allow me to control electrical appliances using PC and I found it here. Here is a circuit (figure 1) for using the printer port of a PC, for control application using software and some interface hardware. The interface circuit along with the given software can be used with the printer port of any PC for controlling up to eight equipments.

The interface circuit shown in figure 1 is drawn for only one device, being controlled by D0 bit at pin 2 of the 25-pin parallel port. Identical circuits for the remaining data bits D1 through D7 (available at pins 3 through 9) have to be similarly wired. The use of opto-coupler ensures complete isolation of the PC from the relay driver circuitry.

 

 

 

Background

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 is a simple tutorial on parallel port interfacing and programming, with some examples.

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 the 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' which 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.

 

 

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
Hardware

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

 

 

 

The lines in DB25 connector are divided into three groups, they are:

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

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 to the 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.

The registers found in a standard parallel port are:

  1. Data register
  2. Status register
  3. Control register

As their names specify, Data register is connected to Data lines, Control register is connected to Control lines and Status register 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, whatever you write to these registers will appear in the corresponding lines as voltages. Of course, you can measure it with a multimeter. And whatever 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.

Where these registers are?

In an IBM PC, these registers are IO mapped and will have an unique address. We have to find these addresses to work with the 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 base address + 1 and the control register is at base address + 2. So, once we have the base address, we can calculate the address of each register in this manner. The table below shows the register addresses of LPT1 and LPT2.

RegisterLPT1LPT2
Data register (baseaddress + 0)0x3780x278
Status register (baseaddress + 1)0x3790x279
Control register (baseaddress + 2)0x37a0x27a

 

 

 

 

 

//------------------------------May.07..2009------------------------------
//--------------------Masturbate by sealplusplus ---------------------
//----------World is SHIT..  General George Smith Patton said----


并口有5个标准模式。
具体说就是并口,里边和线的关系比较紧密。因为是数据传输和控制的操作。一共有三种线。
1:数据线。
2:控制线。
3:状态线。

因为是并口传输,所以一次可以传8个bit。8跟数据线。
控制线4跟,状态线4跟。

线上的电压(+/-)和寄存器的状态(1/0)。Register具体的不知道是CPU的AX/BX/CX/DX还是程序的内存区域,实际编程的时候没有什么区别,无非就是Register和变量的事情,但是线上的电压和Register状态是不是实时的联系。多少和编程有点关系,因为要是过几个CPU时间就改变状态了,那么只要访问变量就可以,但是要不是实时的,那么还的用函数或者其他方式去读(等待反映然后去读Register状态)。
以上是个人的理解,可能有失误,本着原则是大家共同学习。

 

 

Add: 最后仔细读了一下发现是,地址,不是CPU的Register。

 

use Inpout32.dll (or hwinterface.ocx) for Win 98/NT/2000/XP. This DLL has the following features:

  1. Works seamless with all versions of Windows (Win 98, NT, 2000 and XP)
  2. Using a kernel mode driver embedded in the DLL
  3. No special software or driver installation required
  4. Driver will be automatically installed and configured automatically when the DLL is loaded
  5. No special APIs required, only two functions Inp32 and Out32.
  6. Can be easily used with VC++ and VB or C#.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值