How to calculate your own values to send to program

How to calculate your own values to send to program

You have to think the value you give to the program as a binary number. Every bit of the binary number control one output bit. The following table describes the relation of the bits, parallel port output pins and the value of those bits.

Pin     2   3   4   5   6   7   8   9
Bit     D0  D1  D2  D3  D4  D5  D6  D7
Value   1   2   4   8   16  32  64  128

For example if you want to set pins 2 and 3 to logic 1 (led on) then you have to output value 1+2=3. If you want to set on pins 3,5 and 6 then you need to output value 2+8+16=26. In this way you can calculate the value for any bit combination you want to output.

Making changes to source code

You can easily change te parallel port number int the source code by just changing the memory address where the program read the parallel port address. For more information, check the following table.

Format of BIOS Data Segment at segment 40h:
Offset  Size    Description
 08h    WORD    Base I/O address of 1st parallel I/O port, zero if none
 0Ah    WORD    Base I/O address of 2nd parallel I/O port, zero if none
 0Ch    WORD    Base I/O address of 3rd parallel I/O port, zero if none
 0Eh    WORD    [non-PS] Base I/O address of 4th parallel I/O port, zero if none

For example change the line addr:=MemW[$0040:$0008]; in the source code to addr:=MemW[$0040:$000A]; if you want to output to LPT2.

Instead of trying to read the address from the DOS information data block you can always use the I/O address fixed to source code. The LPT1 port is typically at I/O-address 378h or 3BCh.

To get to know the port address to use you can use for example the method: On modern Windows systems (I tested in Windows 2000) you can get to know the parallel port I/O addrss through device manager. First open the device manager (start – settings – control panel – system – hardware – device manager). Then select there the parallel port you are interrested from Ports (COM & LPT) section. With mouse right button you can get menu where you select Properties. From there select Resources where you should see a screen like this:

Windows device control IO address view

The details in this image are from the parallel port built into the motherboard of my PC.

Programming I/O

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s

%d bloggers like this: