- GCode and Part Programs
- G&M Codes
- Named Parameter Indirection (like arrays of variables in other languages)
Named Parameter Indirection (like arrays of variables in other languages)
15 Apr 2018 19:10 #109085
by yeltrow
I would like to use arrays so that I can have a custom action run on arbitrary places on a gridded fixture. Imagine milling custom sized pockets for coins in a grid. I run batches of custom jobs so having a standard DEBUGGED program with a parameter area would be very handy. I would like to supply something like
(first coin)
#<n> = 0
#<coin_x[#<n>]> = 1
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 1
( second coin)
#<n> = #<n> + 1
#<coin_x[#<n>]> = 3
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 1.25
( third coin)
#<n> = #<n> + 1
#<coin_x[#<n>]> = 5
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 0.8
Ideally retrieval of the data would be something like G0 X<coin_x[#<n>]> --- but I haven't been able to make that work.
This flat out doesn't work. The calculation of the array index gets taken literally as the parameter name of a named parameter.
What CAN work is using something like
(data size of 3 parameters)
#<d_size> = 3
( user parameter location start of array)
#<d_base> = 500
#<n> = 0
(first coin data)
#[d_base + #<d_size> * #<n> + 0 ] = 1
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] = 1
(next coin data)
#<n> = #<n> + 1
#[d_base + #<d_size> * #<n> + 0 ] = 3
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] = 1.25
(next coin data)
#<n> = #<n> + 1
#[d_base + #<d_size> * #<n> + 0 ] = 5
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] =0.8
retrieval would look something like G0 X#[d_base + #<d_size> * #<n> + 0 ]
(zero is the offset from the start of data block for that coin for the "X" variable. Maybe #<x_var>???)
But that is SO GROSS. Any more elegant solutions? Maybe some O code to get/set parameters?
Thank you for your thoughts!
(first coin)
#<n> = 0
#<coin_x[#<n>]> = 1
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 1
( second coin)
#<n> = #<n> + 1
#<coin_x[#<n>]> = 3
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 1.25
( third coin)
#<n> = #<n> + 1
#<coin_x[#<n>]> = 5
#<coin_y[#<n>]> = 1
#<coin_dia[<#<n>]> = 0.8
Ideally retrieval of the data would be something like G0 X<coin_x[#<n>]> --- but I haven't been able to make that work.
This flat out doesn't work. The calculation of the array index gets taken literally as the parameter name of a named parameter.
What CAN work is using something like
(data size of 3 parameters)
#<d_size> = 3
( user parameter location start of array)
#<d_base> = 500
#<n> = 0
(first coin data)
#[d_base + #<d_size> * #<n> + 0 ] = 1
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] = 1
(next coin data)
#<n> = #<n> + 1
#[d_base + #<d_size> * #<n> + 0 ] = 3
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] = 1.25
(next coin data)
#<n> = #<n> + 1
#[d_base + #<d_size> * #<n> + 0 ] = 5
#[d_base + #<d_size> * #<n> + 1 ] = 1
#[d_base + #<d_size> * #<n> + 2 ] =0.8
retrieval would look something like G0 X#[d_base + #<d_size> * #<n> + 0 ]
(zero is the offset from the start of data block for that coin for the "X" variable. Maybe #<x_var>???)
But that is SO GROSS. Any more elegant solutions? Maybe some O code to get/set parameters?
Thank you for your thoughts!
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
Less
More
- Posts: 5007
- Thank you received: 1441
15 Apr 2018 21:21 #109094
by Todd Zuercher
Replied by Todd Zuercher on topic Named Parameter Indirection (like arrays of variables in other languages)
You can set up a repeat array with an o-sub and two repeat calls here is an example.
forum.linuxcnc.org/49-basic-configuratio...9-array-offset#47103
forum.linuxcnc.org/49-basic-configuratio...9-array-offset#47103
Please Log in or Create an account to join the conversation.
24 Apr 2018 16:01 #109552
by andypugh
Replied by andypugh on topic Named Parameter Indirection (like arrays of variables in other languages)
You can do indirection with _numbered_ parameters. It is even documented.
Please Log in or Create an account to join the conversation.
- GCode and Part Programs
- G&M Codes
- Named Parameter Indirection (like arrays of variables in other languages)
Time to create page: 0.093 seconds