Difference between revisions of "S7-SoftPLC:Basic configuration"

From IBHsoftec Wiki English
Jump to: navigation, search
Line 557: Line 557:
  
  
'''Function 140 trigger watchdog'''<br />
+
'''Function 140 trigger watchdog'''
This function is needed, if very long PLC cycles occur. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
+
 
 +
This function is needed, if very long PLC cycles occur. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
 +
 
 +
 
 +
Error codes:
 +
 
 +
None
  
Error codes:<br />
 
None
 
  
 
Example:
 
Example:
 +
<code>
 +
{|
 +
| CALL || SFC 210
 +
|-
 +
|style="width: 5em"| IN0 ||style="width: 11em"| := 140  ||  // function 140
 +
|-
 +
| IN1 || := 0 || // no DB
 +
|-
 +
| IO2 || := MD 20  || // no function code
 +
|-
 +
| OUT3 || := MW 24 || // error code
 +
|}
 +
</code>
 +
  
<table>
+
'''Function 141 Read HostFlags'''
<tbody>
+
<tr class="odd">
+
<td align="left">CALL</td>
+
<td align="left">SFC 210</td>
+
<td align="left"></td>
+
</tr>
+
<tr class="even">
+
<td align="left">IN0</td>
+
<td align="left">:= 140</td>
+
<td align="left">// function 140</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">IN1</td>
+
<td align="left">:= 0</td>
+
<td align="left">// bo DB</td>
+
</tr>
+
<tr class="even">
+
<td align="left">IO2</td>
+
<td align="left">:= MD 20</td>
+
<td align="left">// no function code</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">OUT3</td>
+
<td align="left">:= MW 24</td>
+
<td align="left">// error code</td>
+
</tr>
+
</tbody>
+
</table>
+
  
'''Function 141 Read HostFlags'''<br />
+
With this function HostFlags can be read.
With this function HostFlags can be read.
+
  
<table>
+
{| class="wikitable"
<tbody>
+
|-
<tr class="odd">
+
! Bit !! Hostflag message
<td align="left">Bit</td>
+
|-
<td align="left">Hostflag message</td>
+
|style="width: 5em"| 0 || HostCom: Handshake of the receive mailbox
</tr>
+
|-
<tr class="even">
+
| 1 || DevAck: Handshake of the send mailbox
<td align="left">0</td>
+
|-
<td align="left">HostCom: Handshake of the receive mailbox</td>
+
| 2 || PdAck: Handshake of the process image
</tr>
+
|-
<tr class="odd">
+
| 3 ||  ERR: communication error to one network device  
<td align="left">1</td>
+
|-
<td align="left">DevAck: Handshake of the send mailbox</td>
+
| 4 || PdExtAck: extended handshake of the pcrocess image
</tr>
+
|-
<tr class="even">
+
| 5 || COM: I/O exchange to one network device established
<td align="left">2</td>
+
|-
<td align="left">PdAck: Handshake of the process image</td>
+
| 6 || RUN: DEVICE is communicating, configuration valid
</tr>
+
|-
<tr class="odd">
+
| 7 || READY: DEVICE is running, end of initialisation
<td align="left">3</td>
+
|}
<td align="left">ERR: communication error to one network device</td>
+
</tr>
+
<tr class="even">
+
<td align="left">4</td>
+
<td align="left">PdExtAck: extended handshake of the pcrocess image</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">5</td>
+
<td align="left">COM: I/O exchange to one network device established</td>
+
</tr>
+
<tr class="even">
+
<td align="left">6</td>
+
<td align="left">RUN: DEVICE is communicating, configuration valid</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">7</td>
+
<td align="left">READY: DEVICE is running, end of initialisation</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
 
If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
  
Error codes:<br />
+
 
0x807F = Internal driver access error
+
Error codes:
 +
 
 +
0x807F = Internal driver access error
 +
 
  
 
Example:
 
Example:
 +
<code>
 +
{|
 +
| CALL || SFC 210
 +
|-
 +
|style="width: 5em"| IN0 ||style="width: 11em"| := 141  ||  // function 141
 +
|-
 +
| IN1 || := 0 || // no DB
 +
|-
 +
| IO2 || := MD 20  || // returns the HostFlags
 +
|-
 +
| OUT3 || := MW 24 || // error code
 +
|}
 +
</code>
  
<table>
 
<tbody>
 
<tr class="odd">
 
<td align="left">CALL</td>
 
<td align="left">SFC 210</td>
 
<td align="left"></td>
 
</tr>
 
<tr class="even">
 
<td align="left">IN0</td>
 
<td align="left">:= 141</td>
 
<td align="left">// function 141</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">IN1</td>
 
<td align="left">:= 0</td>
 
<td align="left">// no DB</td>
 
</tr>
 
<tr class="even">
 
<td align="left">IO2</td>
 
<td align="left">:= MD 20</td>
 
<td align="left">// returns the HostFlags</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">OUT3</td>
 
<td align="left">:= MW 24</td>
 
<td align="left">// error code</td>
 
</tr>
 
