Black Box IC908C, IC907C manual Programming Examples, Register Description, 1.Registers, Address

Models: IC907C IC908C

1 20
Download 20 pages 20.05 Kb
Page 11
Image 11
4.4 Programming Examples

RELAY OUTPUT CARD PCI

4.4 Programming Examples

Below are several simple examples using 80x86 assembly code for energizing and checking the state of the reed relays on the Relay Output Card PCI. All examples assume a base address of 300 Hex.

Example #1: Programming example to set Relay #27 on, write a “1” in bit position D2, to port address Base+3, or 303 Hex.

MOV DX, 303H

;Set DX to

Port D

MOV AL,

00001000B

;Set bit 3

to a ‘1’

OUT DX,

AL

 

 

Example #2: Another method that takes into account the read-back capability of the output ports.

MOV DX, 303H

;Set DX to Port D

IN AL, DX

;Get old port setting

NOT AL

;Invert bits - see note below

OR AL, 00001000B

;OR in bit 3

OUT DX, AL

;Set Bit 3

NOTE

Reading back the ports results in the binary complement of the output.

4.5 Register Description

Table 4-1. Registers.

Address

Mode

D7

D6

D5

D4

D3

D2

D1

D0

 

 

 

 

 

 

 

 

 

 

Base+0

R/W

P1D7

P1D6

P1D5

P1D4

P1D3

P1D2

P1D1

P1D0

 

 

 

 

 

 

 

 

 

 

Base+1

R/W

P2D7

P2D6

P2D5

P2D4

P2D3

P2D2

P2D1

P2D0

Base+2

R/W

P3D7

P3D6

P3D5

P3D4

P3D3

P3D2

P3D1

P3D0

Base+3

R/W

P4D7

P4D6

P4D5

P4D4

P4D3

P4D2

P4D1

P4D0

 

 

 

 

 

 

 

 

 

 

R/W = Read/Write bits

NOTE

The reed relay ports have a non-destructive readback capability. Reading back the ports results in the binary complement of the output. This is particularly useful when writing software that queries the last value written to prevent inadvertently changing the state of the relays.

10

Page 11
Image 11
Black Box IC908C, IC907C manual Programming Examples, Register Description, 1.Registers, Address, Relay Output Card Pci