Direct DP-RAM access

As an alternative to consistent access via the IO task, direct access to the DP-RAM is also available. Only WORD consistency is possible, although access is very fast, and the maximum dead time (age of a read variable or delay time until a variable is sent to the fieldbus after writing) is the same as the cycle time of the IO task. Please note that that the fieldbus output variables that are written via direct access must not be linked with IO task variables, since they would be overwritten again by the IO task. The offsets of the access functions refer to the fieldbus device variable addresses, i.e. the address should be looked up under the "Variable" tab for the associated variable in the fieldbus devices (address 4.1 in the example shown):

Direct DP-RAM access 1:

With FC310x PROFIBUS PC cards please note that the 4 bytes preceding the first input and output variable of a PROFIBUS slave are used for the PROFIBUS protocol header (i.e. the smallest variable offset for the FC310x is also 4). Writing of these respective 4 bytes would lead to PROFIBUS malfunction. Therefore, only those areas actually containing variables should be accessed directly. An overview can be displayed at the bottom of the window on the right by clicking on the process image of the device in the tree:

Direct DP-RAM access 2:

Options for printing the list or copying it to Excel, for example, are available through right-clicking on the list.

The access functions have to use the DP-RAM address that is shown under PCI bus/slot on the "FC310x", "FC510x" or "FC520x" tab when the fieldbus device is clicked in the tree:

Direct DP-RAM access 3:

ReadInputsDirect

long _stdcall ReadInputsDirect(unsigned long dpRamAddress, int offset, int length, unsigned char * pData);

The ReadInputsDirect function is used for reading fieldbus device input variables directly from the DP-RAM. Calling of this function is very fast (approx. 1.5 µs per word). The DP-RAM address dpRamAddress of the fieldbus device, the offset and the length of the input variables in the DP-RAM and a pointer pData to a memory area into which the input data can be copied are transferred.

Return values:

0:   no error

-1: DP-RAM pointer could not be allocated

-2: Offset too large

-3: DP-RAM address is different than for previous calls of ReadInputsDirect or WriteOutputsDirect

-5: DLL no longer active

WriteOutputsDirect

long _stdcall WriteOutputsDirect(unsigned long dpRamAddress, int offset, int length, unsigned char * pData);

The WriteOutputsDirect function is used for writing fieldbus device input variables directly into the DP-RAM. Calling of this function is very fast (approx. 1.5 µs per area). The DP-RAM address dpRamAddress of the fieldbus device, the offset and the length of the output variables in the DP-RAM and a pointer pData to the output data are transferred.

Return values:

0:   no error

-1: DP-RAM pointer could not be allocated

-2: Offset too large

-3: DP-RAM address is different than for previous calls of ReadInputsDirect or WriteOutputsDirect

-5: DLL no longer active

GetDirectInputPointer

void * GetDirectInputPointer(unsigned long dpRamAddress);

The function GetDirectInputPointer can be used to obtain a pointer to the input process image in the DP-RAM. The addresses of the input variables have to be taken from the System Manager as described above. The DP-RAM address dpRamAddress of the fieldbus device has to be transferred.

Return values:

0:   Error

!= 0: Pointer to DP-RAM input variables

GetDirectOutputPointer

void * GetDirectOutputPointer(unsigned long dpRamAddress);

The function GetDirectOutputPointer can be used to obtain a pointer to the output process image in the DP-RAM. The addresses of the output variables have to be taken from the System Manager as described above. The DP-RAM address dpRamAddress of the fieldbus device has to be transferred.

Return values:

0:   Error

!= 0: Pointer to DP-RAM input variables