Showing results for 
Search instead for 
Did you mean: 

How to control a EtherCAT slave (IndraDrive CS) via REST API?

How to control a EtherCAT slave (IndraDrive CS) via REST API?


I have a hardware CtrlX core and have installed the ethercat_master app there. There are two IndraDrive CS MPE drive systems connected to the CtrlX via EtherCAT. Each drive system has a motor attached. The ethercat_master finds the drive systems with no issue; in principle, everything works.

Now my goal is to control the drive systems via REST API. I believe that I have understood the basic concepts of the API and of the data layer. For example, I can read real-time process data from the drive systems via REST. But I can't write realtime process data to the drive systems. For brevity, I'll focus on the master control word in the following description.

Whatever I do, there is no chance to change the master control word that the ethercat_master sends to the drive systems. This works neither via REST API nor via the web UI of the CtrlX. It is also not possible to change the master control word by writing S-0-0134 to the drive systems in the I/O engineering tool. In every case, the drive system seems to accept the written value for fractions of a second, but then the value changes back again.

I believe that the ethercat_master writes the master control word to the drives cyclically, and therefore it cannot be changed by writing S-0-0134 to the drive systems, or by writing values at the data layer IndraDrive nodes that are mapped below the ethercat_master node. Instead, the desired values must probably be written to the ethercat_master (which in turn sends them out to the drive systems). But I couldn't find out yet how to do it. Looking at the data layer, the ethercat_master does not seem to provide appropriate nodes.

Please see the attached screenshots for clarification.

Could somebody please explain what I have to do to be able to change the master control word that the ethercat_master sends to the drive systems?

Thank you very much in advance, and best regards!




Established Member

Hi @Binarus,

It should be possible to write a value to the drive control word on the datalayer there. With a similar setup (ctrlX core OS V2.4 and MPE20 drive) I can write a value both from the datalayer in the webinterface and via a rest client, e.g. to set the drive from state Ab to AH with value 35840. 

Is the etherCAT master + slaves in state OP, and the drive in state Ab (visible on display) when you are sending the command? What response do you receive if you send a PUT request via restAPI? Does the drive receive the new control word value (can be checked with the parameter editor in Indraworks/ctrlX drive engineering)? 





Hi @Yvonne_ 

Thank you very much for your your reply. Your input has been invaluable, because since then I at least knew that it should work as I thought.

Yes, both the ethercat_master and the slaves had been in the OP state, and the drive systems had shown "Ab" in their display. But whatever I did, the drive systems had not accepted any process data I had sent to them, neither via the REST API nor via the web UI. I also had tried to change the master control word in the parameter editor in Drive Engineering, but that didn't work either. While the web UI had shown the new value for fractions of a second, I believe that this was due to a glitch in the UI and that the drive system had not accepted the new value at all, not even during a small time span.

In the meantime, I have found out the cause of the problem: Originally, somebody had installed the PLC app and the Motion app in addition to the ethercat_master app. It had been clear to me that those apps probably would prevent me from using the rest API as intended, so I had disabled them. Obviously, that was not enough:

There were still entries in the scheduler related to them. Even uninstalling (in addition to disbling) them didn't solve the problem. Then I decided to become radical and deleted every entry in the scheduler except the one where this isn't possible. Of course, the ethercat_app didn't work afterwards, but it was easy to add it back to the scheduler.

This finally made the drive systems accept process data. At least, it was working via Web UI last Friday. I haven't tried via REST yet, because it was already later in the evening, but I'm convinced that it now will work via REST as well.

So the cause of the problem was that disabling the PLC and Motion app left inappropriate entries in the scheduler configuration, and that these entries even survived uninstalling the apps.

Without your reply, I would have been unsure whether the REST API and the Web UI should work the way I imagined, and probably wouldn't have looked into the scheduler configuration. Again, thank you very much!

Best regards, and have a nice week!