</tbody>
 
</table>
 
  
'''Function 142 Read DevFlags'''<br />
+
'''Function 142 Read DevFlags'''
With this function DevFlags can be read.
+
  
<table>
+
With this function DevFlags can be read.
<tbody>
+
 
<tr class="odd">
+
{| class="wikitable"
<td align="left">Bit</td>
+
|-
<td align="left">Deviceflag message</td>
+
! Bit !! Deviceflag message
</tr>
+
|-
<tr class="even">
+
|style="width: 5em"| 0 || HostCom: Handshake of the receive mailbox
<td align="left">0</td>
+
|-
<td align="left">HostCom: Handshake of the receive mailbox</td>
+
| 1 || DevCom: Handshake of the send mailbox
</tr>
+
|-
<tr class="odd">
+
| 2 || PdCom: Handshake of the process image
<td align="left">1</td>
+
|-
<td align="left">DevCom: Handshake of the send mailbox</td>
+
| 3 || Reserved
</tr>
+
|-
<tr class="even">
+
| 4 || PdExtCom: extended handshake of the pcrocess image
<td align="left">2</td>
+
|-
<td align="left">PdCom: Handshake of the process image</td>
+
| 5 || NotRdy: HOST program not ready
</tr>
+
|-
<tr class="odd">
+
| 6 || Init: Initialisation with parameter from dual-port memory
<td align="left">3</td>
+
|-
<td align="left">Reserved</td>
+
| 7 || Reset: Reset DEVICE
</tr>
+
|}
<tr class="even">
+
<td align="left">4</td>
+
<td align="left">PdExtCom: extended handshake of the pcrocess image</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">5</td>
+
<td align="left">NotRdy: HOST program not ready</td>
+
</tr>
+
<tr class="even">
+
<td align="left">6</td>
+
<td align="left">Init: Initialisation with parameter from dual-port memory</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">7</td>
+
<td align="left">Reset: Reset DEVICE</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
 
If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
  
Error codes:<br />
+
 
0x807F = Internal driver access error
+
Error codes:
 +
 
 +
0x807F = Internal driver access error
 +
 
  
 
Example:
 
Example:
 +
<code>
 +
{|
 +
| CALL || SFC 210
 +
|-
 +
|style="width: 5em"| IN0 ||style="width: 11em"| := 142  ||  // function 142
 +
|-
 +
| IN1 || := 0 || // no DB
 +
|-
 +
| IO2 || := MD 20  || // returns the DevFlags
 +
|-
 +
| OUT3 || := MW 24 || // error code
 +
|}
 +
</code>
  
<table>
 
<tbody>
 
<tr class="odd">
 
<td align="left">CALL</td>
 
<td align="left">SFC 210</td>
 
<td align="left"></td>
 
</tr>
 
<tr class="even">
 
<td align="left">IN0</td>
 
<td align="left">:= 142</td>
 
<td align="left">// function 142</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">IN1</td>
 
<td align="left">:= 0</td>
 
<td align="left">// no DB</td>
 
</tr>
 
<tr class="even">
 
<td align="left">IO2</td>
 
<td align="left">:= MD 20</td>
 
<td align="left">// returns the DevFlags</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">OUT3</td>
 
<td align="left">:= MW 24</td>
 
<td align="left">// error code</td>
 
</tr>
 
</tbody>
 
</table>
 
  
'''Function 150 Execute DevGetTaskState'''<br />
+
'''Function 150 Execute DevGetTaskState'''
With this function the global diagnostic infomation, reported from the CIF-module, can be read. The structure contains information about the bus condition and the condition of several slaves. The information is stored in bit-fields. In this way information about the master and the condition of the fieldbus is available. Furthermore it can be read, which slaves are configured and in use, which slaves are active and inactive and which slaves contain diagnostic information.<br />
+
The driver function DevGetTaskState is called internally. The result is written into a DB. To be able to use the function, the information to the function should be extracted from the Hilscher manual dpm_pie.pdf. The DB should comply with the DPM_DIAGNOSTICS structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
+
  
Error codes:<br />
+
With this function the global diagnostic infomation, reported from the CIF-module, can be read. The structure contains information about the bus condition and the condition of several slaves. The information is stored in bit-fields. In this way information about the master and the condition of the fieldbus is available. Furthermore it can be read, which slaves are configured and in use, which slaves are active and inactive and which slaves contain diagnostic information. The driver function DevGetTaskState is called internally. The result is written into a DB. To be able to use the function, the information to the function should be extracted from the Hilscher manual dpm_pie.pdf. The DB should comply with the DPM_DIAGNOSTICS structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
0x813A = data block not available<br />
+
0x8222 = size of data block to small<br />
+
0x8225 = range overflow<br />
+
0x807F = internal driver access error
+
  
