Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: FIREF00X on March 18, 2023, 07:38:38 AM
-
Hello, I'm new to the forum. Sorry for my english, I use translator.
I would like to buy mach4 , but before buying, I would like to know if there is anyone who can convert two scripts for mach3 to mach4 . The two scripts are:
1) auto tool zero , which via a 10 mm high touch pad, resets the tool on the piece to be machined.
2) script for manual tool change. This script measures the height of the tool we want to change using a touch pad positioned wherever one wants, then moves to the "tool change" position, we change the tool and the machine returns to the touch pad to measure the height of the new tool, finally it returns to the position where we left off the previous machining. If anyone can convert them, write here. Thanks
-
Hi,
Mach4 can be programmed to do as you wish, but......this is the big but......Lua is quite different to VB as is the structure between Mach4 and Mach3.
There is no direct translation from one to the other, there is a distinct learning curve, and most people find that they come to hate Mach4 before they
get accustomed to it and come to love it. It would be reasonable to expect that it could take a month of some very intense learning before you
would be confident to start writing your own code.
The Auto Tool Zero is commonplace and you will find that there are many examples from other forum members that you can copy and adapt to your machine.
Tool changers are much harder because it seems that every tool changer is different to the next, and copying someone else's code is not likely to work,
you have to generate your own.
Mach4 has a very distinct learning curve. You would be advised to allow plenty of time for a transition...if you are under strict time constraints for a business
for example that could make something which is just challenging to really bloody hard!
Craig
-
Thanks for the reply.
I'm already trying to understand the new mach4 language, but it's hard for me. It's a pity that when they created mach4, they didn't think of creating a little program capable of converting the many scripts created for mach3 that are out there.
-
Hi,
It's a pity that when they created mach4, they didn't think of creating a little program capable of converting the many scripts created for mach3 that are out there.
There is no such thing, nor is there any translation that takes VB code to Lua, they are just too different.
When I made the decision to migrate to Mach4 it was because I was so disgusted with the bugs of VB in Mach3. So by my reckoning its a good thing that there
is such a marked difference between the two.
Craig
-
Firefoox,
This might help you with the LUA.
https://www.machsupport.com/forum/index.php?topic=45397.msg289143#msg289143
Bill
-
thank you
Since you are so prepared on mach4, I wanted to ask why some scripts that I found here on the manual tool change forum, don't work, they give errors, but whoever posted it, from what I understand, says it works perfectly. But I want to point out that for now I'm trying with the mach4 demo, I don't know if this is the problem.
-
Most tool change scripts are very specific to the machine.
You get the errors because you are missing some of the things the script is looking for.
You can start with one and modify for your machine.
-
Hi,
the problem with tool changers is that they are all different, what will work with one does not work with the other.
The scripts which are released with Mach4 are intended as examples. It may be that one closely approximates your machine so you can copy the script and
modify it to suit. The expectation that your are going to find a script which is exactly right for your machine is doomed to fail.
If you are going to write your own code you'll need:
https://www.lua.org/docs.html (https://www.lua.org/docs.html)
Mach4 uses version 5.3 to my knowledge.
Have you checked out the Mach4 API? It is Mach4Hobby/Doc/Mach4CoreAPI.chm, you'll refer to that document again and again.
My own little contribution for ENUMS, return codes, pound variables and the like is here:
https://www.machsupport.com/forum/index.php?topic=40051.0 (https://www.machsupport.com/forum/index.php?topic=40051.0)
Craig
-
Meanwhile, thank you for your replies, but for now I must admit that I have great difficulty understanding this " Lua ", it will take some time. I understand that a script can be good for one machine and not another, but the ones for mach3 were written in a generic form and it was enough to adapt only some parameters. For example, the manual tool change was nothing more than a touch pad placed in a position (you entered the coordinates where it was positioned) which measured the length of the old tool, then after the tool change it measured the new one and then returned to the point where you had left the work. I believe that many users who have mach3 and their scripts, not knowing how to write them with " Lua " think about it before switching to mach4.
-
hi, I found here a manual tool change script that seems to work, but I have a problem: if I copy the contents of this script in m6.mcs present in the profile macros, when I launch the gcode and the m6 instruction arrives, the script starts automatically. Instead, I would like that when the m6 instruction arrives, it must ask me to press the key I created called "tool change", after which the script must start which will move the axes to a precise point etc etc. How should I do? I tried to copy the original m6.mcs and copied the contents of the script associating it to the key I created, but nothing seems to work. Who helps me? Thanks in advance.
-
Hi,
when you want a macro or script to stop and get either a response or data from the operator you are required to use wxWidgets dialogs.
Talk about starting at the hard place first!!!!
wxWidgets is an open source software library that gives you 'windows' type functions. For instance you might want a file dialog, that is to say a window
that opens with a file directory so you can choose a file to operate on. There are a huge variety of such functions....but I find wxWidgets the hardest thing to
use in Mach4. Note that wxWidgets is not written into Mach4, but rather that Mach4 uses wxWidgets as an imported library. wxWidgets is used by an absolutely huge number
of programs, of which Mach4 is just one....and a small one at that.
The documentation for wxWidgets is superb, it's written for geeks, by geeks and in 'geekese'....you'll come to hate it as I do. If you really want to build your own forms
the best tool to use is called wxFormBuilder. Its an Integrated Development Environment (IDE) and allows you to compose code....but is in itself quite a learning curve.
There are three approaches to this problem:
1) Roll your sleeves up and get stuck into wxWidgets documentation and download and install wxFormBuilder and learn the software as well as is required to achieve the result.
2) Cheat! Find another Mach4 macro that has a wxWidgets dialog that is similar to what you want and copy it. Then you'll have to modify it to match what you want, still a learning curve
but is exactly where I started.
3) Change the macro such that you do not require a wxWidget dialog, of if you do make sure its the exact same as some other dialog that you can copy verbatim.
https://www.wxwidgets.org/ (https://www.wxwidgets.org/)
Craig
-
Thank you. But I'm terribly frightened by all of this. To hook up a key I have to study a program :(. They could have created at least one team to which to make paid script requests.... too bad!!!.
-
HI,
as I said you chose the hardest thing to start with....why? Can you not avoid having to use a wxWidget?
Can you not find an existing wxWidget that does what you want that you can copy?
Presumably if you include an m6() macro call in your Gcode file you want to change tools? Why then do you need to stop and ask the operator?
Is it not redundant?
As it turns out wxWidgets, at least the simple ones that we Mach hobbyists are likely to use, are actually fairly simple....but, and this is the big but......
they still have to be learned. With a concerted effort and some coaching you could be up and running crafting your own widgets in 6 to 10 hours or
so. Most people get really pissed off and walk away long before they learn what needs be learnt and seem to imagine that developing CNC software
should be a s easy as falling off a log. Spoiler....ITS NOT!! Ask yourself the question 'am I the sort of person who gets 'stuck in' and masters challenges or am I the sort
of person who whinges because it does not fall into place automatically?'
As I have said before and I will repeat it, 'the simplest way to include a widget in your code is to find an existing widget which is close and then modify it.'
That is exactly what I did and started from there. I have used wxFormBuilder a few times since then, but still have only a sketchy understanding of it....but I can
with care and patience use it to craft some bloody nifty widgets, even if I do say so myself. Total investment of my time ......guessing 20 hours.
May I suggest you think about an m6() macro that does not require a widget. That is not to say that operator input cannot be used. For instance you might wish to
manually jog to a tool change location, Mach can do that, and all it requires is a <Cycle Start> button press to resume its automatic operation once you have jogged to the required location.
They could have created at least one team to which to make paid script requests.... too bad!!!.
They do, NFS do write code for people and get paid for it including Mach4Hobby and Mach4Industrial.
If you have paid for Mach4Industrial you'll find that NFS roll out the red carpet for you, the extra support is the most substantial extra cost of Industrial.
Unless I'm much mistaken you don't really need that sort of help...you just need to start writing your own code, but do yourself a favor and leave out wxWidgets to start with!
Craig
-
ok thank you
-
Hi,
you may like to think about this API:
LUA Syntax:
rc = mc.mcFileHoldAquire(
number mInst,
string reason,
number JogAxisBits)
Description:
Used to hold G code processing.
When you are running a Gcode file you cannot jog. The trajectory planner can only have one master, and when the Gcode interpreter is consuming
a Gcode file the it is the master. If you want to jog say....you cannot, as that would require the GUI to be the master so as to allow the jogging.
Just pausing the Gcode will not do....you have to release the planner.
It is for this reason that the API exists. If you are sailing through a Gcode file file and you have a m6() macro or similar that you want to execute but requires
that the operator manually jog somewhere, you can put the Gcode file on hold and release the planner. Then operator can jog and/or do whatever needs be done.
LUA Syntax:
rc = mc.mcFileHoldRelease(
number mInst)
Description:
Used to exit a file hold state.
This is the API that releases the file hold and so the Gcode interpreter becomes the planner master again.
This technique uses the <CycleStart> button. This avoids the need to use a wxWidgets dialog.
Craig