×
Siemens Industry Online Support
Siemens AG
Entry type: Application example Entry ID: 21447513, Entry date: 09/04/2014
(4)
Rate

Data acquisition and storage with an OPC client in C# and the SIMATIC NET .NET OPC Client API

  • Entry
  • Associated product(s)
Task The quick acquisition and storage for sometimes large data volumes such as operation or machine data or the download of recipe data into a controller are frequent tasks in production automation. OPC provides standardized interfaces for this, which allow a connection of Windows applications t...

Task
The quick acquisition and storage for sometimes large data volumes such as operation or machine data or the download of recipe data into a controller are frequent tasks in production automation. OPC provides standardized interfaces for this, which allow a connection of Windows applications to controllers.

Solution
The application on hand illustrates a possible procedure for creating individual OPC Clients in C#, suitable for data acquisition in the automation world. On the one hand SIMATIC S7 controller data sets are simulated and sent to the OPC client, which saves them into a database. On the other hand the user can download a recipe data set from the PC application into the controller.

With the .NET OPC client, the SIMATIC NET OPC server offers a simple and intuitive programming interface for developers in the languages C# and Visual Basic. The special advantage is that this interface can be used for the COM DA server and for the UA server of SIMATIC NET.

The following main points will be discussed in this application:

  • Creating an OPC client with C# in Microsoft .NET.
  • Implementing the functions "Save data" and "Download recipe".
  • Using variable services for communicating with the SIMATIC NET OPC server.
  • Persistent saving of data from SIMATIC S7 to a database (Microsoft Access or csv files).
  • Using ADO.NET for encapsulating the database calls.
  • Implementation of a simple but universal handshake between SIMATIC S7 controller and OPC client software to ensure a coordinated processing of the orders.
  • Demonstration of a suitable software design for providing beginners with a basic structure for the development of their own applications.

The figure below shows the surface of an OPC client and the hardware structure with an S7-300 station.


Figure 01


Figure 02

Downloads

Content of Download

Download

Documentation
Data Acquisition and Storage with an OPC Client in C# and the SIMATIC NET.NET OPC Client API
21447513_CSharp_OPCDataTransaction_DOKU_V2_1_en.pdf ( 3444 KB )
Code 
STEP 7 V13 Project, Executable OPC Client Application, C# Source Code
21447513_Csharp_OpcDataTransaction_CODE.zip ( 10864 KB )

Archive

Content of Download

Download

Mass Data Recording with OPC .NET 
Version 1 of this application does not solve the task with the .NET OPC client API, but with the OPC Runtime Callable Wrapper (RCW). The structure of the C# program is also treated in much greater detail.
21447513_OPC_Massendaten_V1.zip ( 5485 KB )

Further Information
The following table contains links to additional OPC examples.

Title Entry ID

Data Communication Between S7 Station and PC Station, Using SIMATIC NET OPC Server

67295801

Determining the Transmission Times for Typical Configurations Between S7 Stations and PC Stations via SIMATIC NET OPC Server

45351400

Programming OPC DA .NET Clients with C# for the SIMATIC NET OPC Server (COM/DCOM)

21043779

Programming an OPC UA .NET Client with C# for the SIMATIC NET OPC UA Server via RCW

42014088

Individual Programmed Signaling System Based on the SIMATIC NET OPC Alarm and Event/OPC UA Server

26548467

OPC Communication via the SEND/RECEIVE Protocol with a Visual Basic .NET OPC Client

21523291

Simple Plant Visualization with OCX Data Control in VBA for Excel

23829402

Using the XML-DA Interface of the SIMATIC NET OPC Server with Visual Basic .NET

21402169

Controlling with the PC - The SIMATIC NET OPC Inproc Server as DP Master

21045282

Distributed Automation with the PC - The SIMATIC NET OPC Server as DP Slave

21040390

External Block Management with S7 Block Management Services of the SIMATIC NET OPC Server

21495347

Supervision of Industrial Wireless LAN Connections by Means of the SNMP OPC Server and Excel

23577797

OPC DA Client for Simple Plant Visualization via Standard Web Browser

24272005


Last Changes
Complete review of the code and the documentation


Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.
Rate entry
no rating
Requests and feedback
What do you want to do?
Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we have no further questions, you will not hear from us.