What's new
What's new

Interactive Macro Educational Resources?

Zahnrad Kopf

Diamond
Joined
Apr 5, 2010
Location
Tropic of Milwaukee
I have a VeryLongTermProject that I've been working on that requires learning how to write some possibly complex macros. I've bought books, I've read forums ( including the sticky, here ), and even tried reaching out to others that are more knowledgeable. ( which is technically, just about anybody... )


No Love. No matter what I try, in very short order, my eyes glaze over and a chrome squirrel runs past. POOF.


What was I saying... ?

Oh yeah... Macros... Is anyone aware of an interactive educational resource that might help me learn what I need to learn in effort to write what I need? Ultimately, I want to machine a family of parts that are similar, but editing in various values to result in the creation of the machine movements that will result in the machining of each member of the family. There will likely be approximately 20 values that change each time. I have all the math, already. I even have an Excel spreadsheet that calculates most of what is needed, including some of the machine movements. I'm looking to take this to the next level by having all of this in one or a few macros that will then actually _do_ all of this...

I would post everything here, but there is much of it that is covered by NDA, and some may even be proprietary. So... that's not much of an option at this point, unfortunately.

Any help? Anyone? I'd even consider paying someone to help, but I'm not even sure what that might cost. Ultimately, I really want ( and need ) to learn for myself.
 
Could you do it instead with parametric CAD and integrated CAM? I've done this with Fusion 360 to make similar parts of all different shapes and sizes with some variables and some math. Open variables window, change two or three variables, robert is your father's brother.

Go to CAM, regenerate toolpath, post to machine.

I can see the advantage of doing it all in gcode with macros, but I know it's not too complicated to do the other way and I'd rather make it happen at a PC instead of standing at a machine control.

EDIT: Swapped CAD for CAM and CAM for CAD. One of those days.
 
I know you said you’ve read books but have you read this one?

Yes. The Smid book was the very first one I bought when I started out with this idea. In full disclosure, I have not looked at the CD yet. The damn chrome squirrel always runs past before I can even remember to do so. But I will check right after I finish typing this.

Could you do it instead with parametric CAM and integrated CAD?

< SNIP >

... and I'd rather make it happen at a PC instead of standing at a machine control.

No. First off, there is no CAM that will actually allow what I am doing. You'll have to just believe me on that one. I have worked in every quality CAM system available at one point or another during the last 30 years and have always had this idea. For the reasons that I outlined in my original post, I cannot post the "why" of it. But trust me, there are none that allow manipulation of the sort I need.

Ironically, it's bone simple to do manually.

As for the last part of your reply - No. In fact, I would MUCH rather do this at the control if at all possible. In my head, I see being able to simply edit or write a few of the parameters that change from part to part into the macro, and let it do all the math and path.

Boiled down, they are all straight line moves in two axis. Three for positioning. It is their locations and specific values that are the only real changes.
 
"macros" on CNC are a just a set of (pretty crude) programming extensions to a crude base language. Which means that if you aren't a general computer programmer to begin with they are a hard way to learn.

