Difference between revisions of "S7-SoftPLC:Data Interface"

From IBHsoftec Wiki English
Jump to: navigation, search
 
(9 intermediate revisions by one other user not shown)
Line 13: Line 13:
 
{|
 
{|
 
|-
 
|-
| unsigned long int DLLexport ReadVal || (unsigned long int typ,
+
| unsigned long int DLLexport ReadVal || (unsigned long int type,
 
|-
 
|-
|  || unsigned long int nr,
+
|  || unsigned long int no,
 
|-
 
|-
|  || unsigned long int DBNr,
+
|  || unsigned long int DBNo,
 
|-
 
|-
 
|  || unsigned long int size,
 
|  || unsigned long int size,
Line 35: Line 35:
 
| DBNo || Number of data block || 1 – 16383
 
| DBNo || Number of data block || 1 – 16383
 
|-
 
|-
| size || Number of bits<br />0..7= bit no 0 7<br />8 = 1 byte<br />16 = 1 word<br />32 = 1 double word || <br /><br />nur 'I','Q','M' only
+
| size || Number of bits<br />0..7= bit no 0 7<br />8 = 1 byte<br />16 = 1 word<br />32 = 1 double word || <br /><br />'I','Q','M' only
 
|-
 
|-
 
| val ||  Read value || Pointer to a valid variable in the user applications address space
 
| val ||  Read value || Pointer to a valid variable in the user applications address space
 
|-
 
|-
| Rückgabe || 0 on Error || Error messages
+
| return || 0 on Error || Error messages
 
|}
 
|}
  
Line 49: Line 49:
 
Writes a value in ''S7-SoftPLC''.
 
Writes a value in ''S7-SoftPLC''.
  
<table>
+
{|
<tbody>
+
|-
<tr class="odd">
+
| unsigned long int DLLexport WriteVal || (unsigned long int type,
<td align="left">unsigned long int DLLexport WriteVal</td>
+
|-
<td align="left">(unsigned long int type,</td>
+
|  || unsigned long int no,
</tr>
+
|-
<tr class="even">
+
|  || unsigned long int DBNo,
<td align="left"> </td>
+
|-
<td align="left">unsigned long int no,</td>
+
|  || unsigned long int size,
</tr>
+
|-
<tr class="odd">
+
|  || unsigned long int far * val);,
<td align="left"> </td>
+
|}
<td align="left">unsigned long int DBNo,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned long int size,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int far * val);,</td>
+
</tr>
+
</tbody>
+
</table>
+
  
<br />
 
  
 
+
{| class="wikitable"
<table>
+
|-
<tbody>
+
! Parameter !! Description !!  comment
<tr class="odd">
+
|-
<td align="left">parameter</td>
+
| type || 'I' = input<br />'Q' = output<br />'M' = flag<br />'C' = counter value<br />'T' = timer value<br />'D' = data word or double data word<br />'B' = data bit, byte, wort, doppelwort on <br />byte address<br />'P' = P_Parameter || <br /><br /><br />16-bit-access only<br />16-bit-access only<br />depending on size<br />depending on size<br />compatible to S7 only<br />S7 from version 3 only!<br />
<td align="left">description</td>
+
|-
<td align="left">comment</td>
+
| no || adress || Byte address of operand to be written
</tr>
+
|-
<tr class="even">
+
| DBNo || number of data block || 1 – 16383
<td align="left">type</td>
+
|-
<td align="left">'I' = input<br />
+
| size || number of bits<br />0..7= bit no 0 7<br />8 = 1 byte<br />16 = 1 word<br />32 = 1 double word || <br /><br />'I','Q','M' only
'Q' = output<br />
+
|-
'M' = flag<br />
+
| val ||  value to be written ||
'C' = counter value<br />
+
|-
'T' = timer value<br />
+
| return || 0 on error || Error messages
'D' = data word or double data word<br />
+
|}
'B' = data bit, byte, wort, doppelwort on byte address<br />
+
'P' = P_Parameter</td>
+
<td align="left"> <br />
+
 <br />
+
 <br />
+
16-bit-access only<br />
+
16-bit-access only<br />
+
depending on size<br />
+
depending on size<br />
+
 <br />
+
compatible to S7 only<br />
+
S7 from version 3 only</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">no</td>
+
<td align="left">adress</td>
+
<td align="left">Byte address of operand to be written</td>
+
</tr>
+
<tr class="even">
+
<td align="left">DBNo</td>
+
<td align="left">number of data block</td>
+
<td align="left">1 – 16383</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">size</td>
+
<td align="left">number of bits<br />
+
0..7= bit no 0 7<br />
+
8 = 1 byte<br />
+
16 = 1 word<br />
+
32 = 1 double word</td>
+
<td align="left"> <br />
+
'I','Q','M' only</td>
+
</tr>
+
<tr class="even">
+
<td align="left">val</td>
+
<td align="left">value to be written</td>
+
<td align="left"> </td>
+
</tr>
+
<tr class="odd">
+
<td align="left">return</td>
+
<td align="left">0 on error</td>
+
<td align="left">Error messages</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
Length of parameter list (Visual-C): 20 bytes.
 
Length of parameter list (Visual-C): 20 bytes.
  
'''Read multiple values'''<br />
 
Reads multiple values from ''S7-SoftPLC''.
 
  
<table>
+
'''Read multiple values'''
<tbody>
+
<tr class="odd">
+
<td align="left">unsigned long int DLLexport ReadVals</td>
+
<td align="left">(unsigned long int type,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned long int no,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int DBNo,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned long int size,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int far * vals);,</td>
+
</tr>
+
</tbody>
+
</table>
+
  
<br />
+
Reads multiple values from ''S7-SoftPLC''.
  
 +
{|
 +
|-
 +
| unsigned long int DLLexport ReadVals || (unsigned long int type,
 +
|-
 +
|  || unsigned long int no,
 +
|-
 +
|  || unsigned long int DBNo,
 +
|-
 +
|  || unsigned long int size,
 +
|-
 +
|  || unsigned long int far * vals);,
 +
|}
  
<table>
+
 
<tbody>
+
{| class="wikitable"
<tr class="odd">
+
|-
<td align="left">parameter</td>
+
! Parameter !! Description !!  Comment
<td align="left">description</td>
+
|-
<td align="left">comment</td>
+
| type || 'I' = input<br />'Q' = output<br />'M' = flag<br />'D' = data word<br />'B' = data byte on byte address || <br /><br /><br />S5 compatible<br />compatible to S7 only
</tr>
+
|-
<tr class="even">
+
| no || adress ||
<td align="left">type</td>
+
|-
<td align="left">'I' = input<br />
+
| DBNo || number of data block || 1 – 16383
'Q' = output<br />
+
|-
'M' = flag<br />
+
| size || number of data bytes or data words || destination size in bytes for type 'I', 'Q', 'M' and 'B', destination size in data words for 'D'
'D' = data word<br />
+
|-
'B' = data byte on byte address</td>
+
| vals ||  Value of byte ||  Pointer to a valid array in the user applications address space
<td align="left"> <br />
+
Warning: Array has to be big enough!
 <br />
+
|-
 <br />
+
| return || 0 on error || Error messages
S5 compatible<br />
+
|}
compatible to S7 only</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">no</td>
+
<td align="left">adress</td>
+
<td align="left"> </td>
+
</tr>
+
<tr class="even">
+
<td align="left">DBNo</td>
+
<td align="left">number of data block</td>
+
<td align="left">1 – 16383</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">size</td>
+
<td align="left">number of data bytes or data words</td>
+
<td align="left">destination size in bytes for type 'I', 'Q', 'M' and 'B', destination size in data words for 'D'</td>
+
</tr>
+
<tr class="even">
+
<td align="left">vals</td>
+
<td align="left">Value of byte</td>
+
<td align="left">Pointer to a valid array in the user applications address space<br />
+
Warning: Array has to be big enough!</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">return</td>
+
<td align="left">0 on error</td>
+
<td align="left">Error messages</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
Length of parameter list (Visual-C): 20 bytes.
 
Length of parameter list (Visual-C): 20 bytes.
 +
  
 
WARNING: FOR DATA BLOCKS (TYPE 'D') THE ARRAY HAS TO BE TWICE AS BIG, SINCE 2 BYTES ARE NECESSARY FOR EVERY DATA WORD!
 
WARNING: FOR DATA BLOCKS (TYPE 'D') THE ARRAY HAS TO BE TWICE AS BIG, SINCE 2 BYTES ARE NECESSARY FOR EVERY DATA WORD!
  
'''Write multiple values'''<br />
 
Writes multiple values to ''S7-SoftPLC''.
 
  
<table>
+
'''Write multiple values'''
<tbody>
+
<tr class="odd">
+
<td align="left">unsigned long int DLLexport WriteVals</td>
+
<td align="left">(unsigned long int type,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned long int no,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int DBNo,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned long int size,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int far * vals);,</td>
+
</tr>
+
</tbody>
+
</table>
+
  
<br />
+
Writes multiple values to ''S7-SoftPLC''.
  
 +
{|
 +
|-
 +
| unsigned long int DLLexport WriteVals || (unsigned long int type,
 +
|-
 +
|  || unsigned long int no,
 +
|-
 +
|  || unsigned long int DBNo,
 +
|-
 +
|  || unsigned long int size,
 +
|-
 +
|  || unsigned long int far * vals);,
 +
|}
  
<table>
+
 
<tbody>
+
{| class="wikitable"
<tr class="odd">
+
|-
<td align="left">parameter</td>
+
! Parameter !! Description !!  Comment
<td align="left">description</td>
+
|-
<td align="left">comment</td>
+
| type || 'I' = input<br />'Q' = output<br />'M' = flag<br />'D' = data word<br />'B' = data byte on byte address || <br /><br /><br />S5 compatible<br />compatible to S7 only
</tr>
+
|-
<tr class="even">
+
| no || adress ||
<td align="left">type</td>
+
|-
<td align="left">'I' = input<br />
+
| DBNo || number of data block || 1 – 16383
'Q' = output<br />
+
|-
'M' = flag<br />
+
| size || number of data bytes or data words<br />'I'<br />'Q'<br />'M'<br />'B'<br />'D' || <br />Destination size in bytes<br />Destination size in bytes<br />Destination size in bytes<br />Destination size in bytes<br />Destination size in data words
'D' = data word<br />
+
|-
'B' = data byte on byte address</td>
+
| vals ||  value of byte || Pointer to a valid array in the user applications address space
<td align="left"> <br />
+
Warning: Array has to be big enough!
 <br />
+
|-
 <br />
+
| return || 0 on error || Error messages
S5 compatible<br />
+
|}
compatible to S7 only</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">no</td>
+
<td align="left">adress</td>
+
<td align="left"> </td>
+
</tr>
+
<tr class="even">
+
<td align="left">DBNo</td>
+
<td align="left">number of data block</td>
+
<td align="left">1 – 16383</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">size</td>
+
<td align="left">number of data bytes or data words<br />
+
'I'<br />
+
'Q'<br />
+
'M'<br />
+
'B'<br />
+
'D'</td>
+
<td align="left"> <br />
+
Destination size in bytes<br />
+
Destination size in bytes<br />
+
Destination size in bytes<br />
+
Destination size in bytes<br />
+
Destination size in data words</td>
+
</tr>
+
<tr class="even">
+
<td align="left">value of byte</td>
+
<td align="left">value of byte</td>
+
<td align="left">Pointer to a valid array in the user applications address space<br />
+
Warning: Array has to be big enough!</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">return</td>
+
<td align="left">0 on error</td>
+
<td align="left">Error messages</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
Length of parameter list (Visual-C): 20 bytes.
 
Length of parameter list (Visual-C): 20 bytes.
 +
  
 
WARNING: FOR DATA BLOCKS (TYPE = D) THE ARRAY HAS TO BE TWICE AS BIG, SINCE 2 BYTES ARE NECESSARY FOR EVERY DATA WORD!
 
WARNING: FOR DATA BLOCKS (TYPE = D) THE ARRAY HAS TO BE TWICE AS BIG, SINCE 2 BYTES ARE NECESSARY FOR EVERY DATA WORD!
  
'''Read DB'''<br />
 
Reads the content of a data block from ''S7-SoftPLC''.
 
  
<table>
+
'''Read DB'''
<tbody>
+
<tr class="odd">
+
<td align="left">unsigned long int DLLexport ReadDB</td>
+
<td align="left">(unsigned long int no,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned short int far * block,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int far * size,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned long int synchronous);</td>
+
</tr>
+
</tbody>
+
</table>
+
  
<br />
+
Reads the content of a data block from ''S7-SoftPLC''.
  
 +
{|
 +
|-
 +
| unsigned long int DLLexport ReadDB || (unsigned long int no,
 +
|-
 +
|  || unsigned short int far * block,
 +
|-
 +
|  || unsigned long int far * size,
 +
|-
 +
|  || unsigned long int synchronous);
 +
|}
  
<table>
+
 
<tbody>
+
{| class="wikitable"
<tr class="odd">
+
|-
<td align="left">parameter</td>
+
! Parameter !! Description !!  Comment
<td align="left">description</td>
+
|-
<td align="left">comment</td>
+
| no || number of data block || 1..16383
</tr>
+
|-
<tr class="even">
+
| block || pointer to data block content || Pointer to a valid array in the user applications address space.
<td align="left">no</td>
+
Warning: Array has to be big enough!
<td align="left">number of data block</td>
+
|-
<td align="left">1..16383</td>
+
| size || number of words that are to be read from the data block || If the data block is smaller than the size, the size will be reduced automatically.  
</tr>
+
Pointer to a valid variable in the user applications address space.
<tr class="odd">
+
|-
<td align="left">block</td>
+
| synchronous || always 0 || irrelevant for S7
<td align="left">pointer to data block content</td>
+
|-
<td align="left">pointer to a valid array in the user applications address space.<br />
+
| return || 0 on error || Error messages
Warning: Array has to be big enough!</td>
+
|}
</tr>
+
<tr class="even">
+
<td align="left">size</td>
+
<td align="left">number of words that are to be read from the data block</td>
+
<td align="left">if the data block is smaller than the size, the size will be reduced automatically. Pointer to a valid variable in the user applications address space.</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">synchronous</td>
+
<td align="left">always 0</td>
+
<td align="left">irrelevant for S7</td>
+
</tr>
+
<tr class="even">
+
<td align="left">return</td>
+
<td align="left">0 on error</td>
+
<td align="left">Error messages</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
Length of parameter list (Visual-C): 16 bytes.
 
Length of parameter list (Visual-C): 16 bytes.
 +
  
 
WARNING: WORD-ORIENTED READING, LOW- AND HIGH-BYTE ARE SWAPPED.
 
WARNING: WORD-ORIENTED READING, LOW- AND HIGH-BYTE ARE SWAPPED.
  
'''Write DB'''<br />
 
Writes a data block to ''S7-SoftPLC''.
 
  
<table>
+
'''Write DB'''
<tbody>
+
<tr class="odd">
+
<td align="left">unsigned long int DLLexport WriteDB</td>
+
<td align="left">(unsigned long int no,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned short int far * block,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int far * size,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned long int synchronous);</td>
+
</tr>
+
</tbody>
+
</table>
+
  
<br />
+
Writes a data block to ''S7-SoftPLC''.
  
 +
{|
 +
|-
 +
| unsigned long int DLLexport WriteDB || (unsigned long int no,
 +
|-
 +
|  || unsigned short int far * block,
 +
|-
 +
|  || unsigned long int far * size,
 +
|-
 +
|  || unsigned long int synchronous);
 +
|}
  
<table>
+
 
<tbody>
+
{| class="wikitable"
<tr class="odd">
+
|-
<td align="left">parameter</td>
+
! Parameter !! Description !!  Comment
<td align="left">description</td>
+
|-
<td align="left">comment</td>
+
| no || number of data block || 1..16383
</tr>
+
|-
<tr class="even">
+
| block || pointer to data block content || Pointer to a valid array in the user applications address space
<td align="left">no</td>
+
Warning: Array has to be big enough!
<td align="left">number of data block</td>
+
|-
<td align="left">1..16383</td>
+
| size || number of words that are to be written into the block || If the data block is smaller than the size, the size will be reduced automatically.
</tr>
+
Pointer to a valid variable in the user applications address space.
<tr class="odd">
+
|-
<td align="left">block</td>
+
| synchronous || always 0 || irrelevant for S7
<td align="left">pointer to data block content</td>
+
|-
<td align="left">Pointer to a valid array in the user applications address space<br />
+
| return || 0 on error || Error messages
Warning: Array has to be big enough!</td>
+
|}
</tr>
+
<tr class="even">
+
<td align="left">size</td>
+
<td align="left">number of words that are to be written into the block</td>
+
<td align="left">if the data block is smaller than the size, the size will be reduced automatically.<br />
+
Pointer to a valid variable in the user applications address space.</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">synchronous</td>
+
<td align="left">always 0</td>
+
<td align="left">irrelevant for S7</td>
+
</tr>
+
<tr class="even">
+
<td align="left">return</td>
+
<td align="left">0 on error</td>
+
<td align="left">Error messages</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
Length of parameter list (Visual-C): 16 bytes.
 
Length of parameter list (Visual-C): 16 bytes.
 +
  
 
WARNING: WORD-ORIENTED READING, LOW- AND HIGH-BYTE ARE SWAPPED.
 
WARNING: WORD-ORIENTED READING, LOW- AND HIGH-BYTE ARE SWAPPED.
  
'''Read S7 DB'''<br />
 
Reads the content of a S7 data block from the PLC (byte oriented).
 
  
<table>
+
'''Read S7 DB'''
<tbody>
+
<tr class="odd">
+
<td align="left">unsigned long int DLLexport ReadDB_S7</td>
+
<td align="left">(unsigned long int no,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned char int far * block,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int far * size);</td>
+
</tr>
+
</tbody>
+
</table>
+
  
<br />
+
Reads the content of a S7 data block from the PLC (byte oriented).
  
 +
{|
 +
|-
 +
| unsigned long int DLLexport ReadDB_S7 || (unsigned long int no,
 +
|-
 +
|  || unsigned char int far * block,
 +
|-
 +
|  || unsigned long int far * size,
 +
|}
  
<table>
+
 
<tbody>
+
 
<tr class="odd">
+
{| class="wikitable"
<td align="left">parameter</td>
+
|-
<td align="left">description</td>
+
! Parameter !! Description !!  Comment
<td align="left">comment</td>
+
|-
</tr>
+
| no || number of data block || 1..16383
<tr class="even">
+
|-
<td align="left">no</td>
+
| block || pointer to data block content || Pointer to a valid array in the user applications address space
<td align="left">number of data block</td>
+
Warning: Array has to be big enough!
<td align="left">1..16383</td>
+
|-
</tr>
+
| size || number of bytes that are to be read into the block || If the data block is smaller than the size, the size will be reduced automatically.
<tr class="odd">
+
Pointer to a valid variable in the user applications address space.
<td align="left">block</td>
+
|-
<td align="left">pointer to data block content</td>
+
| return || 0 on error || Error messages
<td align="left">Pointer to a valid array in the user applications address space<br />
+
|}
Warning: Array has to be big enough!</td>
+
</tr>
+
<tr class="even">
+
<td align="left">size</td>
+
<td align="left">number of bytes that are to be read into the block</td>
+
<td align="left">if the data block is smaller than the size, the size will be reduced automatically.<br />
+
Pointer to a valid variable in the user applications address space.</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">return</td>
+
<td align="left">0 on error</td>
+
<td align="left">Error messages</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
Length of parameter list (Visual-C): 12 bytes.
 
Length of parameter list (Visual-C): 12 bytes.
  
'''Write S7 DB'''<br />
 
Writes the content of a S7 data block in the PLC (byte-oriented).
 
  
<table>
+
'''Write S7 DB'''
<tbody>
+
<tr class="odd">
+
<td align="left">unsigned long int DLLexport WriteDB_S7</td>
+
<td align="left">(unsigned long int no,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned char int far * block,</td>
+
</tr>
+
<tr class="odd">
+
<td align="left"> </td>
+
<td align="left">unsigned long int far * size);</td>
+
</tr>
+
</tbody>
+
</table>
+
  
<br />
+
Writes the content of a S7 data block in the PLC (byte-oriented).
  
 +
{|
 +
|-
 +
| unsigned long int DLLexport WriteDB_S7 || (unsigned long int no,
 +
|-
 +
|  || unsigned char int far * block,
 +
|-
 +
|  || unsigned long int far * size,
 +
|}
  
<table>
+
 
<tbody>
+
{| class="wikitable"
<tr class="odd">
+
|-
<td align="left">parameter</td>
+
! Parameter !! Description !!  Comment
<td align="left">description</td>
+
|-
<td align="left">comment</td>
+
| no || number of data block || 1..16383
</tr>
+
|-
<tr class="even">
+
| block || pointer to data block content || Pointer to a valid array in the user applications address space
<td align="left">no</td>
+
Warning: Array has to be big enough!
<td align="left">number of data block</td>
+
|-
<td align="left">1..16383</td>
+
| size || number of bytes that are to be written into the block || If the data block is smaller than the size, the size will be reduced automatically.
</tr>
+
Pointer to a valid variable in the user applications address space.
<tr class="odd">
+
|-
<td align="left">block</td>
+
| return || 0 on error || Error messages
<td align="left">pointer to data block content</td>
+
|}
<td align="left">Pointer to a valid array in the user applications address space<br />
+
Warning: Array has to be big enough!</td>
+
</tr>
+
<tr class="even">
+
<td align="left">size</td>
+
<td align="left">number of bytes that are to be written into the block</td>
+
<td align="left">if the data block is smaller than the size, the size will be reduced automatically.<br />
+
Pointer to a valid variable in the user applications address space.</td>
+
</tr>
+
<tr class="odd">
+
<td align="left">return</td>
+
<td align="left">0 on error</td>
+
<td align="left">Error messages</td>
+
</tr>
+
</tbody>
+
</table>
+
  
 
Length of parameter list (Visual-C): 12 bytes.
 
Length of parameter list (Visual-C): 12 bytes.
 +
  
 
=== Functions for data conversion ===
 
=== Functions for data conversion ===
  
'''FloatToMC5'''<br />
 
Converts floating point numbers from IBM-PC-format into S7 double words.
 
  
<table>
+
'''FloatToMC5'''
<tbody>
+
<tr class="odd">
+
<td align="left">void DLLexport FloatToMC5</td>
+
<td align="left">(float FloatValue,</td>
+
</tr>
+
<tr class="even">
+
<td align="left"> </td>
+
<td align="left">unsigned long far * MC5Val);</td>
+
</tr>
+
</tbody>
+
</table>
+
  
<br />
+
Converts floating point numbers from IBM-PC-format into S7 double words.
  
 +
{|
 +
|-
 +
| void DLLexport FloatToMC5 || (float FloatValue,
 +
|-
 +
|  ||  unsigned long far * MC5Val);
 +
|}
  
<table>
 
<tbody>
 
<tr class="odd">
 
<td align="left">parameter</td>
 
<td align="left">description</td>
 
<td align="left">comment</td>
 
</tr>
 
<tr class="even">
 
<td align="left">FloatVal</td>
 
<td align="left">floating point number in IEEE- or INTEL-format</td>
 
<td align="left"> </td>
 
</tr>
 
<tr class="odd">
 
<td align="left">MC5Val</td>
 
<td align="left">floating point number in Siemens-S7-format</td>
 
<td align="left"> </td>
 
</tr>
 
</tbody>
 
</table>
 
  
'''MC5ToFloat'''<br />
+
{| class="wikitable"
  Converts S7 double words into floating point numbers in IBM-PC-format.
+
|-
 +
! Parameter !! Description !! Comment
 +
|-
 +
| FloatVal || floating point number in IEEE- or INTEL-format ||
 +
|-
 +
| MC5Val || floating point number in Siemens-S7-format ||
 +
|}
  
<table>
 
<tbody>
 
<tr class="odd">
 
<td align="left">void DLLexport MC5ToFloat</td>
 
<td align="left">(unsigned long far * MC5Val</td>
 
</tr>
 
<tr class="even">
 
<td align="left"> </td>
 
<td align="left">float FloatVal);</td>
 
</tr>
 
</tbody>
 
</table>
 
  
<br />
+
'''MC5ToFloat'''
  
 +
Converts S7 double words into floating point numbers in IBM-PC-format.
 +
 +
{|
 +
|-
 +
| void DLLexport MC5ToFloat  || (unsigned long far * MC5Val
 +
|-
 +
|  || float FloatVal);
 +
|}
 +
 +
 +
{| class="wikitable"
 +
|-
 +
! Parameter !! Description !!  Comment
 +
|-
 +
| MC5Val || floating point number in Siemens-S7-format ||
 +
|-
 +
| FloatVal || floating point number in IEEE- or INTEL-format ||
 +
|}
  
<table>
 
<tbody>
 
<tr class="odd">
 
<td align="left">parameter</td>
 
<td align="left">description</td>
 
<td align="left">comment</td>
 
</tr>
 
<tr class="even">
 
<td align="left">MC5Val</td>
 
<td align="left">floating point number in Siemens-S7-format</td>
 
<td align="left"> </td>
 
</tr>
 
<tr class="odd">
 
<td align="left">FloatVal</td>
 
<td align="left">floating point number in IEEE- or INTEL-format</td>
 
<td align="left"> </td>
 
</tr>
 
</tbody>
 
</table>
 
  
 
=== Accessing with a web server ===
 
=== Accessing with a web server ===
  
 
If you are intending to access ''S7-SoftPLC'' with web applications(IIS), which should have access to the process data, please contact our support for examples. The ''S7-SoftPLC'' installs an object, which allows data access from script languages (VB Sript, J Script).
 
If you are intending to access ''S7-SoftPLC'' with web applications(IIS), which should have access to the process data, please contact our support for examples. The ''S7-SoftPLC'' installs an object, which allows data access from script languages (VB Sript, J Script).

Latest revision as of 12:32, 19 December 2012

Data interface to S7-SoftPLC

S7-SoftPLC can be accessed directly by various high level languages (e.g. Visual Basic®, Visual C/C++® or Borland C++Builder®). The DLL required for this (PLC32.DLL) is installed with S7-SoftPLC. The PLC32.DLL is a 32 Bit application.

Below the available functions for a data exchange are described.

Data transmitting functions

Read a single value

Reads a value from S7-SoftPLC.

unsigned long int DLLexport ReadVal (unsigned long int type,
unsigned long int no,
unsigned long int DBNo,
unsigned long int size,
unsigned long int far * val);,


Parameter Description Comment
type 'I' = input
'Q' = output
'M' = flag
'C' = counter value
'T' = timer value
'D' = data word or double data word
'B' = data bit, word, double word on
byte address
'P' = P_Parameter



16-bit-access only
16-bit-access only
depending on size
depending on size
compatible to S7 only
S7 from version 3 only
no adress Byte address of read in operand
DBNo Number of data block 1 – 16383
size Number of bits
0..7= bit no 0 7
8 = 1 byte
16 = 1 word
32 = 1 double word


'I','Q','M' only
val Read value Pointer to a valid variable in the user applications address space
return 0 on Error Error messages

Length of parameter list (Visual-C): 20 bytes.


Write a single value

Writes a value in S7-SoftPLC.

unsigned long int DLLexport WriteVal (unsigned long int type,
unsigned long int no,
unsigned long int DBNo,
unsigned long int size,
unsigned long int far * val);,


Parameter Description comment
type 'I' = input
'Q' = output
'M' = flag
'C' = counter value
'T' = timer value
'D' = data word or double data word
'B' = data bit, byte, wort, doppelwort on
byte address
'P' = P_Parameter



16-bit-access only
16-bit-access only
depending on size
depending on size
compatible to S7 only
S7 from version 3 only!
no adress Byte address of operand to be written
DBNo number of data block 1 – 16383
size number of bits
0..7= bit no 0 7
8 = 1 byte
16 = 1 word
32 = 1 double word


'I','Q','M' only
val value to be written
return 0 on error Error messages

Length of parameter list (Visual-C): 20 bytes.


Read multiple values

Reads multiple values from S7-SoftPLC.

unsigned long int DLLexport ReadVals (unsigned long int type,
unsigned long int no,
unsigned long int DBNo,
unsigned long int size,
unsigned long int far * vals);,


Parameter Description Comment
type 'I' = input
'Q' = output
'M' = flag
'D' = data word
'B' = data byte on byte address



S5 compatible
compatible to S7 only
no adress
DBNo number of data block 1 – 16383
size number of data bytes or data words destination size in bytes for type 'I', 'Q', 'M' and 'B', destination size in data words for 'D'
vals Value of byte Pointer to a valid array in the user applications address space

Warning: Array has to be big enough!

return 0 on error Error messages

Length of parameter list (Visual-C): 20 bytes.


WARNING: FOR DATA BLOCKS (TYPE 'D') THE ARRAY HAS TO BE TWICE AS BIG, SINCE 2 BYTES ARE NECESSARY FOR EVERY DATA WORD!


Write multiple values

Writes multiple values to S7-SoftPLC.

unsigned long int DLLexport WriteVals (unsigned long int type,
unsigned long int no,
unsigned long int DBNo,
unsigned long int size,
unsigned long int far * vals);,


Parameter Description Comment
type 'I' = input
'Q' = output
'M' = flag
'D' = data word
'B' = data byte on byte address



S5 compatible
compatible to S7 only
no adress
DBNo number of data block 1 – 16383
size number of data bytes or data words
'I'
'Q'
'M'
'B'
'D'

Destination size in bytes
Destination size in bytes
Destination size in bytes
Destination size in bytes
Destination size in data words
vals value of byte Pointer to a valid array in the user applications address space

Warning: Array has to be big enough!

return 0 on error Error messages

Length of parameter list (Visual-C): 20 bytes.


WARNING: FOR DATA BLOCKS (TYPE = D) THE ARRAY HAS TO BE TWICE AS BIG, SINCE 2 BYTES ARE NECESSARY FOR EVERY DATA WORD!


Read DB

Reads the content of a data block from S7-SoftPLC.

unsigned long int DLLexport ReadDB (unsigned long int no,
unsigned short int far * block,
unsigned long int far * size,
unsigned long int synchronous);


Parameter Description Comment
no number of data block 1..16383
block pointer to data block content Pointer to a valid array in the user applications address space.

Warning: Array has to be big enough!

size number of words that are to be read from the data block If the data block is smaller than the size, the size will be reduced automatically.

Pointer to a valid variable in the user applications address space.

synchronous always 0 irrelevant for S7
return 0 on error Error messages

Length of parameter list (Visual-C): 16 bytes.


WARNING: WORD-ORIENTED READING, LOW- AND HIGH-BYTE ARE SWAPPED.


Write DB

Writes a data block to S7-SoftPLC.

unsigned long int DLLexport WriteDB (unsigned long int no,
unsigned short int far * block,
unsigned long int far * size,
unsigned long int synchronous);


Parameter Description Comment
no number of data block 1..16383
block pointer to data block content Pointer to a valid array in the user applications address space

Warning: Array has to be big enough!

size number of words that are to be written into the block If the data block is smaller than the size, the size will be reduced automatically.

Pointer to a valid variable in the user applications address space.

synchronous always 0 irrelevant for S7
return 0 on error Error messages

Length of parameter list (Visual-C): 16 bytes.


WARNING: WORD-ORIENTED READING, LOW- AND HIGH-BYTE ARE SWAPPED.


Read S7 DB

Reads the content of a S7 data block from the PLC (byte oriented).

unsigned long int DLLexport ReadDB_S7 (unsigned long int no,
unsigned char int far * block,
unsigned long int far * size,


Parameter Description Comment
no number of data block 1..16383
block pointer to data block content Pointer to a valid array in the user applications address space

Warning: Array has to be big enough!

size number of bytes that are to be read into the block If the data block is smaller than the size, the size will be reduced automatically.

Pointer to a valid variable in the user applications address space.

return 0 on error Error messages

Length of parameter list (Visual-C): 12 bytes.


Write S7 DB

Writes the content of a S7 data block in the PLC (byte-oriented).

unsigned long int DLLexport WriteDB_S7 (unsigned long int no,
unsigned char int far * block,
unsigned long int far * size,


Parameter Description Comment
no number of data block 1..16383
block pointer to data block content Pointer to a valid array in the user applications address space

Warning: Array has to be big enough!

size number of bytes that are to be written into the block If the data block is smaller than the size, the size will be reduced automatically.

Pointer to a valid variable in the user applications address space.

return 0 on error Error messages

Length of parameter list (Visual-C): 12 bytes.


Functions for data conversion

FloatToMC5

Converts floating point numbers from IBM-PC-format into S7 double words.

void DLLexport FloatToMC5 (float FloatValue,
unsigned long far * MC5Val);


Parameter Description Comment
FloatVal floating point number in IEEE- or INTEL-format
MC5Val floating point number in Siemens-S7-format


MC5ToFloat

Converts S7 double words into floating point numbers in IBM-PC-format.

void DLLexport MC5ToFloat (unsigned long far * MC5Val
float FloatVal);


Parameter Description Comment
MC5Val floating point number in Siemens-S7-format
FloatVal floating point number in IEEE- or INTEL-format


Accessing with a web server

If you are intending to access S7-SoftPLC with web applications(IIS), which should have access to the process data, please contact our support for examples. The S7-SoftPLC installs an object, which allows data access from script languages (VB Sript, J Script).