Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking time to go into operational mode #874

Open
Rohithossain007 opened this issue Nov 20, 2024 · 0 comments
Open

Taking time to go into operational mode #874

Rohithossain007 opened this issue Nov 20, 2024 · 0 comments

Comments

@Rohithossain007
Copy link

Hi first of all I am new to this. I am using 2 motors Qrob70. Currently trying to get the motors into operational mode. However it is taking some time initially. Like lets say 5 or 10 secs to get the motor from safe op to operational (I am also using EtherCAT not CAN). Is there any solve to that meaning I want it directly to go to operational mode every time I start the code. Currently I am using this code:

void transition_to_operational() {
char IOmap[4096];

if (ec_init("enp2s0")) { 
    printf("EtherCAT initialized on interface 'eth0'.\n");

    if (ec_config_init(FALSE) > 0) {
        printf("%d slaves found and configured.\n", ec_slavecount);

        if (ec_config_map(IOmap) > 0) {
            printf("Process data mapped successfully.\n");
        } else {
            printf("Failed to map process data.\n");
            ec_close();
            return;
        }

        ec_configdc();

        ec_slave[0].state = EC_STATE_PRE_OP;
        ec_writestate(0);
        ec_statecheck(0, EC_STATE_PRE_OP, EC_TIMEOUTSTATE);
        printf("Slave moved to PRE-OPERATIONAL state.\n");

        //ec_slave[0].state = EC_STATE_SAFE_OP;
        //ec_writestate(0);
        //ec_statecheck(0, EC_STATE_SAFE_OP, EC_TIMEOUTSTATE);
        //printf("Slave moved to SAFE-OPERATIONAL state.\n");

        printf("Switching on the motor...\n");
        set_control_word(0x0006, 0);
        ec_send_processdata();
        ec_receive_processdata(EC_TIMEOUTRET);
        usleep(10000);

        set_control_word(0x0007, 0);
        ec_send_processdata();
        ec_receive_processdata(EC_TIMEOUTRET);
        usleep(10000);

        ec_slave[0].state = EC_STATE_OPERATIONAL;
        ec_writestate(0);
        ec_statecheck(0, EC_STATE_OPERATIONAL, EC_TIMEOUTSTATE);

        if (ec_slave[0].state == EC_STATE_OPERATIONAL) {
            printf("Slave is now in OPERATIONAL state.\n");
        } else {
            printf("Failed to move slave to OPERATIONAL state.\n");
        }
    } else {
        printf("No slaves found!\n");
    }
    ec_close();
} else {
    printf("Failed to initialize EtherCAT.\n");
}

}

Any advises would be appreciated.

@Rohithossain007 Rohithossain007 changed the title Not going directly into operational mode Taking time to go into operational mode Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant