IGH(ethercat)命令行不能进入OP原因

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

     问题:在使用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;
}

/************************************
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

leecheni

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值