Access to fieldbus process data

Consistent access via the IO task only works for fieldbus variables that are linked to the IO task. As shown above for an input variable configuration, for all fieldbus variables to be accessed consistently, associated IO task variables have to be created and linked with them. The access function offsets refer to the addresses of the IO task variables (the BoxErrorCounter variable is allocated to address 0 of the input process image of the IO task):

Access to fieldbus process data 1:

The process image of the IO task can be exported in the form of an H file by right-clicking on the IO task in the tree:

Access to fieldbus process data 2:

StartImageUpdate

long StartImageUpdate(int portNo, int time, int outpLength, int inpLength);

The StartImageUpdate function must be called once during start-up of the application for initiating the timer that ensures consistent access to the process data. The port portNo of the IO task, the time cycle time time in ms, and the length of the input or output process image inpLength or outpLength of the IO task (according to the addresses generated during variable definition) must be specified. Within the timer routine the input process image of the IO task is read consistently and held in the local buffer, enabling fast access to the input process data via the function ReadInputs. The output process image of the IO task is only consistently updated with the local process image, if the local process image was accessed by calling WriteOutputs. The WriteOutputs call is therefore very quick.

Return values:

0:   no error

-1: Timer could not be started

-2: AMS address could not be read

-3: Not enough memory for local process image

-4: Timer already running

StartImageUpdateWithWd

long StartImageUpdateWithWd(int portNo, int time, int outpLength, int inpLength, int wdTime);

The function StartImageUpdateWithWd has the same functionality as StartImageUpdate, although in addition it starts a watchdog. The watchdog is re-triggered when the functions ReadInputs or WriteOutputs are called. If this is not the case during the watchdog time, an IO reset is carried out for all devices (this leads to the outputs being disabled), and the outputs in the process image are set to 0.

StopImageUpdate

long StopImageUpdate(void);

The function StopImageUpdate only has to be called if the DLL is not automatically unloaded on termination of the application (e.g. for applications based on LabVIEW-CVI).

Return values:

0:   no error

-5: DLL no longer active

ReadInputs

long ReadInputs(int offset, int length, unsigned char * pData);

The function ReadInputs is used to read the local input process image or parts thereof. The following parameters are transferred: the offset within the input process image of the IO task, the length of the data to be read, and a pointer pData to a memory area into which the input data can be copied.

Return values:

0:   no error

-1: Timer not running

-2: Offset too large

-5: DLL no longer active

WriteOutputs

long WriteOutputs(int offset, int length, unsigned char * pData);

The function WriteInputs is used to write to the local input process image or parts thereof. The following parameters are transferred: the offset within the output process image of the IO task, the length of the data to be read, and a pointer pData to a memory area into which the output data can be copied.

Return values:

0:   no error

-1: Timer not running

-2: Offset too large

-5: DLL no longer active