Difference between revisions of "IBHNet:Accessing PLC variables"

From IBHsoftec Wiki English
Jump to: navigation, search
 
Line 468: Line 468:
  
 
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
HRESULT Connect([in, string] BSTR Station,[in] long MPIAdr)
Station: Station Name
MPIAdr: MPI Addrerss
Return Value: Successful operation returns S_OK, E_FAIL or the sequence number 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 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
HRESULT AW(long nr, [out, retval] long *pVal)
nr: Number of the output 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 output word
HRESULT AW(long nr, [in] long newVal)
nr: Number of the output 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 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.