HOANLK
  • Login
  • Register
Cart / 0$

No products in the cart.

No Result
View All Result
  • Home
  • Automation
    • SIEMENS
    • PANASONIC
    • SERVO
    • EPLAN
    • MITSUBISHI
  • Technology
    • .NET
    • PYTHON
    • IOT
  • LIBRARY
  • Project
    • Project 2019-2023
  • Shop
  • Contact
  • English
    • Tiếng Việt
    • English
    • Русский
HOANLK
No Result
View All Result
2

Connect OPC DA C# and KepwareV6

by hoanlk
06/05/2024
in C-SHARP

I. Introducing OPC DA

What is OPC DA?

OPC DA (OLE for Process Control – Data Access) is a communication standard in the field of automation and process control. OPC DA is used to transfer data from automation devices and systems to computer applications such as HMI (Human-Machine Interface), SCADA (Supervisory Control and Data Acquisition) and data management systems .

Special of OPC

  1. Compatibility: OPC DA enables communication between devices and applications from different manufacturers without having to worry about incompatibility.
  2. High reliability: OPC DA is designed to ensure high stability and reliability in data transmission from device to application.
  3. Scalability: It allows to expand the system by adding new devices without having to change the communication structure.
  4. Data transmission speed: OPC DA is capable of transmitting data at fast speeds, suitable for applications that require real time.

II.Configuration instructions and source code

Register OPC on the computer

  1. Copy the OPCDAAuto.dll library file to drive C//window//System32 and C//window//SysWoW64 (Library link at the end of the article)
  2. Command 1: %windir%\System32\regsvr32.exe %windir%\System32\OPCDAAuto.dll For 32bit windows
  3. Command 2: %windir%\SysWoW64\regsvr32.exe %windir%\SysWoW64\OPCDAAuto.dll For 64bit windows

Config Kepware OPC V6

Kepware OPC is a software that helps connect and transfer data from automation devices and systems to computer applications such as HMI, SCADA, MES (Manufacturing Execution System), ERP (Enterprise Resource Planning), and many more. other system, supports many communication protocols such as Modbus, Siemens, Allen-Bradley, OPC UA, and many others, allowing connection to a variety of devices and systems. This is a popular solution used in automation and production management applications to connect and manage data from different devices and systems.

In this article. I use Kepware OPC V6 to connect. Because Kepware is so famous among technical people for their developments and also for easy, fast, convenient connection, support for many drivers of different brands, and clear device management. , friendly, coherent, fast.

This is an example I have pre-configured on Kepware OPC.

OPC DA C#

OPC DA C# source code on Visual Studio

Source code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OPCAutomation;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        OPCServer oServer;
        OPCGroup oGroup;
        Array handles = new Array[2];

        public int temp1;
        public int temp2;

        public Form1()
        {
            InitializeComponent();
            SET_opc();
        }

        public void SET_opc()
        {
            //add server - reference the kepserver that should already be setup
            oServer = new OPCServer();
            oServer.Connect("Kepware.KEPServerEX.V6", null);
            oServer.OPCGroups.DefaultGroupIsActive = true;
            oServer.OPCGroups.DefaultGroupDeadband = 0f; //the percentage change required before a change is reported, used to filter noise
            oServer.OPCGroups.DefaultGroupUpdateRate = 10; //the rate is ms before item is updated

            //set up group - this is an arbitrary container to place OPC items
            oGroup = oServer.OPCGroups.Add("g1");
            oGroup.IsSubscribed = false; //dont need to be subscribed to data change events
            oGroup.OPCItems.DefaultIsActive = false; //the item does not need to be active, it will only be refreshed with the latest value after we synch read

            //add group items - items can capture the values of registers from the device, the item is setup within the kepserver
            int[] h = new int[3];

            //index starts at 1
            h[1] = oGroup.OPCItems.AddItem("Channel1.Device1.PV", 1).ServerHandle; //the handle is a server generated value that we use to reference the item for further operations
            h[2] = oGroup.OPCItems.AddItem("Channel1.Device1.SV", 2).ServerHandle;
            handles = (Array)h;
        }

        public void Sync_read() //reads device
        {
            System.Array values; //opc server will store the values in this array
            System.Array errors; //opc server will store any errors in this array
            object qualities = new object(); //opc server will store the quality of the item 
            object timestamps = new object(); //store the timestamp of the read

            //read directly from device
            oGroup.SyncRead((short)OPCAutomation.OPCDataSource.OPCDevice, 2, ref handles, out values, out errors, out qualities, out timestamps);

            temp1 = (int)values.GetValue(1);
            temp2 = (int)values.GetValue(2);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Sync_read();
            textBox1.Text = temp1.ToString();
            textBox2.Text = temp2.ToString();
        }
    }
}

