2.9.2 issue: The initial stat.5x_offset is 0 instead of 1

More
19 Jan 2024 20:47 #291147 by vmihalca
HI guys,

I have a wierd issue on my machines. I have a development laptop, with debian 12 and the latest linuxcnc 2.9.2 compiled from sources today. 
Then I have the minipc that runs the lathe, same debian 12, same revision of linuxcnc 2.9.2 compiled at 10 minutes time difference. 
I am building a custom UI for my lathe and I noticed this issue only on the lathe machine but not on the development machine. 
On the lathe machine, calling 'stat.g5x_index' returns 0, while on the development machine it returns 1
According to the documentation, it should return 1 for G54
g5x_index (returns integer) - currently active coordinate system, G54=1, G55=2 etc.

On the the development machine, the result is correct, and I can't figure out what's the difference. In order to test its not something related to my app, I switched the UI to axis, and launched the app, and noticed that on the coordinate system displayed on the plot is G53 instead of G54. 
I have no idea what I'm doing wrong. You can see in the attached picture what the issue is. 

photos.app.goo.gl/g22NPhzSDsRDMYFJ6

Also I launched a simulated configuration on the lathe and I noticed that there it loads correctly with G54, so I assume its something in my config files. I have tried with both startup codes including G54 and not including G54, and the result was the same. 

Please give me some hints, I've wasted 4 hours on this today.

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

More
20 Jan 2024 07:41 #291166 by cmorley
it sounds like a race condition.
The hal_glib library (used in gladevcp gscreen, and qtvcp) has a forced_update() function that is called just before the GUI's main loop.
This is probably the reason it doesn't show up in those screens.

You could do the same or make your code to ignore 0 and use 1 instead.

Chris

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

More
20 Jan 2024 13:29 #291204 by vmihalca
Yes it was a race condition, but not the one I was ever expecting.
I have my configs distributed across multiple hal files, so excepting the main one, I ended up commenting all of them and testing to see that it shows G54, then uncommented one by one and tested until I isolated the one with problem. Then inside that file I commented/uncommented lines until I found the problem.

TLDR: I have a relay that's toggled by some On/Off physical buttons, and a contact from that relay goes into linuxcnc as input. When the relay is ON, the input is ON

I had something like this:

input-01 -> halui.machine.on
input-01-not -> halui.machine.off

Belive me or not, this was the cause of the issue, I would have not discovered it just by logic not in a thousand years.
It seems that these pins are expecting just to be pulsed on or off.
One solution would have been to use some onsehsot component, but I did it in ladder, so now I I just pulse this pins when the relay turns on/off.

Hope this will help others, I am glad I found the issue.
If someone can explain what was actually happening, I would be happy not to die stupid.

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

Time to create page: 0.050 seconds
Powered by Kunena Forum