SerialConnection_manual

1 minute read

Written By mskoo, VCANUS

M-7024 모델을 이용한 SerialPort Connection(ModBusRTU)에 대한 내용이다
DASUtill, SDK 프로그램 이용 방법과 Master write 프로그래밍 방법 및 사용 법 정리

DASUtil 이용 방법

1. 프로그램 다운 경로

다운로드 링크 에서 DCON_Utility_Pro_PC_V4 다운

2. 프로그램 설치 경로

zip해제 후 > DCON_Utility_Pro_PC > DCON_Utility_Pro.exe 설치

3. 프로그램 실행 및 설정 방법

(1) DCON_Utility_Pro.exe 실행 (2) COM Port 누르고 Search Options 설정

settingport

settinginfo

settinginfo2

settinginfo3

settinginfo4

참고 : DCON Utility Pro User Manual

(3) Start Search 화살표 클릭하여 포트정보 찾기

findport

(4) 찾은 정보 확인

findresult


DAS SDK(NModbus4 라이브러리) 설치

1. 프로그램 다운로드 경로

(1)프로젝트를 만든 후 우측의 “솔루션 탐색기”의 “프로젝트(ModbusExample)“에 우클릭으로 “NuGet 패키지 관리(N)..”를 선택

dll1

(2) “찾아보기” 선택 > 검색창에 “NModbus” 검색 > “NModbus4” 선택 > “설치” 클릭

dll2

(3) 출력창에서 NModbus4 라이브러리 설치 상태를 확인

dll3


프로그래밍

1. NModbus4 라이브러리 참조

(1) 위 DAS SDK(NModbus4 라이브러리) 설치 참조 (2) 다운 받은 라이브러리 불러오기

using Modbus.Device;

2. 참조 함수

(1) 클래스 사용

SerialPort port = new SerialPort();
ModbusSerialMaster master = new ModbusSerialMaster();

(2) write 함수

void WriteSingleRegisters(byte slaveAddress, ushort startAddress, ushort[] data);

3. 포트 설정 및 설정 값

(1) port Setting

port.PortName = cboxPortList.Text;
port.BaudRate = 9600;
port.DataBits = 8;
port.Parity = Parity.None;
port.StopBits = StopBits.One;

(2) master Setting

master = ModbusSerialMaster.CreateRtu(port);

(3) write registerAddress 인자는 주소값이 40003번지라면 40003이 아닌 3을 넣어야 함 value 허용범위값 : 0 - 10V -> 0 - 10000

byte slaveAddress = Convert.ToByte(txtSlaveAdress.Text);
ushort registerAddress = Convert.ToUInt16(txtRegiAdress.Text); //ex)40003->3
ushort value = Convert.ToUInt16(txtValue.Text); //0~10V : 0~10000
master.WriteSingleRegister(slaveAddress, registerAddress, value);

4. address 정리

address

참고 : Series User Manual link(M-7024)


MmodBusRtu_M7024 사용법

위 프로그래밍으로 작성한 실행파일 및 라이브러리 사용법이다.

1. exe 파일 실행

vsc_serial_communication -> SerialPortConnection -> bin -> Release -> SerialPortConnection.exe 실행

2. dll 파일 참조

(1) 참조 경로

vsc_serial_communication -> SerialPortConnection -> bin -> Debug -> SerialPortConnection.dll 참조 추가

(2) 코드 추가

using ModbusRtu_M7024;
using System.Threading;
ModbusRtu_M7024.ModbusRtu_M7024 modbusRtu_m7024 = new ModbusRtu_7024.ModbusRtu_M7024();

3. cs 사용법

(1) comboBox 에서 port name 설정 연결버튼 클릭

exe1

exe2

(2) 송신 textBox에 각각 값 입력 후 Write버튼 클릭

exe3

Leave a comment