Save Variables

More
07 Dec 2017 12:28 #102739 by andypugh
andypugh replied the topic: Save Variables

HalaszAttila wrote: The counter is in HAL code. A dont know how can i count the parts from G code.

I could imagine a custom M-code or G-code that incremented a counter. (and, potentially, saved the counter to disc)

Is there a documentation how to install custom C HAL module.

See: linuxcnc.org/docs/html/hal/comp.html
You probably just need
sudo halcompile --install the_file_name
The following user(s) said Thank You: HalaszAttila
More
07 Dec 2017 13:52 #102741 by Todd Zuercher
Todd Zuercher replied the topic: Save Variables

HalaszAttila wrote: 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
More
08 Dec 2017 19:10 #102788 by BigJohnT
BigJohnT replied the 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.
(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
More
08 Dec 2017 19:50 #102791 by Todd Zuercher
Todd Zuercher replied the 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.)
More
08 Dec 2017 20:34 #102795 by BigJohnT
BigJohnT replied the topic: Save Variables
I'm thinking of adding that to this section
linuxcnc.org/docs/2.7/html/examples/gcode.html
JT
Time to create page: 0.061 seconds
Powered by Kunena Forum