Mach 4 lua capabilities

When asking about building on another board, I meant design only. Not using other boards.

The 2040 chips, I forgot they were easily purchased for use. I knew that and forgot it. Fun to think that this is so easily built nowadays.

I have used a whiznet Ethernet for a lora gateway I built at some point. Needed to interface into my automation system with things in my yard. I cannot remember what version that was. It’s been years and going without issue ever since.

Good luck finishing the first project. Halfway into one thing I see potential in another thing I discover during the first project from what’s learned along the way. Then I start another thing. Continue that until I die, I think.

1 Like

It is a straight replacement for the ESS. Take out the ESS, add this thing in, connect the ethernet to a RPI running LinuxCNC, done. Nothing on the AvidCNC side changes. Just your motion planner :grin:

Active vibration and ringing reduction is definitely top of my list. I will have the electronics package for measuring it by next week some time. Talk about a pretty penny :frowning:

1 Like

Is that just an imu on each axis?

1 Like

Also, I’ll buy it when you’re done. Definitely

1 Like

Sort of, just an accelerometer like this little monster;

Makes sense. That way you can do what klipper does to allow fast printing without reducing quality.

So, I am starting to add things to my screens and testing them out. However, I would like to add the functionality to windows that exist already and the isn’t editable source for the modules from avid.

Is there a reason we cannot access the source for those? They are all compiled but having the source for the modules would be nice. That way I can remove things that would not be needed, reuse registers and design things to work along with them instead of completely separate.

Michael, as far as I know you can edit the screenset. When you’re talking about editing windows, do you mean things like the touch plate utility (stuff that pops up in a new window?)

Yes. That’s what I mean.

I decompiled the code and I’m looking through it now. I didn’t realize it was fairly simple bytecode compiling.

Found a utility and have the lua now. It’s 13418 lines!

That’s not fun to sift through. I’m going to find ways to make it easier to work with the code. I’ve never used lua and mach seems to pick things nobody wants to use when programming.

In case anyone wants to decompile, just use this from git.

Can you walk me through what you’re decompiling, and why?

I am no expert at all in programming, but anything I could imagine you want to do should be editable right inside Mach using the Zerobrane editor, including I believe PLC scripts.

I didn’t know about that zero brain editor. I’ll see what it gives me.

I want to modify the touch plate setup. Add another touch plate and have settings to give machine position of that plate.

I need 2 types of touching. One for of I’m only doing one tool the whole time that would only use the normal touch plate setup. A second one that touches the plate on the material, moves to the second plate and touches. Records that difference in height to store for m6. Then, the mtc script would be the same but adding the step to move back to the fixed plate and touch. Then subtract or add the difference obtained during the first setup.

Nevermind, I’ve been using the zero brain editor but, you cannot access the luac programs in modules. They are compiled. Decompiling works but, it’s huge and no ability to run it because it’s referencing things that aren’t available while writing it.

Again, huge proviso here that I am NOT a great programmer, and I am very new to hacking around in Mach. Here’s what I do know: Screensets are compiled on the fly and you CAN edit them, and do that exact M6 script you want. I’ve done a similar thing myself.

It took me a while to get my head around the fact that there are modules that you can edit, but you can’t edit them because they are compiled, but in certain situations they are decompiled so you can edit them, only to have them recompiled again.

I’d give you my script, but it’s crap and it doesn’t come with the knowledge that I gained by going on the journey to make it, and learning what I tried explaining in a very confusing way above.

Definitely check out the Lua scripting guide on Mach’s side, the API reference that ONLY in the Mach directory, the Lua examples that are in there as well, and also this:

I just saw that video as recommended on YouTube. I’ll have to watch this and mess around more. I really like being able to use program languages on more than 1 thing ever. I’m going to devote time to something that may not be fruitfull. I’m a little less excited about this now that I’ve seen how convoluted it is.

Thanks for the link and some explanation. I’ll see if I can access those screens somehow through the mach interface instead of external tools. Hopefully they do decompile to work with them in a way that allows testing.