So the first question is, how are your fundamental programming skills (G-code misses most of them - lots of CNC programs don't actually have variables, real predicates, etc.)? If you can work in say C or Fortran then CNC macro will be about finding "what constructs are available to let me make up what I actually want."
(There's a second level you will need, in which you come to grasp deeply how any algorithm can be expressed with any crude branching mechanism, though it may look really awkward...)

I would suggest that "learning to program with variables, conditionals (predicates), and loops, on PC" is a good first step if you don't already have those skills. There will be less of the "chrome squirrel" because you can write little programs, run them, debug them, change them, and get "hands on". [The chrome squirrel appears in part because nobody really wants to read or remember "on model A machines variable #63457 is 1 if comp mode A is in use, or Z if comp mode B is in use, machines with comp mode C will not have a variable #63457, model B machines ....."

The next step is to figure out how to print status (variable values, messages) out of a macro to the screen - without actually doing anything. Now you can develop your macro part way, run it, see it print the right values ("COMPUTED NEW Z = 7.4375") - and know you have the computation right, and with prints that say where you are in the program, the flow control right.

Now you filli in the actual machining commands, which are logically pretty simple though they have a very awkward syntax.
 
Thank you for the input, Bryan_Machine.

To be honest, the chrome squirrel is less about the subject matter, and more about the student. A lifelong condition both afflictions wrapped into one. ( "Ooh! Shiny!" & "Look! A squirrel!" ) Now add in all the normal things small shop owners deal with daily and it doesn't really make a good learning environment.

As for programming, I'm capable in general, but trying to do this while we also look for our new location, wrangle the construction planning, and try to keep the shop going while scheduling work through and making sure we keep getting more work, as well.

Long ago, in another lifetime, I taught myself PERL. I've learned a few other languages over the years, but that one was by far, one of the more difficult tasks. Of course, that's one of the things that has served to really hamper any real progress on my part with this. With everything else, there have been programs and widgets that one can install on their PC to interact with and test out efforts. I have yet to find something like that for cnc macros. Hence, the post. :)

That is also why I mused that I may end up having to have someone do this for me and then try to learn from the examples...
 
Yes. The Smid book was the very first one I bought when I started out with this idea. In full disclosure, I have not looked at the CD yet. The damn chrome squirrel always runs past before I can even remember to do so. But I will check right after I finish typing this.

I checked it. Bit of a chore since this laptop doesn't have an optical drive. Made me remember why I never got that far. LOL. Anyway, the CD is simply just a few text editor examples of some of the ones in the book. I'm sure they're helpful in their context, but not for me in this instance.

Still looking for a better way to learn macro programming. Alternatively, someone that can hold me hand along the journey might be needed. Failing that, I am going to try and find a way to dumb down some of the specifics of what I need, and see if I cannot find a way to post those as general questions, here.

Thanks.
 
I'm just worried that I've never seen a chrome squirrel. Does that make me weird? Or are you the weird one? Or is the squirrel watching US run by HIM? :scratchchin:

Macros are useful, and I use them quite a bit, but I think they suck to learn too. The best advise I have is to actually write a macro on a machine and run it. Maybe carve out a few hours after work to mess with it. Simple stuff, like:
#800 = [#800+1]

Write that in MDI, pull up your macro variables list in your control, hit cycle start a bunch of times and watch #800 increment +1 every time you hit cycle start.

Then write:
#800 = 3.
G0 G91 X#800

Okay? Now cycle start will move X 3 inches positive. Now change the number in #800 to some other number and hit cycle start. Now type G90 and cycle start! :)


Just start screwing with things like this, and pretty soon you'll see the magic fairies, (or chrome squirrels, or whatever other mythical creature you want to conjure up next ya fuckin' weirdo) works to move numbers around to other places and be used in meaningful ways. At least that's how I learned on my own.

EDIT: You might think about posting exactly what it is you want to do. There are a million different ways of going about the same thing with macros, and your thing might be simpler than you think.
 
I'm just worried that I've never seen a chrome squirrel. Does that make me weird? Or are you the weird one? Or is the squirrel watching US run by HIM? :scratchchin:

Matt, you shouldn't worry. I am definitely the weird one. Well... in this specific case, anyway... :rolleyes5: LOL

It's more of a double whammy combining "Look! A squirrel!" and having the added, "Ooooh... shiiiiinnnnnyyyyyy..."


Macros are useful, and I use them quite a bit, but I think they suck to learn too. The best advise I have is to actually write a macro on a machine and run it. Maybe carve out a few hours after work to mess with it. Simple stuff, like:
#800 = [#800+1]

Write that in MDI, pull up your macro variables list in your control, hit cycle start a bunch of times and watch #800 increment +1 every time you hit cycle start.

Then write:
#800 = 3.
G0 G91 X#800

Okay? Now cycle start will move X 3 inches positive. Now change the number in #800 to some other number and hit cycle start. Now type G90 and cycle start! :)

