Hướng dẫn lập trình plc s7 1200 Informational, Transactional
Hoàng Gia Automation xin gửi đến bạn đọc tài liệu bộ lập trình PLC Siemens S7-1200. Show Giới thiệu về bộ lập trình PLC Siemens Simatic S7-1200Bộ lập trình PLC Siemens Simatic S7-1200 là bộ điều khiển lập trình PLC cơ bản với thiết kế dạng module nhỏ gọn, linh hoạt. PLC Simatic S7-1200 hỗ trợ đầy đủ các chức năng điều khiển và truyền thông, thích hợp với nhiều ứng dụng tự động hóa khác nhau, phù hợp cho các ứng dụng quy mô nhỏ tới trung bình. Ứng dụng – Giải pháp của bộ lập trình PLC Siemens Simatic S7-1200Bộ lập trình PLC Siemens Simatic S7-1200 được ứng dụng rộng rãi trong các lĩnh vực như:
CÔNG TY CÔNG NGHỆ TỰ ĐỘNG HÓA HOÀNG GIA Địa chỉ: Số 103 Khúc Thừa Dụ, P. Vĩnh Niệm, Q. Lê Chân, Hải Phòng Điện thoại: 0913.385.368 Email: [email protected] Website: www.hgautomation.vn Hai chuẩn truyền thông công nghiệp được sử dụng phổ biến hiện nay với hai khung truyền gói tin khác nhau: 1.1. Modbus RTU.
2. Giao thức Modbus TCP/IP.2.1. Mô hình kết nối.Mô hình kết nối giữa PLC và thiết bị đầu cuối bằng chuẩn Modbus TCP/IP và giao tiếp với nhau bằng mô hình Server và Client. 2.2. Các function và thanh ghi. 2.2.1. Thanh ghi. Địa chỉ Kích thước Mô tả 0xxxx 1bit Đọc viết ngõ đầu ra số. 1xxxx 1bit Đọc ngõ vào số 3xxxx 16bit Đọc thanh ghi đầu vào 4xxxx 16bit Đọc và viết thanh ghi. 2.2.2. Mã hàm được sử dụng trong PLC (Funtion Code). MODE MB_DATA_ADDR MB_DATA_LEN Modbus function Function and data type 0 1 to 9,999 1 to 2,000 01 Read 1 to 2,000 output bits on the remote address 0 to 9,998 0 10,001 to 19,999 1 to 2,000 02 Read 1 to 2,000 input bits on the remote address 0 to 9,998 0 · 40,001 to 49,999 · 400,001 to 465,535 1 to 125 03 · Read 1 to 125 holding registers on the remote address 0 to 9,998 · Read 1 to 125 holding registers on the remote address 0 to 65,534 0 30,001 to 39,999 1 to 125 04 Read 1 to 125 input words on the remote address 0 to 9,998 1 1 to 9,999 1 05 Write 1 output bit on the remote address 0 to 9,998 1 · 40,001 to 49,999 · 400,001 to 465,535 1 06 · Write 1 holding register on the remote address 0 to 9,998 · Write 1 holding register on the remote address 0 to 65,534 1 1 to 9,999 2 to 1,968 15 Write 2 to 1,968 output bits on the remote address 0 to 9,998 1 · 40,001 to 49,999 · 400,001 to 465,535 2 to 123 16 · Write 2 to 123 holding registers on the remote address 0 to 9,998 · Write 2 to 123 holding registers on the remote address 0 to 65,534 2 1 to 9,999 1 to 1,968 15 Write 1 to 1,968 output bits on the remote address 0 to 9,998 2 · 40,001 to 49,999 · 400,001 to 465,535 1 to 123 16 · Write 1 to 123 holding registers on the remote address 0 to 9,998 · Write 1 to 123 holding registers on the remote address 0 to 65,534 11 The MB_DATA_ADDR and MB_DATA_LEN parameters are not evaluated when this function is executed. 11 Read status word and event counter of the server: · The status word reflects the the processing status (0 – not processing, 0xFFFF – processing). · The event counter is incremented when the Modbus request was executed successfully. If an error occurred during execution of a Modbus function, a message is sent by the server, but the event counter is not incremented. 80 – 1 08 Check the server status with the diagnostic code 0x0000 (return loop test – the server sends the request back): · 1 WORD per call 81 – 1 08 Reset the event counter of the server with the diagnostic code 0x000A: · 1 WORD per call 101 0 to 65,535 1 to 2,000 01 Read 1 to 2,000 output bits on the remote address 0 to 65,535 102 0 to 65,535 1 to 2,000 02 Read 1 to 2,000 input bits on the remote address 0 to 65,535 103 0 to 65,535 1 to 125 03 Read 1 to 125 holding registers on the remote address 0 to 65,535 104 0 to 65,535 1 to 125 04 Read 1 to 125 input words on the remote address 0 to 65,535 105 0 to 65,535 1 05 Write 1 output bit on the remote address 0 to 65,535 106 0 to 65,535 1 06 Write 1 holding register on the remote address 0 to 65,535 115 0 to 65,535 1 to 1,968 15 Write 1 to 1,968 output bits on the remote address 0 to 65,535 116 0 to 65,535 1 to 123 16 Write 1 to 123 holding registers on the remote address 0 to 65,535 2.3. Frame truyền của chuẩn truyền thông.
Ví dụ 1: Ghi giá trị từ Client lên Server dữ liệu cho phép gửi 6 thanh ghi (MB_DATA_LEN), thanh ghi bắt đầu 40001, tổng dữ liệu request (MB_DATA_PTR) là 12 thanh ghi. Frame Client gửi lên Server: 36 28 00 00 00 13 63 10 9C 41 00 06 0C 00 01 00 02 00 03 00 00 00 00 00 00 Trong đó:
Frame phản hồi từ Server: 36 27 00 00 00 06 63 10 9C 41 00 06 Trong đó:
Ví dụ 2: Client đọc giá trị từ Server với 5 thanh ghi, thanh ghi bắt đầu là 40000. Frame Client gửi lên Server: 01 A5 00 00 00 0D 63 03 9C 40 00 05 Trong đó:
Frame Server phản hồi: 01 A6 00 00 00 06 63 03 0A 00 0C 00 7B 00 02 00 02 00 22 Trong đó:
2.4 Cấu hình PLC S7-1200 trong TIA Portal 3. Kết luận Ở trên là bài chia sẻ về chi tiết của giao thức modbus TCP/IP của PLC S7-1200, hi vọng bài viết sẽ mang lại kiến thức cho những ai chưa rõ về giao thức này, hoặc có thể tự thực hành để nắm rõ hơn về nó. Biết đâu sau này bạn có dịp tiếp cận nó thì sẽ dễ dàng hơn sao. Trong bài viết nếu có gì sai sót, hãy báo mình biết để điều chỉnh kịp thời nhé. Chúc bạn may mắn và thành công, |