Modbus 확인:

- AdvancedHMi + C# + ESP8266

- AdvancedHMI에서 읽고 쓰고 ...

 

AdvancedHMICS.7z
3.72MB

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

// 2022.07.02
// 맨위의 창에서 "Any CPU" 우측에 빌드 타겟을 AdvancedHMIcs 로 변경
// Ctr+Shift+B : 프로젝트 모두 빌드하면 왼쪽 도구항목에 AdvancedHMI 컴포넌트 보임
// 그리고 c# 참조에서 추가할 것 : 자동으로 추가가 안됨 ...!!!!!
// "MfgControl.AdvancedHMI.Controls.dll" + "MfgControl.AdvancedHMI.Drivers.dll"
// 시작 Base Address = 1 : 따라서 읽을 주소에 1 추가할 것
namespace AdvancedHMICS
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            btnDisconnect.Enabled = false;
            tbModbusAddess.Text = modbusTCPCom1.IPAddress.ToString();
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
            modbusTCPCom1.IPAddress = tboxIP.Text;
            tbModbusAddess.Text = modbusTCPCom1.IPAddress.ToString();
            btnConnect.BackColor = Color.Aqua;
            btnConnect.Enabled = false;
            btnDisconnect.Enabled = true;
        }

        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            btnConnect.Enabled = true;
            btnDisconnect.Enabled = false;
        }

        private void btnCoilRead_Click(object sender, EventArgs e)
        {
            tbCoilValue.Text = modbusTCPCom1.Read(tbCoilAddess.Text);
        }

        private void btnDinputRead_Click(object sender, EventArgs e)
        {
            tbDinputValue.Text = modbusTCPCom1.Read(tbInputAddess.Text);
        }

        private void btnAinputRead_Click(object sender, EventArgs e)
        {
            tbAinputValue.Text = modbusTCPCom1.Read(tbAnalogueAddess.Text);
        }

        private void btnHregRead_Click(object sender, EventArgs e)
        {
            tbHregValue.Text = modbusTCPCom1.Read(tnhRegAddess.Text);
        }

        private void btnCoilWrite_Click(object sender, EventArgs e)
        {
            modbusTCPCom1.Write(tbCoilAddess.Text, tbCoilValue.Text);
        }

        private void btnDinputWrite_Click(object sender, EventArgs e)
        {
            modbusTCPCom1.Write(tbInputAddess.Text, tbDinputValue.Text);
        }

        private void btnAinputWrite_Click(object sender, EventArgs e)
        {
            modbusTCPCom1.Write(tbAnalogueAddess.Text, tbAinputValue.Text);
        }

        private void btnHregWrite_Click(object sender, EventArgs e)
        {
            modbusTCPCom1.Write(tnhRegAddess.Text, tbHregValue.Text);
        }

        private void btnTest_Click(object sender, EventArgs e)
        {
            tbCoilValue.Text = modbusTCPCom1.Read("00101");
        }
    }
}

AdvancedHMI 다운로드 :

https://www.advancedhmi.com/index.php?main_page=index&cPath=2 

 

AdvancedHMI Software : HMI Software by AdvancedHMI, Solution to Monitor and Control PLC Data

 

www.advancedhmi.com

 

참고할 곳 : 

http://comfilewiki.co.kr/ko/doku.php?id=comfilepi:advancedhmi_uidriver:index

블로그 이미지

DIYworld

,