1

I am learning to control things now. :) I am using SOEM, ethercat stack for the same. PC is my master and servo motor would be my slave. I have learnt couple of things there but stuck at moving the servo motor. I made sure that the data is sent from the master but for some reason, it is not reaching at the slave, i.e. servo motor. That is the reason to reaching out to you guys.

My concise is that it has to do something with the Sync Manager but as a learner, I am not sure.

// Code for reaching the slaves to operational state

// And then I try to control the servo motor by writing to its control word(6040). 
// send_data & receive_data is called as usual for master/slave.

 if(ec_slave[0].state == EC_STATE_OPERATIONAL) {
    uint16 status[1];
    int pointer_2=sizeof(status);
    uint16 uint16val;
    printf("Operational state reached for all slaves.\n");

    for(i = 1; i <= 10; i++) {
      ec_send_processdata();
      wkc = ec_receive_processdata(EC_TIMEOUTRET);
      ec_SDOread(1,0x6041,0,FALSE,&pointer_2,&status, EC_TIMEOUTRXM);

      printf("status=%d\n", status[0]);
      uint16val=0xf;
      ec_SDOwrite(1, 0x6040, 0, FALSE, sizeof(uint16val), &uint16val, EC_TIMEOUTRXM);
      osal_usleep(5000);
    }
  }

The status this code prints is '608'.

Are there any experts out there who can direct me next steps? Cheers to them.

P.S. Please change/add the tags if they do not fit right.

Hemant Bhargava
  • 3,251
  • 4
  • 24
  • 45
  • What are you expecting the servo to do? What does it actually do? The StatusWord is a bitfield; it would make much more sense to print it has Hexadecimal. 608 = 0x260 which corresponds to: Remote + SwitchOnDisabled + QuickStop. Writing 0x0f to ControlWord sets: EnableOperation+QuickStop+EnableVoltage+SwitchOn. There is clearly more to controlling the servo drive than that as indicated in https://www.motorpowerco.com/media/filer_public/be/2f/be2fecd9-844f-4272-99b0-be6352401fa4/flexi_pro_ethercat_canopen_fw141x_rev64.pdf sections 7.7 to 7.14 depending on the operating mode. – Clifford Jul 27 '21 at 12:45
  • @Clifford, Thanks for the response. I do not expect it to much things. Expect it only to move. It can be a small move as well. I would build things from there once I see movement. I believed that ec_SDOWrite should have updated the control word, and move the servo motor. `ec_SDOwrite(1, 0x6040, 0, FALSE, sizeof(uint16val), &uint16val, EC_TIMEOUTRXM);` 0x6040 is the logical address of the control register. Changing that should have started the servo. Right? – Hemant Bhargava Jul 28 '21 at 05:22
  • No. Why would it move when you have not told it how or where to move? That would be dangerous. Clearly you need to read the manual. – Clifford Jul 28 '21 at 06:25
  • @Clifford, Thanks for the response. Yes, that's the question here. What should I do to move it? Clearly, I have not understood and it is difficult to read the manual soon. Till the time I read the manual, I was looking for some help to move forward. – Hemant Bhargava Jul 28 '21 at 08:16
  • Reading the manual should be the _first step_. I have never used etherCAT, I am just looking at the manual and seeing that your code does not even resemble the necessary steps. Since I have no idea about the machine you are controlling, it would be unsafe to advise in how to make it move; and I mean physical injury/death kind of unsafe. – Clifford Jul 28 '21 at 10:08

0 Answers0