Also, I wouldn’t mind looking at your code even if you’re not happy with it. I am doing this all in simulation and not on the actual machine. I know how harmful that can be already. I’ve got an extrusion cross member to remind me.

You basically are forced to use the internal tools. When you go into screen editing the screen is decompiled so that you can edit it. Once you exit the editor it’s recompiled so that you can run it.

There are some external scripts, like M6 that you CAN edit externally, but get compiled into the screen set so you’re better off editing with Zerobrane.

There’s a video specifically showing how to edit the M6 script that Mach put out, that’s what I followed and my script is a very light variation of that one.

My script won’t work for you because if references registers that you don’t have. I manually made my registers, but it would be better for the script to make them. I haven’t solved for that yet.

There isn’t a way to access the auto z touch plate screen within mach dele editing screens. It runs a script on mouse button up that then loads the poop up window. I wanted to modify that but, I may just need to create a fully separate one. Knowing how they designed it, I guess I’ll figure out after messing with the code enough and reading up.

I guess you made the registers in the registers.json file?

You can manually make registers, which is fine for testing but really should be done in a script for toolsetting because those numbers change dynamically…

My guess is that the touch plate utility was built in WxWidgets. There’s something in one of the Mach lua manuals about how you’d build something like that. I haven’t spent anytime figuring out how the touch plate utility works. There are a few screensets that have similar things so maybe some digging there would yield something.

1 Like

Yep! Its an external lib, actually; https://www.wxwidgets.org/

Also, this helps; https://wxlua.sourceforge.net/

I just got into this with the manual tool load/unload feature I am adding. It makes a prettier popup for instructing the operator.

Thanks. I’ll check it out now. Looking at testing registers to store and recall now.

I have spent a lot of time trying to understand how to get something added to mach4 to do what my mach3 screenset does and I am stumped. The amount of work i have done on this and the little progress I have made with it is not great. I have tried using several scripts for m6 itself that rely on knowing the current tools length in the holder. That could work for some people but, you might as well just have separate gcode files and manually touch off the surface of the material between the different tools used. What is needed in the avid touch plate setup is an extra option.

I am absolutely positive that anyone using the avid machines with the touch plate setup would benefit from having this available to them. I can only hope that Avid or a community member with the skills required can develop this for the community.

I am going to describe what I think would be the best addition to the touch plate.

Within the touch plate program, there should be an option for a second probe location in the xy. Manually type in that machine location.

I have a plate mounted to a post that can be moved out of the way when loading materials. It is connected to the plate so that when the wire is connected to the spindle, it triggers the probe when touched. This can be at variable height because it can be moved. So, what needs to happen on job setup should be like this:

Load material, if job uses multiple tools then there should be a button in the touch plate window that enables a first setup step. This would be setting material zero and then move to the xy location that is stored for the second plate.

You would place the touch plate on the material surface, or bed if you use the bed. Then jog above it and press a button to probe that as z0 in this sequence.
Then z retracts to machine 0 and moves to the xy location of the second plate.
This second place is probed and the offset is stored somehow.

Now that we know the current tools z 0 location and the difference between it and the second plate, we can use that difference to adjust the next tool when the m6 is called.

Since the current avid screenset has a MTC location capture button, this is used during m6.
M6 is called, tool moves to tool change location. Next tool is inserted.
Attach wire to spindle, press next in window and tool moves to machine z 0 to move over to the xy of second plate.
Tool probes second plate. tool 2 touch location updates the difference stored and becomes the new difference stored and tool length is changed according to the calculated difference between the first difference and the second difference.

Go back to position before the start of m6 routine. cycle start to move through the next section of gcode.

I know this is possible. I just suck at programming for mach4 in lua. I also cannot find the time to get deep enough into it. This would benefit the entire customer base though. most of what I do does not leave a location to touch off of because it is gone by the time m6 is called.
Being able to run 1 file for an entire job and knowing that the next tool will be in the right place is pretty comforting.

This would work for the 4th axis as well. On the 4th, I always lose the location. Sheet goods are not as much of an issue.

Please avid, build this into the screenset. It is a huge benefit to all of us. Even if they do not know. They will love it after it exists. My only other option is using mach3 again because I have it there.