Hello Guest it is April 26, 2024, 02:58:16 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - SwiftyJ

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 »
41
Mach4 General Discussion / Re: lua in Mach 4
« on: August 19, 2022, 07:45:12 AM »
Did a bit more searching and I think these guys are going to do what I need once I get the usage through my thick skull. Me smart like tractor.

These next two functions are very helpful inside lua macros (scripts) since they will stop the machine if an error condition occurs (provided you check for and handle that error condition). Either of these functions will stop the execution of the GCode after the macro ends, but will not halt the execution of the macro itself. You will need to put "return" statements in after the calling of these functions, in order to halt the macro itself.
mcCntlMacroAlarm(...)
number: rc = mc.mcCntlMacroAlarm(number: inst, number: error_number, string: error_message)

mcCntlMacroStop(...)
    number: rc = mc.mcCntlMacroStop(number: inst, number: error_number, string: error_message)

I used mcCntlMacroStop in the example I gave you. It sounds like you were trying to use another API call where I put "some gcode string". In the script you posted, you created a gcode string using the string.format and assigned it to the variable Gcode and then use used it in this API call - mc.mcCntlGcodeExecuteWait(inst, GCode). It is here where you would check the return code as I showed in my example.

42
Mach4 General Discussion / Re: what is wrong with this g code
« on: August 16, 2022, 05:28:10 PM »
If you upgrade to a newer build of Mach and then revert back to an older one this graphical error seems to occur. For me deleting the .dat files in the profile folder fixed it

43
Mach4 General Discussion / Re: lua in Mach 4
« on: August 13, 2022, 04:58:56 AM »
To stop it continuing if you press stop you need to check the return code of mc.mcCntlGcodeExecuteWait each time you call it. If you look up the mc.CntlGCodeExecuteWait in the Mach4API.chm file in the docs folder you will see it returns four possible errors one of those being "no error". So you can do something like the following to exit the M6 macro if something happens during execution. The CntlMacroStop call forces the control into idle

Code: [Select]
local rc
rc = mc.mcCntlGcodeExecuteWait(inst, "some gcode string")
if (rc ~= mc.MERROR_NOERROR) then
     mc.mcCntlMacroStop(inst, 6, "Error moving to tool change position")  --The 6 can be replaced with any number, it is just an error number you want to assign. Also custom message can be used
     return --exit the m6 macro
end

Ideally you should check the return codes of when you turn on outputs as well in the same way. Otherwise the activation of an output may fail, such as the draw bar opening, but the machine will continue to move to the next tool position.

44
Mach4 General Discussion / Re: lua in Mach 4
« on: August 12, 2022, 05:03:01 AM »
You're not really gaining anything by using a function there as you are only calling it once.

If you want to tidy things up you can replace that function with all the if statements with the following:

Code: [Select]
local inst = mc.mcGetInstance()
local SelectedTool = mc.mcToolGetSelected(inst)
local CurrentTool = mc.mcToolGetCurrent(inst)

local SigTable = {[1] = mc.OSIG_OUTPUT2, [2] = mc.OSIG_OUTPUT3, [3] = mc.OSIG_OUTPUT4, [4] = mc.OSIG_OUTPUT5}

local TsigSout = mc.mcSignalGetHandle(inst, SigTable[SelectedTool])
local TsigCout = mc.mcSignalGetHandle(inst, SigTable[CurrentTool])

All this does is look up the signal in the table based on the selected tool or current tool

45
Mach4 General Discussion / Re: Read Register from a text file
« on: August 09, 2022, 03:36:51 PM »
There is a standard library that allows you to read/write a file. See the following link for more info

https://www.tutorialspoint.com/lua/lua_file_io.htm

If you can give a bit more detail on what you want to do, might be able to help more. What will the structure of the text file be?

46
If you have assigned the output for the oiler to the toggle button in the Output Signal property, the button state (up / down) will automatically change if this output is activated from else where in Mach.

I would add code to turn on the oiler output in the signal library for the Spindle On output so that every time the spindle output turns on, the oiler will also turn on. If that is what you want of course..

47
Mach4 General Discussion / Re: Line 0: Zero Radius ARC
« on: July 23, 2022, 01:26:10 PM »
I think there is something wrong with the post processor you are using. A lot of your X values have no values after the decimal place and the G2 and G3 commands have 0. values for K and I

48
Mach4 General Discussion / Re: Loss of license
« on: July 10, 2022, 08:23:33 AM »
You are trying to modify the screen script directly which is not possible. You have to do it through the screen editor.

You can watch this video on how to access the screen load script and edit the work zero function

https://www.youtube.com/watch?v=SZuEJn046Pw

49
Mach4 General Discussion / Re: Command to open a specific Wizzard ?
« on: July 06, 2022, 02:48:21 PM »
Can you just copy the code from the wizard into a button on the screen?

Alternatively you could try the following API. But I am not sure if it is appropriate to use this call for running wizards
Code: [Select]
rc = mc.mcScriptExecute(
number mInst,
string filename,
number async)

50
This could be an issue with the pokeys plugin. Are you running the recommended plugin version for the mach4 build you are using?

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 »