Strange behaviour of custom component

More
1 year 6 months ago #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 to join the conversation.

More
1 year 6 months ago #326012 by Hakan
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.

Please Log in to join the conversation.

More
1 year 6 months ago #326022 by endian
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...

Please Log in to join the conversation.

More
1 year 6 months ago #326055 by andypugh
I think we need to see the code.

Please Log in to join the conversation.

More
1 year 6 months ago #326063 by endian
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..

Please Log in to join the conversation.

More
1 year 6 months ago #326068 by andypugh

I have not using any kind of global variables 
I think you are, look at line 159:
Code:
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 == ##) "

Please Log in to join the conversation.

More
1 year 6 months ago #326074 by endian
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 to join the conversation.

More
1 year 6 months ago #326093 by endian
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

Please Log in to join the conversation.

More
1 year 6 months ago #326098 by Hakan
As Andy pointed out, those two variables are shared among all instances.
Code:
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.

Please Log in to join the conversation.

More
1 year 6 months ago #326100 by endian
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...

Please Log in to join the conversation.

Time to create page: 0.095 seconds
Powered by Kunena Forum