Difference between revisions of "IBHNet:Accessing PLC variables"
(6 intermediate revisions by 2 users not shown) | |||
Line 26: | Line 26: | ||
|- | |- | ||
| | | | ||
− | Set up PLC connection<br />'''HRESULT Connect([in, string] BSTR Station,[in] long MPIAdr)'''<br />Station: Station Name<br />MPIAdr: MPI Addrerss<br />Return Value: Successful operation returns S_OK, E_FAIL or the sequence number if failed.<br />The function Connect_DP of the interface IIIBHNet3 should be | + | Set up PLC connection<br />'''HRESULT Connect([in, string] BSTR Station,[in] long MPIAdr)'''<br />Station: Station Name<br />MPIAdr: MPI Addrerss<br />Return Value: Successful operation returns S_OK, E_FAIL or the sequence number if failed.<br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 90: | Line 90: | ||
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
− | |align="center"| | + | |align="center"| - |
|- | |- | ||
|Reads the revision of the SoftPLC.<br />'''HRESULT PLC_Version([out, retval] long *pVal)'''<br />pVal: reports the revision.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. | |Reads the revision of the SoftPLC.<br />'''HRESULT PLC_Version([out, retval] long *pVal)'''<br />pVal: reports the revision.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. | ||
Line 218: | Line 218: | ||
| | | | ||
|- | |- | ||
− | ! ''' | + | ! '''Properties for PLC variable access''' |
+ | Each of the functions listed below initiates a full read respectively write sequence with the PLC. It should be mentioned that reading or writing entire arrays of variables take only a negligible amount of time longer than reading/writing single variables. For this reason, it should be considered to collect all data in a single area of the PLC. This way complete array can be read/written, which may dramatically increase performance. | ||
− | |||
!align="center"| S5 | !align="center"| S5 | ||
!align="center"| S7 <br/> 300/400 | !align="center"| S7 <br/> 300/400 | ||
− | !align="center"| SoftSPS <br/> | + | !align="center"| SoftSPS <br/> and <br/> S7-CX |
!align="center"| S7 <br/> 200 | !align="center"| S7 <br/> 200 | ||
|- | |- | ||
− | | | + | |Reads a flag doubleword<br />'''HRESULT MD(long nr, [out, retval] long *pVal)'''<br />nr: Number of the flag doubleword<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a flag doubleword<br />'''HRESULT MD(long nr, [in] long newVal)'''<br />nr: Number of the flag doubleword<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 232: | Line 232: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a flag word<br />'''HRESULT MW(long nr, [out, retval] long *pVal)'''<br />nr: Number of the flag word<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a flag word<br />'''HRESULT MW(long nr, [in] long newVal)'''<br />nr: Number of the flag word<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 238: | Line 238: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a flag byte<br />'''HRESULT MB(long nr, [out, retval] long *pVal)'''<br />nr: Number of the flag byte <br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a flag byte<br />'''HRESULT MB(long nr, [in] long newVal)'''<br />nr: Number of the flag byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 244: | Line 244: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a flag<br />'''HRESULT M(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Number of the flag byte<br />bit: Bit number in the flag byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. <br /><br />Writes a flag<br />'''HRESULT M(long nr,long bit, [in] BOOL newVal)'''<br />nr: Number of the flag byte<br />bit: Bit number in the flag byte<br />newVal: Value to write <br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 250: | Line 250: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a input doubleword<br />'''HRESULT ED(long nr, [out, retval] long *pVal)'''<br />nr: Number of the input doubleword<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a input doubleword<br />'''HRESULT ED(long nr, [in] long newVal)'''<br />nr: Number of the input doubleword<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 256: | Line 256: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a input word<br />'''HRESULT EW(long nr, [out, retval] long *pVal)'''<br />nr: Number of the input word<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a input word<br />'''HRESULT EW(long nr, [in] long newVal)'''<br />nr: Number of the input word<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 262: | Line 262: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a input byte<br />'''EB(long nr, [out, retval] long *pVal)'''<br />nr: Number of the input byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a input byte<br />'''EB(long nr, [in] long newVal)'''<br />nr: Number of the input byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 268: | Line 268: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads an input<br />'''E(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Number of the input byte<br />bit: Bit number in the input byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes an input<br />'''E(long nr,long bit, [in] BOOL newVal)'''<br />nr: Number of the input byte<br />bit: Bit number in the input byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 274: | Line 274: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a output doubleword<br />'''HRESULT AD(long nr, [out, retval] long *pVal)'''<br />nr: Number of the output doubleword<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a output doubleword<br />'''HRESULT AD(long nr, [in] long newVal)'''<br />nr: Number of the output doubleword<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 280: | Line 280: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | | |
+ | Reads a output word<br />'''HRESULT AW(long nr, [out, retval] long *pVal)'''<br />nr: Number of the output word<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a output word<br />'''HRESULT AW(long nr, [in] long newVal''')<br />nr: Number of the output word<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. | ||
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 286: | Line 287: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a output byte<br />'''HRESULT AB(long nr, [out, retval] long *pVal)'''<br />nr: Number of the output byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes a output byte<br />'''HRESULT AB(long nr, [in] long newVal)'''<br />nr: Number of the output byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 292: | Line 293: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads an output<br />'''HRESULT A(long nr,long bit, [out, retval] BOOL *pVal)'''<br />nr: Number of the output byte<br />bit: Bit number in the output byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small.<br /><br />Writes an output<br />'''HRESULT A(long nr,long bit, [in] BOOL newVal)'''<br />nr: Number of the output byte<br />bit: Bit number in the output byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 298: | Line 299: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a data doubleword<br />'''HRESULT DD(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />Writes a data doubleword<br />'''HRESULT DD(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 304: | Line 305: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a data word<br />'''HRESULT DW(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />Writes a data word<br />'''HRESULT DW(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 310: | Line 311: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a data byte<br />'''HRESULT DB(long DBNr,long nr, [out, retval] long *pVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />Writes a data byte<br />'''HRESULT DB(long DBNr,long nr, [in] long newVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 316: | Line 317: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads a data bit<br />'''HRESULT D(long DBNr,long nr,long bit, [out, retval] BOOL *pVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />bit: Bit number within the data byte<br />pVal: Read value<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />Writes a data bit<br />'''HRESULT D(long DBNr,long nr,long bit, [in] BOOL newVal)'''<br />DBNr: Number of the data block<br />nr: Byte offset within the data block<br />bit: Bit number within the data byte<br />newVal: Value to write<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 328: | Line 329: | ||
| | | | ||
|- | |- | ||
− | !''' | + | !'''System Functions of the Interface IIIBHnet2''' |
!align="center"| S5 | !align="center"| S5 | ||
!align="center"| S7 <br/> 300/400 | !align="center"| S7 <br/> 300/400 | ||
− | !align="center"| SoftSPS <br/> | + | !align="center"| SoftSPS <br/> and <br/> S7-CX |
!align="center"| S7 <br/> 200 | !align="center"| S7 <br/> 200 | ||
|- | |- | ||
− | | | + | |Reboot of the IBH Link.<br />'''HRESULT ResetDevice(BSTR device)'''<br />device: Station name.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected module does not support the function. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 340: | Line 341: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads the key switch position of the PLC.<br />'''HRESULT Key_Position([out, retval] long *pVal)'''<br />pVal: returns the key switch position.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 346: | Line 347: | ||
|align="center"| - | |align="center"| - | ||
|- | |- | ||
− | | | + | |Reads the available nodes on the bus.<br />'''HRESULT LifeList(BSTR device, VARIANT * lifelist)'''<br />lifelist: contains a list with the nodes.<br />0x30 = Active, 0x20 = Active Ready, 0x10 = Not existing, 0x00 = Passive<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 352: | Line 353: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Reads the System Status Lists (SSL) from the PLC.<br />'''HRESULT SZ_List(long SZL_ID, long INDEX, VARIANT * SZ_List)'''<br />For more information please consult the Siemens dokumentation for the SFC51. Installation folder: C:\Program Files\Siemens\Dokumentation\English\STEP 7 - System and Standard Functions for S7-300 and S7-400 Chapter: System Status Lists (SSL).<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 358: | Line 359: | ||
|align="center"| - | |align="center"| - | ||
|- | |- | ||
− | | | + | |Terminates the driver IBH_NetPcom.exe.<br />'''HRESULT TerminateDriver()'''<br />Return Value: Always S_OK.<br /><br />For the Protocols RFC1006, API or 1200 irrelevant. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 370: | Line 371: | ||
| | | | ||
|- | |- | ||
− | !''' | + | !'''Advanced functions and .NET of the Interface IIIBHnet3''' |
!align="center"| S5 | !align="center"| S5 | ||
!align="center"| S7 <br/> 300/400 | !align="center"| S7 <br/> 300/400 | ||
− | !align="center"| SoftSPS <br/> | + | !align="center"| SoftSPS <br/> and <br/> S7-CX |
!align="center"| S7 <br/> 200 | !align="center"| S7 <br/> 200 | ||
|- | |- | ||
− | | | + | |Set up PLC connection.<br />'''HRESULT Connect_DP(BSTR Station, long DPAdr, long Rack, long Slot)'''<br />Station: Station name<br />DPAdr: MPI<sup>®</sup> or Profibus address<br />Rack: Rack number (normally 0)<br />Slot: Slot number. For MPI normally 0, for Profibus the slot number of the CPU inside the rack.<br />Return Value: Successful operation returns S_OK, E_FAIL if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed.<br />If the protocol RFC1006 is chosen in the IBHNet station, the parameter DPAdr is irrelevant. For connections to a Siemens CP, only the parameters Rack and Slot are regarded. With an IBH Link S7++, the MPI/Profibusaddress is a combination from the lower 5 Bit of the parameter Slot and the lower 3 Bit of the parameter Rack. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 382: | Line 383: | ||
|align="center"| - | |align="center"| - | ||
|- | |- | ||
− | | | + | |Set up a routed PLC connection to a PLC in a MPI/Profibus subnet, if the CPU supports it.<br />'''HRESULT Subnet_Connect_DP(BSTR Station, long MPIStart, long MPIZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Station name<br />MPIStart: MPI<sup>®</sup> or Profibus address, the IBH Link is connected to.<br />MPIZiel: Destination MPI<sup>®</sup> or Profibus address inside the subnet.<br />RackZiel: Destination rack number in the subnet (normally 0).<br />SlotZiel: Destination slot number in the subnet (normally 2).<br />Subnet_HH: Subnet ID HighWord, from Project.<br />Subnet_LL: Subnet ID LowWord, from Project.<br />Return Value: Successful operation returns S_OK, E_FAIL if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 388: | Line 389: | ||
|align="center"| - | |align="center"| - | ||
|- | |- | ||
− | | | + | |Set up a routed PLC connection to a PLC in a TCP/IP subnet, if the CPU supports it.<br />'''HRESULT Subnet_Connect_IP(BSTR Station, long MPIStart, BSTR IPZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Station name<br />MPIStart: MPI<sup>®</sup> or Profibus address, the IBH Link is connected to.<br />IPZiel: Destination TCP/IP address inside the subnet.<br />RackZiel: Destination rack number in the subnet (normally 0).<br />SlotZiel: Destination slot number in the subnet (normally 2).<br />Subnet_HH: Subnet ID HighWord, from Project.<br />Subnet_LL: Subnet ID LowWord, from Project.<br />Return Value: Successful operation returns S_OK, E_FAIL if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 394: | Line 395: | ||
|align="center"| - | |align="center"| - | ||
|- | |- | ||
− | | | + | |Set up a routed PLC connection to a PLC in a H1 subnet, if the CPU supports it.<br />'''HRESULT SubnetConnectH1(BSTR Station, long MPIStart, BSTR H1Ziel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL)'''<br />Station: Station name<br />MPIStart: MPI<sup>®</sup> or Profibus address, the IBH Link is connected to.<br />H1Ziel: Destination H1 address inside the subnet.<br />RackZiel: Destination rack number in the subnet (normally 0).<br />SlotZiel: Destination slot number in the subnet (normally 2).<br />Subnet_HH: Subnet ID HighWord, from Project.<br />Subnet_LL: Subnet ID LowWord, from Project.<br />Return Value: Successful operation returns S_OK, E_FAIL if failed.<br /><br />The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed. |
|align="center"| - | |align="center"| - | ||
|align="center"| X | |align="center"| X | ||
Line 400: | Line 401: | ||
|align="center"| - | |align="center"| - | ||
|- | |- | ||
− | | | + | |Reads the raw contents of a datablock from the PLC.<br />'''HRESULT ReadDB(long DBNr, VARIANT*DB, long * Len)'''<br />DBNr: Data block number<br />DB: VARIANT variable, that contains a SAFEARRAY of type Byte containing the block.<br />Len: Block length<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_INVALIDARG if the datablock does not exist.<br /><br />To use this function, detailled internal knowledge of S7 blocks is required. For legal reasons this information can not be published by IBHsoftec. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 406: | Line 407: | ||
|align="center"| - | |align="center"| - | ||
|- | |- | ||
− | | | + | |Writes the raw contents of a datablock to a PLC.<br />'''HRESULT WriteDB(long DBNr, VARIANT DB, long Len)'''<br />DBNr: Data block number<br />DB: VARIANT variable, that contains a SAFEARRAY of type Byte containing the block.<br />Len: Block length<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_INVALIDARG if the datablock does not exist. <br />To use this function, detailled internal knowledge of S7 blocks is required. For legal reasons this information can not be published by IBHsoftec. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 412: | Line 413: | ||
|align="center"| - | |align="center"| - | ||
|- | |- | ||
− | | | + | |Reads an array of values from the PLC<br />'''HRESULT DotNetReadVals(long typ, long nr, long DBNr, long size, VARIANT * vals)'''<br />typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d<br />nr: Start offset for Input/Output/Flags, for D the start offset within the DB<br />DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0<br />size: Number of Bytes to read<br />vals: VARIANT variable, that contains a SAFEARRAY of type Byte containing the values read from the PLC.<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 418: | Line 419: | ||
|align="center"| X | |align="center"| X | ||
|- | |- | ||
− | | | + | |Writes an array of values to the PLC<br />'''HRESULT DotNetWriteVals(long typ, long nr, long DBNr, long size, VARIANT vals)'''<br />typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d<br />nr: Start offset for Input/Output/Flags, for D the start offset within the DB<br />DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0<br />size: Number of Bytes to read<br />vals: VARIANT variable, that contains a SAFEARRAY of type Byte with the values to write to the PLC<br />Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small.<br /><br />DotNetWriteVals passes the data in a VARIANT variable, that contains a SAFEARRAY of type Byte. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC. |
|align="center"| X | |align="center"| X | ||
|align="center"| X | |align="center"| X | ||
Line 427: | Line 428: | ||
− | + | ||
+ | In the installation folder of the '''''IBHNet''''' driver, samples for Visual Basic 6 can be found. The samples are commented. Samples for other programming languages will follow. Contact our product support to ask for more samples. | ||
− | |||
− | |||
+ | {|class="wikitable" | ||
+ | |class="hintergrundfarbe5"|'''Attention: If multiple threads need to access the same IBHNet object, the access functions to the IBHNet object need to be locked from each other. Suitable mechanisms are for instance Critical Sections, Semaphores or Mutexes. A simple locking with variables is not suitable to securely avoid race conditions.''' | ||
+ | |- | ||
+ | |} | ||
− | + | Following error codes will be returned: | |
− | + | {| class="wikitable" | |
− | + | |- | |
− | + | !Errorcode | |
− | + | !Description | |
− | + | |- | |
− | + | |1 | |
− | + | |netpcomv.CreateInstance failed | |
− | + | |- | |
− | + | |2 | |
− | + | |netpcomv.MPI_open failed | |
− | + | |- | |
− | + | |3 | |
− | + | |netpcomv.MPI_ConnRequest failed | |
+ | |- | ||
+ | |4 | ||
+ | |connection request to SoftPlc failed | ||
+ | |- | ||
+ | |5 | ||
+ | |netpcomv.MPI_close failed | ||
+ | |- | ||
+ | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
If accessing a variable fails, still an exception will be raised. | If accessing a variable fails, still an exception will be raised. | ||
Line 486: | Line 469: | ||
It is also possible to access the LOGO! RCE versions via RFC1006. In this case the MPI address 128 has to be used in the function Connect(), for Connect_DP() the slot 128 has to be used. MPI address and rack need to be 0. The possible variables are inputs, outputs, flags, the DB1 and the order number. | It is also possible to access the LOGO! RCE versions via RFC1006. In this case the MPI address 128 has to be used in the function Connect(), for Connect_DP() the slot 128 has to be used. MPI address and rack need to be 0. The possible variables are inputs, outputs, flags, the DB1 and the order number. | ||
− | + | Additional security settings are necessary with S7-1500 to permit access from IBHNet. To do so, navigate to the PLC properties 'Protection' section. There the Option: 'Connection mechanisms - Permit Access over PUT/GET communication from remote partner' must be checked. |
Latest revision as of 11:45, 9 April 2013
Accessing PLC variables
The IBHNet network driver ships with an object, which allows access to variables of the PLC. This COM-Server can be used in any programming language, such as VisualBasic, Delphi a.s.o..
Its interface name is IIIBHnet. In VisualBasic for instance, it is presented as IBHNet 1.0 Type Library from the menu "Project – References". The RFC1006 protocol should be always used to read and write variables, if possible. Only obsolete devices may require other protocols. To access variables from the PLC the methods and properties listed below are available:
Functions of the Interface IIIBHnet | S5 | S7 300/400 |
SoftSPS and S7-CX |
S7 200 |
---|---|---|---|---|
Search first configured station HRESULT FirstStation(BSTR* pVal) pVal: First Station found Return Value: Successful operation returns S_OK, if no station exists, S_FALSE is returned. |
X | X | X | X |
Search further configured stations HRESULT NextStation(BSTR* pVal) pVal: Station name Return Value: Successful operation returns S_OK If no further station exists, S_FALSE is returned. |
X | X | X | X |
Set up PLC connection |
X | X | X | X |
PLC Disconnect HRESULT Disconnect() Parameters: None Return Value: Always S_OK. |
X | X | X | X |
Reads a single value from the PLC HRESULT ReadVal(long typ, long nr, long DBNr, long size, long *val) typ : 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d nr: Start offset for Input/Output/Flags, for D the start offset within the DB DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0 size: 0..7 = The bit number within the byte read, 8 = Byte, 16 = Word, 32 = Doubleword val: The value read from the PLC Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
X | X | X | X |
Reads an array of values from the PLC HRESULT ReadVals(long typ, long nr, long DBNr, long size, SAFEARRAY(unsigned char) vals) typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d nr: Start offset for Input/Output/Flags, for D the start offset within the DB DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0 size: Number of Bytes to read vals: The array with the values read from the PLC Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. ReadVals returns the data in a SAFEARRAY from type Byte. DotNetReadVals returns the data in a VARIANT variable, that contains a SAFEARRAY of type Byte. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC. |
X | X | X | X |
Writes a single value from the PLC HRESULT WriteVal(long typ, long nr, long DBNr, long size, long val) typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d nr: Start offset for Input/Output/Flags, for D the start offset within the DB DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0 size: 0..7 = The bit number within the byte read, 8 = Byte, 16 = Word, 32 = Doubleword val: The value to be written to the PLC Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
X | X | X | X |
Writes an array of values to the PLC HRESULT WriteVals(long typ, long nr, long DBNr, long size,SAFEARRAY(unsigned char) vals) typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d nr: Start offset for Input/Output/Flags, for D the start offset within the DB DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0 size: Number of Bytes to read vals: The array with the values to write to the PLC Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. WriteVals passes the data in a SAFEARRAY from type Byte. DotNetWriteVals passes the data in a VARIANT variable, that contains a SAFEARRAY of type Byte. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC. |
X | X | X | X |
Writes the .bin file of the SoftPLC, containing the PLC Program. HRESULT PLC_Store() Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the .bin file of the SoftPLC, containing the PLC Program. HRESULT PLC_Restore() Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Properties of the interface IIIBHnet | S5 | S7 300/400 |
SoftSPS and S7-CX |
S7 200 |
Reads the operational state of the PLC. HRESULT PLC_Run([out, retval] BOOL *pVal) pVal: TRUE = Run, FALSE = Stop Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
X | X | X | - |
Reads the revision of the SoftPLC. HRESULT PLC_Version([out, retval] long *pVal) pVal: reports the revision. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the number of cyles of the SoftPLC. HRESULT PLC_Cycles([out, retval] long *pVal) pVal: reports the current count. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Switches the PLC to Stop mode. HRESULT PLC_Stop([in] BOOL newVal) The parameter newVal is reserved and must be always FALSE. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
X | X | X | - |
Warm Restart of the PLC. HRESULT PLC_Run_OB100([in] BOOL newVal) The parameter newVal is reserved and must be always TRUE. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
X | X | X | - |
Hot Restart of the PLC. HRESULT PLC_Run_OB101([in] BOOL newVal) The parameter newVal is reserved and must be always TRUE. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
X | X | X | - |
Terminates the SoftPLC. HRESULT PLC_Terminate([in] BOOL newVal) The parameter newVal is reserved and must be always FALSE. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the serial number of the SoftPLC. HRESULT PLC_SerialNr([out, retval] BSTR *pVal) pVal: returns the serial number. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the user name of the SoftPLC. HRESULT PLC_Name([out, retval] BSTR *pVal) pVal: returns the user name. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the company name of the SoftPLC. HRESULT PLC_Firma([out, retval] BSTR *pVal) pVal returns the company name. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the order number of the PLC. HRESULT PLC_Mlfb([out, retval] BSTR *pVal) pVal: returns the company name. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
X | X | X | - |
Reads the current scan cycle time of the SoftPLC. HRESULT PLC_CycleAct([out, retval] long *pVal) pVal returns the cycle time. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the minimum scan cycle time of the SoftPLC. HRESULT PLC_CycleMin([out, retval] long *pVal) pVal: returns the minimum cycle time. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the maximum scan cycle time of the SoftPLC. HRESULT PLC_CycleMax([out, retval] long *pVal) pVal returns the maximum cycle time. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the maximum jitter of the SoftPLC. HRESULT PLC_JitterMax([out, retval] long *pVal) pVal: returns the maximum jitter. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the current jitter of the SoftPLC. HRESULT PLC_JitterAct([out, retval] long *pVal)) pVal: returns the current jitter. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Starts the SoftPLC. HRESULT PLC_Load([in] long newVal) newVal: 0 = As Process, 1 = As Service, 2 = As AutoStart Service, 3 = As DemandStart Service. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Path to the configuration file PLC43.ini of the SoftPLC. HRESULT PLC_InitPath([out, retval] BSTR *pVal) pVal: returns the path. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the SoftPLCs memory size. HRESULT PLC_MemTotal([out, retval] long *pVal) pVal: returns the memory size. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Reads the SoftPLCs free memory size. HRESULT PLC_MemFree([out, retval] long *pVal) pVal: returns the free memory size. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | - | X | - |
Get configured station by index. HRESULT Station(long Nr, [out, retval] BSTR* pVal) Nr: Station index pVal: If the station is not found, an empty name name is returned. Return Value: Successful operation returns S_OK, if the station does not exist, S_FALSE is returned. |
- | X | X | - |
Properties for PLC variable access
Each of the functions listed below initiates a full read respectively write sequence with the PLC. It should be mentioned that reading or writing entire arrays of variables take only a negligible amount of time longer than reading/writing single variables. For this reason, it should be considered to collect all data in a single area of the PLC. This way complete array can be read/written, which may dramatically increase performance. |
S5 | S7 300/400 |
SoftSPS and S7-CX |
S7 200 |
Reads a flag doubleword HRESULT MD(long nr, [out, retval] long *pVal) nr: Number of the flag doubleword pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a flag doubleword HRESULT MD(long nr, [in] long newVal) nr: Number of the flag doubleword newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a flag word HRESULT MW(long nr, [out, retval] long *pVal) nr: Number of the flag word pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a flag word HRESULT MW(long nr, [in] long newVal) nr: Number of the flag word newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a flag byte HRESULT MB(long nr, [out, retval] long *pVal) nr: Number of the flag byte pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a flag byte HRESULT MB(long nr, [in] long newVal) nr: Number of the flag byte newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a flag HRESULT M(long nr,long bit, [out, retval] BOOL *pVal) nr: Number of the flag byte bit: Bit number in the flag byte pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a flag HRESULT M(long nr,long bit, [in] BOOL newVal) nr: Number of the flag byte bit: Bit number in the flag byte newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a input doubleword HRESULT ED(long nr, [out, retval] long *pVal) nr: Number of the input doubleword pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a input doubleword HRESULT ED(long nr, [in] long newVal) nr: Number of the input doubleword newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a input word HRESULT EW(long nr, [out, retval] long *pVal) nr: Number of the input word pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a input word HRESULT EW(long nr, [in] long newVal) nr: Number of the input word newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a input byte EB(long nr, [out, retval] long *pVal) nr: Number of the input byte pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a input byte EB(long nr, [in] long newVal) nr: Number of the input byte newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads an input E(long nr,long bit, [out, retval] BOOL *pVal) nr: Number of the input byte bit: Bit number in the input byte pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes an input E(long nr,long bit, [in] BOOL newVal) nr: Number of the input byte bit: Bit number in the input byte newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a output doubleword HRESULT AD(long nr, [out, retval] long *pVal) nr: Number of the output doubleword pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a output doubleword HRESULT AD(long nr, [in] long newVal) nr: Number of the output doubleword newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a output word |
X | X | X | X |
Reads a output byte HRESULT AB(long nr, [out, retval] long *pVal) nr: Number of the output byte pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes a output byte HRESULT AB(long nr, [in] long newVal) nr: Number of the output byte newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads an output HRESULT A(long nr,long bit, [out, retval] BOOL *pVal) nr: Number of the output byte bit: Bit number in the output byte pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. Writes an output HRESULT A(long nr,long bit, [in] BOOL newVal) nr: Number of the output byte bit: Bit number in the output byte newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC is too small. |
X | X | X | X |
Reads a data doubleword HRESULT DD(long DBNr,long nr, [out, retval] long *pVal) DBNr: Number of the data block nr: Byte offset within the data block pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. Writes a data doubleword HRESULT DD(long DBNr,long nr, [in] long newVal) DBNr: Number of the data block nr: Byte offset within the data block newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
X | X | X | X |
Reads a data word HRESULT DW(long DBNr,long nr, [out, retval] long *pVal) DBNr: Number of the data block nr: Byte offset within the data block pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. Writes a data word HRESULT DW(long DBNr,long nr, [in] long newVal) DBNr: Number of the data block nr: Byte offset within the data block newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
X | X | X | X |
Reads a data byte HRESULT DB(long DBNr,long nr, [out, retval] long *pVal) DBNr: Number of the data block nr: Byte offset within the data block pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. Writes a data byte HRESULT DB(long DBNr,long nr, [in] long newVal) DBNr: Number of the data block nr: Byte offset within the data block newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
X | X | X | X |
Reads a data bit HRESULT D(long DBNr,long nr,long bit, [out, retval] BOOL *pVal) DBNr: Number of the data block nr: Byte offset within the data block bit: Bit number within the data byte pVal: Read value Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. Writes a data bit HRESULT D(long DBNr,long nr,long bit, [in] BOOL newVal) DBNr: Number of the data block nr: Byte offset within the data block bit: Bit number within the data byte newVal: Value to write Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. |
X | X | X | X |
System Functions of the Interface IIIBHnet2 | S5 | S7 300/400 |
SoftSPS and S7-CX |
S7 200 |
Reboot of the IBH Link. HRESULT ResetDevice(BSTR device) device: Station name. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected module does not support the function. |
- | X | X | X |
Reads the key switch position of the PLC. HRESULT Key_Position([out, retval] long *pVal) pVal: returns the key switch position. Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | X | X | - |
Reads the available nodes on the bus. HRESULT LifeList(BSTR device, VARIANT * lifelist) lifelist: contains a list with the nodes. 0x30 = Active, 0x20 = Active Ready, 0x10 = Not existing, 0x00 = Passive Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | X | X | X |
Reads the System Status Lists (SSL) from the PLC. HRESULT SZ_List(long SZL_ID, long INDEX, VARIANT * SZ_List) For more information please consult the Siemens dokumentation for the SFC51. Installation folder: C:\Program Files\Siemens\Dokumentation\English\STEP 7 - System and Standard Functions for S7-300 and S7-400 Chapter: System Status Lists (SSL). Return Value: Successful operation returns S_OK, E_FAIL on Errors. E_NOTIMPL will be returned, if the connected PLC does not support the function. |
- | X | X | - |
Terminates the driver IBH_NetPcom.exe. HRESULT TerminateDriver() Return Value: Always S_OK. For the Protocols RFC1006, API or 1200 irrelevant. |
- | X | X | X |
Advanced functions and .NET of the Interface IIIBHnet3 | S5 | S7 300/400 |
SoftSPS and S7-CX |
S7 200 |
Set up PLC connection. HRESULT Connect_DP(BSTR Station, long DPAdr, long Rack, long Slot) Station: Station name DPAdr: MPI® or Profibus address Rack: Rack number (normally 0) Slot: Slot number. For MPI normally 0, for Profibus the slot number of the CPU inside the rack. Return Value: Successful operation returns S_OK, E_FAIL if failed. The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed. If the protocol RFC1006 is chosen in the IBHNet station, the parameter DPAdr is irrelevant. For connections to a Siemens CP, only the parameters Rack and Slot are regarded. With an IBH Link S7++, the MPI/Profibusaddress is a combination from the lower 5 Bit of the parameter Slot and the lower 3 Bit of the parameter Rack. |
- | X | - | - |
Set up a routed PLC connection to a PLC in a MPI/Profibus subnet, if the CPU supports it. HRESULT Subnet_Connect_DP(BSTR Station, long MPIStart, long MPIZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL) Station: Station name MPIStart: MPI® or Profibus address, the IBH Link is connected to. MPIZiel: Destination MPI® or Profibus address inside the subnet. RackZiel: Destination rack number in the subnet (normally 0). SlotZiel: Destination slot number in the subnet (normally 2). Subnet_HH: Subnet ID HighWord, from Project. Subnet_LL: Subnet ID LowWord, from Project. Return Value: Successful operation returns S_OK, E_FAIL if failed. The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed. |
- | X | - | - |
Set up a routed PLC connection to a PLC in a TCP/IP subnet, if the CPU supports it. HRESULT Subnet_Connect_IP(BSTR Station, long MPIStart, BSTR IPZiel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL) Station: Station name MPIStart: MPI® or Profibus address, the IBH Link is connected to. IPZiel: Destination TCP/IP address inside the subnet. RackZiel: Destination rack number in the subnet (normally 0). SlotZiel: Destination slot number in the subnet (normally 2). Subnet_HH: Subnet ID HighWord, from Project. Subnet_LL: Subnet ID LowWord, from Project. Return Value: Successful operation returns S_OK, E_FAIL if failed. The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed. |
- | X | - | - |
Set up a routed PLC connection to a PLC in a H1 subnet, if the CPU supports it. HRESULT SubnetConnectH1(BSTR Station, long MPIStart, BSTR H1Ziel, long RackZiel, long SlotZiel, long Subnet_HH, long Subnet_LL) Station: Station name MPIStart: MPI® or Profibus address, the IBH Link is connected to. H1Ziel: Destination H1 address inside the subnet. RackZiel: Destination rack number in the subnet (normally 0). SlotZiel: Destination slot number in the subnet (normally 2). Subnet_HH: Subnet ID HighWord, from Project. Subnet_LL: Subnet ID LowWord, from Project. Return Value: Successful operation returns S_OK, E_FAIL if failed. The function Connect_DP of the interface IIIBHNet3 should be preferred to set up a connection, because it returns always an exception in programming languages like VisualBasic or C#, if failed. |
- | X | - | - |
Reads the raw contents of a datablock from the PLC. HRESULT ReadDB(long DBNr, VARIANT*DB, long * Len) DBNr: Data block number DB: VARIANT variable, that contains a SAFEARRAY of type Byte containing the block. Len: Block length Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_INVALIDARG if the datablock does not exist. To use this function, detailled internal knowledge of S7 blocks is required. For legal reasons this information can not be published by IBHsoftec. |
X | X | X | - |
Writes the raw contents of a datablock to a PLC. HRESULT WriteDB(long DBNr, VARIANT DB, long Len) DBNr: Data block number DB: VARIANT variable, that contains a SAFEARRAY of type Byte containing the block. Len: Block length Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_INVALIDARG if the datablock does not exist. To use this function, detailled internal knowledge of S7 blocks is required. For legal reasons this information can not be published by IBHsoftec. |
X | X | X | - |
Reads an array of values from the PLC HRESULT DotNetReadVals(long typ, long nr, long DBNr, long size, VARIANT * vals) typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d nr: Start offset for Input/Output/Flags, for D the start offset within the DB DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0 size: Number of Bytes to read vals: VARIANT variable, that contains a SAFEARRAY of type Byte containing the values read from the PLC. Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC. |
X | X | X | X |
Writes an array of values to the PLC HRESULT DotNetWriteVals(long typ, long nr, long DBNr, long size, VARIANT vals) typ: 'E' = Input = 69d, 'A' Output = 65d, 'M' Flags = 77d, 'D' Datablock = 68d nr: Start offset for Input/Output/Flags, for D the start offset within the DB DBNr: Datablock number for typ = 'D' (68d), for Input/Output/Flags 0 size: Number of Bytes to read vals: VARIANT variable, that contains a SAFEARRAY of type Byte with the values to write to the PLC Return Value: Successful operation returns S_OK, E_FAIL on Errors, E_ABORT if the PLC denies access or E_INVALIDARG if the desination Area in the PLC does not exist or is too small. DotNetWriteVals passes the data in a VARIANT variable, that contains a SAFEARRAY of type Byte. In the .Net languages the vals parameter is an object. If the destination area in the PLC does nor exist or is too small, the PLC reports this to the driver and the function will return E_INVALIDARG. The connection to the PLC stays established. For this type of error there is no need do disconnect from the PLC. |
X | X | X | X |
In the installation folder of the IBHNet driver, samples for Visual Basic 6 can be found. The samples are commented. Samples for other programming languages will follow. Contact our product support to ask for more samples.
Attention: If multiple threads need to access the same IBHNet object, the access functions to the IBHNet object need to be locked from each other. Suitable mechanisms are for instance Critical Sections, Semaphores or Mutexes. A simple locking with variables is not suitable to securely avoid race conditions. |
Following error codes will be returned:
Errorcode | Description |
---|---|
1 | netpcomv.CreateInstance failed |
2 | netpcomv.MPI_open failed |
3 | netpcomv.MPI_ConnRequest failed |
4 | connection request to SoftPlc failed |
5 | netpcomv.MPI_close failed |
If accessing a variable fails, still an exception will be raised.
It is also possible to access the LOGO! RCE versions via RFC1006. In this case the MPI address 128 has to be used in the function Connect(), for Connect_DP() the slot 128 has to be used. MPI address and rack need to be 0. The possible variables are inputs, outputs, flags, the DB1 and the order number.
Additional security settings are necessary with S7-1500 to permit access from IBHNet. To do so, navigate to the PLC properties 'Protection' section. There the Option: 'Connection mechanisms - Permit Access over PUT/GET communication from remote partner' must be checked.