EtherCAT for STM32 - Page 1
Forum section: electronics / projects

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: May 08, 2023, 12:34:54 pm
content: Hi,I'm new to EtherCAT,and one of my customers needs it, so I want to know if you recommend any tutorials and opensource libraries to implement that, Master and salve versions, since there would be a master STM32 and several STM32 slaves, I would probably choose the STM32H series.Thanks

author: ajb
author_rank: Super Contributor
timestamp: May 08, 2023, 02:11:06 pm
content: EtherCAT involves messages that are passed from device to device, where each device processes the messages on-the-fly. As a message is received, the device extracts and processes messages intended for it, injects its own outgoing messages, and recomputes checksums all without stopping the flow of data. This is done to reduce latency and improve the determinism of the overall system. But you cannot implement those features in a conventional Ethernet MAC like you'll find in an STM32. You could do the implementation in an FPGA, or there are interface modules and ASICs available for use with your own MCU, which are probably the way you want to go.

author: EugenioN
author_rank: Contributor
timestamp: May 08, 2023, 08:13:29 pm
content: For an ethercat slave controller you'll need ethernet hardware, custom ASIC specific for the job and firmware with some wizardry.More specifically: a couple of low latency (plus fast link down detection) ethernet phy, a dedicated mac ic to handle frame routing and on-the-fly data processing plus a CPU or micro running the slave protocol fine tuned and tailored to fit and describe your system.Then you should read and understand the over-complicated and obfuscated german-austrian documentation. Then write an xml file describing the slave interface.Also, you should buy from Beckhoff some magic numbers (vendor ID), join the ethercat technology group and buy a conformance test software.The master controller Is simpler: just software.Are you really, really, *really* sure Ethercat Is the only viable solution for your customer?If you need fast communication from a master and a chain of slaves, why don't you use plain TCP sockets? No packets collisions (because of physical topology), so deterministic performances are already thereMy two cents.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: May 09, 2023, 08:11:23 am
content: QuoteThanks for the feedback, do you suggest some chips?QuoteMy customer asked for it, and I know they would not need it, But they are asking for it anyway.

author: Smokey
author_rank: Super Contributor
timestamp: May 09, 2023, 08:25:57 am
content: https://www.digikey.com/en/products/filter/interface/controllers/753?s=N4IgjCBcoLQCxVAYygMwIYBsDOBTANCAPZQDaIcAzAOwCsCAugL4tA

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: May 09, 2023, 10:13:16 am
content: Thanks Smokey,I wonder if we have Chinese players in this field too? do we have Chinese chips for EtherCAT?

author: Smokey
author_rank: Super Contributor
timestamp: May 09, 2023, 10:27:49 pm
content: This maybe?https://en.ctimes.com.tw/DispNews.asp?O=HK33K8VF2OUSAA00NEIn order to be officially EtherCat compliant, you have to pay the Ethercat group a licensing fee, and you need to pass a qualification to make sure your thing complies with the standards.Neither of those things (licensing fees, and compliance) seem very high on the list of Chinese chip manufacturers.

author: jbb
author_rank: Super Contributor
timestamp: May 09, 2023, 11:05:20 pm
content: I used EtherCAT in the past for a work project. It’s got some really good points and some tricky points.Waffle:We built a prototype megawatt-class power electronics converter with EtherCAT control. The PWM was synchronised using EtherCAT clocks (I think we got peak-to-peak time jitter of 100 ns or better). Most ADC readings and all PWM commands were handled in real-time over EtherCAT. Our cycle time was 100 us (i.e. 10 kHz update rate) and very stable. We could have hit more like 40 us, but we wanted to read capacitor voltages, run control algorithm and update PWM registers in a single cycle.Good:- instead of a central Ethernet switch, the devices daisy-chain. It’s not as flexible as a centralised switch but it does make it much easier to get consistent real-time behaviour- you can address several (even all!) EtherCAT peripherals in a chain with a SINGLE Ethernet frame. With TCP/IP or similar you have to send & receive more & more packets as you add more peripherals- the Fieldbus Memory Management Units (FMMUs) are actually really powerful & useful- if you use hardware EtherCAT peripherals (ASIC or FPGA core) you get a really consistent delay of (I think) 1.2us per peripheral. For many applications you can stack up dozens of peripherals and still meet timing.- the clock synchronisation really does work- we didn’t implement it, but allegedly you can connect the last peripheral back to the master controller (this turns a daisy-chain into a ring) and survive a single cable failureBad:- getting your head around the identification, addressing and especially FMMUs can be a steep learning curve- you need to use EtherCAThardwarefor every peripheral if you want the precise clock synchronisation- your EtherCAT master device may need special hardware to get best performance out of the clock synchronisationUgly:- some implementations (we hit this with a paid IP core for Xilinx FPGAs) can update ‘outputs’ from the FMMUseven if the EtherCAT frame has a bad checksumwhich could mean, for example, that a corrupted EtherCAT signal could trigger incorrect control signals. CHECK the documentation for the specific ASIC or FPGA IP core to see if this is a concern

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: May 10, 2023, 11:42:37 am
content: jbb Thanks for your great feedback, Did you only use XIlinx FPGA cores? or did you use some ASICs too?