Ethercat random jitter fix

More
7 months 2 weeks ago #344305 by grandixximo
I never discussed with Rob, maybe on next meeting 

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

More
7 months 2 weeks ago #344306 by TAKUYA
Replied by TAKUYA on topic Ethercat random jitter fix
@grandixximo Good news. The patch you did worked. DC-phased is now active and I can see changing values for drift, err, final, out and reset-count. Nothing on the drift and jitter signals though, not sure if that is how it should be. 

Also, regarding the pll-step value with the older version of the patch, it was at 1000. 
The following user(s) said Thank You: grandixximo

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

More
7 months 2 weeks ago #344307 by grandixximo
Yes, drift is a testing value, you need set pll-step to 0 and then set drift, and you can go into the grinding window, it's just for testing, and finding where the grinding window is. You don't need to use, system should be working now, no more grinding.
The following user(s) said Thank You: TAKUYA

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

More
7 months 2 weeks ago - 7 months 2 weeks ago #344310 by 0x2102
Replied by 0x2102 on topic Ethercat random jitter fix
Thanks Luca for all your work around this. I am experiencing grinding noise myself. Very random and I really only noticed it because I have my EtherCat system on a bench for testing, so no machine noise. 

Until now I was running the latest 1.40.0 release from Scott (9/2024) and wanted to try your code to see if that fixes the issue for me. 

While testing your current linuxcnc-ethercat code I encountered a reproducible SIGSEGV in lcec_parse_config().

Minimal configuration:
<masters>
  <master idx="0" appTimePeriod="1000000">
  </master>
</masters>

The crash happens during:
for (slave = master->first_slave; slave != NULL; slave = slave->next)
Even though no slave is defined in the XML.
Looking at lcec_main.c, both master and slave structures are allocated via:

master = LCEC_ALLOCATE(lcec_master_t);
slave  = LCEC_ALLOCATE(lcec_slave_t);

but are not explicitly zero-initialized.

If master->first_slave contains a non-NULL value, the code enters the loop and
dereferences an invalid pointer.

Adding explicit initialization fixes the issue:

master = LCEC_ALLOCATE(lcec_master_t);
memset(master, 0, sizeof(*master));

slave = LCEC_ALLOCATE(lcec_slave_t);
memset(slave, 0, sizeof(*slave));

After applying this change the driver starts correctly.

The issue may have existed previously but remained hidden depending on memory layout or allocator behavior.

I thought I share if anybody else has the exact same issue. 

BTW, I am not that good in coding and had a bit of help from my "buddy". 
Last edit: 7 months 2 weeks ago by 0x2102.
The following user(s) said Thank You: grandixximo

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

More
7 months 2 weeks ago #344311 by grandixximo
I'm not good at coding either, I'm having the code checked by YangYang aka Mika in the forum, he is the master coder lol.

I did quick commit to fix the bug, seems legitimate, it was also present in original master. Thank you for reporting, hope the grinding noise goes away. Thank you for testing the code, would appreciate if you could leave a comment if my branch worked out without grinding noise for you. Thanks.

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

More
7 months 2 weeks ago - 7 months 2 weeks ago #344314 by andrax
Replied by andrax on topic Ethercat random jitter fix
Hi,

I just updated LinuxCNC via the package manager.
When I set `syncToRefClock=“true”`, I still get the error `lcec_conf: ERROR: Invalid master attribute syncToRefClock`.
I've now downloaded the EtherCAT master from GitHub.
When I run `make`, I get the following errors:

Code:
devices/lcec_ep9214.c: In function ‘lcec_ep9214_write’: devices/lcec_ep9214.c:206:23: warning: unused variable ‘hal_data’ [-Wunused-variable]   206 |   lcec_ep9214_data_t *hal_data = (lcec_ep9214_data_t *)slave->hal_data;       |                       ^~~~~~~~ devices/lcec_ep9214.c:205:12: warning: unused variable ‘pd’ [-Wunused-variable]   205 |   uint8_t *pd = slave->master->process_data;       |            ^~ [code]Linking lcec.so ld -d -r -o lcec.so.tmp lcec_main.o lcec_devicelist.o lcec_ethercat.o lcec_pins.o lcec_lookup.o lcec_modparam.o lcec_malloc.o objcopy -j .rtapi_export -O binary lcec.so.tmp lcec.so.sym (echo '{ global : '; tr -s '\0' < lcec.so.sym | xargs -r0 printf '%s;\n' | grep .; echo 'local : * ; };') > lcec.so.ver gcc -shared -Bsymbolic -Wl,-rpath,/lib -Wl,--version-script,lcec.so.ver -o lcec.so lcec_main.o lcec_devicelist.o lcec_ethercat.o lcec_pins.o lcec_lookup.o lcec_modparam.o lcec_malloc.o -lm -Wl,--whole-archive liblcecdevices.a -Wl,--no-whole-archive -L/lib -llinuxcnchal -lethercat -lrt chmod -x lcec.so Compiling realtime lcec_conf.c Compiling realtime lcec_conf_icmds.c Compiling realtime lcec_conf_util.c gcc -o lcec_conf lcec_conf.o lcec_conf_icmds.o lcec_conf_util.o lcec_devicelist.o lcec_ethercat.o lcec_pins.o lcec_lookup.o lcec_modparam.o lcec_malloc.o -Wl,-rpath,/lib -L/lib -llinuxcnchal -lexpat -Wl,--whole-archive liblcecdevices.a -Wl,--no-whole-archive -lethercat -lm Compiling realtime lcec_devices.c gcc -o lcec_devices lcec_devices.o lcec_devicelist.o lcec_ethercat.o lcec_pins.o lcec_lookup.o lcec_modparam.o lcec_malloc.o -Wl,-rpath,/lib -L/lib -llinuxcnchal -lexpat -Wl,--whole-archive liblcecdevices.a -Wl,--no-whole-archive -lethercat -lm (cd configgen ; go build devicelist.go) /bin/sh: 1: go: not found make[1]: *** [Makefile:118: configgen/devicelist] Fehler 127 make[1]: Verzeichnis „/home/ich/Downloads/linuxcnc-ethercat-master/src“ wird verlassen make: *** [Makefile:4: build] Fehler 2
[/code]


Edit:
I've used Git now.
git clone github.com/sittner/linuxcnc-ethercat.git
There were no errors this time,
but the syncToRefClock=“true” still doesn't work.

 
Last edit: 7 months 2 weeks ago by andrax.

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

Time to create page: 0.163 seconds
Powered by Kunena Forum