7.2. Hilscher Fieldbus CIF Card

For more information on the CIF Driver, please refer to the Cogent CIF Driver for Hilscher Fieldbus CIF Cards manual.

7.2.1. I/O Block Functions

The DR_ApReadBlock and DR_ApWriteBlock functions access the process I/O data area of the card. The offset and size parameters specify what portion of the buffer area to transfer, and is dependent on the field configuration. Typically, field data is always mapped to the beginning of the block (offset of 0) and is continguous up to the number of bytes defined by the field device (slave) configuration. The output process data buffer is mapped as buffer 0, while 1 will access the input process data buffer.

7.2.2. Control Block Functions

The DR_ApReadControl and DR_ApWriteControl functions access the control parameter blocks of the card. Only buffer 2 is valid for CIF cards, which provides access to the protocol parameters.

The control parameters for the Hilscher Fieldbus card use the following structure (see file cif_api.h):

typedef struct {
     unsigned char	Mode;
     unsigned char	reserved1;
     unsigned char	Format;
     unsigned short	WatchdogTime;
     unsigned char	reserved5[3];
     unsigned char	reserved8[8];
} cif_ApParms_t;

The control parameters do vary with the specific fieldbus protocol and additional structure definitions can be found in the cif_api.h file.

Access to the control data is accomplished via buffer 2 with a length of 16, using the functions DR_ApReadControl and DR_ApWriteControl, as follows:

DR_ApReadControl (dev, 2, 0, 16, &control, &error)
DR_ApWriteControl (dev, 2, 0, 16, &control, &error)

It is recommended that reserved bytes be set to 0. Most protocols reserve the last 11 bytes, so the length may be shortened to 5, depending on the protocol. Note that a read of the control parameters may return only zero data from some cards.

The components of the control structure are defined as follows:

ParameterDescriptionLength
ModeType of handshake mechanism for process data delivery.byte
Cycle_timeCycle time of the fieldbus cycle (hwere applicable).byte
FormatStorage format of word data.byte
WatchdogTimeHOST-supervision time in multiples of a msec.short

The handshake modes available are:

ModeName (see cif_api.h)Description
0IOMODE_DEV_UNBUFcard controlled, bus synchronous data transfer
1IOMODE_DEV_BUFcard controlled, buffered data transfer
2IOMODE_NO_CTLno handshake
3IOMODE_HOST_BUFHOST controlled, buffered data transfer
4IOMODE_HOST_UNBUFHOST controlled, bus synchronous data transfer

Not all modes are available for all protocols.

The available storage formats are:

FormatName (see cif_api.h)Description
0FORMAT_INTELIntel; little-endian; low-byte, high-byte
1FORMAT_MOTORLAMotorola; big-endian; high-byte, low-byte

After writing the control block, the system must do a WARM reset before the changes will take effect (see the cardReset command in the Device Driver for Hilscher CIF Cards manual).

7.2.3. Status Block Functions

The DR_ApReadStatus function accesses the status blocks of the card. Only buffer 2 is valid for CIF cards, which provides master status as well as field device (slave) status and diagnostic information.

The status of the Hilscher Fieldbus Card is read from buffer 2 with a length of 64, using the function DR_ApReadStatus, as follows:

DR_ApReadStatus (dev, 2, 0, 64, &status, &error)

The offset and length are ignored. Status is a structure of type cif_ApState_t (see the file cif_api.h) and is defined as follows:

typedef struct {
    unsigned char	global_bits;
    unsigned char	bus_status;
    unsigned char	err_rem_addr;
    unsigned char	err_rem_event;
    unsigned char	reserved[28];
    unsigned char	state [16];
    unsigned char	diag [16];
} cif_ApState_t;

where:

State ElementDescriptionLength
global_bits
Error bits, as follows:
bit 0: Ctrl, parameterization error
bit 1: Aclr, slave error causing AutoClear mode
bit 2: Ndata: at least one slave not in data exchange mode or reporting an error
bit 3-7: reserved
byte
bus_status
Main state of the master system:
0x00 OFFLINE
0x40 STOP
0x80 CLEAR
0xC0 OPERATE
byte
err_rem_addrRemote address of error sourcebyte
err_rem_eventError numberbyte
stateA bitfield classifying every slave as active (1) or inactive (0)16 x byte
diagA bitfield showing diagnostic bit of every slave16 x byte