2018/12/19

저렴한 가정용 메시 네트워크 장비의 탄생

메시 네트워크(Mesh Network)를아시나요? 

Image result for mesh network



기존 유, 무선 네트워크 환경은 엑세스 포인트(Access Point, 이하 ‘AP’)라고 하여 중계기를 통해 신호를 연결해가는 방식으로 모든 AP가 유선으로 연결되어 있는 형태입니다. 

가정용으로는 무선 영역 확장을 위해 증폭기나 리피터, 혹은 AP 브릿지모드를 사용 하고 있습니다.
가정과는 달리 대규모 작업 현장같은 광할한 영역을 수용하기 위한 기술로 메시 네트워크 기술을 사용 하고 있습니다.  
 - 메시 네트워크 상세정보 : http://www.elec4.co.kr/article/articleView.asp?idx=14972

메시 네트워크 장비들은 고가의 장비 들입니다.
장비 제조 업체는 Tropos Networks, Belair, Packethop, SkyPilot, RomanAD가 선두에서 이끌어가고 있으며 국내에서는 삼성SDS, 엘지-노텔, Tropos Networks, Belair 등이 무선 네트워크 제품 들을 판매하고 있습니다.

최근 넷기어에서 보급형 메시 장비들을 발매 하였습니다.
넷기어에 박수를 보내며~

넷기어 Orbi : https://www.netgear.co.kr/orbi/


2018/12/03

SIEMENS PLC communication programing - C# S7.netplus


최근 HMI 개발 까지는 아니고.. 단순 Value 몇개를 주기적으로 읽어 와야 하는 경우가 있어 개발 하게되었습니다..

이번 게시글은 C# S7.Net 라이브러리 사용 법을 설명 하고자 합니다.
혹시 필요하신분 있으시면 참조 하시기 바랍니다.

S7.Net 개발 허브 주소 https://github.com/S7NetPlus/s7netplus
매뉴얼 : https://github.com/S7NetPlus/s7netplus/blob/develop/Documentation/Documentation.pdf


먼저 S7.Netplus 라이브러를 설치해야 합니다. NuGet package로 쉽게 설치 할 수 있습니다..

※ 다만 버전 확인을 해야 합니다. S7.Net 0.2 버전 이후부터는 .Net Framework 4.5.2 이상 설치가 필요합니다. 서버에 설치 된 .Net Framework 버전을 확인 하십시요.


간단하게 시뮬레이터를 만들어 보았습니다. 대충 프로그램 레이아웃은 아래와 같습니다.


먼저 접속 부분 항목들 설명드리자면,
CPU Type은 라이브러리에 정의 되어 있습니. FormLoad시 아래와 같이 지정해 줍니다.
private void FormMain_Load(object sender, EventArgs e)
{
    try
    {
        cbCpuType.DataSource = Enum.GetNames(typeof(CpuType));
        cbCpuType.SelectedIndex = 1// Default is S7-300
        btnMWrite.Enabled = false;
    }
    catch (Exception ex)
    {
        MessageBox.Show(this, ex.Message, "informaiton", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}
cs

IP address, Rack, Slot은 CPU 설정을 확인 후 잘 넣어줍니다.

Connect 버튼 이벤트 함수는 아래와 같습니다.
private void btnConnect_Click(object sender, EventArgs e)
{
    try
    {
        CpuType cpu = (CpuType)Enum.Parse(typeof(CpuType), cbCpuType.SelectedValue.ToString());
        string ip = tbIPaddress.Text;
        short rack = short.Parse(tbRack.Text);
        short slot = short.Parse(tbSlot.Text);
        plc = new Plc(cpu, ip, rack, slot);
        plc.Open();
        btnConnect.Enabled = false;
    }
    catch (PlcException pe)
    {
        MessageBox.Show(this, pe.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    catch (Exception ex)
    {
        MessageBox.Show(this, ex.Message, "informaiton", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}
cs

S7.Net.Plc plc = new Plc(cputype, ipaddress, rack, slot);
plc.Open();
이상으로 plc에 접속 가능합니다.

값을 읽을 때는 자료형에 유의해야 합니다. 자료형에 맞는 네이밍 규칙이 있습니다.
예) Int : DB220.DBW100, Real : DB220.DBD100, BOOL : DB220.DBX100.1

Read 버튼 이벤트 함수 내용은 아래와 같습니다.
private void btnMRead_Click(object sender, EventArgs e)
{
    try
    {
        if (plc.IsConnected)
        {
            string vaddress = tbAddress.Text;
            if (rbReal.Checked == true)
            {
                double result = ((uint)plc.Read(vaddress)).ConvertToFloat();
                tbPV.Text = string.Format("{0}", result.ToString());
            }
            if (rbInt.Checked == true)
            {
                short result = ((ushort)plc.Read(vaddress)).ConvertToShort();
                tbPV.Text = string.Format("{0}", result.ToString());
            }
            if (rbDInt.Checked == true)
            {
                int result = ((uint)plc.Read(vaddress)).ConvertToInt();
                tbPV.Text = string.Format("{0}", result.ToString());
            }
            if (rbBit.Checked == true)
            {
                bool result = (bool)plc.Read(vaddress);
                tbPV.Text = string.Format("{0}", result.ToString());
            }
            if (rbString.Checked == true)
            {
                int db = Convert.ToInt32(tbDB.Text);
                int startByteAdr = Convert.ToInt32(tbDBW.Text);                        
                int count = Convert.ToInt32(tbCount.Text);                         
                byte[] byteArray = plc.ReadBytes(DataType.DataBlock, db, startByteAdr, count);
                string result = S7.Net.Types.String.FromByteArray(byteArray);
                tbPV.Text = string.Format("{0}", result.ToString());
            }
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(this, ex.Message, "informaiton", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}
cs

쓰는 기능은 필요치 않아서... 없습니다. 쿨럭.

읽는 포인트가 많지 않다면 1초주기로 계속 돌려도 서버 퍼포먼스나 처리 속도에서
전혀 문제가 없는 듯 합니다.





지멘스 PLC 통신 프로그래밍

지멘스 PLC 통신 프로그래밍 현재 SIEMENS S7-300 PLC 계열 장비를 사용중입니다. 얼마전 간단히 PLC Value 몇개를 주기적으로 모니터링 해야 하는 경우가 생겼습니다. C#을 주로 사용하고 있어서 C#으로 SIEMENS PLC와...