BRT38 拉绳位移传感器接入说明
模型清单
可使用下列名称或 ID 在 ThinkLink 中搜索对应模型。
| 模型类型 | 名称 | id_name | 平台模型 ID |
|---|---|---|---|
| RPC | [BRT38 GET] 22114 | brt38_get_22114 | 130690456718569472 |
| RPC | [BRT38 SET] 22114 | brt38_set_22114 | 130690455674187776 |
| Template | BRT38 | BRT38_22114 | 130673399658606592 |
| Thing Model | [BRT38] | brt38_22114 | 130673398912020480 |
| Parameter Thing Model | [BRT38-PARA] | brt38_para_22114 | 130690453296017408 |
EdgeBus 代码
以下是该设备使用的原始 EdgeBus 代码。
import { Buffer } from "buffer";
import { buildOtaFile } from "@EBSDK/run";
import { EBModel } from "@EBSDK/EBCompiler/EBModel/EBModel";
import { EventInfoItem } from "@EBSDK/EBCompiler/plugins/EBHelper";
import type { UserConfUPItem } from "@EBSDK/EBCompiler/plugins/EBHelper";
import { CheckbitEnum, getOtaConfig } from "@EBSDK/otaConfig";
// BRITER BRT38 RS485/Modbus-RTU.
// The BRT38 requires separate FC03 windows for encoder value, turn count,
// and single-turn value. In particular, 0x0000 may only be read with count 2.
// 0x0020-0x0021: signed angular-velocity raw value.
const eventInfo: UserConfUPItem[] = [
{
name: "briter-brt38",
port: 22,
version: "0x88",
dataType: "0x02",
upPeriodIndex: 70,
quInfo: [
{
protocol: "modbus",
addr: "0x01",
code: "0x03",
periodIndex: 70,
indexAPP: 150,
indexCMD: 0,
copySize: 1,
isLast: false,
listVal: [{ start: "0x0000", end: "0x0001" }],
},
{
protocol: "modbus",
addr: "0x01",
code: "0x03",
periodIndex: 70,
indexAPP: 150,
indexCMD: 0,
copySize: 1,
isLast: false,
listVal: [{ start: "0x0002", end: "0x0002" }],
},
{
protocol: "modbus",
addr: "0x01",
code: "0x03",
periodIndex: 70,
indexAPP: 150,
indexCMD: 0,
copySize: 1,
isLast: false,
listVal: [{ start: "0x0003", end: "0x0003" }],
},
{
protocol: "modbus",
addr: "0x01",
code: "0x03",
periodIndex: 70,
indexAPP: 150,
indexCMD: 0,
copySize: 1,
isLast: true,
listVal: [{ start: "0x0020", end: "0x0021" }],
},
],
},
];
const otaConfig = getOtaConfig({
BaudRate: 9600,
StopBits: 1,
DataBits: 8,
Checkbit: CheckbitEnum.NONE,
Battery: true,
ConfirmDuty: 60,
BzType: 22114,
BzVersion: 2,
});
const MODBUS_TT = (ebModel: EBModel) => {
for (const info of eventInfo) {
const event = new EventInfoItem(info);
event.upEventSetup();
event.eventInstall();
}
return JSON.stringify(ebModel, null, 2);
};
buildOtaFile(import.meta.url, otaConfig, MODBUS_TT);本项目将布瑞特 BRT38 RS485 拉绳位移传感器通过 KC21 接入 ThinkLink。默认通信参数为 Modbus 地址 1、9600 bps、8N1;KC21 使用电池模式和 LoRaWAN Class A。
接线
- 红:5–24V DC 正极;黑:GND。
- 白:RS485-A;绿:RS485-B。
- 黄:置零线,本次集成不控制。
上报数据
设备上报编码器值、圈数、单圈值、角速度原值,以及 KC21 电池电压、RSSI 和 SNR。 毫米位移和角度需要具体型号的轮周长、分辨率和零点基准;这些参数未确认前不做换算。
参数配置
项目提供 brt38_para_22114 参数物模型,以及 brt38_set_22114 / brt38_get_22114 设置和读取 RPC。可配置 KC21 的采集与上报共用周期(默认 900s)和 Modbus 轮询地址(默认 1); 周期设置会同时保持上电延时 100ms、心跳周期 86400s。模板还挂载 UART 设置 RPC,默认使用 9600 bps、8 数据位、1 停止位、无校验。
这里的 Modbus 地址只改变 KC21 向哪个从站发起查询,不会写 BRT38 的地址寄存器。置零、方向、 当前值及设备地址等传感器写寄存器仍未开放。
部署与联调
模型与模板部署至 PUBLIC,EdgeBus 代码和固件部署至 sx。联调设备为 KC21 6353012b00039567。先读取参数,再设置并读回 period_up=900、addr_modbus=1、 pwron_delay=100、period_heart=86400,确认参数闭环完成。四个设置项均从设备当前 shared_attrs 回填;随后使用 MT-EB 调试 RPC 验证 FC03 分别读取 0x0000×2、0x0002×1、0x0003×1 与 0x0020×2,并确认 22114/V2 业务遥测持续更新。 其中 0x0000 起始地址单次只能读取 2 个寄存器,不能合并为 0x0000×4。
若无响应,依次核对传感器供电、A/B 极性、地址 1 和 9600/8N1。禁止在未确认现场状态时下发置零或改地址命令。