驱动器使用

您所在的位置:网站首页 汇川伺服canopen控制 驱动器使用

驱动器使用

2023-09-16 23:54| 来源: 网络整理| 查看: 265

文章目录 常用mode of operationDS402的状态切换状态迁移的简易代码(读状态字、写控制字)

CANopen对于运动控制来说是一款优秀的通讯协议,采用了面向对象的一些设计思路,比如对象字典,过程数据对象(PDO),==服务数据对象(SDO)==等等。CANopen定义了完整的同步控制机制,使其成为主流的运动控制协议,除了在CAN总线上运行外,还被搬到了以太网上(CANopen over Ethernet),形成了著名的PowerLink,EtherCat工业以太网协议(CoE)。

常用mode of operation

在这里插入图片描述 控制字 control word:

6--------------7---------------15--------------------7 通信前的准备 电机去使能 电机使能 电机去使能

Tips:

1 通信准备工作 control word=6;

2 在进行控制前,先设置操作模式 mode of operation 在使能电机;

3 模式切换,先去使能control word =7, 在重新设置模式。

转自 https://www.cnblogs.com/freshmen/p/4749129.html

DS402的状态切换

一般支持ethercat的驱动器用的都是CoE协议,在配置好PDO后,ethercat的domain中包含了映射的Object Dictionary数据,通过读写domain即可读写对象字典中的对应数据,其中最主要的两个参数( 控制字 和 状态字) 的简单使用如下:

控制字用于控制驱动器的各种状态切换(其中过程 0 和 过程 1 还有 Error Occurs 都是自动切换的,其他状态切换一般需要通过写驱动器的控制字来完成): 在这里插入图片描述 各个状态的解释如下: 在这里插入图片描述 以下是各个状态切换的条件,其中 Bit0、Bit1 等所指的是控制字的对应位:

在这里插入图片描述 在这里插入图片描述

控制字各bit表示的含义 在这里插入图片描述状态字各bit表示的含义 在这里插入图片描述 状态迁移的简易代码(读状态字、写控制字) switch(cmd) { case ServoCommandOFF: // init value: If in Switch_On_Disabled state, change to Ready_To_Switch On { output.control_word_ = 0x06; // operation: Shut down break; } case ServoCommandON: { if( (input.status_word_ & 0x0040) == 0x0040 ) { output.control_word_ = 0x06; // operation: Shut down } else if ( (input.status_word_&0x007f) == 0x0031 ) // FSA State: Ready to Switch On { output.control_word_ = 0x07; // operation: Switch On } break; } case ServoCommandEnable: // 上使能 { if ( (input.status_word_&0x007b) == 0x0033 ) // FSA State: Switch On { output.control_word_ = 0x0f; // Enable Operation } else { output.control_word_ = 0x0b; // 急停, Quick Stop } break; } case ServoCommandDisable: // 下使能 { output.control_word_ = 0x07; // Disable operation break; } case ServoCommandEmeStop: // 急停 { output.control_word_ = 0x0b; // 急停, Quick Stop break; } case ServoCommandFaultReset: // 错误恢复, 错误恢复后需要重新使能 { if( (input.error_code_!= 0) || (input.status_word_&0x0008) ) { output.control_word_ = output.control_word_ | 0x0080; } else { output.control_word_ = output.control_word_ & 0xff7f; } break; } case ServoCommandHalt: // 暂停 Halt On; Warning!!! 在暂停驱动器之前确保控制器已经停止发送位置指令 { output.control_word_ = output.control_word_ | 0x0100; break; } case ServoCommandHaltReset: // 取消暂停 Halt Off, Warning!!! { output.control_word_ = output.control_word_ & 0xfeff; // if ( (input.status_word_& 0x007f) == 0x0037) // FSA State: Operation enabled (正常工作状态) = Switch On + Enable Operation + Quick Stop Off + No warning + Voltage On // { // output.target_cmd_ = data_->out.pos; // } break; } default: output.control_word_ = 0x0b; // 急停, Quick Stop break; } if ( (input.status_word_& 0x007f) == 0x0037) // (正常工作状态)Switch On + Enable Operation + Quick Stop Off + No warning + Voltage On { // 表示进入 Operation Enabled 状态,这里可以控制电机位置,速度,力矩等 } else if ( (input.status_word_&0x004f) == 0x0040 ) // FSA State: Switch On Disabled { output.control_word_ = 0x06; // operaton: shut down } else if ( (input.status_word_ &0x006f) == 0x0021 ) // FSA State: Quick Stop On + Realdy Switch On { output.control_word_ = 0x07; // operation: Switch On + Enable Voltage(强电) } else if ( (input.status_word_&0x006f) == 0x0023 ) // FSA State: Quick Stop On + Switch On { output.control_word_ = 0x0f; // operation: Enable Operation } else { output.target_vel_ = 0; output.control_word_ = 5; // Disable Operation( Switch On + Enable Voltage + Quick Stop On) }

当然,除了用一堆if…else也可以用有限状态机来实现啊,ref link: http://blog.csdn.net/gw569453350game/article/details/50427937

该部分转自博主【风竹夜】,博文地址:https://blog.csdn.net/gw569453350game/article/details/51025425



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3