Example:
 
  
<table>
+
Error codes:
<tbody>
+
<tr class="odd">
+
<td align="left">L</td>
+
<td align="left">DW#16#2</td>
+
<td align="left"></td>
+
</tr>
+
<tr class="even">
+
<td align="left">T</td>
+
<td align="left">MD20</td>
+
<td align="left">// task 2</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">CALL</td>
+
<td align="left">SFC 210</td>
+
<td align="left"></td>
+
</tr>
+
<tr class="even">
+
<td align="left">IN0</td>
+
<td align="left">:= 150</td>
+
<td align="left">// function 150</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">IN1</td>
+
<td align="left">:= 300</td>
+
<td align="left">// DB 300</td>
+
</tr>
+
<tr class="even">
+
<td align="left">IO2</td>
+
<td align="left">:= MD 20</td>
+
<td align="left">// task number</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">OUT3</td>
+
<td align="left">:= MW 24</td>
+
<td align="left">// error code</td>
+
</tr>
+
</tbody>
+
</table>
+
  
Adequate DB example:
+
0x813A = data block not available
  
DATA_BLOCK DB 300<br />
+
0x8222 = size of data block to small
  TITLE=DIAG<br />
+
 
  VERSION : 0.1<br />
+
0x8225 = range overflow
  STRUCT<br />
+
 
  bGlobalBits : BYTE;<br />
+
0x807F = internal driver access error
  bDPM_state : BYTE;<br />
+
 
  tError : STRUCT<br />
+
 
  bErr_Rem_Adr : BYTE;<br />
+
Example:
  bErr_Event : BYTE;<br />
+
<code>
  END_STRUCT;<br />
+
{|
  usBus_Error_Cnt : WORD;<br />
+
|-
  usTime_Out_Cnt : WORD;<br />
+
| L ||  DW#16#2 
  abReserved : ARRAY[0..7] OF BYTE;<br />
+
|-
  abSl_cfg : ARRAY[0..15] OF BYTE;<br />
+
| T || MD 20 || // task 2
  abSl_state : ARRAY[0..15] OF BYTE;<br />
+
|-
  abSl_diag : ARRAY[0..15] OF BYTE;<br />
+
| CALL || SFC 210
  END_STRUCT;<br />
+
|-
  BEGIN<br />
+
|style="width: 5em"| IN0 ||style="width: 11em"| := 150  ||  // function 150
 +
|-
 +
| IN1 || := 300 || // DB 300
 +
|-
 +
| IO2 || := MD 20  || // task number
 +
|-
 +
| OUT3 || := MW 24 || // error code
 +
|}
 +
</code>
 +
 
 +
Adequate DB example:
 +
DATA_BLOCK DB 300
 +
  TITLE=DIAG
 +
  VERSION : 0.1
 +
  STRUCT
 +
  bGlobalBits : BYTE;
 +
  bDPM_state : BYTE;
 +
  tError : STRUCT
 +
  bErr_Rem_Adr : BYTE;
 +
  bErr_Event : BYTE;
 +
  END_STRUCT;
 +
  usBus_Error_Cnt : WORD;
 +
  usTime_Out_Cnt : WORD;
 +
  abReserved : ARRAY[0..7] OF BYTE;
 +
  abSl_cfg : ARRAY[0..15] OF BYTE;
 +
  abSl_state : ARRAY[0..15] OF BYTE;
 +
  abSl_diag : ARRAY[0..15] OF BYTE;
 +
  END_STRUCT;
 +
  BEGIN
 
  END_DATA_BLOCK
 
  END_DATA_BLOCK
  
'''Function 151 Execute DevGetInfo'''<br />
 
With DevGetInfo various information can be read from the dual-port of the CIF-card. These are:
 
  
DW#16#1 GET_DRIVER_INFO Driver status information<br />
+
'''Function 151 Execute DevGetInfo'''
DW#16#2 GET_VERSION_INFO version information of the CIF<br />
+
 
DW#16#3 GET_FIRMWARE_INFO version of the CIF firmware<br />
+
With DevGetInfo various information can be read from the dual-port of the CIF-card. These are:
DW#16#4 GET_TASK_INFO Task information<br />
+
 
DW#16#5 GET_RCS_INFO CIF specific operating system information<br />
+
DW#16#1 GET_DRIVER_INFO Driver status information
DW#16#6 GET_DEV_INFO Device information<br />
+
 
DW#16#7 GET_IO_INFO Device I/O information<br />
+
DW#16#2 GET_VERSION_INFO version information of the CIF
DW#16#8 GET_IO_SEND_DATA Device I/O send data
+
 
 +
DW#16#3 GET_FIRMWARE_INFO version of the CIF firmware
 +
 
 +
DW#16#4 GET_TASK_INFO Task information
 +
 
 +
DW#16#5 GET_RCS_INFO CIF specific operating system information
 +
 
 +
DW#16#6 GET_DEV_INFO Device information
 +
 
 +
DW#16#7 GET_IO_INFO Device I/O information
 +
 
 +
DW#16#8 GET_IO_SEND_DATA Device I/O send data
 +
 
  
 
The driver function DevGetInfo is called internally. The result is written into a DB. In order to use the function, the information to the function should be extracted from the Hilscher manual devdrv.pdf. The DB should comply with the structures described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
 
