That’s the whole macro. You can change those values and save them whenever you want, just open the file, edit it, save and you’re done.
Now write your macro like this:
;My new macro
G65 "YourDefines.mac"
Now at this point in your macro you have all of your defines “loaded” into memory
So you can then do:
m200 "Your pizza is <PIZZA> diameter and has <TOPPINGS> toppings"
So that’s how you “call” your defines. Anytime you run a macro you can “call” your defines like this.
Now if you want to use a macro to create a defines file you can actually do that like this:
#130 = 1 ;dialog timer for text on screen
m225 #130 "Creating tool macro"
M120 "specialdefines.mac" ;create macro for this tool number
m223 "DEFINE <NUMBER> %0.f" #149
m123 ;
This code snippet can be used in a macro to create another macro file with custom defines. So this would create a file called “specialdefines.mac” and in the file it would produce this:
DEFINE <NUMBER> 123 (123 being whatever #149 is)
Hopefully that’s helpful. The best way to learn is to try something like this that’s really simple.
I think there is a misconception here that is important to note. The way I read the Centroid documentation, DEFINE is just an alias or text substitution feature (like it is in many languages). It doesn’t create any variable, it just substitues whatever text was given for whatever keyword. So in the example above, it doesn’t create a variable ProbLocX12 with a value of 16.5, it actually replaces the text ProbLocX12 with the text 16.5 when interpreting or compiling (I don’t know if this is a compiled or interpreted language).
For example, you can’t do math on ProbLocX12 like say “ProbLocX12 = ProbLocX12 + 1”, because that would end up being interpreted as “16.5 = 16.5 + 1”, which doesn’t make sense.
So using DEFINE is a great way to use short names for whole chucks of macro code, or probably better yet to give a sensible name to an enumerated variable, but it does not create or store any data, it only represents some text.
There is in fact no way to create a variable in the macro language as far as I can tell, they are all pre-defined, enumerated variables/parameters that are referenced by their numbers. They are like pound variables in Mach4.
JJneeb - I understand your explanation of the defines function and it’s limitations. What your saying makes logical sense.
Corbin - You posted alot of helpful examples and the way you use your defines to reference Centroid’s user variables reinforces what JJneeb explained.
Eric - your explanation of the macro using pizza size and toppings was very helpful and really made this all click for me. This is probably all the farther I need to go (right now…).
I had this idea of creating a full utility that could program in muliple park locations for different functions and save them into user variables but ultimaly, if I know the 3 (or more) areas I want to stop at, I can just write a simple macro with those locations and if I need to change it I’ll just update it in the macro file.
Eric - I want to make sure I’m not misunderstanding what you are saying becuase I think it also makes sense and it doesn’t neccesarly contradict the way JJneeb explained it but it does seem to approach things from a different angle.
Using the pizza example you gave me, there should be a way to jog my machine to a random location and use your method to define the PIZZA as whatever the X location is and the TOPPINGS as the Y location in such a way that I could then call those locations back up to use with the following macro…
Furthermore I could tell the machine to rapid to location PIZZA,TOPPINGS (using the correct syntax of course) OR using it in formulas, coordinates for a temp WCS, etc…
You CAN do math on a DEFINE just like you showed in your example:
16.5 = 16.5 + 1
The result of that is 17. If you wanted to store that result you can save it back to a macro using the example I show above:
#130 = 1 ;dialog timer for text on screen
m225 #130 “Creating tool macro”
M120 “specialdefines.mac” ;create macro for this tool number
m223 “DEFINE %0.f” #149
m123 ;
So you can update that DEFINE in your special DEFINEs macro with that newly computed value. So so short, you CAN use the a DEFINE that is a straight text replacement to actually store data.
If you follow my example not only is your data stored in your own defines macro, the updated value would be called next time you run your main macro (as long as you have a G65 call for that G65 macro)
I am using this exact method for a lot of our new macros that are coming later this year.
You can jog your machine to any value that / is set to. You can use my example above to set the DEFINE to any location you want either manually or have a macro do it for you
Ya, I was going to point out that that second part could be done. That is basically using a text substitution as a constant value, and then updating the constant value whenever you need to change it. It isn’t a variable, and its not efficient from a code or cpu cycle standpoint, but its about the only thing you can do absent the ability to have user defined variables.
But back to the math part since thats more interesting. You’re saying you can change the value of a Defined word with the equal sign, or are you just saying you can update the word’s meaning by re-defining it later after the math is done on it using constants and variables? I guess I’ll have to try some examples and see if I get runtime errors or not.
I’m a beginner when it comes to the coding but let me see if I’m following the logic…
#130 is a temporary user defined variable that is reset each time power is cycled and in this case you are setting it to a value of 1
M225 is the code for posting the message “Creating tool macro” on the screen for a the duration in seconds that you set for variable 130# in the previous step (in this case 1 second).
M120 opens your macro called “specialdefines.mac” which contains all your custom Defines.
M223 writes a formatted string to the file… I’m a little lost after this. The portion of Syntax “%0.f” indicates that what ever number comes next will be rounded to the nearest integer. #149 is another temporary user defined variable.
M123 records a value and/or comment in the data file but in this case there is nothing listed after the code so what is being written?
Per this example (or snippet of an example), what is actually being written into the defines file that can be called up later? I assume that it is able to overwrite an existing variable of the same name othwise everytime you run the macro your list of defines just gets longer and longer…?
I am genuinely more than happy answer question here, however I think you might be better served by looking at this doc:
Not only is this the Acorn router manual, it’s also the G code programming guide. They list all of the variables that you can use, how you can use them, all of the M code with examples, etc.
This would be your best place to start. I would write some really small programs to test out things you want to do.
If you get hung up on something I can help you here, and also the Centroid forum is really good as well.
Again, not trying to put you off, but if I answered all of your questions above with the context they deserve I’d essentially be writing (poorly) half of that programming manual I linked
I’ve spent some time doing what you suggested in learning some of the programming basics. I can now read through a given macro and get the gist of what is happening. Regarding my request for a list of user defined variables…. I noticed you can generate log of everything that you set up in the AVID Wizard. In that log seems to be all the 97xx variable that avid uses - relative to how you set up your machine. I read through all of them and made consolidated list so that any variable I choose for my program does not conflict.
Im not asking to go line by line and verify this list but it would be helpful to know if using the log is a good way to generate the list or if there is a bunch that are missing because they are generated and and saved somewhere else…
Also, this project is currently centered around adding a intermediate position to change my tools that is different then hovering over the tool touch off plate but I have a few questions.
Is this function already being developed by AVID for a future update? If so, i may not try to reinvent a wheel that is currently being invented…
in the CNCM folder there are multiple macro’s included from centroid (I presume) as well as a folder with AVID’s custom macros. When you using AVID’S control interface, does it rely only on avid’s custom macro’s or does it still use some of centroids stock macro’s as well?
Specifically, is the “mfunc6.mac” what is being used when a tool change is called for on machine without ATC?
Is that the primary macro I would want to modify to include the additional behavior I am wanting?
That is used for every machine and every tool change regardless of what spindle/ATC you have. This script is going to get a MASSIVE update (along with nearly 40 supporting sub scripts) with ATC.
Honestly I would just wait, we already built this for you
Thank you for adding this functionality, the ability to set a specific MTC location is the one feature I was missing from the previous mach 4 controller.
Do you have any feedback for me on whether or not going through the log file created by the utility wizard is a good way to verify what user parameters are being used and which ones should be free?
It’s not how I would do it, but that list is pretty decent.
I think at this point it’s not worth doing because we are largely moving away from those (sort of) and using DEFINE commands to make them more human readable