Impulse 463E User Manual

Page 86

Advertising
background image

© Sealevel Systems, Inc.

- 83 -

SeaI/O User Manual

Reading From Inputs / Outputs

In order to read from the inputs or outputs, the SeaIO module must first be opened
successfully. The VC++ example below shows how to read in four inputs, starting at
input 3 and continuing until input 6. In this case, since we are not reading in a full 8
bits, the data will be present in the lowest order bits of the data array.

unsigned char data[1] = {0};
int slaveId = 247
int type = D_INPUTS;
int start = 3;
int range = 4;

result = cw32.Read(slaveId, type, start, range, data);



Reading in inputs within Visual Basic is similar; D_INPUTS is the read type required
for either language to access the inputs. The example below shows how it can be
done through VB. If the current status of the outputs is required, a read can be
performed using the COILS type.

dim slaveId, startLoc, range as Integer
dim recvData(2) as Byte

slaveId = 247
startLoc = 1
range = 16

returnValue = SeaMaxW32Read(seaMaxPointer, slaveId, D_INPUTS, _
startLoc, range, recvData(0))


Writing to Outputs

Writing outputs is similar to reading inputs, with the single exception that
Write or SeaMaxW32Write is called instead of Read. The two examples
below show how to write to digital outputs using Write and
SeaMaxW32Write in Visual C++ and Visual Basic, respectively.

result = cw32.Write(slaveId, COILS, start, range, data);


returnValue = SeaMaxW32Write(seaMaxPointer, slaveId, COILS, startLoc,
range, sendData(0))


Advertising