The driver function DevGetInfo is called internally. The result is written into a DB. In order to use the function, the information to the function should be extracted from the Hilscher manual devdrv.pdf. The DB should comply with the structures described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
  
Error codes:<br />
 
0x813A = data block not available<br />
 
0x8222 = data block size to small<br />
 
0x8225 = not an available function number<br />
 
0x807F = internal driver access error
 
  
Example:
+
Error codes:
  
<table>
+
0x813A = data block not available
<tbody>
+
<tr class="odd">
+
<td align="left">L</td>
+
<td align="left">DW#16#1</td>
+
<td align="left">// function GET_DRIVER_INFO</td>
+
</tr>
+
<tr class="even">
+
<td align="left">T</td>
+
<td align="left">MD20</td>
+
<td align="left"></td>
+
</tr>
+
<tr class="odd">
+
<td align="left">CALL</td>
+
<td align="left">SFC 210</td>
+
<td align="left"></td>
+
</tr>
+
<tr class="even">
+
<td align="left">IN0</td>
+
<td align="left">:= 151</td>
+
<td align="left">// function 151</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">IN1</td>
+
<td align="left">:= 300</td>
+
<td align="left">// DB 300</td>
+
</tr>
+
<tr class="even">
+
<td align="left">IO2</td>
+
<td align="left">:= MD 20</td>
+
<td align="left">// function number</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">OUT3</td>
+
<td align="left">:= MW 24</td>
+
<td align="left">// error code</td>
+
</tr>
+
</tbody>
+
</table>
+
  
'''Function 152 Execute DevGetTaskParameter'''<br />
+
0x8222 = data block size to small
With this function the global settings, as for example the transfer rate of the bus, the watchdog time etc. can be read from the CIF-card. The driver function DevGetTaskParameter is called internally. The result is written into a DB. To be able to use the function, the information to the function should be extracted from the Hilscher manual devdrv.pdf. The DB should correspond to the structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
+
 
 +
0x8225 = not an available function number
 +
 
 +
0x807F = internal driver access error
  
Error codes:<br />
 
0x813A = data block not available<br />
 
0x8222 = data block size to small<br />
 
0x8225 = not an available function number<br />
 
0x807F = internal driver access error
 
  
 
Example:
 
Example:
 +
<code>
 +
{|
 +
|-
 +
| L ||  DW#16#1  || // function GET_DRIVER_INFO
 +
|-
 +
| T || MD 20
 +
|-
 +
| CALL || SFC 210
 +
|-
 +
|style="width: 5em"| IN0 ||style="width: 11em"| := 151  ||  // function 151
 +
|-
 +
| IN1 || := 300 || // DB 300
 +
|-
 +
| IO2 || := MD 20  || // function number
 +
|-
 +
| OUT3 || := MW 24 || // error code
 +
|}
 +
</code>
  
<table>
 
<tbody>
 
<tr class="odd">
 
<td align="left">L</td>
 
<td align="left">DW#16#2</td>
 
<td align="left">// task 2</td>
 
</tr>
 
<tr class="even">
 
<td align="left">T</td>
 
<td align="left">MD20</td>
 
<td align="left"></td>
 
</tr>
 
<tr class="odd">
 
<td align="left">CALL</td>
 
<td align="left">SFC 210</td>
 
<td align="left"></td>
 
</tr>
 
<tr class="even">
 
<td align="left">IN0</td>
 
<td align="left">:= 152</td>
 
<td align="left">// function 152</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">IN1</td>
 
<td align="left">:= 300</td>
 
<td align="left">// DB 300</td>
 
</tr>
 
<tr class="even">
 
<td align="left">IO2</td>
 
<td align="left">:= MD 20</td>
 
<td align="left">// function number</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">OUT3</td>
 
<td align="left">:= MW 24</td>
 
<td align="left">// error code</td>
 
</tr>
 
</tbody>
 
</table>
 
  
'''Function 153 Read slave diagnostics of a specific slave'''<br />
+
'''Function 152 Execute DevGetTaskParameter'''
With this function the standard diagnostic data of a DP-slave can be read. The information is returned in DPM_SLAVE_SINGLE_DIAGNOSTICS format. This function may not be used in conjunction with the driver CIFCFG.DLL (PROFIBUS<sup>®</sup> with CIF-card). In this case the SFC 13 (as hardware PLC), provided by the driver CIFCGF.DLL, has to be used instead. Details can be extracted from the Hilscher Manual dpm_pie.pdf, section DDLM_Slave_Diag. The DB should comply with the structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
+
 
 +
With this function the global settings, as for example the transfer rate of the bus, the watchdog time etc. can be read from the CIF-card. The driver function DevGetTaskParameter is called internally. The result is written into a DB. To be able to use the function, the information to the function should be extracted from the Hilscher manual devdrv.pdf. The DB should correspond to the structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
 +
 
 +
 
 +
Error codes:
 +
 
 +
0x813A = data block not available
 +
 
 +
0x8222 = data block size to small
 +
 
 +
0x8225 = not an available function number
 +
 
 +
