ecat_servo

Open EtherCAT CiA402 servo drive implementation


Project maintained by kubabuda Hosted on GitHub Pages — Theme by mattgraham

EtherCAT compatible servo drives for everyone

I am building EtherCAT adapter for open motor controllers like ODrive, STMBL, or your next thing.

Why that matters

We got a known problem in state of art open source robotics. On one side for years we got things like LinuxCNC: multiple axis, builtin PLC, free, field proven. If its not fit for application, every year progress in development tools (toolchains, code etitors, hardware) makes it easier to roll out custom one that will do the job. On he other side, we got plenty of OSS+OSHW actuators: projects like ODrive, STMBL, VESC and many more. Good to power things from BLDC motor in quadcopter, to benchtop laser ploter, to electric scooter, to industrial machining center. What is missing? Good free way to properly connect one to another. This might not sound like a problem for electric scooter, but starts to be when one tries to build robotic arm, quadruped robot or fast CNC machine, and I will explain why.

How OSS motion control used to be done

Legacy way of motion control in open source was to use step-dir over parallel port. It is simple way to control stepper motors working in open loop (without encoders or other sensors), devised back when everyone used PC towers that had LPT. Some modern digital servodrives are still supporting it, but this starts to be problematic for several reasons.

How it is done now (in open source and entry level motion controllers)

LinuxCNC

Microcontroller based motion controllers

Mach

Mach is not open source, but is affordable PC based controller with large entry level user base

CAN bus

Summary

I am sure I ommited some motion control solutions from this market segment. Let me know if I need to correct something.

How it could be done

We need simple to use, low cost and powerful solution that is compatible with industry standards, that is not totally owned by That One Company Behind It. And we need to make it completely open source, so we can do with it what we want. From all the options above, solution that is nearest to this all is EtherCAT. It gives us fast controller on the cheap, plenty of I/O and actuators to choose from numerous vendors, is properly supported with LinuxCNC, has multiple open source master libraries (SOEM, EtherLab) and more.

What is there to be done

Licensing

EtherCAT Technology Group (ETG) calls it open network, but it is not open as in GPL or MIT license. It means anyone can sign up to be member of ETG and get access to documentation, code samples and code generation tools, for free. It comes however with obligation not disclose any of these materials to anyone who is not member of ETG. EtherCAT trademark licensing implies also that no device can be sold with EtherCAT markings if vendor offering it has no valid Conformance Testing Tool license. Official code stack from Beckhoff is called Slave Stack Code. Licensing on that code prohibits it from being used in open source projects. Luckily there is alternative, GPL licensed stack: SOES from Open EtherCAT Society. This means following project is going to be under GPL too.

TLDR one should be good with using EtherCAT in OSS project if he use SOES, and does not sell anything marked with EtherCAT logo or name

Select motion control protocol

EtherCAT itself is only data link layer. One could roll out his own protocol on top of it, but what we want is to adapt standard protocols for interoperability with devices available on the market. Most popular protocol for EtherCAT is CoE: CANopen over EtherCAT, that mirrors CANopen way of working with Object Dictionary and Protocol Data Objects, but uses EtherCAT network instead of CAN bus. For motion control over EtherCAT, it means CoE CiA402. There is alternative protocol, SERCOS over EtherCAT, which seems to be way less popular and (for new, open source projects) has no real edge over CoE CiA402 that I know of.

This project will focus on CiA402, and will start by implementing its csp mode (cyclic synchronous position), as most convinient to use with CNC controllers like LinuxCNC.

Get hardware

Select ESC (Ethercat Slave Controller) chip

EtherCAT does not require special hardware on controller (master) side, generic Ethernet adapter is all that is needed. On slave side, hardware support is neecessary in form of dedicated ESC chip. Well, it can be also done with FPGA and IP cores are available for purchase but I am going to leave this aside for now.

We will start with cheap, simple to use ESC from known well brand that is available from typical vendors. That is Microchip LAN9252, and we will see how it fares

Adapter board

First thing to consider is which ESC interface is going to be used. CiA 402 will not work with just GPIO, it requires some PDI. We are limited by exposed extension ports on existing OSS-OSHW motion control projects. STMBL exposes SPI1 of STM32F405. ODrive has SPI2 from same MCU. Parallel PDI, called HBI (high bandwidth interface) in LAN9252 docs and FSMC in STM32 docs, is faster, but would eat too many already used pins. We have to make it with SPI.

There are a few LAN 9252 dev boards with SPI exposed. There is range of official evaluation boards from Microchip. Then there is EasyCAT: third party Arduino shield with LAN9252, made by some Italian company that offers it with simple to use code generation tool (which unfortunately is not realy CoE compatible). Same company offers also EasyCAT Pro: small, bare minimum LAN9252 board with SPI breakout, even smaller than EVB-LAN9252-SPI. Its form factor is easier to embed into projects than Arduino shield. At 50 EUR it is pretty affordable, and would be good place to start.

Entire point of this project is to make high performance, end to end open source motion control. It will start from custom LAN9252-SPI board design

Software

Select software stack

Only available open source solution is SOES, released under GPL ver. 2

Execute TODO list

Stuff I already know will be needed:

Disclaimer

The EtherCAT Technology, the trade name and logo “EtherCAT” are the intellectual property of, and protected by Beckhoff Automation GmbH.

Next: LAN9252-SPI PCB design

Back to the table of contents