问题:在使用IGH操作清能德创伺服的时候,使用命名行ethercat states OP,该命令不能使从站进入OP模式,还会报错。

原因:经过反复测试后,发现是在第二步ethercat config中没有使主站获得伺服配置。
步骤1:需要编辑一个小程序,是主站获得伺服配置
sc_cooldrive=ecrt_master_slave_config(master,CoolDrivePos0,CoolDrive); 使主站获得伺服0配置
sc_cooldrive=ecrt_master_slave_config(master,CoolDrivePos1,CoolDrive); ; 使主站获得伺服1配置
//check_slave_config_states();
printf("master_reset,Retry configuring slaves.\n");
ecrt_master_reset(master); 重启主站
check_slave_config_states();
/** Retry configuring slaves.
*重试配置从站
* Via this method, the application can tell the master to bring all slaves to
* OP state. In general, this is not necessary, because it is automatically
* done by the master. But with special slaves, that can be reconfigured by
* the vendor during runtime, it can be useful.
*通过这个方法,应用程序可以告诉主站将所有从站设置为OP状态。一般来说,
*这是不必要的,因为它是由主程序自动完成的。但是对于特殊的从站(可以由供应商
*在运行时重新配置),它可能很有用。
*/
//$CC test_noPDO.c -o ectest_noPDO -L /home/lee/igh-mc -lethercat
//scp ectest_noPDO root@192.168.58.1:/home/mc
#include "config_qn.h"
void check_master_state(void)
{
ec_master_state_t ms;
ecrt_master_state(master, &ms);
if (ms.slaves_responding != master_state.slaves_responding) {
printf("found %u slave(s).\n", ms.slaves_responding);
}
if (ms.al_states != master_state.al_states) {
printf("AL states: 0x%02X.\n", ms.al_states);
}
if (ms.link_up != master_state.link_up) {
printf("Link is %s.\n", ms.link_up ? "up" : "down");
}
master_state = ms;
}
/*****************************************************************************/
void check_slave_config_states(void)
{
ec_slave_config_state_t s;
ecrt_slave_config_state(sc_cooldrive, &s);
if (s.al_state != sc_cooldrive_state.al_state) {
printf("CoolDrive: State 0x%02X.\n", s.al_state);
}
if (s.online != sc_cooldrive_state.online) {
printf("CoolDrive: %s.\n", s.online ? "online" : "offline");
}
if (s.operational != sc_cooldrive_state.operational) {
printf("CoolDrive: %soperational.\n", s.operational ? "yes" : "Not ");
}
sc_cooldrive_state = s;
}
/*****************************************************************************/
void check_domain1_state(void)
{
ec_domain_state_t ds;
ecrt_domain_state(domainServoInput, &ds);
if (ds.working_counter != domainServoInput_state.working_counter) {
printf("Domain1: WC %u.\n", ds.working_counter);
}
if (ds.wc_state != domainServoInput_state.wc_state) {
printf("Domain1: State %u.\n", ds.wc_state);
}
domainServoInput_state = ds;
}
/************************************
解决IGH伺服配置问题

本文介绍了一种解决使用IGH操作清能德创伺服时遇到的问题的方法,即通过编写特定的小程序使主站获得伺服配置,并通过命令行正确地进入OP模式。
最低0.47元/天 解锁文章
3648





