Help with EtherCAT PDO Mapping for Sensor Integration in LinuxCNC

More
06 Nov 2024 15:04 #313914 by mc_cubus
Hello,

This is my first post on the forum, so please excuse me if I make any mistakes. I would really appreciate any assistance.

I am currently in the process of developing a machine that will use 3-axis kinematics and several additional motors for control (this part is still not fully specified). The system will also include a sensor for distance measurement — specifically, the Confocal Sensor IFD2411 from MicroEpsilon. I plan to have both the motors and the sensor communicate via EtherCAT on LinuxCNC.

Since I do not yet have access to the motors, I am currently focusing on integrating just the sensor as a HAL component into LinuxCNC, to retrieve measurement data.

Current Setup

I have already initialized ethercat-master on the PC. Below is the output after running `ethercat master`:


team@LinuxCNC0:~$ ethercat master
Master0
  Phase: Idle
  Active: no
  Slaves: 3
  Ethernet devices:
    Main: 90:e2:fc:b4:49:03 (attached)
      Link: UP
      Tx frames:   648084
      Tx bytes:    46402960
      Rx frames:   648081
      Rx bytes:    46402780
      Tx errors:   0
      Tx frame rate [1/s]:    179    173    173
      Tx rate [KByte/s]:     10.5   10.2   10.2
      Rx frame rate [1/s]:    179    173    173
      Rx rate [KByte/s]:     10.5   10.2   10.2
    Common:
      Tx frames:   1805865
      Tx bytes:    139386748
      Rx frames:   1805860
      Rx bytes:    139386448
      Lost frames: 5
      Tx frame rate [1/s]:    179    173    173
      Tx rate [KByte/s]:     10.5   10.2   10.2
      Rx frame rate [1/s]:    179    173    173
      Rx rate [KByte/s]:     10.5   10.2   10.2
      Loss rate [1/s]:          0     -0      0
      Frame loss [%]:         0.0   -0.0    0.0
  Distributed clocks:
    Reference clock:   Slave 0
    DC reference time: 0
    Application time:  0
                       2000-01-01 00:00:00.000000000


Slaves

The slaves are detected as follows:

team@LinuxCNC0:~$ ethercat slaves
0  0:0  PREOP  +  ECAT-2513 4-Port EtherCAT Junction(IN/OUT1)
1  0:1  PREOP  +  ECAT-2513 4-Port EtherCAT Junction(OUT2/OUT3)
2  0:2  OP     +  IFC2411


I am using the following topology:  
[Master - PC] <----> [ECAT-2513 - Junction] <
> [Slave - Sensor IFC2411]

EtherCAT PDO Mapping

When I run `ethercat pdos`, I get the following output:

team@LinuxCNC0:~$ ethercat pdos
=== Master 0, Slave 2 ===
SM0: PhysAddr 0x1000, DefaultSize 1024, ControlRegister 0x26, Enable 1
SM1: PhysAddr 0x1400, DefaultSize 1024, ControlRegister 0x22, Enable 1
SM2: PhysAddr 0x1800, DefaultSize    0, ControlRegister 0x64, Enable 1
SM3: PhysAddr 0x1818, DefaultSize   24, ControlRegister 0x20, Enable 1
  TxPDO 0x1a00 "Channel 1 distance 1 TxPDOMap OV1"
    PDO entry 0x6000:01, 32 bit, "Channel 1 distance 1__OV00"
  TxPDO 0x1a30 "Channel 1 intensity 1 TxPDOMap OV1"
    PDO entry 0x6010:01, 32 bit, "Channel 1 intensity 1__OV00"
  TxPDO 0x1a80 "Channel 1 shutter TxPDOMap OV1"
    PDO entry 0x6030:01, 32 bit, "Channel 1 shutter__OV00"
  TxPDO 0x1ae0 "Counter TxPDOMap OV1"
    PDO entry 0x7000:01, 32 bit, "Counter__OV00"
  TxPDO 0x1ae8 "Time stamp TxPDOMap OV1"
    PDO entry 0x7001:01, 32 bit, "Time stamp__OV00"
  TxPDO 0x1af0 "Frequency TxPDOMap OV1"
    PDO entry 0x7002:01, 32 bit, "Frequency__OV00"


At this point, I would like to create an ethercat-conf.xml file to map these PDOs to HAL pins in LinuxCNC, but I am not sure how to do this correctly.

I would greatly appreciate any guidance or examples on how to proceed with this configuration!

Please Log in or Create an account to join the conversation.

More
08 Nov 2024 14:59 #314077 by Organical_rob
Hello, I'm new here too, but I've had to deal with the topic intensively recently.
You can create the ethercat_conf.xml very roughly if you run "ethercat xml" and then copy what is displayed into the XML.

You can then load the XML for testing purposes with "halcmd loadusr -W lcec_conf ethercat_conf.xmf". Now run "halcmd lcec" and then you can use "halcmd show" to see whether it is displaying the variables.

As long as the ethercat master is still idle, you will unfortunately not see any content.

To do this, you have to put together a small dummy machine somehow. Then

addf lcec.read-all servo-thread

addf lcec.write-all servo-thread

must appear in the .hal file so that the values ​​are queried. then look for a machine ini from the demos (which also contains your hal file) and

then start linuxcnc **.ini

if that works, "ethercat master" will show you Phase: operation at the top and you can also look at the values ​​with halcmd show.

I hope that helps a little.
The following user(s) said Thank You: mc_cubus

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum