Round system parameter to tenths?

More
24 Oct 2023 01:47 #283654 by nick.smith
Round system parameter to tenths? was created by nick.smith
If I have:

G28.1
(debug , X is #5161)

It will display the result as 5.123456

How can I format it to 5.1234? Also, how can I pull just the integer and modulus?

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

More
24 Oct 2023 01:56 #283655 by cmorley
The following user(s) said Thank You: MaHa

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

More
24 Oct 2023 01:59 #283656 by nick.smith
Replied by nick.smith on topic Round system parameter to tenths?
Excellent, but I'm not on 2.9 sadly.

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

More
24 Oct 2023 11:19 #283690 by andypugh
Replied by andypugh on topic Round system parameter to tenths?
To answer the second question

#100 = [#5161 MOD 10]
#101 = [#5161 - #100]
(debug, #101 #100)

If you want 2.9, it's installable, but I haven't quite finished all the documentation work around the release. But this process should work:
linuxcnc.org/docs/2.9/html/getting-start...dating-linuxcnc.html
Except that the package name is 2.9-uspace not 2.9-rtpreempt. (That's one of the thinngs I need to change)

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

More
19 Aug 2025 08:45 #333664 by xenon-alien
Replied by xenon-alien on topic Round system parameter to tenths?
Hello.
I have the same question.
After probing i have the Z coordinate value.
I measuring 2 points to align the B axis.
I'm doing it 2 times.
The 2nd measuring if gives a result with equal 2 decimals don't rotate the B axis.
Is there a code for the g-code to get a result in parameter, like in the debug
%.xf = x (0-9) number of decimals?

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

More
19 Aug 2025 13:03 #333674 by andypugh
Replied by andypugh on topic Round system parameter to tenths?

Is there a code for the g-code to get a result in parameter, like in the debug
%.xf = x (0-9) number of decimals?

No, sorry. 

But if you just want to compare two numbers to see if they differ by less than a certain amount:
O100 IF [ ABS[#100 - #101] LT 0.01]
  <do stuff>
O100 ENDIF

linuxcnc.org/docs/html/gcode/overview.html#gcode:functions
linuxcnc.org/docs/stable/html/gcode/o-co...ml#ocode:conditional
 
The following user(s) said Thank You: xenon-alien

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

More
21 Aug 2025 09:22 #333754 by xenon-alien
Replied by xenon-alien on topic Round system parameter to tenths?

But if you just want to compare two numbers to see if they differ by less than a certain amount:

O100 IF [ ABS[#100 - #101] LT 0.01]
  <do stuff>
O100 ENDIF


https://linuxcnc.org/docs/html/gcode/overview.html#gcode:functions
https://linuxcnc.org/docs/stable/html/gcode/o-code.html#ocode:conditional
 

Thank you.
I saw that documents, but  I'm not realized it can be done so simple way...

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

More
26 Aug 2025 06:49 #333932 by xenon-alien
Replied by xenon-alien on topic Round system parameter to tenths?
I figured out how to make it work the axis alignment
But on 2.8.4 LCNC my code hangs out the LCNC when i uncomment the:
O100 do
O100 while [#_<ValueABS> GT 0.007]
The whole code in the attachment.

I want to combine 3 measurings in one file (also in attachment), but the same result - The LCNC freezes out without errors.

The decimal test code works fine
Maybe the global parameters makes the issue?
Can anyone tell how to solve this?
Attachments:

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

More
28 Aug 2025 14:00 #334042 by andypugh
Replied by andypugh on topic Round system parameter to tenths?
You may be seeing a problem caused by the G-code preview. That runs through the code to draw the lines, but won't update values based on probe results etc (as it doesn't _move_ anything).

The trick here is probably
O100 while [#<_task> EQ 1.0 AND #<_deltaabs> GT 0.007]

Which will end the loop early in preview generation.

linuxcnc.org/docs/stable/html/gcode/over...ub:system-parameters
The following user(s) said Thank You: xenon-alien

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

More
29 Aug 2025 07:36 - 29 Aug 2025 08:42 #334076 by xenon-alien
Replied by xenon-alien on topic Round system parameter to tenths?

The trick here is probably
O100 while [#<_task> EQ 1.0 AND #<_deltaabs> GT 0.007]
 

Thank you! It's HELPED!!
 
Attachments:
Last edit: 29 Aug 2025 08:42 by xenon-alien.

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

Time to create page: 0.083 seconds
Powered by Kunena Forum