LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Good way to connect to Siemens PLC? Alternative to OPC server?

We currently connect from Labview to Siemens PLC in the following setup, are there other ways to connect to a Simens PLC that might suit our needs better?

Labview exe on windows 7<-> NI OPC server (+DSC runtime) <-> ethernet <-> Simens PLC (S7-300 / S7-400 ?)

We first developed the project in Labview 2012, and now when it is time for a review and bug fix we realize that our code base is now LV2015. Means we need to upgrade also the NI OPC server and NI DSC Runtime. Since we did not pay for any SSP it means we have to pay for the whole OPC + DSC runtime again. For each client system.

Even if we do this, the yearly SSP cost for all client systems is unattractive.

 

Can we accomplish the same thing in other ways? What we need is simply to read and write a bunch of variables=data cells in the PLC and about 1Hz.

 

 

0 Kudos
Message 1 of 20
(7,506 Views)

To read/write PLC items I simply use Datasocket functions with a DA OPC server (NI OPC would be ok I guess).

Here is an example of reading a generic item. It can be a variable or even a memory block.

The URL string depends on the OPC server. The trick is to read the item as a variant, then get the OPC Quality as a variant attribute. At last you need to convert the variant to the proper data type; a memory block would be converted to a LabVIEW cluster.

This is a simple example. In a real program, you would open the connection once and use it many times.Read OPC item example.png

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 2 of 20
(7,458 Views)

One possible alternative is Modbus:

LabVIEW exe with Modbus communication <-> ethernet <-> PLC with Modbus communication.

 

Modbus API is available here: http://forums.ni.com/t5/NI-Labs-Toolkits/LabVIEW-Modbus-API/ta-p/3524019 , I believe it is also included in newer versions of DSC (I'm not sure about runtime licensing though).

 

I've done this in one application, I've set up Modbus Master in my LV application and there was Modbus communication enabled on PLC side. I'm not sure about PLC side technical details (someone else programmed it), but I think it's not rocket science 😉 One possible caveat: Modbus communication with PLC can be slow, so be sure to benchmark your application before jumping into full-scale developement.

 

Also - there is always an option to simply save the whole project to LV 2012... Wouldn't that be the best way for you?

 

Message 3 of 20
(7,449 Views)

Edit, I use shared variables to connect between Labview and OPC, like this.

Labview exe on windows 7<-> shared variables<-> NI OPC server (+DSC runtime) <-> ethernet <-> Simens PLC (S7-300 / S7-400 ?).

0 Kudos
Message 4 of 20
(7,444 Views)

But if you are using shared variables and want to stick with them, why are you asking an alternative?

Shared variables are chained to DSC.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 20
(7,442 Views)

PiDi, thanks for your answers.

A collegue use Proibus in a project and said he had to program the data send/received in quite a low level. Was it maybe Modbus he was actually sending? I just googled and saw Profibus more as a cabling standard. I will look up the link and learn if Modvus can help us.

 

And you are definately right, for the current program release I will go for the "save as LV2012" option. Or try to only deploy the shared library with the OPC-server in LV2012, seems rest of the code can be LV2015.

But the project will need to be maintained in the future also, and here we are looking for good solutions...

 

 

0 Kudos
Message 6 of 20
(7,440 Views)

pincpanter, tried your example with NI OPC server, but did not know how to construct a proper opc-URL. In NI-OPC-QC (quick client) one example variable looks like. Tried to use these data with your url structure (and with backslash and dots instead of slash). Can you explain how do this?

2017-04-07 11_05_49-Item Properties.png

0 Kudos
Message 7 of 20
(7,437 Views)

Paolo, I am looking for alternatives, just explained that currently I use shared variables.

0 Kudos
Message 8 of 20
(7,435 Views)

There are in fact many different ways to connect to a Siemens S7 PLC from within a LabVIEW application.

 

1) There is of course OPC, but that requires an OPC Server somewhere either from Siemens or a 3rd party, that knows how to connect to the PLC properly. And accessing OPC from within LabVIEW can either be done with Datasocket, if your requirements are not very demanding and you can live with creating your datasocket URLs correctly, control binding which also uses datasocket internally, or the LabVIEW DSC system which allows a lot more control over how the OPC items are accessed.

 

2) Modbus/TCP is another solution that does not require much on the LabVIEW side but you need to have a Siemens PLC that supports this protocol or install an according program block in the PLC.

 

3) There are various 3rd party libraries that access the ISO on TCP protocol that all Siemens S7 PLC with Ethernet interface support. Most of them are either DLLs, ActiveX components or .Net assemblies and require some work to interface, but it's definitely possible. One of them I used in the past is the Accon-AGLink software from Deltalogic. Works like a charm.

Another is a native LabVIEW library from  Data Ahead called SP7 Toolkit and you can buy it from the NI 3rd Party Addons here. For the price you can't really do much wrong and for accessing Datablock and IO items it works well. The nice thing about this library is that it is pure LabVIEW code, so it will work on any LabVIEW platform that has a network connection, including the cRIO controllers from NI. With DLLs, ActiveX and .Net based libraries you are usually restricted to Windows only systems, although the Accon AGLink library does support Linux too, but my attempts to get that library to work on a x86 based NI Linux Realtime cRIO where pretty discouraging and the fact that it would anyhow not work on the cheaper ARM based cRIOs was the final knockout for this solution.

 

4) You can implement your own simple TCP protocol in the Siemens PLC in a programming block and connect to it with the LabVIEW TCP nodes. Siemens provides some samples about implementing your own TCP protocol on their PLCs, a document describing this can be found here. This may be the most reliable solution in terms of controlling the whole protocol.

The ISO on TCP based solutions all have the slightly disturbing problem that they rely on a protocol that is not officially documented by Siemens. Also if you use a third party library that uses the ISO on TCP protocol you usually have to disable the option to compress the datablocks in the Siemens PLC. Most libraries do not support the new TIA extension that can also read compressed data items.

 

We ended up developing our own VI library that uses the ISO on TCP based protocol since we needed also asynchronous operation for better throughput control than what the library from Data Ahead could provide. 

Rolf Kalbermatter
My Blog
Message 9 of 20
(7,432 Views)

Profibus is a serial interface using on the electrical level a RS-485 circuitry and on the protocol level a protocol that includes also provisions for realtime control and industrial level error control. It's protocol timing is demanding enough that you can't reliably implement it in the user space of an application (for instance in LabVIEW on top of VISA) but either need to have a dedicated controller on the interface board that handles the low level timing aspects autonomously or a kernel device driver that sits on top of the hardware interface and thanks to its higher priority and direct interrupt capability from the hardware can handle the protocol in quasi-realtime.

Profinet is the sibling of Profibus which uses an Ethernet interface instead of an RS-485 circuitry for the physical transport layer.

In order to make a product which implements a Profibus or Profinet interface, one has to be a member of the Profibus Organization. Only members of that organzation get the right to use certain patents that cover the actual implementation of the various Profibus/Profinet protocols.

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 20
(7,422 Views)