Just start screwing with things like this, and pretty soon you'll see the magic fairies, (or chrome squirrels, or whatever other mythical creature you want to conjure up next ya fuckin' weirdo) works to move numbers around to other places and be used in meaningful ways. At least that's how I learned on my own.

EDIT: You might think about posting exactly what it is you want to do. There are a million different ways of going about the same thing with macros, and your thing might be simpler than you think.

You are correct. And I have in fact done that. I grok that much. The part that I'm losing my focus on is the combination and syntax order for how to eat the whole meal, if you will.

I know how to do all the math required for the various calculations.
I know how to NAME all the various variables that I foresee being required.

I do not understand how to arrange all of it within a macro and call upon those in order to have it spit out the program.

Having just said ( written ) that, I wonder if this may not actually be more of a program + macro type deal... Where I define the one, basic move ( that all others are a variant of ) within a program and then use the macro to affect the changes to the basic variances of those moves...

:scratchchin:

Gah. Damn chrome squirrel just ran by again...
 
Maybe I should just start like that,...

Okay.

So, one of the things that will change from sibling to sibling in the family of parts is the length. It could be 1/2". It could be 2".

I envision that the mill will always start by entering at a certain depth in the part, and travelling from Part Xstart YDepthOFCut Z0.000 to Part Xend YDepthOfCut Z0.000. And that length is always part of the user inputs.

Am I asking too much to have it also add entry/exit to the moves? Can that not also be part of the calcs?

Let's assume that the part is in the rotary, in A axis. Typical Y&Z at center of rotation. Let us assume a 2" diameter Keyway mill, a 2" square part, and cutting a 1/2" deep keyway/slot.

So, in the beginning user inputs a Part Length value at a prompt of 2.0" And also a depth of cut of 1/2".
I envision this looking like -


Part Start?
#800 = 0.

Part End?
#801 = 2.

Depth Of Cut?
#803 = 0.500

Diameter of mill?
#804 = 2.0


And it taking that input and using it in the output -

