diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/Makefile b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/Makefile index 72090f4f1..d2dd47014 100755 --- a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/Makefile +++ b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/Makefile @@ -1,3 +1,3 @@ -SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c mitsubishi_fx2n.c mitsubishi_q02u.c +SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c mitsubishi_fx2n.c mitsubishi_q02u.c mitsubishi_q06h.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/README.md b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/README.md index a5fa32bb6..c143acaee 100644 --- a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/README.md +++ b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/README.md @@ -1,24 +1,53 @@ -# 三菱 FX2N通信测试 +# 三菱通信测试 [TOC] -## 通信接线及参数设置 +## 三菱FX2N通信测试 + +### 通信接线及参数设置 * 串口 * FX2N自带8针圆口422,用于程序的下载。全系列不支持网口,且需购买串口拓展模块FX2N-485-BD用于通信测试。 * 接线:RDA和SDA短接,引出A;RDB与SDB短接,引出B。 * 串口模块支持MC-1C协议,通信速率:9600;数据位:7bit;停止位:1bit;校验:偶校验 -## 存储区 +### 存储区 - 存储区 I,Q,M,D区。 -## 通信测试 +### 通信测试 - 共测试BOOL,INT16,FLOAT共三种类型数据。 - 测试M区及D区数据。 +## 三菱Q06H通信测试 + +### 通信接线及参数设置 + +* 接口 + * 首次连接时,可通过CPU自带的串口(打印机方口线)进行程序的下载。 + * 本次测试通过Q06H拓展的模块QJ71E71_100模块的网口模块进行MC—3E通信测试。 + * PLC网口模块IP:192.168.250.21 端口号:4000 + +### 存储区 + +- 存储区 I,Q,M,D区。 + +### 通信测试 + +- 共测试BOOL,INT16,FLOAT共三种类型数据。 +- 测试M区及D区数据。 + +- 测试截图: + + 解析完成的配方为 + + ![](./image/q06h_recipe.png) + + 测试结果: + + ![](./image/q06h_communication_test.png) diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/Q02UPLC.jpg b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/Q02UPLC.jpg new file mode 100644 index 000000000..1ea129440 Binary files /dev/null and b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/Q02UPLC.jpg differ diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/Q06HPLC.jpg b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/Q06HPLC.jpg new file mode 100644 index 000000000..e86a13c74 Binary files /dev/null and b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/Q06HPLC.jpg differ diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/q06h_communication_test.png b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/q06h_communication_test.png new file mode 100644 index 000000000..380205847 Binary files /dev/null and b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/q06h_communication_test.png differ diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/q06h_recipe.png b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/q06h_recipe.png new file mode 100644 index 000000000..970a4c41d Binary files /dev/null and b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/image/q06h_recipe.png differ diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/test_recipe_mc_1c.json b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/json/test_recipe_mc_1c.json similarity index 100% rename from APP_Framework/Applications/control_app/plc_demo/mitsubishi/test_recipe_mc_1c.json rename to APP_Framework/Applications/control_app/plc_demo/mitsubishi/json/test_recipe_mc_1c.json diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/json/test_recipe_mc_3e.json b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/json/test_recipe_mc_3e.json new file mode 100644 index 000000000..6c99230a4 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/json/test_recipe_mc_3e.json @@ -0,0 +1,494 @@ +{ + "device_id": 1, + "device_name": "Q02UCPU_MC_3E", + "communication_type": 0, + "socket_config": { + "plc_ip": "192.168.250.21", + "local_ip": "192.168.250.233", + "gateway": "192.168.250.1", + "netmask": "255.255.254.0", + "port": 4000 + }, + "protocol_type": 7, + "read_period": 2000, + "read_item_list": [ + { + "value_name": "", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "0", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "ֹͣ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "1", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "ʹ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "2", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "3", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "ͣ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "4", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "λ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "5", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "λ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "6", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "Զ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "20", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "21", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "22", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "ֶģʽ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "23", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "Զģʽ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "24", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "з", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "25", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "λ", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "26", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "1", + "value_type": 1, + "device_code": "M", + "head_device_number_string": "27", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "0", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "1", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "1", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "2", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "2", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "3", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "3", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "4", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "4", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "5", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "5", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "6", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "50", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "7", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "51", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "8", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "52", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "9", + "value_type": 3, + "device_code": "D", + "head_device_number_string": "53", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "ٶ", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "200", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "ٶ", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "202", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "ٶ", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "204", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "ʼλ", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "206", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "յλ", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "208", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "ֵ", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "300", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "1", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "302", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "2", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "304", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "3", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "306", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "4", + "value_type": 9, + "device_code": "D", + "head_device_number_string": "308", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "Y001", + "value_type": 1, + "device_code": "Y", + "head_device_number_string": "1", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "Y002", + "value_type": 1, + "device_code": "Y", + "head_device_number_string": "2", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "Y010", + "value_type": 1, + "device_code": "Y", + "head_device_number_string": "10", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "D400", + "value_type": 4, + "device_code": "D", + "head_device_number_string": "400", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "D402", + "value_type": 8, + "device_code": "D", + "head_device_number_string": "402", + "device_points_count": 4, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "D406", + "value_type": 8, + "device_code": "D", + "head_device_number_string": "406", + "device_points_count": 4, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "B1", + "value_type": 1, + "device_code": "B", + "head_device_number_string": "1", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "B10", + "value_type": 1, + "device_code": "B", + "head_device_number_string": "10", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "B20", + "value_type": 1, + "device_code": "B", + "head_device_number_string": "20", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 100 + }, + { + "value_name": "W1", + "value_type": 3, + "device_code": "W", + "head_device_number_string": "1", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "W2", + "value_type": 4, + "device_code": "W", + "head_device_number_string": "2", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "W4", + "value_type": 9, + "device_code": "W", + "head_device_number_string": "4", + "device_points_count": 2, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "W6", + "value_type": 8, + "device_code": "W", + "head_device_number_string": "6", + "device_points_count": 4, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "W22", + "value_type": 3, + "device_code": "W", + "head_device_number_string": "22", + "device_points_count": 1, + "command_type": 1, + "monitoring_timer": 100 + }, + { + "value_name": "B44", + "value_type": 1, + "device_code": "B", + "head_device_number_string": "44", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 500 + }, + { + "value_name": "B200", + "value_type": 1, + "device_code": "B", + "head_device_number_string": "200", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 500 + }, + { + "value_name": "Y100", + "value_type": 1, + "device_code": "Y", + "head_device_number_string": "100", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 500 + }, + { + "value_name": "X150", + "value_type": 1, + "device_code": "X", + "head_device_number_string": "150", + "device_points_count": 1, + "command_type": 0, + "monitoring_timer": 500 + } + + ] +} \ No newline at end of file diff --git a/APP_Framework/Applications/control_app/plc_demo/mitsubishi/mitsubishi_q06h.c b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/mitsubishi_q06h.c new file mode 100644 index 000000000..a65e26722 --- /dev/null +++ b/APP_Framework/Applications/control_app/plc_demo/mitsubishi/mitsubishi_q06h.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 AIIT XUOS Lab + * XiUOS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +/** + * @file mitsubishi_q06h.c + * @brief PLC MITSUBISHI Q06H app + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2023.10.30 + */ + +#include + +extern int Adapter4GActive(void); + +void ControlQ06hTest(void) +{ + int i, j = 0; + int read_data_length = 0; + uint8_t read_data[128] = {0}; + +#ifdef CONNECTION_ADAPTER_4G + Adapter4GActive(); +#endif + + ControlProtocolType melsec_3e_protocol = ControlProtocolFind(); + if (NULL == melsec_3e_protocol) { + printf("%s get melsec 3e protocol %p failed\n", __func__, melsec_3e_protocol); + return; + } + + printf("%s get melsec 3e protocol %p successfull\n", __func__, melsec_3e_protocol); + + if (CONTROL_REGISTERED == melsec_3e_protocol->protocol_status) { + ControlProtocolOpen(melsec_3e_protocol); + + for (;;) { + read_data_length = ControlProtocolRead(melsec_3e_protocol, read_data, sizeof(read_data)); + printf("%s read [%d] melsec 3c data %d using receipe file\n", __func__, i, read_data_length); + if (read_data_length) { + for (j = 0; j < read_data_length; j ++) { + printf("j %d data 0x%x\n", j, read_data[j]); + } + } + i++; + memset(read_data, 0, sizeof(read_data)); + PrivTaskDelay(10000); + } + + //ControlProtocolClose(melsec_3c_protocol); + } +} +PRIV_SHELL_CMD_FUNCTION(ControlQ06hTest, Mitsubishi Q06H Demo, PRIV_SHELL_CMD_MAIN_ATTR); + +