What's new
What's new

Macro Programming Fundamentals

Hello Moriseikiman,​


Most of your messages in the Message Blocks, contain more that 26 characters, including spaces, therefore, will be truncated to 26 characters when displayed. This may have the message not make much sense to the operator; accordingly, an abbreviated message is better than a verbose message that will be truncated.

Regards,

Bill
 

Hello Moriseikiman,​


Most of your messages in the Message Blocks, contain more that 26 characters, including spaces, therefore, will be truncated to 26 characters when displayed. This may have the message not make much sense to the operator; accordingly, an abbreviated message is better than a verbose message that will be truncated.

Regards,

Bill
The longer ones are just comments that are only explanatory for making sense of the program while reading it. They can be deleted before sending it to the machine to save space. Not sure if I sent the final version here so some of the user messages and error messages (#3006 and #3000) might also still be too long, I shortened them as I saw necessary when I tried it out.

It actually works pretty neatly when called from MDI, the last message is always on the screen during the operation even when going between jog and MDI mode, at least on Fanuc 10M.

I also realized after making it that you can find the high or low spot of the arc by jogging the haimer along the edge of a boss or a bore and get the centering pretty close with one take only. And it doesn't even have to be exactly centered to take the first measurement quite accurately. I tried it and it was off much less than the tolerance of that Haimer.
 
Last edited:
There is also a limitation on the maximum number of characters in a block.
I could not continuously type more than 34 characters in a block on a 7.2 inch LCD screen, using the MDI keys. An externally-created program, transferred to the machine, can have more characters.
 
I just saw an old post where angelw says he uses VB to write and troubleshoot macros.
What else is involved besides changing the #'s to another character VB can use.
Is it fairly straightforward to get the VB environment set up?

Thanks
 
I just saw an old post where angelw says he uses VB to write and troubleshoot macros.
What else is involved besides changing the #'s to another character VB can use.
Is it fairly straightforward to get the VB environment set up?

Thanks
Only small changes is the syntax for Conditional and WHILE features, but the structure remains the same. There is no change in the VB environment needed.
In areas of the Macro Program where axes motion takes place, in the VB environment, I format and Print the output to a file and run the resulting file in a CNC back plot program, to confirm the Macro Program will generate the correct axes moves when run on the respective CNC machine tool.

Regards,

Bill
 
Only small changes is the syntax for Conditional and WHILE features, but the structure remains the same. There is no change in the VB environment needed.
In areas of the Macro Program where axes motion takes place, in the VB environment, I format and Print the output to a file and run the resulting file in a CNC back plot program, to confirm the Macro Program will generate the correct axes moves when run on the respective CNC machine tool.

Regards,

Bill
That's great info, thanks Bill!

If I understand correctly, you run the macro program in VB, then use the vb "Print" command to put the pure gcode result in a file (with no macros), and back plot the code in a plotter program? Or do you have one of those plotter programs that understands fanuc macros?

Macro noob here trying to get up to speed. Just got Sinha's book. The macros I've made in a gcode editor get tedious to follow after a certain size. I'm thinking breaking the various functions it does in to different programs...
 
That's great info, thanks Bill!

If I understand correctly, you run the macro program in VB, then use the vb "Print" command to put the pure gcode result in a file (with no macros), and back plot the code in a plotter program? Or do you have one of those plotter programs that understands fanuc macros?

Macro noob here trying to get up to speed. Just got Sinha's book. The macros I've made in a gcode editor get tedious to follow after a certain size. I'm thinking breaking the various functions it does in to different programs...
I just back plot the resulting code in a plotting program.
Yes, there is no Tab Indexing of the Macro Code as in typical programming languages and quite long programs can get hard to follow, therefore, breaking the code up into smaller Macro, or Sub Programs being called by a Main Macro Program or the extended level Macro and Sub Programs themselves is a good methods of structuring the overall Macro to make it easier to follow and debug.

Regards,
Bill
 
Last edited:
Macro noob here trying to get up to speed. Just got Sinha's book. The macros I've made in a gcode editor get tedious to follow after a certain size. I'm thinking breaking the various functions it does in to different programs...
We all had to start somewhere. Sinha's book is a good book. He might even be ok on most days of the week lol. Also look at this one as well. It was Smid that got me started before I met Bill or Sinha.
https://www.amazon.com/Fanuc-Custom-Macros-Peter-Smid/dp/0831131578

Then if you don't understand something drop in and ask.
 
Only small changes is the syntax for Conditional and WHILE features, but the structure remains the same. There is no change in the VB environment needed.
In areas of the Macro Program where axes motion takes place, in the VB environment, I format and Print the output to a file and run the resulting file in a CNC back plot program, to confirm the Macro Program will generate the correct axes moves when run on the respective CNC machine tool.

Regards,

Bill
Getting set up here. I haven't used Visual Studio in 30 years lol

Are you using Visual Studio, or just their "Visual Studio Code" app with some kind of Basic extension?
Seems like the latter would work...

Thanks,
Dave
 
Does anyone know what system variable #3005 is used for? The manual says it is for read/write setting data. What setting data? Chat GPT says it is for #3005 is for displaying predefined messages by their message number. Which predefined messages?
 
Does anyone know what system variable #3005 is used for? The manual says it is for read/write setting data. What setting data? Chat GPT says it is for #3005 is for displaying predefined messages by their message number. Which predefined messages?
The predefined message is your message as in the following example:
#3006=1 (MESSAGE)
Where "MESSAGE" is your predefined message (you would replace the word MESSAGE in the above example with the message you want displayed on the Message Page.

It uses the same syntax as the Alarm System Variable #3000, where the program will be halted when the #3000 Block is executed. Similarly, #3006 will halt the the program, but unlike the Alarm System Variable #3000, the program can be continued after reading and doing whatever may be instructed by the message.

An example of the #3000 Alarm System Variable being used is as follows:

IF[#20 GT 24] GOTO100
--------------
--------------
Program Code
--------------
--------------
M99
N100 #3000 = 1 (TOOL NUMBER OUT OF RANGE)

Example of using #3006 Message System Variable being used is as follows:
G91 G28 Z0.0
G53 X-500.0 Y0.0
#3006 = 1 (INVERT PART IN VICE)
--------------
--------------
Program Code
--------------
--------------
Regards,
Bill
 
#3005 is for displaying predefined messages by their message number
It is not 3005. It is 3006, as mentioned by Bill.
And, there is no message number displayed.
#3006=1 or #3006=2 are equivalent.
The halted program can be restarted by pressing CYCLE START again.
Automatic switch over to the message screen is parameter-dependent.
 
Does anyone know what system variable #3005 is used for? The manual says it is for read/write setting data. What setting data? Chat GPT says it is for #3005 is for displaying predefined messages by their message number. Which predefined messages?
#3005 is used to read or write the data in the Settings area of the control. See the attached from the manual for an 0i series control. To better understand the data, one could try executing #100=#3005 then view #100 to see the data format. No idea what one would really want to use this for. Even less understandable is why someone would look at some shit spit out by Chat GPT rather than believe what is in the manual.
 

Attachments

  • #3005.pdf
    80.5 KB · Views: 4
one could try executing #100=#3005 then view #100 to see the data format
The manual says "Binary values are converted to decimals."
Therefore, i believe, the decimal value stored in #100 will need to be converted to its binary equivalent to understand the data.
 
The manual says "Binary values are converted to decimals."
Therefore, i believe, the decimal value stored in #100 will need to be converted to its binary equivalent to understand the data.
I wonder if then a decimal value assigned to #3005 would be converted to binary? Seems like it must. I don’t have access to a control to test.
 
#3005 is used to read or write the data in the Settings area of the control. See the attached from the manual for an 0i series control. To better understand the data, one could try executing #100=#3005 then view #100 to see the data format. No idea what one would really want to use this for. Even less understandable is why someone would look at some shit spit out by Chat GPT rather than believe what is in the manual.
Thanks. I had to dust off the 18T manual to get a understanding of what this does. The 31i manuals only say what I listed before. It seems like a pretty useless variable unless you want to force one of those settings on in the program. #3005=4 will set the punch code to EIA. #3005=6 will set the punch code to ISO. Nowadays you use PRM[].
Chat GPT is useful for some things, like exacting the last four digits of the astronomical Julian date from the machine date. It writes a pretty close macro program for that with the right prompts.
And thanks Sinha for the compliment on the age. Gen X for life.
 








 
Back
Top