Difference between revisions of "S7-SoftPLC:Data Interface"
Line 13: | Line 13: | ||
{| | {| | ||
|- | |- | ||
− | | unsigned long int DLLexport ReadVal || (unsigned long int | + | | unsigned long int DLLexport ReadVal || (unsigned long int type, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int no, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int DBNo, |
|- | |- | ||
| || unsigned long int size, | | || unsigned long int size, | ||
Line 51: | Line 51: | ||
{| | {| | ||
|- | |- | ||
− | | unsigned long int DLLexport WriteVal || (unsigned long int | + | | unsigned long int DLLexport WriteVal || (unsigned long int type, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int no, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int DBNo, |
|- | |- | ||
| || unsigned long int size, | | || unsigned long int size, | ||
Line 73: | Line 73: | ||
{| | {| | ||
|- | |- | ||
− | | unsigned long int DLLexport ReadVals || (unsigned long int | + | | unsigned long int DLLexport ReadVals || (unsigned long int type, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int no, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int DBNo, |
|- | |- | ||
| || unsigned long int size, | | || unsigned long int size, | ||
Line 98: | Line 98: | ||
{| | {| | ||
|- | |- | ||
− | | unsigned long int DLLexport WriteVals || (unsigned long int | + | | unsigned long int DLLexport WriteVals || (unsigned long int type, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int no, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int DBNo, |
|- | |- | ||
| || unsigned long int size, | | || unsigned long int size, | ||
Line 123: | Line 123: | ||
{| | {| | ||
|- | |- | ||
− | | unsigned long int DLLexport ReadDB || (unsigned long int | + | | unsigned long int DLLexport ReadDB || (unsigned long int no, |
|- | |- | ||
− | | || unsigned short int far * | + | | || unsigned short int far * block, |
|- | |- | ||
− | | || unsigned long int far * | + | | || unsigned long int far * size, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int synchronous); |
|} | |} | ||
Line 146: | Line 146: | ||
{| | {| | ||
|- | |- | ||
− | | unsigned long int DLLexport WriteDB || (unsigned long int | + | | unsigned long int DLLexport WriteDB || (unsigned long int no, |
|- | |- | ||
− | | || unsigned short int far * | + | | || unsigned short int far * block, |
|- | |- | ||
− | | || unsigned long int far * | + | | || unsigned long int far * size, |
|- | |- | ||
− | | || unsigned long int | + | | || unsigned long int synchronous); |
|} | |} | ||
Line 170: | Line 170: | ||
{| | {| | ||
|- | |- | ||
− | | unsigned long int DLLexport ReadDB_S7 || (unsigned long int | + | | unsigned long int DLLexport ReadDB_S7 || (unsigned long int no, |
|- | |- | ||
− | | || unsigned char int far * | + | | || unsigned char int far * block, |
|- | |- | ||
− | | || unsigned long int far * | + | | || unsigned long int far * size, |
|} | |} | ||
Line 189: | Line 189: | ||
{| | {| | ||
|- | |- | ||
− | | unsigned long int DLLexport WriteDB_S7 || (unsigned long int | + | | unsigned long int DLLexport WriteDB_S7 || (unsigned long int no, |
|- | |- | ||
− | | || unsigned char int far * | + | | || unsigned char int far * block, |
|- | |- | ||
− | | || unsigned long int far * | + | | || unsigned long int far * size, |
|} | |} | ||
Revision as of 11:44, 19 December 2012
Contents
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 |
Rückgabe | 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);, |
TABLE
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);, |
TABLE
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);, |
TABLE
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); |
TABLE
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); |
TABLE
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, |
TABLE
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, |
TABLE
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); |
TABLE
MC5ToFloat
Converts S7 double words into floating point numbers in IBM-PC-format.
void DLLexport MC5ToFloat | (unsigned long far * MC5Val |
float FloatVal); |
TABLE
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).