0x807F = internal driver access error
  
Error codes:<br />
 
0x813A = data block not available<br />
 
0x8222 = dize of data block to small<br />
 
0x8225 = range overflow<br />
 
0x807F = internal driver access error
 
  
 
Example:
 
Example:
 +
<code>
 +
{|
 +
|-
 +
| L ||  DW#16#2  || // task 2
 +
|-
 +
| T || MD 20
 +
|-
 +
| CALL || SFC 210
 +
|-
 +
|style="width: 5em"| IN0 ||style="width: 11em"| := 152  ||  // function 152
 +
|-
 +
| IN1 || := 300 || // DB 300
 +
|-
 +
| IO2 || := MD 20  || // function number
 +
|-
 +
| OUT3 || := MW 24 || // error code
 +
|}
 +
</code>
  
<table>
 
<tbody>
 
<tr class="odd">
 
<td align="left">L</td>
 
<td align="left">DW#16#2B</td>
 
<td align="left">// PROFIBUS<sup>®</sup> address of the slave (here : 11dec)</td>
 
</tr>
 
<tr class="even">
 
<td align="left">T</td>
 
<td align="left">MD20</td>
 
<td align="left"></td>
 
</tr>
 
<tr class="odd">
 
<td align="left">CALL</td>
 
<td align="left">SFC 210</td>
 
<td align="left"></td>
 
</tr>
 
<tr class="even">
 
<td align="left">IN0</td>
 
<td align="left">:= 153</td>
 
<td align="left">// function 153</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">IN1</td>
 
<td align="left">:= 300</td>
 
<td align="left">// DB 300</td>
 
</tr>
 
<tr class="even">
 
<td align="left">IO2</td>
 
<td align="left">:= MD 20</td>
 
<td align="left">// function number</td>
 
</tr>
 
<tr class="odd">
 
<td align="left">OUT3</td>
 
<td align="left">:= MW 24</td>
 
<td align="left">// error code</td>
 
</tr>
 
</tbody>
 
</table>
 
  
Adequate DB example:
+
'''Function 153 Read slave diagnostics of a specific slave'''
  
DATA_BLOCK DB 300<br />
+
With this function the standard diagnostic data of a DP-slave can be read. The information is returned in DPM_SLAVE_SINGLE_DIAGNOSTICS format. This function may not be used in conjunction with the driver CIFCFG.DLL (PROFIBUS<sup>®</sup> with CIF-card). In this case the SFC 13 (as hardware PLC), provided by the driver CIFCGF.DLL, has to be used instead. Details can be extracted from the Hilscher Manual dpm_pie.pdf, section DDLM_Slave_Diag. The DB should comply with the structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.
  TITLE=<br />
+
 
  VERSION : 0.1<br />
+
 
  STRUCT<br />
+
Error codes:
  DPM_SLAVE_DIAG : STRUCT<br />
+
 
  Stationsstatus_1 : BYTE;<br />
+
0x813A = data block not available
  Stationstatus_2 : BYTE;<br />
+
 
  Stationstatus_3 : BYTE;<br />
+
0x8222 = dize of data block to small
  bMaster_Add : BYTE; // corresponding master address<br />
+
 
  usIdent_Number : WORD; // ident number, big endian (motorola format)<br />
+
0x8225 = range overflow
  abExt_Diag_Data : ARRAY[0..99] OF BYTE; // extended diagnostic field<br />
+
 
  END_STRUCT;<br />
+
0x807F = internal driver access error
  END_STRUCT;<br />
+
 
  BEGIN<br />
+
 
 +
Example:
 +
<code>
 +
{|
 +
|-
 +
| L || DW#16#2B  || // PROFIBUS® address of the slave (here : 11dec)
 +
|-
 +
| T || MD 20
 +
|-
 +
| CALL || SFC 210
 +
|-
 +
|style="width: 5em"| IN0 ||style="width: 11em"| := 153  ||  // function 153
 +
|-
 +
| IN1 || := 300 || // DB 300
 +
|-
 +
| IO2 || := MD 20  || // function number
 +
|-
 +
| OUT3 || := MW 24 || // error code
 +
|}
 +
</code>
 +
 
 +
Adequate DB example:
 +
DATA_BLOCK DB 300
 +
TITLE=
 +
  VERSION : 0.1
 +
  STRUCT
 +
  DPM_SLAVE_DIAG : STRUCT
 +
  Stationsstatus_1 : BYTE;
 +
  Stationstatus_2 : BYTE;
 +
  Stationstatus_3 : BYTE;
 +
  bMaster_Add : BYTE; // corresponding master address
 +
  usIdent_Number : WORD; // ident number, big endian (motorola format)
 +
  abExt_Diag_Data : ARRAY[0..99] OF BYTE; // extended diagnostic field
 +
  END_STRUCT;
 +
  END_STRUCT;
 +
  BEGIN
 
  END_DATA_BLOCK
 
  END_DATA_BLOCK

Revision as of 10:01, 17 January 2013

The basic configuration features of the CIF-cards are set here.

