ad keyence app demo

This commit is contained in:
Wien.b 2023-05-16 20:01:27 -07:00
parent 07b87016ba
commit 01848defec
5 changed files with 116 additions and 1 deletions

View File

@ -1,3 +1,3 @@
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance keyence
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
SRC_FILES := kv_8000.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,22 @@
# KEYENCE 通信测试
[TOC]
## 通信接线及参数设置
* 网口
*Mosbus TCP协议IP192.168.250.40Port502
## 存储区
- 存储区ZF区。
## 通信测试
1共测试INT16类型数据。
2测试ZF区数据。
3D区数据测试用功能码03和06以字为单位读写。如读写ZF1则配方文件中起始地址则直接写1即可。

View File

@ -0,0 +1,53 @@
/*
* 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 kv_8000.c
* @brief PLC KEYENCE KV-8000 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.4.12
*/
#include <control.h>
void ControlKV8000Test(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp 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(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlKV8000Test, KEYENCE Plc KV_8000 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,37 @@
{
"device_id": 1,
"device_name": "GJ2",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.40",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 502
},
"protocol_type": 2,
"read_period": 100,
"read_item_list": [
{
"value_name": "ZF0",
"value_type": 3,
"function_code": 3,
"start_address": 0,
"quantity": 1
},
{
"value_name": "ZF1",
"value_type": 3,
"function_code": 3,
"start_address": 1,
"quantity": 1
},
{
"value_name": "ZF2",
"value_type": 3,
"function_code": 3,
"start_address": 2,
"quantity": 1
}
]
}