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

What is the proper way of setting my motor to operational? #660

Open
UnderJollyRogers opened this issue Nov 3, 2022 · 5 comments
Open

Comments

@UnderJollyRogers
Copy link

I am trying to control Qrob motors using SOEM, I use the following code to set the motors to operational mode:

static int ConfigureMotors()
    {
        char IOmap[4096];
        static int usedMemory = ec_config_map(&IOmap);
        static int expectedWKC = (ec_group[0].outputsWKC * 2) + ec_group[0].inputsWKC;
        ec_configdc();
        ec_statecheck(0, EC_STATE_SAFE_OP, EC_TIMEOUTSTATE * 4);
        ec_slave[0].state = EC_STATE_OPERATIONAL;
        ec_send_processdata();
        ec_receive_processdata(EC_TIMEOUTRET);
        ec_writestate(0); /* request OP state for the motor */
        int chk = 200;
        do
        {
            ec_send_processdata();
            ec_receive_processdata(EC_TIMEOUTRET);
            ec_statecheck(0, EC_STATE_OPERATIONAL, 5000);
        } while (--chk && ec_slave[0].state != EC_STATE_OPERATIONAL);
        if (chk == 0){
            return 1;
        }
        else{
            return 0;
        }
        // cout<<"chk: "<<chk<<endl;
    }

Although the motors works fine, sometimes the motor refuses to set to OPERATIONAL mode. Let's said that 1 of 4 tries the motors cannot go to OPERATIONAL mode. I know that the hardware is fine because I tested the motors using twincat. But still, I am not sure how to increase the reliability of my code.

Any suggestion of how can I improve my code of if there is something missing?

@ArthurKetels
Copy link
Contributor

To have stable and reliable real-time communication with servo slaves see the many older posts about this subject. One I recommend is #487 (comment)

@nakarlsson
Copy link
Contributor

@UnderJollyRogers , can this issue be closed?

@paul218
Copy link

paul218 commented Jun 7, 2023

Hello, I am using the same servomotor (Qrob80).
Were you able to make it work?
I have problems writing and reading the POD mapping. I think is the problem of SYNC time.

@UnderJollyRogers
Copy link
Author

Yes, I was able to solve the problem. I did two things,

  1. I created a for loop to set each slave in operational mode, one at a time.
    For (int i =1; i<=number_of_slaved;i++){
    ec_slave[i].state = EC_STATE_OPERATIONAL;
    }
  2. I avoid using the function: ec_statecheck(0, EC_STATE_OPERATIONAL, 5000);
    Apparently, you just need to check if the motor are in safe operational.

@ArthurKetels
Copy link
Contributor

Sorry to say this is a fake solution. Setting the local structure to operational does not make the slave go to operational state. The result is simply that the slave stays in safe-OP.

The fact that you can still control the slave in safe-OP is a violation of the EtherCAT state machine rules. In safe-OP all outputs should remain in a safe state (i.e. motors should be disabled). Ah well, not all slave manufacturers test their product as thorough as mandated I guess.

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

4 participants