If no PROFIBUS® is used, the configuration has to be executed with the System Configurator SyCon of the Hilscher company.

How the driver is integrated into S7-SoftPLC is part of these instructions:

Using Status and Control SFC

Querying CIF-status

To query the CIF-status the status SFC has to be called cyclically (e.g. from the OB 1). The SFC contains the following parameters:

Name Sort Type Function
HostFlags OUT BYTE HostFlags
DevFlags OUT BYTE DevFlags

CALL SFC 252
OUT0  :=MB10 // HostFlags
OUT1  :=MB11 // DeviceFlags

The HostFlags and DeviceFlags are described exactly in the section Control-SFC function 141 and function 142, as well as in the Hilscher document tke.pdf on page 8.


Control-SFC

The Control SFC is used to execute special functions of the CIF-card. The control block is called in the following way:

L #Value
T MD 20
CALL SFC 210
IN0  := 142 // INPUT Function number.
IN1  := 0 // INPUT Data block number (on DB operationen, else 0).
IO2  := MD 20 // IN_OUT Parameter of function / Result.
OUT3  := MW 24 // OUTPUT Default 80xx Error codes, 0 on success.

When succeeded, the BR bit is set as well.


Control-SFC functions overview

Function number Function description
102 Set number of digital in/outputs
108 Set number of analog in/outputs
125 Read process inputs
126 Write process outputs
130 Read global diagnostic bits
131 Read bus status
132 Read incorrect bus address
133 Read error number
134 Read status bits
135 Read diagnostic bits
136 Read dual-port memory
137 Write dual-port memory
140 Trigger watchdog
141 Read HostFlags
142 Read DevFlags
150 Call DevGetTaskState and provide result in DB
151 Call DevGetInfo and provide result in DB
152 Call DevGetTaskParameter and provide result in DB


Function 102 Set number of digital in/outputs

With this function the number of the digital in/outputs can be set. 512 byte digital in/outputs are preset in S7-SoftPLC. With this function the number of digital in/outputs can be reduced. That causes an acceleration of S7-SoftPLC. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error code:

0x8222 = size to big


Example:

L 50 // 50 digital I/Os necessary only
T MD 20 // set number of digital I/Os
CALL SFC 210
IN0  := 102 // function 102
IN1  := 0 // no DB
IO2  := MD 20 // size
OUT3  := MW 24 // error code


Function 108 Set number of analog in/outputs

With this function the number of the analogue in/outputs can be set. The maximum size of the dualport RAM, found during the initialization of the card, is preset in S7-SoftPLC. With this function the number of analog in/outputs can be reduced to the required number. It is counted from byte 0 of the dualport. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Fehlercode:

0x8222 = Size to big


Example:

L 100 // 100 analog I/Os necessary only
T MD 20 // set number of analog I/Os
CALL SFC 210
IN0  := 108 // function 108
IN1  := 0 // no DB
IO2  := MD 20 // size
OUT3  := MW 24 // error code


Function 125 Read process inputs

With this function the process inputs can be read into a data block. Herewith every available peripheral byte can be accessed. The function writes asynchronous. With word oriented inputs no data consistence exists and the function can only be used with byte oriented inputs.If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x813A = data block not available

0x8222 = size of data block bigger than size of source area

0x8042 = READY or COM missing

0x807F = internal driver access error


Example:

L W#16#0100 // process input start address
T MD 20
CALL SFC 210
IN0  := 125 // function 125
IN1  := 300 // DB 300
IO2  := MD 20 // process input start address
OUT3  := MW 24 // error code


Function 126 Write process outputs

With this function a data block can be written into the process outputs. Herewith every available peripheral byte can be accessed. The function writes asynchronously. With word oriented outputs no data consistence exists and the function can only be used byte oriented. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x813A = data block not available

0x8222 = size of data block bigger than size of source area

0x8042 = READY or COM missing

0x807F = internal driver access error


Example:

L W#16#0100 // process output start address
T MD 20
CALL SFC 210
IN0  := 126 // function 126
IN1  := 300 // DB 300
IO2  := MD 20 // process output start address
OUT3  := MW 24 // error code


Function 130 Read global diagnostic bits

With this function global diagnostic bits can be read.

Bit PROFIBUS® message
0 Parameter error
1 Component branched because of bus error in Auto_Clear_Modus
2 At least one slave is not transferring data or reports a fatal error
3 Fatal bus error, further data transferring impossible
4 Short circuit on the bus
5 Host not ready
6 reserved
7 reserved


Bit Interbus message
0 Parameter error
1 System error occured
2 At least one slave reports module error
3 At least one defective W1-port
4 At least one defective W2-port
5 reserved
6 reserved
7 reserved

If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x807F = Internal driver access error


Example:

CALL SFC 210
IN0  := 130 // function 130
IN1  := 0 // no DB
IO2  := MD 20 // diagnostic bits
OUT3  := MW 24 // error code


Function 131 Read bus status

With this function the bus status can be read.

Bit Interbus message
0 Bus segment turned off
1 reserved
2 reserved
3 reserved
4 reserved
5 reserved
6 reserved
7 reserved

If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x807F = Internal driver access error


Example:

CALL SFC 210
IN0  := 131 // function 131
IN1  := 0 // no DB
IO2  := MD 20 // bus status
OUT3  := MW 24 // error code


Function 132 Read incorrect bus address

With this function the incorrect bus address can be read. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x807F = Internal driver access error


Example:

CALL SFC 210
IN0  := 132 // function 132
IN1  := 0 // no DB
IO2  := MD 20 // incorrect bus address
OUT3  := MW 24 // error code


Function 133 Read error number

With this function the error number can be read. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x807F = Internal driver access error


Example:

CALL SFC 210
IN0  := 133 // function 133
IN1  := 0 // no DB
IO2  := MD 20 // error number
OUT3  := MW 24 // error code


Function 134 Read status bits

With this function the status bits can be read. Before the call the status byte number (0..15) must be selected. After the function call, the selected status byte is returned. If a binary digit in status byte is 1, the corresponding slave is active, if it is 0, it is inactive. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x807F = Internal driver access error


Example:

L W#16#03 // byte number 3
T MD 20
CALL SFC 210
IN0  := 134 // function 134
IN1  := 0 // no DB
IO2  := MD 20 // before calling status byte nummer, after calling the content of the status byte
OUT3  := MW 24 // error code


Function 135 Read diagnostic bits

With this function the diagnostic bits can be read. Before the call the diagnostic byte number (0..15) must be selected. After the function call, the selected diagnostic byte is returned. If a bit in the diagnostic byte is 1, the status of the corresponding slave has changed (from active to inactive or vice versa). If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x807F = Internal driver access error


Example:

L W#16#03 // byte number 3
T MD 20
CALL SFC 210
IN0  := 135 // function 135
IN1  := 0 // no DB
IO2  := MD 20 // before calling diagnostic byte number, after calling the content of diagnostic byte
OUT3  := MW 24 // error code


Function 136 Read dual-port memory

With this function an area from the dual-port memory of the CIF-card can be written into a data block. Basically it begins with the first byte in the data block. The length is passed in the I/O-parameter low word and the relative address in the dual-port memory in the I/O-parameter high word. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x813A = data block not available

0x8222 = size of data block to small

0x8224 = range overflow

0x8042 = READY or COM missing

0x807F = Internal driver access error


Example:

L DW#16#0100000A // copy 10 bytes from the relative address 100H
T MD 20
CALL SFC 210
IN0  := 136 // function 136
IN1  := 60 // DB 60
IO2  := MD 20 // 10 bytes are read from the relative address 0x100H
OUT3  := MW 24 // error code


Function 137 Write dual-port memory

With this function an area from the data block can be written into the dual-port memory of the CIF-card. Basically it begins with the first byte in the data block. The length is passed in the I/O-parameter low word and the relative address in the dual-port memory in the I/O-parameter high word. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x813A = data block not available

0x8222 = size of data block to small

0x8224 = range overflow

0x8042 = READY or COM missing

0x807F = Internal driver access error


Example:

L DW#16#0100000A // copy 10 bytes into the relatice address 100H
T MD 20
CALL SFC 210
IN0  := 137 // function 137
IN1  := 60 // DB 60
IO2  := MD 20 // 10 bytes are written into the relative address 0x100H
OUT3  := MW 24 // error code


Function 140 trigger watchdog

This function is needed, if very long PLC cycles occur. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

None


Example:

CALL SFC 210
IN0  := 140 // function 140
IN1  := 0 // no DB
IO2  := MD 20 // no function code
OUT3  := MW 24 // error code


Function 141 Read HostFlags

With this function HostFlags can be read.

Bit Hostflag message
0 HostCom: Handshake of the receive mailbox
1 DevAck: Handshake of the send mailbox
2 PdAck: Handshake of the process image
3 ERR: communication error to one network device
4 PdExtAck: extended handshake of the pcrocess image
5 COM: I/O exchange to one network device established
6 RUN: DEVICE is communicating, configuration valid
7 READY: DEVICE is running, end of initialisation

If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x807F = Internal driver access error


Example:

CALL SFC 210
IN0  := 141 // function 141
IN1  := 0 // no DB
IO2  := MD 20 // returns the HostFlags
OUT3  := MW 24 // error code


Function 142 Read DevFlags

With this function DevFlags can be read.

Bit Deviceflag message
0 HostCom: Handshake of the receive mailbox
1 DevCom: Handshake of the send mailbox
2 PdCom: Handshake of the process image
3 Reserved
4 PdExtCom: extended handshake of the pcrocess image
5 NotRdy: HOST program not ready
6 Init: Initialisation with parameter from dual-port memory
7 Reset: Reset DEVICE

If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x807F = Internal driver access error


Example:

CALL SFC 210
IN0  := 142 // function 142
IN1  := 0 // no DB
IO2  := MD 20 // returns the DevFlags
OUT3  := MW 24 // error code


Function 150 Execute DevGetTaskState

