Welcome, Guest. Please login or register.
Did you miss your activation email?
September 22, 2018, 08:52:21 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  Macro Tutorial
Pages: 1   Go Down
Print
Author Topic: Macro Tutorial  (Read 2035 times)
0 Members and 2 Guests are viewing this topic.
DavidS
Active Member

Offline Offline

Posts: 9


View Profile
« on: October 31, 2017, 02:02:12 PM »

I've been using Mach3 for few years, and up to now managed to avoid writing macros.  Now I need to produce some, and having read many of the posts, I am still stuck as to how to start.  Is there a tutorial anywhere that I have missed?  Just looking at the reference guide does not show the fundamental step by step first moves that I need, mainly because I am still at a very basic level.

Any help would be appreciated!
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 5,973



View Profile WWW
« Reply #1 on: October 31, 2017, 02:21:02 PM »

Look at some of the macros that are included with Mach3.
Or ask specific questions, and other members can maybe explain.

Or look at tutorials for VB programming, but they'll have far more info than you need.
Logged

Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Tweakie.CNC
CNC is only limited by our imagination.
Global Moderator
*
Offline Offline

Posts: 7,402


Super Kitty


View Profile WWW
« Reply #2 on: November 01, 2017, 01:25:32 AM »

Check out the Video Tutorials - The Introduction to Scripting should get you started. http://www.machsupport.com/videos/

Tweakie.
Logged

Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
joeaverage
Active Member

Offline Offline

Posts: 3,956



View Profile
« Reply #3 on: November 01, 2017, 02:00:58 AM »

Hi David,
I was in very much the same position, had used Mach3 without having to get down and dirty writing macros. When I did it was a challenge and then I thought,
'what the hell...if I'm going to learn a new computer language it should be better than Visual Basic, or rather Cypress Enable, Mach3s VB subset, ie it should
be Lua and Mach4'.

Don't get me wrong Lua is a challenge too, maybe even more than VB. Lua itself is easy its once you start adding all Machs API calls and wxWidget calls and
Machs modular structure does it become complex. In addition the programming in Mach4 is modern style, that is to say it is Object Oriented in style and is
quite new and strange to someone like me who cut his teeth on procedural languages like Fortran.

It has taken a while but I am slowly gaining familiarity with Lua/Mach4 and its very satisfying. The complete combination of Lua/Mach/wx.Widgets is very VERY
capable and easily hoses Mach3  and VB into the weeds. I'm glad I made the switch, I was up for the challenge and have been rewarded with a much more modern
and capable toolset.

Craig
Logged

My wife left with my best friend...
     and I miss him!
DavidS
Active Member

Offline Offline

Posts: 9


View Profile
« Reply #4 on: November 02, 2017, 11:36:56 AM »

Thank you for the replies.  My immediate interest is in implementing conditional jumps, such as if...then.  I needed a conditional statement in some code that I was writing, and the advice from the forum was that it cannot be done in Mach3, but could be done using a macro.Taking up ger21's point, could one of our members give me an example of an if command executed in a G code program by using a macro?

Many thanks.
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 5,973



View Profile WWW
« Reply #5 on: November 02, 2017, 12:11:00 PM »

You'd need to explain EXACTLY what you want to do. This may not be a trivial macro.
Logged

Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
DavidS
Active Member

Offline Offline

Posts: 9


View Profile
« Reply #6 on: November 03, 2017, 08:05:19 AM »

Hi Ger21

Thanks again for the quick reply.  A practical example is where a complex profile is being cut.  The program runs through various  cutting profiles at various depths etc. and at an appropriate point it tests the value of parameter #100.  #100 is a function of the thickness of the workpiece and the depth of cut.  Progressive cuts reduce #100, until when the tool breaks through the value of #100 reaches zero.  At this point the tool motion stops, or carries on in the program and does something else.  My intention is to use a Z axis height probe to derive the depths (surface and base) which will be built into the opening part of the program.  I wish to avoid simply using loops which will usually result in substantial over-travel into the material supporting the workpiece.

Example:

N1   {Piece of G code which carries out a number of actions, progressively reducing N
   #100 from, say, 5 down to 0 at which point the program jumps in accordance with the    IF statement}
N10   

.
.
.
.
IF [#100 EQ 0] GOTO 110   

GOTO 200

N110  {Another part of the program. Arrives here if #100=0}

N200 {A different part of the program.  Arrives here is #100 is not equal to 0}


I know that IF...THEN...ELSE and GOTO are available in Fanuc, but clearly not in Mach3.  However, there have been a number of posts that state that these functions can be implemented in Mach3 using a macro.  I have seen some examples of macros, but these use expressions that I have yet to learn.  The macros that come with Mach3 are similar - impenetrable without a primer.  There have been suggestions that I learn by looking at a few examples - although this rather like being advised to learn French by reading a few works by Proust in the original language.   Smiley

If you can give me an example for the above program I would be grateful.

Regards
Logged
ger21
Global Moderator
*
Offline Offline

Posts: 5,973



View Profile WWW
« Reply #7 on: November 03, 2017, 11:00:36 AM »

Quote
However, there have been a number of posts that state that these functions can be implemented in Mach3 using a macro.

Yes, but I've never seen one, and don't know how to do it.
I don't think you can actually jump to another point in the g-code, but I could be wrong. You can test for #100, but what you do after that would probably need to be done in the macro???

It would probably be something like this:

thickness = GetVar(100)
If thickness = 0 then
.....
Logged

Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!