Strange behaviour of custom component

  • endian
  • endian's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
09 Apr 2025 22:19 #326011 by endian
Hello Gentlmen,

Excuse me, but once again I am facing weird behaviour of custom components file during its programming... 

I need 3 axis there fore I am using a 3pcs of components in the .hal file via count = 3..

I have many IOs stuff because component will communicate with profibus DP driver and it is basicly same as with ethercat but little bit different(other story) But long story short.. when I am homing there we have a custom homing subroutine and modes of driver are changing etc.. issue is comming - I have starting homing with single axis(over internal subroutine), any of them and mode of driver operation is changed over all components==all axis .. what exactly help me right now is have custom names of same component each but it is little bit tricky...

What the behaviour is this overflowing from one to other component in the single instance of lcnc?

Thanks En....

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

More
09 Apr 2025 23:59 #326012 by Hakan
Replied by Hakan on topic Strange behaviour of custom component
Guessing but it sounds like the component uses global C variables.
Check out 8.4 here linuxcnc.org/docs/html/hal/comp.html#_per_instance_data_storage if relevant.
The following user(s) said Thank You: endian

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

  • endian
  • endian's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
10 Apr 2025 10:03 - 10 Apr 2025 10:05 #326022 by endian
Replied by endian on topic Strange behaviour of custom component
I have not using any kind of global variables ... and therefore it is little bit tricky to me 

I have changing mode of operation of servo driver from Velocity 225 to Position 224 ... When I have netted the single one pin for example - from joint.0 to component.0 and others have hard setp opModeCode 225 ... working only single one properly on homing sequence well

But when I netted them all ... every component driver 0.1.2 for example want to change the operation mode for homing just in the moment of single one of then all other are changing too ... I not really understand what is going on but only solution which is working is to create custom component for each axis ... which works well but I do not want have extra custom components when single one with instances should do their jobs same well...
Last edit: 10 Apr 2025 10:05 by endian.

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

More
11 Apr 2025 12:59 #326055 by andypugh
Replied by andypugh on topic Strange behaviour of custom component
I think we need to see the code.
The following user(s) said Thank You: endian

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

  • endian
  • endian's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
11 Apr 2025 14:16 #326063 by endian
Replied by endian on topic Strange behaviour of custom component
Probably .hal and .comp which is overflowing

Excuse me for mess in the component but it is in the working session ...

I am sorry

I will enumerate all hard code and

Is has behaviour as I described higher ... I am confused and I have feeling like something in the working session is mixing together but no way to find it out...

Please let me know what I am doing wrong


thanks
regards E..
Attachments:

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

More
11 Apr 2025 14:53 #326068 by andypugh
Replied by andypugh on topic Strange behaviour of custom component

I have not using any kind of global variables 

I think you are, look at line 159:
enum MODE_SELECTION{WRITEMODE, WAITVELOMODE, INITIAL, WORKING, WAITINGFORENABLE, HOMING};
static enum MODE_SELECTION mode_selection;

mode_selection is a static global in the code. 

I don't know for sure if that is enough to cause the problem? 

it looks like mode_selection should be a local variable (actually, make it a parameter so that you can debug using it)

Also maybe consider using a "switch" command on mode_selection rather than repeated "if (mode_selection == ##) "
The following user(s) said Thank You: endian

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

  • endian
  • endian's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
11 Apr 2025 15:39 #326074 by endian
Replied by endian on topic Strange behaviour of custom component
yes switch will be necessary but my pain was that mixing stuff ... and therefore I erase all switches out to separation possible cases of mixing...

I will try and let you know

thanks

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

  • endian
  • endian's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
11 Apr 2025 17:38 - 11 Apr 2025 18:11 #326093 by endian
Replied by endian on topic Strange behaviour of custom component
I edited the file to switches but no change at all...

I do not know what should be that reason of overflowing datas between components defineted by counts/names

only different component name is helping to split that computing stuff - but it is highly non-efective way to do that
Attachments:
Last edit: 11 Apr 2025 18:11 by endian.

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

More
11 Apr 2025 18:40 #326098 by Hakan
Replied by Hakan on topic Strange behaviour of custom component
As Andy pointed out, those two variables are shared among all instances.
enum MODESWAP{WRITEMODE, WAITVELOMODE, INITIAL, WORKING, WAITINGFORENABLE, HOMING};
enum MODESWAP modeSwap;

enum HOMESTATE{HOMETRIGGER, HOMECONFIRM, HOMESEEKING};
enum HOMESTATE homeState;
It wasn't so easy to just "variable" before the lower lines so you might have to rework that a bit.
The following user(s) said Thank You: endian

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

  • endian
  • endian's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
11 Apr 2025 19:09 - 11 Apr 2025 19:21 #326100 by endian
Replied by endian on topic Strange behaviour of custom component
Okay I got it... But how to customize them to not hard code them ... any ideas which will be readable after some time?

Thank you all...
Last edit: 11 Apr 2025 19:21 by endian.

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

Time to create page: 0.118 seconds
Powered by Kunena Forum