With this function the global diagnostic infomation, reported from the CIF-module, can be read. The structure contains information about the bus condition and the condition of several slaves. The information is stored in bit-fields. In this way information about the master and the condition of the fieldbus is available. Furthermore it can be read, which slaves are configured and in use, which slaves are active and inactive and which slaves contain diagnostic information. The driver function DevGetTaskState is called internally. The result is written into a DB. To be able to use the function, the information to the function should be extracted from the Hilscher manual dpm_pie.pdf. The DB should comply with the DPM_DIAGNOSTICS structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x813A = data block not available

0x8222 = size of data block to small

0x8225 = range overflow

0x807F = internal driver access error


Example:

L DW#16#2
T MD 20 // task 2
CALL SFC 210
IN0  := 150 // function 150
IN1  := 300 // DB 300
IO2  := MD 20 // task number
OUT3  := MW 24 // error code

Adequate DB example:

DATA_BLOCK DB 300
TITLE=DIAG
VERSION : 0.1
STRUCT
bGlobalBits : BYTE;
bDPM_state : BYTE;
tError : STRUCT
bErr_Rem_Adr : BYTE;
bErr_Event : BYTE;
END_STRUCT;
usBus_Error_Cnt : WORD;
usTime_Out_Cnt : WORD;
abReserved : ARRAY[0..7] OF BYTE;
abSl_cfg : ARRAY[0..15] OF BYTE;
abSl_state : ARRAY[0..15] OF BYTE;
abSl_diag : ARRAY[0..15] OF BYTE;
END_STRUCT;
BEGIN
END_DATA_BLOCK


Function 151 Execute DevGetInfo

With DevGetInfo various information can be read from the dual-port of the CIF-card. These are:

DW#16#1 GET_DRIVER_INFO Driver status information

DW#16#2 GET_VERSION_INFO version information of the CIF

DW#16#3 GET_FIRMWARE_INFO version of the CIF firmware

DW#16#4 GET_TASK_INFO Task information

DW#16#5 GET_RCS_INFO CIF specific operating system information

DW#16#6 GET_DEV_INFO Device information

DW#16#7 GET_IO_INFO Device I/O information

DW#16#8 GET_IO_SEND_DATA Device I/O send data


The driver function DevGetInfo is called internally. The result is written into a DB. In order to use the function, the information to the function should be extracted from the Hilscher manual devdrv.pdf. The DB should comply with the structures described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x813A = data block not available

0x8222 = data block size to small

0x8225 = not an available function number

0x807F = internal driver access error


Example:

L DW#16#1 // function GET_DRIVER_INFO
T MD 20
CALL SFC 210
IN0  := 151 // function 151
IN1  := 300 // DB 300
IO2  := MD 20 // function number
OUT3  := MW 24 // error code


Function 152 Execute DevGetTaskParameter

With this function the global settings, as for example the transfer rate of the bus, the watchdog time etc. can be read from the CIF-card. The driver function DevGetTaskParameter is called internally. The result is written into a DB. To be able to use the function, the information to the function should be extracted from the Hilscher manual devdrv.pdf. The DB should correspond to the structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x813A = data block not available

0x8222 = data block size to small

0x8225 = not an available function number

0x807F = internal driver access error


Example:

L DW#16#2 // task 2
T MD 20
CALL SFC 210
IN0  := 152 // function 152
IN1  := 300 // DB 300
IO2  := MD 20 // function number
OUT3  := MW 24 // error code


Function 153 Read slave diagnostics of a specific slave

With this function the standard diagnostic data of a DP-slave can be read. The information is returned in DPM_SLAVE_SINGLE_DIAGNOSTICS format. This function may not be used in conjunction with the driver CIFCFG.DLL (PROFIBUS® with CIF-card). In this case the SFC 13 (as hardware PLC), provided by the driver CIFCGF.DLL, has to be used instead. Details can be extracted from the Hilscher Manual dpm_pie.pdf, section DDLM_Slave_Diag. The DB should comply with the structure described there. If the function was not executed successfully, the BR is not set. The return value contains the standard 80xx error codes.


Error codes:

0x813A = data block not available

0x8222 = dize of data block to small

0x8225 = range overflow

0x807F = internal driver access error


Example:

L DW#16#2B // PROFIBUS® address of the slave (here : 11dec)
T MD 20
CALL SFC 210
IN0  := 153 // function 153
IN1  := 300 // DB 300
IO2  := MD 20 // function number
OUT3  := MW 24 // error code

Adequate DB example:

DATA_BLOCK DB 300
TITLE=
VERSION : 0.1
STRUCT
DPM_SLAVE_DIAG : STRUCT
Stationsstatus_1 : BYTE;
Stationstatus_2 : BYTE;
Stationstatus_3 : BYTE;
bMaster_Add : BYTE; // corresponding master address
usIdent_Number : WORD; // ident number, big endian (motorola format)
abExt_Diag_Data : ARRAY[0..99] OF BYTE; // extended diagnostic field
END_STRUCT;
END_STRUCT;
BEGIN
END_DATA_BLOCK