본문 바로가기
Siemens Automation/STEP7

S7-300 S7-1200 & 광성계측기 이기종 통신

by 의명 2020. 6. 7.

SYSTEM CONFIGURATION



SIEMENS 

S7-3152PN/DP (6ES7315-2EH14-0AB0)

IP ADDRESS - 192.168.1.96

SUBNET MASK - 255.255.255.0

PORT - 2000


광성계측기

KDX-202

IP ADDRESS - 192.168.1.106

SUBNET MASK - 255.255.255.0

PORT - 2000


노트북

IP ADDRESS - 192.168.1.33

SUBNET MASK - 255.255.255.0


KDX-202 장비의 경우 물리적으로 이더넷포트가 달려 있었으며, 

실제 통신 방식은 MODBUS 방식이였기 때문에 통신을 하기위해 공부를 많이 했습니다

제일 먼저 광성계측기 장비의 데이터 맵을 확인하였습니다


테스트를 하기 위해 특정 데이터 코드를 광성계측기 쪽으로 날려줘야 하는데 어떤 것을 날려줄까 

확인을 하다보니 제일 간편한 몇개의 데이터를 요청했습니다



요청 코드 예제 (Data Map 참조)


1. HZ - FF.04.00.09.00.01.F4.16


2. 상전압 – FF.04.00.0E.00.01.45.D7


3. 적산전력량 – FF.04.00.0A.00.01.04.16


4. 1 WORD – FF.04.00.00.00.01.24.14


5. 8 WORD – FF.04.00.00.00.08.E4.12


6. 10 WORD – FF.04.00.00.00.0A.65.D3


7. 55 WORD – FF.04.00.00.00.37.A4.D2


CRC LO, CRC HI 부분은 각 BYTE 끝에 들어가는 부분인데 구글에서 CRC 계산하는 사이트에서 검색하여 사용 (아래 사이트 참조)


https://www.lammertbies.nl/comm/info/crc-calculation?crc=8005&metho


1번 HZ에 대한 CRC 계산


PLC PROGRAM



Parameters

 

Parameter

Declaration

Data Type

Memory Area

Description

REQ

INPUT

BOOL

I, Q, M, D, L

Control parameter REQUEST starts the job for establishing the connection specified by ID. The job starts on the rising edge.

ID

INPUT

WORD

M, D, constant

Reference to the connection to be established to the remote partner or between the user program and the communications level of the operating system. ID must be identical to the associated parameter ID in the local connection description.
Range of values: W#16#0001 to W#16#0FFF

DONE

OUTPUT

BOOL

I, Q, M, D, L

DONE status parameter:

  • 0: Job not yet started or still running.

  • 1: Job executed without error.

BUSY

OUTPUT

BOOL

I, Q, M, D, L

  • BUSY = 1: Job is not yet completed.

  • BUSY = 0: Job is completed.

ERROR

OUTPUT

BOOL

I, Q, M, D, L

ERROR status parameter:

  • ERROR=1: An error occurred in job processing. STATUS returns detailed information on the type of error

STATUS

OUTPUT

WORD

M, D

STATUS status parameter: Error information

CONNECT

IN_OUT

ANY

D

Pointer to the associated connection description (UDT 65), see Assigning Parameters for Open Communications Connections with TCP and ISO on TCP and Assigning Parameters for the Local Communications Access Point with UDP

Note: For S7-300 CPUs, please note that the CONNECT parameter always requires the complete specifications of the DB parameter (e.g. P#DB13.DBX0.0 Byte 100). For S7-300 CPUs, leaving out an explicit DB no. is not permitted and causes an error message in the user program.

 

 

Error Information

 

ERROR

STATUS
(W#16#...)

Explanation

0

0000

Connection was established successfully

0

7000

No job processing active

0

7001

Start job processing, establishing connection

0

7002

Follow-on call (REQ irrelevant), connection being established

1

8086

The ID parameter is outside the permitted range.

1

8087

Maximal number of connections reached; no additional connection possible

1

8089

The parameter CONNECT parameter does not point to a data block.

1

809A

The parameter CONNECT parameter points to a field that does not match the length of the connection description (UDT65).

1

809B

The local_device_id in the connection description does not match the CPU or the associated interface is locked.

1

80A0

Group error for error codes W#16#80A1 and W#16#80A2

1

80A1

Connection or port is already occupied by user

1

80A2

Local or remote port is occupied by the system

1

80A3

Attempt being made to re-establish an existing connection

1

80A4

IP address of the remote connection end point is invalid, it may match the local IP address

1

80A7

Communications error: you have called TDISCON before TCON was complete. TDISCON must first complexly terminate the connection referenced by the ID.

1

80B2

The parameter CONNECT parameter points to a data block that was generated with the keyword UNLINKED.

1

80B3

Inconsistent parameter assignment: Group error for the error codes W#16#80A0 to W#16#80A2, W#16#80A4, W#16#80B4 to W#16#80B9

1

80B4

When using the protocol variant ISO on TCP (connection_type = B#16#12) for passive establishment of a connection (active_est = FALSE), you violated one or both of the following conditions:

  • local_tsap_id_len >= B#16#02

  • local_tsap_id[1] = B#16#E0

  • With local_tsap_id_len >= B#16#03, local_tsap_id[1] is an ASCII character

local_tsap_id[1] is an ASCII character and local_tsap_id_len >= B#16#03

1

80B5

Error in active_est parameter (UDT 65) in the UDP protocol variant

1

80B6

Parameter assignment error relating to the connection_type parameter (UDT 65)

1

80B7

Error in one of the following parameters of UDT 65: block_length, local_tsap_id_len, rem_subnet_id_len, rem_staddr_len, rem_tsap_id_len, next_staddr_len

1

80B8

Parameter ID in the local connection description (UDT 65) and parameter ID are different

1

80C3

All connection resources are in use.

1

80C4

Temporary communications error:

  • The connection cannot be established at this time.

  • The interface is receiving new parameters.

  • The configured connection is currently being removed by a TDISCON.

  • The H system is connecting and updating.

1

8xyy

General error information, see Error Evaluation with the Output Parameter RET_VAL


TCON CONNECT DB 생성 절차



1. Open Communication Tool Install


2. Program 실행


TCON CONNECT DB 생성 절차



TSEND / TRCV PROGRAM



S7-300 & KDX-202 COMMUNICATION TEST OK



S7-1200 & KDX-202 COMMUNICATION TEST OK



실제로 해결하고 보니 아무것도 아닌 통신 프로그램이지만 각 제품의 특성을 정확하게 이해하는데 오래 걸렸습니다


이기종 통신을 하니 발전하는 제 모습을 보니 뿌듯하구요^^


지멘스 교육이나 기술지원, 견적 등 문의 사항이 있으시면 언제든지 연락주시고,


제가 도움을 드릴 수 있는 내용은 최대한 답을 드릴수 있도록 하겠습니다.


긴글 읽어주셔서 감사드리고, 틈나는대로 계속 관련 내용 업데이트하도록 하겠습니다


감사합니다.



댓글