r2k-in-the-vortex
Hullo, so in summary, what would it take to crossbreed OpenPLC with EtherCAT?

Some background.
Where I'm coming from we are using Beckhoff TwinCAT running on Windows PC(achieving realtime with some clever voodoo using Intel VT-x) and controlling everything over EtherCAT and talking to non-realtime part of the system over Ads(realtime message router that TwinCAT is built around). Very similar to CodeSys.

Now I have no illusions that OpenPLC could approach practical usefulness of these proprietary systems any time soon, but one can dream, no?

The motivation is clearly there, TwinCAT costs ~600-700€ per machine, no bulk discounts. Build thousands of machines and it adds up to a pretty penny. You can run stuff with trial licences for hobby purpose, you just need to manually renew the licence every now and then, but for actual machines, you need to pay a significant amount.

The beauty of EtherCAT is that you can get IO modules of any kind imaginable from many sources, all you really need is a free NIC on the PC and Ethernet cables to chain it all up. It scales like nobodies business and its properly realtime. You can even do safety over EtherCAT, but that is another topic entirely.

For the slave modules EtherCAT is generally implemented in hardware, ASIC-s or FPGA-s, for master, if its PC you need an EtherCAT driver. As far as I know that's all available open source.

So, how to mate EtherCAT to OpenPLC? Where to start?
Reply 0 0
Tecko
very nice project i am able to build my own projekt, on your´s.
i have two questions.
first:
is there a way to implement SOEM in OpenPLC_v3?
second:
OpenPLC_v2 is after a few hours not reachable?
I have to start the nodejs again.
Do you have a solution?
Reply 0 0
thiagoralves
OpenPLC_v2 is long gone and is not supported anymore. In any case, v2 and v3 cores are similar, so I suppose it shouldn't be too hard to port @r2k-in-the-vortex changes to v3.
Reply 0 0
Neidheardt
Hello, this is more related to TwinCAT 3 itself, but I hope I could receive some help on it. I'm working on a project that requires the control of 2 stepper motors. I'm pretty much new to TC3 and I tried to get a motor running, but apparently I'm using the wrong library(I'm running it as if it was a servo). I tried using the controller library to get the stepper function block, but I've never used ST before, so I'm having a hard time understanding how to write the PLC program. I can't even find stepper control example programs, to start with. If anyone could provide me an example code to control a stepper in ST, I'd appreciate it!
Reply 0 0
NWT.Stuff
Neidheardt.

Please advise manufacturer & model of stepper motor you want to control and I'll have a look at it.

Kevin

Reply 0 0
Neidheardt
Thank you for the fast response, Kevin! 
I'm using all-Beckhoff components, so the steppers are AS1010-000 (https://www.beckhoff.com/en-us/products/motion/compact-drive-technology/asxxxx-stepper-motors/as1010.html). The etherCAT coupler is an EK1100, and a EL7031 slice for each stepper. I'm also using TC3 Vision, but I'll look more into it once I get the steppers working.
Reply 1 0
NWT.Stuff
You could try this in ladder https://bulletin.zu.edu.ly/issue_n16_2/Contents/E_06.pdf
Reply 1 0
Neidheardt
The idea was to have everything in structure text, as it would be easier when incorporating TC3 Vision. But I think I'll try Ladder, since I don't have much time to learn ST.
Thank you a lot for the doc you provided!
Reply 0 0
NWT.Stuff
No worries. If you get it working well in ladder it will be relatively easy to convert to structured text 🙂 Kevin
Reply 0 0
mrcstdgl
Hey,

did somebody already achieve the combination of OpenPLC_v3 and EtherCAT?
Would be great if you share your work because i have the same issue now.

Have a nice day,
best regards
Marco
Reply 0 0
mrcstdgl

Hey,

@r2k-in-the-vortex
How did you set up your enp0s3 iface?
I was able to build the whole System, but i cannot connect to the Slaves yet. 

best regards 
Marco

Reply 0 0
r2k-in-the-vortex
Nice to see someone still finds it of interest @mrcstdgl 
It's been a few years so I don't remember all the details, but the key should be getting SOEM to work. I think that either slaveinfo or simple_test was a good indication if things were working or not.

As for any special setup for the interface, I don't really remember any, unless you are trying to run on windows, in that case SOEM needs WinPcap otherwise it can't have raw access to nic.
Reply 0 0
mrcstdgl

I'm actually not running it directly on Windows, but in a Debian Linux VM and the Host-System is Windows.
I actually thougt that i made it work but I can read the Inputs but can't write on any Output. Even if I just put the Input signal on the output, I can clearly see that in the Monitoring of the OpenPLC webserver the Signal for the output is triggered. I also added a small Outputlog and with that I see that the bitWrite function in the EtherCAT.cpp writes the Signal onto the output. But I can't understand why the Inputsignal works and the Outputsignal doesn't...

Do you have any idea?  

Reply 0 0
thiagoralves
EtherCAT is a real time protocol. Running it on top of a VM layer probably defeats the purpose of real time since it can't have direct access to hardware. All it sees is a virtualized NIC. That's probably the main cause for your issues. I suggest you boot a linux OS from a USB stick or something like that so that you can run your code natively. 
Reply 1 0
mrcstdgl
I nearly got it working, the output LEDs are now blinking. But my Problem is that they are blinking and are not set the whole time. I doon't know why this happens, my st-File is just about setting an ourput with an input, but when the input is high the output isn't set high for the whole time, it is blinking with a constant frequency. Do you know what the issue could be?

Update:
The frequency is equal to the task-time -> So I think the issue is that with one cycle only one EtherCAT-package is sent , but shouldn't the Output been set anyways?
Reply 0 0
r2k-in-the-vortex
How long is your task time that you can visually see the LED-s blinking? Normal EtherCAT cycle time is usually 10ms or less, you shouldn't even see a flicker in that case, maybe there is some sort of timeout that needs special modification if you want a slower cycle time. I honestly have never tried to run EtherCAT extra slow.
I think maybe the output module doesn't get a package for what is too long for it and considers it a communication loss or something like that, turning outputs off. That gets reset when the next packet actually arrives and so you get blinky-blinky. Maybe, mostly speculating here.
Reply 0 0
Reply