G1 X-0.500 Y[#804/2]+#803 Z0.000 F20.
X#800 Y[#804/2]+#803 Z0.000
X#801 Y[#804/2]+#803 Z0.000


So does all of this need to be written in a separate program and macro? Or can the macro be configured to spit all of this out?

There is MUCH MUCH more, but this is a starting point, I guess... Thanks.
 
Your entry or exit will be extra moves.

#805 = #800 + [math to define start]
#806 = #801 + {math to define end]

G1 X#805...
G2 .... ; to arc from #805 to #800 ; say
; now in theory at #800
<code as before>
G3 .....; to arc from #801 to #806 say

If you want to sometimes do entry/exit and sometimes not, you need an #if statement.
 
Your entry or exit will be extra moves.

#805 = #800 + [math to define start]
#806 = #801 + {math to define end]

G1 X#805...
G2 .... ; to arc from #805 to #800 ; say
; now in theory at #800
<code as before>
G3 .....; to arc from #801 to #806 say

If you want to sometimes do entry/exit and sometimes not, you need an #if statement.

Thanks. That is very similar to how I was envisioning it, as well. A few of the questions/concerns that it brings up are that this can easily start adding up the number of variables being used and we've not even gotten to the mathematical part of my PetProjectProblem yet so do we REALLY want to do this? I think we do, but then that also begs the concern over if we wish to make this radius value a user input, as well. Again, I think we do. So, again we are adding complexity and number...

So, now I need to redo my variables list...


Side note - the NCPlot Macro Expression Calculator* says that my expression is bad. I won't be at a machine to check it until Monday at the earliest so wonder if you might see why.

It doesn't like something about these -
X#800 Y[#804/2]+#803 Z0.000

* - NCPlot - Macro Calculator
 
I am not sure it will help, but I have all of the macro programs from another lifetime where we cut many different gears and all the operator had to do(besides change chuck details) was change a thumb wheel on the side of the controller. These were ring and pinion sets, 6-1/4, 7-1/4, 8-1/4, and 9-1/4 with every ratio available in each size. It was quite complicated to write but simple to follow.

If #501 didn't equal #599(the thumb wheel) the program ran a sub-program to find the program that equaled #599 and would load new macro values into the main cutting program. Even the rpm's were written to macros. Not sure that would help you or even if that is what you are looking for, but what's mine is yours. :)
 
Thanks, D! ( great to see you, by the by! ) I don't know ( to be honest ) but I'm sure I could glean a few things from the syntax and logic. I'll shoot you an e* right now. Thanks. I appreciate the offer.
 
This is a little off the wall but ... I've found that in programming, you don't train the computer, the computer trains you. So if you're not very trainable, then finding a language or system that is similar to how you normally think is easier than trying to think like an Egyptian.

If you can do this easily with an Excel spreadsheet and manual input, maybe take a look at APL/2 ? It's weird but might be weird in the way you are. I personally like it, it's much more interactive than most languages.

But it may be even worse to you :D Only way to know is try it out and see. Getcher fingers dirty. Go out to the Bridgeport and take a cut. That kinda thing.
 
Still looking for a better way to learn macro programming. Alternatively, someone that can hold me hand along the journey might be needed. Failing that, I am going to try and find a way to dumb down some of the specifics of what I need, and see if I cannot find a way to post those as general questions, here.
Thanks.

Hello Zahnrad Kopf,
Get a copy of VB6 and develop your Macro in that environment. The syntax is quite similar and the resulting Source Code can be converted to the exact User Macro syntax via Global Replace of characters that have to be changed. I write a lot of Macro programs for clients and they are all developed using VB. Where NC axis moves are involved, I output them to a file and back-plot the result.

In terms of variables, I use "V" instead of "#" (# defines a numeric variable as double precision in BASIC and can't be used in Variable naming). When it comes time to actually create the User Macro program, "V" can be Globally replaced with "#".

One very big advantage in using VB, is that if you're not familiar with programming, there is a myriad of resources available.

Regards,

Bill
 
I don't know if this will help at all or not... but thought I would throw it out there.

One of the companies I used to work with hired a guy to come in and teach the guys in the tool room macro's. We all had varying levels of knowledge and ability, so he went through basics building up to more complex. He taught the "how" as far as building the structure and process. Then we spent maybe a half day writing some macro's we actually needed in the shop.

One of the guys I worked with was a wiz when it came to macros. He wrote(?) an app for his tablet that allowed him to write macro's and test their logic to see if they would work. These two got to talking in martian and it was clear the instructor knew his stuff.

Somewhere.... I may have his contact info. If that is something you would want to pursue.
 
Hello Zahnrad Kopf,
Get a copy of VB6 and develop your Macro in that environment. The syntax is quite similar and the resulting Source Code can be converted to the exact User Macro syntax via Global Replace of characters that have to be changed. I write a lot of Macro programs for clients and they are all developed using VB. Where NC axis moves are involved, I output them to a file and back-plot the result.
In terms of variables, I use "V" instead of "#" (# defines a numeric variable as double precision in BASIC and can't be used in Variable naming). When it comes time to actually create the User Macro program, "V" can be Globally replaced with "#".
One very big advantage in using VB, is that if you're not familiar with programming, there is a myriad of resources available.
Regards,
Bill

Bill,

Thank you for weighing in on this. I appreciate it. As for your recommendation, thank you. You just made it click for me as to why this looked so familiar, yet so frustrating. You are correct. I will look into that. Good tip.


I don't know if this will help at all or not... but thought I would throw it out there.
< snip >
Somewhere.... I may have his contact info. If that is something you would want to pursue.

Thank you. I actually would be open to this. I'm sure others here might be, as well. Unfortunately, I'm not sure the economics of a two person shop ( three with one admin ) correlate with arranging such a visit, but I am more than willing to look into it. Especially if we can use more of it in here.
 








 
Back
Top