你好,欢迎来到 HelloCodeSys
当前位置:首页 > 付费专栏
TTC60,TTC200系列控制器CAN通信配置方法
日期: 2020-05-06 14:36:00 分类:付费专栏 浏览量:47151

TTC控制器有专门支撑其can通信的库文件,其can数据的收发通过调用库文件所包含的can接收和can发送函数来实现,具体如下:

附上一段源代码:

IF bInit THEN
toucan_uti_setup_msg_buffer(
E_TOUCAN_B,
E_TOUCAN_MSG_BUF_1,
E_MSG_BUF_FUNCTION_READ,
16#184,
STANDARD_CAN_ID_FORMAT,
8);
toucan_uti_setup_msg_buffer(
E_TOUCAN_B,
E_TOUCAN_MSG_BUF_2,
E_MSG_BUF_FUNCTION_WRITE,
16#186,
STANDARD_CAN_ID_FORMAT,
8);
bInit := FALSE;
END_IF

(*
Depending on the 'change_can' variable send either one or the other of the specified CAN messages
wr_trigger = 1 starts writing the message provided in the byte array
While 'wr_status' is 0 the buffer has not yet been processed
*)
IF (NOT((changeCan))) THEN
toucan_write_msg(
E_TOUCAN_B,
E_TOUCAN_MSG_BUF_2,
16#186,
STANDARD_CAN_ID_FORMAT,
ADR(byte_array2),
SIZEOF(byte_array2),
wr_trigger,
ADR(wr_status));
ELSE
toucan_write_msg(
E_TOUCAN_B,
E_TOUCAN_MSG_BUF_2,
16#123,
STANDARD_CAN_ID_FORMAT,
ADR(byte_array2),
SIZEOF(byte_array2),
wr_trigger,
ADR(wr_status));
END_IF

关于本站

CodeSys

本站致力于为国内中小型公司或个人提供基于CodeSys编程平台的项目承接和项目渠道,并为CodeSys相关从业专业人士提供知识与项目交流平台。

CodeSys自学网 Copyright©常州酷思智能科技有限公司 HelloCodeSys 苏ICP备2021053036号-1 版权声明 技术支持:江苏东网科技
Top