Library download link OPCDAutomation.dll

Link Video: Audio

OLM PROFIBUS

Share this…
  • Facebook
  • Twitter
  • Linkedin
  • Whatsapp
  • Pinterest
Tags: .NETC-SHARP
hoanlk

hoanlk

Related Posts

PLC INOVANCE C# VISUAL STUDIO 2017
C-SHARP

PLC INOVANCE C# VISUAL STUDIO 2017

27/08/2024

https://youtu.be/xQFevQH5IBE?si=-s-LYoj5K2RZm8oE Introduce Hello everyone! Monitoring and storing data is a necessary need of every factory, business, company, and production workshop....

Instructions to connect PLC S7 Siemens  with .NET library  on Visual Studio
SIEMENS

Instructions to connect PLC S7 Siemens with .NET library on Visual Studio

15/08/2023

Connecting .NET to a Siemens S7-1200 PLC is an important process for controlling and monitoring devices in industrial environments. To...

EPLAN Electric P8 API: Quick tips for creating design drawings
EPLAN

EPLAN Electric P8 API: Quick tips for creating design drawings

15/08/2023

What is EPLAN Electric P8 software? EPLAN Electric P8 software, the main product of the German company EPLAN, is a...

Guide Reporting data Wincc to Excel
SIEMENS

Guide Reporting data Wincc to Excel

30/10/2023

Creating and maintaining machine data records is a very important part of keeping the machine running efficiently. For example, monitoring...

The communication between Mitsubishi FX C# and PC
C-SHARP

The communication between Mitsubishi FX C# and PC

16/08/2023

Introduce The communication program of the PC can be written in assembly language, various high-level languages, industrial control configuration software...

Cơ bản MQTT Broker với C#
C-SHARP

Basic MQTT Broker with C#

11/08/2023

Now I will show you how to develop a simple MQTT broker that can accept all clients and display messages...

Next Post
Summary of errors in SIEMENS WINCC V7

Summary of errors in SIEMENS WINCC V7

EPLAN Electric P8 API: Quick tips for creating design drawings

TIP EPLAN: How to Break Point Eplan P8

Đọc Analog bằng Board PLC MITSUBISHI FX3U

Read Analog using MITSUBISHI PLC Board FX3U

Comments 4

  1. Ken Colechin says:
    1 year ago

    Was just browsing the site and was impressed the layout. Nicely design and great user experience. Just had to drop a message, have a great day! 8dfds87a

    Reply
  2. Ken Holtermann says:
    8 months ago

    Was just browsing the site and was impressed the layout. Nicely design and great user experience. Just had to drop a message, have a great day! we7f8sd82

    Reply
  3. Rich Waller says:
    7 months ago

    Hello
    We have client that are interested about what you selling, please contact us on whatsapp: +44 790 462 9452

    Reply
  4. Jaqueline Supple says:
    4 months ago

    Hello,
    We are interested to resell what you offer to our clients, can we discuss on whatsapp ? Here is my number : +1 204 272 8230

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Home
  • Shop
  • Return policy
  • Contact
  • Account

© 2023 HOANLK - Premium theme by HOANLK.

No Result
View All Result
  • Home
  • Automation
    • SIEMENS
    • PANASONIC
    • SERVO
    • EPLAN
    • MITSUBISHI
  • Technology
    • .NET
    • PYTHON
    • IOT
  • LIBRARY
  • Project
    • Project 2019-2023
  • Shop
  • Contact
  • English
    • Tiếng Việt
    • English
    • Русский

© 2023 HOANLK - Premium theme by HOANLK.

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In