Save Variables
07 Dec 2017 12:28 #102739
by andypugh
You probably just need
Replied by andypugh on topic Save Variables
I could imagine a custom M-code or G-code that incremented a counter. (and, potentially, saved the counter to disc)The counter is in HAL code. A dont know how can i count the parts from G code.
See: linuxcnc.org/docs/html/hal/comp.htmlIs there a documentation how to install custom C HAL module.
You probably just need
sudo halcompile --install the_file_name
The following user(s) said Thank You: HalaszAttila
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
07 Dec 2017 13:52 #102741
by Todd Zuercher
Counting something in G-code is extremely easy. I would consider it basic parametric programming 101. Simply assign a variable as your count (or create a named parameter) and add 1 to it after the completion of each part.
Replied by Todd Zuercher on topic Save Variables
The counter is in HAL code. A dont know how can i count the parts from G code.
Is there a documentation how to install custom C HAL module. For me, will be very useful the param saver module. What you think about? Can i use this for general purposes, i want just to save some parameters that changes over time.
Thanks Attila.
Counting something in G-code is extremely easy. I would consider it basic parametric programming 101. Simply assign a variable as your count (or create a named parameter) and add 1 to it after the completion of each part.
%
(Use _count as your part count variable and create it if it doesn't already exist)
o10 o10 if [EXISTS[#<_count>]
(debug, _count exists and is #<_global>)
o10 else
(debug, _count does not exist setting to 0)
#<_count>=0
o10 endif
(insert the g-code to make your part here)
#<_count>=[#<_count>+1]
(debug, Part count is now #<_count>)
m2
%
The following user(s) said Thank You: BigJohnT, HalaszAttila
Please Log in or Create an account to join the conversation.
08 Dec 2017 19:10 #102788
by BigJohnT
Replied by BigJohnT on topic Save Variables
Pretty cool Todd, I assume you just wrote that off the top of your head and didn't get a chance to debug it. I took the liberty to debug and repost a working example. I need to add that to the docs. BTW, if you use %'s you don't need M2, if you use M2 you don't need the %'s because anything after M2 is ignored.
JT
(Use _count as your part count variable and create it if it doesn't already exist)
o10 if [EXISTS[#<_count>]]
(debug, _count exists and is #<_count>)
o10 else
(debug, _count does not exist setting to 0)
#<_count>=0
o10 endif
(insert the g-code to make your part here)
#<_count>=[#<_count>+1]
(debug, Part count is now #<_count>)
M2
JT
The following user(s) said Thank You: HalaszAttila
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
08 Dec 2017 19:50 #102791
by Todd Zuercher
Replied by Todd Zuercher on topic Save Variables
Actually, most of that was lifted directly from the doccumentation, here
linuxcnc.org/docs/html/gcode/overview.html#gcode:functions
(Most of the time I don't bother with % signs, not sure why I stuck them in this time.)
linuxcnc.org/docs/html/gcode/overview.html#gcode:functions
(Most of the time I don't bother with % signs, not sure why I stuck them in this time.)
Please Log in or Create an account to join the conversation.
08 Dec 2017 20:34 #102795
by BigJohnT
Replied by BigJohnT on topic Save Variables
Please Log in or Create an account to join the conversation.
Time to create page: 0.069 seconds