开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Forgot how to change spindle direction

 

开云体育

Hi Everyone,

?

I haven’t used my mill in a while. I’m trying to cut some stock and noticed that my spindle is running backwards. How can I change the direction of rotation?

?

Thanks,

?

Terry

?

?

?

Sent from for Windows

?


Re: Mach3 Tool Wear Compensation

 

开云体育

Mach3 does not support tool wear comp. It does nothing with that value.



On 2/27/2023 11:18 AM, Ben Fleming wrote:

I understand that there is a tool wear compensation available in Mach3 but? the only place I can find anything associated with this concept? is on the tool table where it say Diam. wear.

I am using Fusion 360 to generate G-code under compensation Type there is a wear option.
I would like to be able to use this when doing final cuts for bearing bores.

I don't understand how to implement this in Mach3

I have read there is a Tool control tab in Mach 3 but I have yet to fine it.

Please advise


Mach3 Tool Wear Compensation

 

I understand that there is a tool wear compensation available in Mach3 but? the only place I can find anything associated with this concept? is on the tool table where it say Diam. wear.

I am using Fusion 360 to generate G-code under compensation Type there is a wear option.
I would like to be able to use this when doing final cuts for bearing bores.

I don't understand how to implement this in Mach3

I have read there is a Tool control tab in Mach 3 but I have yet to fine it.

Please advise


Re: Rhino3D, Meshcam and Mach3

 

开云体育

I am curious as to why you want to use MeshCam overRhinoCam? What version of RC do you have and do you pay yearly maintenance??

Cheers,

Terry

On Feb 18, 2023, at 12:02 PM, Gary <g_burke@...> wrote:

There is a mach3 mm and inch post in the Meshcam post directory when installed?
?
Sent from??for Windows
?
From:?Steven DAntonio
Sent:?Friday, February 17, 2023 10:31 PM
To:?[email protected]
Subject:?[MachCNC] Rhino3D, Meshcam and Mach3
?
Hi

Let me ask a quick question without doing my due diligence or research before hand

I'm currently working with Rhino3D, RhinoCAM Mill, and Mach3 on a home made CNC.? I've heard good things about meshCAM from other violin makers and a thinking of giving it a try (since RhinoCAM is getting a bit pricey).

I was looking around for Mach3 post processors for MeshCAM and am not turning up anything that jumps out at me and says "here it is".? The meshCAM site says comparable with Mach3. Does this mean they have a Mach3 post is supplied in their software?

Anyone have any feeling for how well meshCAM works with Mach3?

Thanks
Steven?

?
<97C07826CDF54615A0344DCBE67A78B8.png>


Re: Rhino3D, Meshcam and Mach3

 

开云体育

There is a mach3 mm and inch post in the Meshcam post directory when installed

?

Sent from for Windows

?

From: Steven DAntonio
Sent: Friday, February 17, 2023 10:31 PM
To: [email protected]
Subject: [MachCNC] Rhino3D, Meshcam and Mach3

?

Hi

Let me ask a quick question without doing my due diligence or research before hand

I'm currently working with Rhino3D, RhinoCAM Mill, and Mach3 on a home made CNC.? I've heard good things about meshCAM from other violin makers and a thinking of giving it a try (since RhinoCAM is getting a bit pricey).

I was looking around for Mach3 post processors for MeshCAM and am not turning up anything that jumps out at me and says "here it is".? The meshCAM site says comparable with Mach3. Does this mean they have a Mach3 post is supplied in their software?

Anyone have any feeling for how well meshCAM works with Mach3?

Thanks
Steven

?


Rhino3D, Meshcam and Mach3

 

Hi

Let me ask a quick question without doing my due diligence or research before hand

I'm currently working with Rhino3D, RhinoCAM Mill, and Mach3 on a home made CNC.? I've heard good things about meshCAM from other violin makers and a thinking of giving it a try (since RhinoCAM is getting a bit pricey).

I was looking around for Mach3 post processors for MeshCAM and am not turning up anything that jumps out at me and says "here it is".? The meshCAM site says comparable with Mach3. Does this mean they have a Mach3 post is supplied in their software?

Anyone have any feeling for how well meshCAM works with Mach3?

Thanks
Steven


Re: wxlua frame

 

开云体育

Hi Brian,

?

I sent it to your support email.. if I got it right you should get it

?

Thanks Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Thursday, February 2, 2023 8:27 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

You can send the Profile off list and I can have a stab at getting it to work. You like that idea?

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 2/1/2023 10:36 PM, Gary wrote:

Hi Brian,

?

I gave that a shot but didn’t seem to change anything, still 2 dialogs when m6 used in a g code file, but it did add a new issue now when I boot mach4 the dialog is run when the screen comes up

It also runs if I am in the screen editor and then exit back to mach …

So still missing something haven’t had much time to play with today, but tomorrow I will do some more testing

I’m thinking is has something to do with this line now that I added the dighandle == nul check

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and dlghandle == nil ) then

?

Thanks Gary

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Wednesday, February 1, 2023 10:16 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Your really really close! Here is what I did to make it so you can't have more than one dialog show at a time.

?

In your PLC script:

local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeReg == nil )then
?? ?toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")
end

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and dlghandle == nil ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

??????? dlghandle = nil-- kill the dialog so the garbage collector can get it back

end

You need to use the dlghandle to see if you have a dialog or not.

?

Test rest of it seems fine. I like what your doing!

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/31/2023 7:00 PM, Gary wrote:

Hi Brian,

?

Below is the code I have running at this time it works form the MDI right loads the dialog when I run the m6 script and I can exit it fine..

?

But when I run it in the g code the dialog runs fine but I get two copies if the dialog on the screen it seems to still be running ok no error’s and I can close both dialogs out with no errors

I know the code looks like crap but I’m not a programmer but did get it to work in the g code with no errors so that’s a start for me.

Any suggestions as to why it runs fine called from the MDI, but then displays 2 dialog boxes when called from the g code file?.

?

Thanks Gary

?

----this is in the m6 macro

?

function m6()

?

local inst = mc.mcGetInstance("M6 Toolchange")

?

local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

local rc = mc.mcRegSetValueString(tchangeReg,"ShowTchangeDlg")

?

?

-- Code to wait for the dialog to end

while(mc.mcRegGetValueString(tchangeReg) == "ShowTchangeDlg") do

??? wx.wxMilliSleep(500)

-- May want to add some code here in the event someone presses stop or kills the program

end

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

local ReturnValue = mc.mcRegGetValueString(tchangeReg)

?

end

?

?

---this is it the screen load script

?

------ Tool change Dialog ------------------------

function ToolChangeDia()

local wx = require("wx")

??????????????? --inst = mc.mcGetInstance()

??????????????? local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

???????????????

local function ManualEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 1 event

??????????????????????????????? Manual()

??? end)()

end

?

local function ManualTouchEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 2 event

??????????????????????????????? ManualTouch()

??? end)()

end

?

local function ManualProbeEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 3 event

??????????????????????????????? ManualProbe()

??? end)()

end

?

local function AbortEvent(event, frame)

??? coroutine.wrap(function()

??? Abort()

??????????????? --mc.mcRegSetValueString(M6reg,"0")

??? frame:Destroy()

??????? -- code for button 4 event

??? end)()

end

?

local function main()

??? -- Create a new frame

??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",

??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

?

??? -- Create Text above each button

??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",

??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))

??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",

???????????????? ???????????????wx.wxPoint(20, 70), wx.wxSize(150, 100))

??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",

??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))

??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",

??????????????????????????????? wx.wxPoint(20, 260), wx.wxSize(150, 100))

?

??? -- Create buttons

??? local Manual = wx.wxButton(frame, wx.wxID_ANY, "Manual",

??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))

??? local ManualTouch = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",

??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))

??? local ManualProbe = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",

??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))

??? local Abort = wx.wxButton(frame, wx.wxID_ANY, "Abort",

??????????????????????????????? wx.wxPoint(200, 280), wx.wxSize(100, 30))

?

??? -- Connect button events

??? Manual:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualEvent)

??? ManualTouch:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualTouchEvent)

??? ManualProbe:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualProbeEvent)

??? Abort:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) AbortEvent(event, frame) end)

?

-- Show the frame

frame:Show(true)

end

?

local co = coroutine.wrap(main)

co() -- start the coroutine

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

function Manual()

--frame:Destroy()

wx.wxMessageBox("Manual")

end

?

function ManualTouch()

--frame:Destroy()

wx.wxMessageBox("Manual Touch off")

end

?

function ManualProbe()

--frame:Destroy()

wx.wxMessageBox("Manual Probe")

end

?

function Abort()

--frame:Destroy()

wx.wxMessageBox("Abort")

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

end

--wx.wxGetApp():MainLoop()

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

return nul

end

?

?

---this is in the PLC

?

----tool change dialog----

local inst = mc.mcGetInstance("M6 Toolchange Dialog")

toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" ) then?? -- put the handle to the toolchange Osig in the global table

????toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)

end

--if ( toolchangeReg == nul ) then

--end

--else

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState( toolchangeActiveReg ) == 1 ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

????????dlghandle = nil-- kill the dialog so the garbage collector can get it back

? end

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Monday, January 30, 2023 8:47 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Sorry I was coaching robotics and had a comp this weekend so I was flat out :) The good news is that I had 2 more teems qualify for states! Okay back to work!?

?

We don't have any real library for semaphores, it's really telling you how you need to architect the system. Let me see if I can make something to show you how I would do it in a screen. But basically we don't allow graphics in the Macro's (Mostly because we didn't see the need and I think this is still the best). How you communicate to the macro's is through registers. The registers are the only way to have thread safe data in Lua to the rest of the system. Having graphics in the Mcodes could and would put the events into the macro's / Gcode thread and we REALLY don't want that! By communicating via registers it will allow you to have your dialog and not have the Gcode interpreter thread plugged up with graphics.

?

Now onto the solution!

?

You need to setup a register in the register conifig dialog:

Mine is at the following path "iRegs0/ToolSettings"

?

So in my M6 macro I would put the following:

local inst = mc.mcGetInstance("M6 Toolchange")
local tchangeReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
local rc = mc.mcRegSetValue(tchangeReg,"ShowTchangeDlg")

-- Code to wait for the dialog to end
while(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg") do
?? ?wx.wxMilliSleep(500)
?-- May want to add some code here in the event someone presses stop or kills the program
end
local ReturnValue = mc.mcRegGetValue(tchangeReg)

-- Continue with the toolchanger and you have the return in the register.

?

?

Now in the screen you can put your dialog in a function and check to see if you need to launch it in the PLC script :


local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeActiveReg == nil)then -- put the handle to the toolchange Osig in the global table
?? ?toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)
end
if(tchangeDlogReg == nil)then
tchangeDlogReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
end

if(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState(toolchangeActiveReg) == 1 && dlghandle == nil)then
?? ?
?? ?dlghandle = YourDialogFunction()-- Remember to pass back something from the dialog so we know it has been done
else
?? ?if(mc.mcRegGetValue(tchangeReg) ~= "ShowTchangeDlg" and? dlghandle ~= nil) then
?? ??? ?dlghandle = nil-- kill the dialog so the garbage collector can get it back
?? ?end
end

?

?

This is all untested and 100% can be changed but I think it clearly shows how I would do it :)

?

Hope that helps!

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/27/2023 9:38 AM, Gary wrote:

Ok thanks Brian,

?

I will try them out, by in the screen not sure what screen the frame? The screen load script ?

?

What my real goal was or is, I have a rotary tool changer, I am checking the m6 macro to see if the new tool is in the rack if not the switching to a manual tool change, the dialog was just a thought if the tool not in rack then give the option to manual tool change and continue is the tool is in the tool table an offset it set, or is tool not in the table and or offset not set then jog down and touch off top of part, or the option to use a touch off plate and probe it, leaving the choices up to me hence the frame and buttons..

?

I will most likely need help I am starting to go over my head now… I did try local semaphore = require("semaphore")

but doesn’t seem to be in the library…. And not sure if it was were the directory is located…

?

Thangs Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control




here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?

?

?

?


Re: wxlua frame

 

开云体育

Hi Gary,

You can send the Profile off list and I can have a stab at getting it to work. You like that idea?


thanks
Brian


______________________________

Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 
On 2/1/2023 10:36 PM, Gary wrote:

Hi Brian,

?

I gave that a shot but didn’t seem to change anything, still 2 dialogs when m6 used in a g code file, but it did add a new issue now when I boot mach4 the dialog is run when the screen comes up

It also runs if I am in the screen editor and then exit back to mach …

So still missing something haven’t had much time to play with today, but tomorrow I will do some more testing

I’m thinking is has something to do with this line now that I added the dighandle == nul check

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and dlghandle == nil ) then

?

Thanks Gary

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Wednesday, February 1, 2023 10:16 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Your really really close! Here is what I did to make it so you can't have more than one dialog show at a time.

?

In your PLC script:

local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeReg == nil )then
?? ?toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")
end

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and dlghandle == nil ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

??????? dlghandle = nil-- kill the dialog so the garbage collector can get it back

end

You need to use the dlghandle to see if you have a dialog or not.

?

Test rest of it seems fine. I like what your doing!

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/31/2023 7:00 PM, Gary wrote:

Hi Brian,

?

Below is the code I have running at this time it works form the MDI right loads the dialog when I run the m6 script and I can exit it fine..

?

But when I run it in the g code the dialog runs fine but I get two copies if the dialog on the screen it seems to still be running ok no error’s and I can close both dialogs out with no errors

I know the code looks like crap but I’m not a programmer but did get it to work in the g code with no errors so that’s a start for me.

Any suggestions as to why it runs fine called from the MDI, but then displays 2 dialog boxes when called from the g code file?.

?

Thanks Gary

?

----this is in the m6 macro

?

function m6()

?

local inst = mc.mcGetInstance("M6 Toolchange")

?

local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

local rc = mc.mcRegSetValueString(tchangeReg,"ShowTchangeDlg")

?

?

-- Code to wait for the dialog to end

while(mc.mcRegGetValueString(tchangeReg) == "ShowTchangeDlg") do

??? wx.wxMilliSleep(500)

-- May want to add some code here in the event someone presses stop or kills the program

end

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

local ReturnValue = mc.mcRegGetValueString(tchangeReg)

?

end

?

?

---this is it the screen load script

?

------ Tool change Dialog ------------------------

function ToolChangeDia()

local wx = require("wx")

??????????????? --inst = mc.mcGetInstance()

??????????????? local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

???????????????

local function ManualEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 1 event

??????????????????????????????? Manual()

??? end)()

end

?

local function ManualTouchEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 2 event

??????????????????????????????? ManualTouch()

??? end)()

end

?

local function ManualProbeEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 3 event

??????????????????????????????? ManualProbe()

??? end)()

end

?

local function AbortEvent(event, frame)

??? coroutine.wrap(function()

??? Abort()

??????????????? --mc.mcRegSetValueString(M6reg,"0")

??? frame:Destroy()

??????? -- code for button 4 event

??? end)()

end

?

local function main()

??? -- Create a new frame

??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",

??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

?

??? -- Create Text above each button

??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",

??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))

??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",

???????????????? ???????????????wx.wxPoint(20, 70), wx.wxSize(150, 100))

??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",

??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))

??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",

??????????????????????????????? wx.wxPoint(20, 260), wx.wxSize(150, 100))

?

??? -- Create buttons

??? local Manual = wx.wxButton(frame, wx.wxID_ANY, "Manual",

??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))

??? local ManualTouch = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",

??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))

??? local ManualProbe = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",

??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))

??? local Abort = wx.wxButton(frame, wx.wxID_ANY, "Abort",

??????????????????????????????? wx.wxPoint(200, 280), wx.wxSize(100, 30))

?

??? -- Connect button events

??? Manual:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualEvent)

??? ManualTouch:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualTouchEvent)

??? ManualProbe:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualProbeEvent)

??? Abort:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) AbortEvent(event, frame) end)

?

-- Show the frame

frame:Show(true)

end

?

local co = coroutine.wrap(main)

co() -- start the coroutine

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

function Manual()

--frame:Destroy()

wx.wxMessageBox("Manual")

end

?

function ManualTouch()

--frame:Destroy()

wx.wxMessageBox("Manual Touch off")

end

?

function ManualProbe()

--frame:Destroy()

wx.wxMessageBox("Manual Probe")

end

?

function Abort()

--frame:Destroy()

wx.wxMessageBox("Abort")

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

end

--wx.wxGetApp():MainLoop()

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

return nul

end

?

?

---this is in the PLC

?

----tool change dialog----

local inst = mc.mcGetInstance("M6 Toolchange Dialog")

toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" ) then?? -- put the handle to the toolchange Osig in the global table

????toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)

end

--if ( toolchangeReg == nul ) then

--end

--else

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState( toolchangeActiveReg ) == 1 ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

????????dlghandle = nil-- kill the dialog so the garbage collector can get it back

? end

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Monday, January 30, 2023 8:47 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Sorry I was coaching robotics and had a comp this weekend so I was flat out :) The good news is that I had 2 more teems qualify for states! Okay back to work!?

?

We don't have any real library for semaphores, it's really telling you how you need to architect the system. Let me see if I can make something to show you how I would do it in a screen. But basically we don't allow graphics in the Macro's (Mostly because we didn't see the need and I think this is still the best). How you communicate to the macro's is through registers. The registers are the only way to have thread safe data in Lua to the rest of the system. Having graphics in the Mcodes could and would put the events into the macro's / Gcode thread and we REALLY don't want that! By communicating via registers it will allow you to have your dialog and not have the Gcode interpreter thread plugged up with graphics.

?

Now onto the solution!

?

You need to setup a register in the register conifig dialog:

Mine is at the following path "iRegs0/ToolSettings"

?

So in my M6 macro I would put the following:

local inst = mc.mcGetInstance("M6 Toolchange")
local tchangeReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
local rc = mc.mcRegSetValue(tchangeReg,"ShowTchangeDlg")

-- Code to wait for the dialog to end
while(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg") do
?? ?wx.wxMilliSleep(500)
?-- May want to add some code here in the event someone presses stop or kills the program
end
local ReturnValue = mc.mcRegGetValue(tchangeReg)

-- Continue with the toolchanger and you have the return in the register.

?

?

Now in the screen you can put your dialog in a function and check to see if you need to launch it in the PLC script :


local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeActiveReg == nil)then -- put the handle to the toolchange Osig in the global table
?? ?toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)
end
if(tchangeDlogReg == nil)then
tchangeDlogReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
end

if(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState(toolchangeActiveReg) == 1 && dlghandle == nil)then
?? ?
?? ?dlghandle = YourDialogFunction()-- Remember to pass back something from the dialog so we know it has been done
else
?? ?if(mc.mcRegGetValue(tchangeReg) ~= "ShowTchangeDlg" and? dlghandle ~= nil) then
?? ??? ?dlghandle = nil-- kill the dialog so the garbage collector can get it back
?? ?end
end

?

?

This is all untested and 100% can be changed but I think it clearly shows how I would do it :)

?

Hope that helps!

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/27/2023 9:38 AM, Gary wrote:

Ok thanks Brian,

?

I will try them out, by in the screen not sure what screen the frame? The screen load script ?

?

What my real goal was or is, I have a rotary tool changer, I am checking the m6 macro to see if the new tool is in the rack if not the switching to a manual tool change, the dialog was just a thought if the tool not in rack then give the option to manual tool change and continue is the tool is in the tool table an offset it set, or is tool not in the table and or offset not set then jog down and touch off top of part, or the option to use a touch off plate and probe it, leaving the choices up to me hence the frame and buttons..

?

I will most likely need help I am starting to go over my head now… I did try local semaphore = require("semaphore")

but doesn’t seem to be in the library…. And not sure if it was were the directory is located…

?

Thangs Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control



here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?

?

?


Re: wxlua frame

 

开云体育

Hi Brian,

?

I gave that a shot but didn’t seem to change anything, still 2 dialogs when m6 used in a g code file, but it did add a new issue now when I boot mach4 the dialog is run when the screen comes up

It also runs if I am in the screen editor and then exit back to mach …

So still missing something haven’t had much time to play with today, but tomorrow I will do some more testing

I’m thinking is has something to do with this line now that I added the dighandle == nul check

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and dlghandle == nil ) then

?

Thanks Gary

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Wednesday, February 1, 2023 10:16 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Your really really close! Here is what I did to make it so you can't have more than one dialog show at a time.

?

In your PLC script:

local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeReg == nil )then
?? ?toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")
end

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and dlghandle == nil ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

??????? dlghandle = nil-- kill the dialog so the garbage collector can get it back

end

You need to use the dlghandle to see if you have a dialog or not.

?

Test rest of it seems fine. I like what your doing!

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/31/2023 7:00 PM, Gary wrote:

Hi Brian,

?

Below is the code I have running at this time it works form the MDI right loads the dialog when I run the m6 script and I can exit it fine..

?

But when I run it in the g code the dialog runs fine but I get two copies if the dialog on the screen it seems to still be running ok no error’s and I can close both dialogs out with no errors

I know the code looks like crap but I’m not a programmer but did get it to work in the g code with no errors so that’s a start for me.

Any suggestions as to why it runs fine called from the MDI, but then displays 2 dialog boxes when called from the g code file?.

?

Thanks Gary

?

----this is in the m6 macro

?

function m6()

?

local inst = mc.mcGetInstance("M6 Toolchange")

?

local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

local rc = mc.mcRegSetValueString(tchangeReg,"ShowTchangeDlg")

?

?

-- Code to wait for the dialog to end

while(mc.mcRegGetValueString(tchangeReg) == "ShowTchangeDlg") do

??? wx.wxMilliSleep(500)

-- May want to add some code here in the event someone presses stop or kills the program

end

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

local ReturnValue = mc.mcRegGetValueString(tchangeReg)

?

end

?

?

---this is it the screen load script

?

------ Tool change Dialog ------------------------

function ToolChangeDia()

local wx = require("wx")

??????????????? --inst = mc.mcGetInstance()

??????????????? local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

???????????????

local function ManualEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 1 event

??????????????????????????????? Manual()

??? end)()

end

?

local function ManualTouchEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 2 event

??????????????????????????????? ManualTouch()

??? end)()

end

?

local function ManualProbeEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 3 event

??????????????????????????????? ManualProbe()

??? end)()

end

?

local function AbortEvent(event, frame)

??? coroutine.wrap(function()

??? Abort()

??????????????? --mc.mcRegSetValueString(M6reg,"0")

??? frame:Destroy()

??????? -- code for button 4 event

??? end)()

end

?

local function main()

??? -- Create a new frame

??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",

??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

?

??? -- Create Text above each button

??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",

??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))

??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",

???????????????? ???????????????wx.wxPoint(20, 70), wx.wxSize(150, 100))

??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",

??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))

??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",

??????????????????????????????? wx.wxPoint(20, 260), wx.wxSize(150, 100))

?

??? -- Create buttons

??? local Manual = wx.wxButton(frame, wx.wxID_ANY, "Manual",

??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))

??? local ManualTouch = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",

??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))

??? local ManualProbe = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",

??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))

??? local Abort = wx.wxButton(frame, wx.wxID_ANY, "Abort",

??????????????????????????????? wx.wxPoint(200, 280), wx.wxSize(100, 30))

?

??? -- Connect button events

??? Manual:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualEvent)

??? ManualTouch:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualTouchEvent)

??? ManualProbe:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualProbeEvent)

??? Abort:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) AbortEvent(event, frame) end)

?

-- Show the frame

frame:Show(true)

end

?

local co = coroutine.wrap(main)

co() -- start the coroutine

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

function Manual()

--frame:Destroy()

wx.wxMessageBox("Manual")

end

?

function ManualTouch()

--frame:Destroy()

wx.wxMessageBox("Manual Touch off")

end

?

function ManualProbe()

--frame:Destroy()

wx.wxMessageBox("Manual Probe")

end

?

function Abort()

--frame:Destroy()

wx.wxMessageBox("Abort")

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

end

--wx.wxGetApp():MainLoop()

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

return nul

end

?

?

---this is in the PLC

?

----tool change dialog----

local inst = mc.mcGetInstance("M6 Toolchange Dialog")

toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" ) then?? -- put the handle to the toolchange Osig in the global table

????toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)

end

--if ( toolchangeReg == nul ) then

--end

--else

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState( toolchangeActiveReg ) == 1 ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

????????dlghandle = nil-- kill the dialog so the garbage collector can get it back

? end

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Monday, January 30, 2023 8:47 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Sorry I was coaching robotics and had a comp this weekend so I was flat out :) The good news is that I had 2 more teems qualify for states! Okay back to work!?

?

We don't have any real library for semaphores, it's really telling you how you need to architect the system. Let me see if I can make something to show you how I would do it in a screen. But basically we don't allow graphics in the Macro's (Mostly because we didn't see the need and I think this is still the best). How you communicate to the macro's is through registers. The registers are the only way to have thread safe data in Lua to the rest of the system. Having graphics in the Mcodes could and would put the events into the macro's / Gcode thread and we REALLY don't want that! By communicating via registers it will allow you to have your dialog and not have the Gcode interpreter thread plugged up with graphics.

?

Now onto the solution!

?

You need to setup a register in the register conifig dialog:

Mine is at the following path "iRegs0/ToolSettings"

?

So in my M6 macro I would put the following:

local inst = mc.mcGetInstance("M6 Toolchange")
local tchangeReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
local rc = mc.mcRegSetValue(tchangeReg,"ShowTchangeDlg")

-- Code to wait for the dialog to end
while(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg") do
?? ?wx.wxMilliSleep(500)
?-- May want to add some code here in the event someone presses stop or kills the program
end
local ReturnValue = mc.mcRegGetValue(tchangeReg)

-- Continue with the toolchanger and you have the return in the register.

?

?

Now in the screen you can put your dialog in a function and check to see if you need to launch it in the PLC script :


local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeActiveReg == nil)then -- put the handle to the toolchange Osig in the global table
?? ?toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)
end
if(tchangeDlogReg == nil)then
tchangeDlogReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
end

if(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState(toolchangeActiveReg) == 1 && dlghandle == nil)then
?? ?
?? ?dlghandle = YourDialogFunction()-- Remember to pass back something from the dialog so we know it has been done
else
?? ?if(mc.mcRegGetValue(tchangeReg) ~= "ShowTchangeDlg" and? dlghandle ~= nil) then
?? ??? ?dlghandle = nil-- kill the dialog so the garbage collector can get it back
?? ?end
end

?

?

This is all untested and 100% can be changed but I think it clearly shows how I would do it :)

?

Hope that helps!

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/27/2023 9:38 AM, Gary wrote:

Ok thanks Brian,

?

I will try them out, by in the screen not sure what screen the frame? The screen load script ?

?

What my real goal was or is, I have a rotary tool changer, I am checking the m6 macro to see if the new tool is in the rack if not the switching to a manual tool change, the dialog was just a thought if the tool not in rack then give the option to manual tool change and continue is the tool is in the tool table an offset it set, or is tool not in the table and or offset not set then jog down and touch off top of part, or the option to use a touch off plate and probe it, leaving the choices up to me hence the frame and buttons..

?

I will most likely need help I am starting to go over my head now… I did try local semaphore = require("semaphore")

but doesn’t seem to be in the library…. And not sure if it was were the directory is located…

?

Thangs Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control



here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?

?

?


Re: wxlua frame

 

开云体育

Hi Gary,

Your really really close! Here is what I did to make it so you can't have more than one dialog show at a time.


In your PLC script:

local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeReg == nil )then
?? ?toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")
end

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and dlghandle == nil ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

??????? dlghandle = nil-- kill the dialog so the garbage collector can get it back

end

You need to use the dlghandle to see if you have a dialog or not.


Test rest of it seems fine. I like what your doing!


______________________________

Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 
On 1/31/2023 7:00 PM, Gary wrote:

Hi Brian,

?

Below is the code I have running at this time it works form the MDI right loads the dialog when I run the m6 script and I can exit it fine..

?

But when I run it in the g code the dialog runs fine but I get two copies if the dialog on the screen it seems to still be running ok no error’s and I can close both dialogs out with no errors

I know the code looks like crap but I’m not a programmer but did get it to work in the g code with no errors so that’s a start for me.

Any suggestions as to why it runs fine called from the MDI, but then displays 2 dialog boxes when called from the g code file?.

?

Thanks Gary

?

----this is in the m6 macro

?

function m6()

?

local inst = mc.mcGetInstance("M6 Toolchange")

?

local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

local rc = mc.mcRegSetValueString(tchangeReg,"ShowTchangeDlg")

?

?

-- Code to wait for the dialog to end

while(mc.mcRegGetValueString(tchangeReg) == "ShowTchangeDlg") do

??? wx.wxMilliSleep(500)

-- May want to add some code here in the event someone presses stop or kills the program

end

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

local ReturnValue = mc.mcRegGetValueString(tchangeReg)

?

end

?

?

---this is it the screen load script

?

------ Tool change Dialog ------------------------

function ToolChangeDia()

local wx = require("wx")

??????????????? --inst = mc.mcGetInstance()

??????????????? local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

???????????????

local function ManualEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 1 event

??????????????????????????????? Manual()

??? end)()

end

?

local function ManualTouchEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 2 event

??????????????????????????????? ManualTouch()

??? end)()

end

?

local function ManualProbeEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 3 event

??????????????????????????????? ManualProbe()

??? end)()

end

?

local function AbortEvent(event, frame)

??? coroutine.wrap(function()

??? Abort()

??????????????? --mc.mcRegSetValueString(M6reg,"0")

??? frame:Destroy()

??????? -- code for button 4 event

??? end)()

end

?

local function main()

??? -- Create a new frame

??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",

??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

?

??? -- Create Text above each button

??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",

??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))

??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",

???????????????? ???????????????wx.wxPoint(20, 70), wx.wxSize(150, 100))

??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",

??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))

??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",

??????????????????????????????? wx.wxPoint(20, 260), wx.wxSize(150, 100))

?

??? -- Create buttons

??? local Manual = wx.wxButton(frame, wx.wxID_ANY, "Manual",

??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))

??? local ManualTouch = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",

??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))

??? local ManualProbe = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",

??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))

??? local Abort = wx.wxButton(frame, wx.wxID_ANY, "Abort",

??????????????????????????????? wx.wxPoint(200, 280), wx.wxSize(100, 30))

?

??? -- Connect button events

??? Manual:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualEvent)

??? ManualTouch:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualTouchEvent)

??? ManualProbe:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualProbeEvent)

??? Abort:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) AbortEvent(event, frame) end)

?

-- Show the frame

frame:Show(true)

end

?

local co = coroutine.wrap(main)

co() -- start the coroutine

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

function Manual()

--frame:Destroy()

wx.wxMessageBox("Manual")

end

?

function ManualTouch()

--frame:Destroy()

wx.wxMessageBox("Manual Touch off")

end

?

function ManualProbe()

--frame:Destroy()

wx.wxMessageBox("Manual Probe")

end

?

function Abort()

--frame:Destroy()

wx.wxMessageBox("Abort")

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

end

--wx.wxGetApp():MainLoop()

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

return nul

end

?

?

---this is in the PLC

?

----tool change dialog----

local inst = mc.mcGetInstance("M6 Toolchange Dialog")

toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" ) then?? -- put the handle to the toolchange Osig in the global table

????toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)

end

--if ( toolchangeReg == nul ) then

--end

--else

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState( toolchangeActiveReg ) == 1 ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

????????dlghandle = nil-- kill the dialog so the garbage collector can get it back

? end

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Monday, January 30, 2023 8:47 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Sorry I was coaching robotics and had a comp this weekend so I was flat out :) The good news is that I had 2 more teems qualify for states! Okay back to work!?

?

We don't have any real library for semaphores, it's really telling you how you need to architect the system. Let me see if I can make something to show you how I would do it in a screen. But basically we don't allow graphics in the Macro's (Mostly because we didn't see the need and I think this is still the best). How you communicate to the macro's is through registers. The registers are the only way to have thread safe data in Lua to the rest of the system. Having graphics in the Mcodes could and would put the events into the macro's / Gcode thread and we REALLY don't want that! By communicating via registers it will allow you to have your dialog and not have the Gcode interpreter thread plugged up with graphics.

?

Now onto the solution!

?

You need to setup a register in the register conifig dialog:

Mine is at the following path "iRegs0/ToolSettings"

?

So in my M6 macro I would put the following:

local inst = mc.mcGetInstance("M6 Toolchange")
local tchangeReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
local rc = mc.mcRegSetValue(tchangeReg,"ShowTchangeDlg")

-- Code to wait for the dialog to end
while(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg") do
?? ?wx.wxMilliSleep(500)
?-- May want to add some code here in the event someone presses stop or kills the program
end
local ReturnValue = mc.mcRegGetValue(tchangeReg)

-- Continue with the toolchanger and you have the return in the register.

?

?

Now in the screen you can put your dialog in a function and check to see if you need to launch it in the PLC script :


local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeActiveReg == nil)then -- put the handle to the toolchange Osig in the global table
?? ?toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)
end
if(tchangeDlogReg == nil)then
tchangeDlogReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
end

if(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState(toolchangeActiveReg) == 1 && dlghandle == nil)then
?? ?
?? ?dlghandle = YourDialogFunction()-- Remember to pass back something from the dialog so we know it has been done
else
?? ?if(mc.mcRegGetValue(tchangeReg) ~= "ShowTchangeDlg" and? dlghandle ~= nil) then
?? ??? ?dlghandle = nil-- kill the dialog so the garbage collector can get it back
?? ?end
end

?

?

This is all untested and 100% can be changed but I think it clearly shows how I would do it :)

?

Hope that helps!

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/27/2023 9:38 AM, Gary wrote:

Ok thanks Brian,

?

I will try them out, by in the screen not sure what screen the frame? The screen load script ?

?

What my real goal was or is, I have a rotary tool changer, I am checking the m6 macro to see if the new tool is in the rack if not the switching to a manual tool change, the dialog was just a thought if the tool not in rack then give the option to manual tool change and continue is the tool is in the tool table an offset it set, or is tool not in the table and or offset not set then jog down and touch off top of part, or the option to use a touch off plate and probe it, leaving the choices up to me hence the frame and buttons..

?

I will most likely need help I am starting to go over my head now… I did try local semaphore = require("semaphore")

but doesn’t seem to be in the library…. And not sure if it was were the directory is located…

?

Thangs Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control


here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?

?


Re: wxlua frame

 

开云体育

Umm it's sort of right but could use a bit of help :) Let me see what I can do to help you out !


Thanks

Brian


______________________________

Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 
On 1/31/2023 7:00 PM, Gary wrote:

Hi Brian,

?

Below is the code I have running at this time it works form the MDI right loads the dialog when I run the m6 script and I can exit it fine..

?

But when I run it in the g code the dialog runs fine but I get two copies if the dialog on the screen it seems to still be running ok no error’s and I can close both dialogs out with no errors

I know the code looks like crap but I’m not a programmer but did get it to work in the g code with no errors so that’s a start for me.

Any suggestions as to why it runs fine called from the MDI, but then displays 2 dialog boxes when called from the g code file?.

?

Thanks Gary

?

----this is in the m6 macro

?

function m6()

?

local inst = mc.mcGetInstance("M6 Toolchange")

?

local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

local rc = mc.mcRegSetValueString(tchangeReg,"ShowTchangeDlg")

?

?

-- Code to wait for the dialog to end

while(mc.mcRegGetValueString(tchangeReg) == "ShowTchangeDlg") do

??? wx.wxMilliSleep(500)

-- May want to add some code here in the event someone presses stop or kills the program

end

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

local ReturnValue = mc.mcRegGetValueString(tchangeReg)

?

end

?

?

---this is it the screen load script

?

------ Tool change Dialog ------------------------

function ToolChangeDia()

local wx = require("wx")

??????????????? --inst = mc.mcGetInstance()

??????????????? local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

???????????????

local function ManualEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 1 event

??????????????????????????????? Manual()

??? end)()

end

?

local function ManualTouchEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 2 event

??????????????????????????????? ManualTouch()

??? end)()

end

?

local function ManualProbeEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 3 event

??????????????????????????????? ManualProbe()

??? end)()

end

?

local function AbortEvent(event, frame)

??? coroutine.wrap(function()

??? Abort()

??????????????? --mc.mcRegSetValueString(M6reg,"0")

??? frame:Destroy()

??????? -- code for button 4 event

??? end)()

end

?

local function main()

??? -- Create a new frame

??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",

??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

?

??? -- Create Text above each button

??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",

??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))

??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",

???????????????? ???????????????wx.wxPoint(20, 70), wx.wxSize(150, 100))

??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",

??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))

??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",

??????????????????????????????? wx.wxPoint(20, 260), wx.wxSize(150, 100))

?

??? -- Create buttons

??? local Manual = wx.wxButton(frame, wx.wxID_ANY, "Manual",

??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))

??? local ManualTouch = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",

??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))

??? local ManualProbe = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",

??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))

??? local Abort = wx.wxButton(frame, wx.wxID_ANY, "Abort",

??????????????????????????????? wx.wxPoint(200, 280), wx.wxSize(100, 30))

?

??? -- Connect button events

??? Manual:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualEvent)

??? ManualTouch:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualTouchEvent)

??? ManualProbe:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualProbeEvent)

??? Abort:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) AbortEvent(event, frame) end)

?

-- Show the frame

frame:Show(true)

end

?

local co = coroutine.wrap(main)

co() -- start the coroutine

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

function Manual()

--frame:Destroy()

wx.wxMessageBox("Manual")

end

?

function ManualTouch()

--frame:Destroy()

wx.wxMessageBox("Manual Touch off")

end

?

function ManualProbe()

--frame:Destroy()

wx.wxMessageBox("Manual Probe")

end

?

function Abort()

--frame:Destroy()

wx.wxMessageBox("Abort")

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

end

--wx.wxGetApp():MainLoop()

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

return nul

end

?

?

---this is in the PLC

?

----tool change dialog----

local inst = mc.mcGetInstance("M6 Toolchange Dialog")

toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" ) then?? -- put the handle to the toolchange Osig in the global table

????toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)

end

--if ( toolchangeReg == nul ) then

--end

--else

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState( toolchangeActiveReg ) == 1 ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

????????dlghandle = nil-- kill the dialog so the garbage collector can get it back

? end

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Monday, January 30, 2023 8:47 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Sorry I was coaching robotics and had a comp this weekend so I was flat out :) The good news is that I had 2 more teems qualify for states! Okay back to work!?

?

We don't have any real library for semaphores, it's really telling you how you need to architect the system. Let me see if I can make something to show you how I would do it in a screen. But basically we don't allow graphics in the Macro's (Mostly because we didn't see the need and I think this is still the best). How you communicate to the macro's is through registers. The registers are the only way to have thread safe data in Lua to the rest of the system. Having graphics in the Mcodes could and would put the events into the macro's / Gcode thread and we REALLY don't want that! By communicating via registers it will allow you to have your dialog and not have the Gcode interpreter thread plugged up with graphics.

?

Now onto the solution!

?

You need to setup a register in the register conifig dialog:

Mine is at the following path "iRegs0/ToolSettings"

?

So in my M6 macro I would put the following:

local inst = mc.mcGetInstance("M6 Toolchange")
local tchangeReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
local rc = mc.mcRegSetValue(tchangeReg,"ShowTchangeDlg")

-- Code to wait for the dialog to end
while(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg") do
?? ?wx.wxMilliSleep(500)
?-- May want to add some code here in the event someone presses stop or kills the program
end
local ReturnValue = mc.mcRegGetValue(tchangeReg)

-- Continue with the toolchanger and you have the return in the register.

?

?

Now in the screen you can put your dialog in a function and check to see if you need to launch it in the PLC script :


local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeActiveReg == nil)then -- put the handle to the toolchange Osig in the global table
?? ?toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)
end
if(tchangeDlogReg == nil)then
tchangeDlogReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
end

if(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState(toolchangeActiveReg) == 1 && dlghandle == nil)then
?? ?
?? ?dlghandle = YourDialogFunction()-- Remember to pass back something from the dialog so we know it has been done
else
?? ?if(mc.mcRegGetValue(tchangeReg) ~= "ShowTchangeDlg" and? dlghandle ~= nil) then
?? ??? ?dlghandle = nil-- kill the dialog so the garbage collector can get it back
?? ?end
end

?

?

This is all untested and 100% can be changed but I think it clearly shows how I would do it :)

?

Hope that helps!

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/27/2023 9:38 AM, Gary wrote:

Ok thanks Brian,

?

I will try them out, by in the screen not sure what screen the frame? The screen load script ?

?

What my real goal was or is, I have a rotary tool changer, I am checking the m6 macro to see if the new tool is in the rack if not the switching to a manual tool change, the dialog was just a thought if the tool not in rack then give the option to manual tool change and continue is the tool is in the tool table an offset it set, or is tool not in the table and or offset not set then jog down and touch off top of part, or the option to use a touch off plate and probe it, leaving the choices up to me hence the frame and buttons..

?

I will most likely need help I am starting to go over my head now… I did try local semaphore = require("semaphore")

but doesn’t seem to be in the library…. And not sure if it was were the directory is located…

?

Thangs Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control


here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?

?


Re: wxlua frame

 

开云体育

Hi Brian,

?

Below is the code I have running at this time it works form the MDI right loads the dialog when I run the m6 script and I can exit it fine..

?

But when I run it in the g code the dialog runs fine but I get two copies if the dialog on the screen it seems to still be running ok no error’s and I can close both dialogs out with no errors

I know the code looks like crap but I’m not a programmer but did get it to work in the g code with no errors so that’s a start for me.

Any suggestions as to why it runs fine called from the MDI, but then displays 2 dialog boxes when called from the g code file?.

?

Thanks Gary

?

----this is in the m6 macro

?

function m6()

?

local inst = mc.mcGetInstance("M6 Toolchange")

?

local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

local rc = mc.mcRegSetValueString(tchangeReg,"ShowTchangeDlg")

?

?

-- Code to wait for the dialog to end

while(mc.mcRegGetValueString(tchangeReg) == "ShowTchangeDlg") do

??? wx.wxMilliSleep(500)

-- May want to add some code here in the event someone presses stop or kills the program

end

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

local ReturnValue = mc.mcRegGetValueString(tchangeReg)

?

end

?

?

---this is it the screen load script

?

------ Tool change Dialog ------------------------

function ToolChangeDia()

local wx = require("wx")

??????????????? --inst = mc.mcGetInstance()

??????????????? local tchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

???????????????

local function ManualEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 1 event

??????????????????????????????? Manual()

??? end)()

end

?

local function ManualTouchEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 2 event

??????????????????????????????? ManualTouch()

??? end)()

end

?

local function ManualProbeEvent(event)

??? coroutine.wrap(function()

??????? -- code for button 3 event

??????????????????????????????? ManualProbe()

??? end)()

end

?

local function AbortEvent(event, frame)

??? coroutine.wrap(function()

??? Abort()

??????????????? --mc.mcRegSetValueString(M6reg,"0")

??? frame:Destroy()

??????? -- code for button 4 event

??? end)()

end

?

local function main()

??? -- Create a new frame

??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",

??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

?

??? -- Create Text above each button

??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",

??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))

??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",

???????????????? ???????????????wx.wxPoint(20, 70), wx.wxSize(150, 100))

??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",

??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))

??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",

??????????????????????????????? wx.wxPoint(20, 260), wx.wxSize(150, 100))

?

??? -- Create buttons

??? local Manual = wx.wxButton(frame, wx.wxID_ANY, "Manual",

??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))

??? local ManualTouch = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",

??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))

??? local ManualProbe = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",

??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))

??? local Abort = wx.wxButton(frame, wx.wxID_ANY, "Abort",

??????????????????????????????? wx.wxPoint(200, 280), wx.wxSize(100, 30))

?

??? -- Connect button events

??? Manual:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualEvent)

??? ManualTouch:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualTouchEvent)

??? ManualProbe:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, ManualProbeEvent)

??? Abort:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) AbortEvent(event, frame) end)

?

-- Show the frame

frame:Show(true)

end

?

local co = coroutine.wrap(main)

co() -- start the coroutine

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

function Manual()

--frame:Destroy()

wx.wxMessageBox("Manual")

end

?

function ManualTouch()

--frame:Destroy()

wx.wxMessageBox("Manual Touch off")

end

?

function ManualProbe()

--frame:Destroy()

wx.wxMessageBox("Manual Probe")

end

?

function Abort()

--frame:Destroy()

wx.wxMessageBox("Abort")

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

end

--wx.wxGetApp():MainLoop()

mc.mcRegSetValueString(tchangeReg, "NoTchangeDig")

return nul

end

?

?

---this is in the PLC

?

----tool change dialog----

local inst = mc.mcGetInstance("M6 Toolchange Dialog")

toolchangeReg = mc.mcRegGetHandle(inst,"gRegs0/ATC/ToolDialog")

if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" ) then?? -- put the handle to the toolchange Osig in the global table

????toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)

end

--if ( toolchangeReg == nul ) then

--end

--else

? if ( mc.mcRegGetValueString(toolchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState( toolchangeActiveReg ) == 1 ) then

??? dlghandle = ToolChangeDia() -- Remember to pass back something from the dialog so we know it has been done

? elseif ( mc.mcRegGetValueString( toolchangeReg ) ~= "ShowTchangeDlg" ) then

????????dlghandle = nil-- kill the dialog so the garbage collector can get it back

? end

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Monday, January 30, 2023 8:47 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

Sorry I was coaching robotics and had a comp this weekend so I was flat out :) The good news is that I had 2 more teems qualify for states! Okay back to work!?

?

We don't have any real library for semaphores, it's really telling you how you need to architect the system. Let me see if I can make something to show you how I would do it in a screen. But basically we don't allow graphics in the Macro's (Mostly because we didn't see the need and I think this is still the best). How you communicate to the macro's is through registers. The registers are the only way to have thread safe data in Lua to the rest of the system. Having graphics in the Mcodes could and would put the events into the macro's / Gcode thread and we REALLY don't want that! By communicating via registers it will allow you to have your dialog and not have the Gcode interpreter thread plugged up with graphics.

?

Now onto the solution!

?

You need to setup a register in the register conifig dialog:

Mine is at the following path "iRegs0/ToolSettings"

?

So in my M6 macro I would put the following:

local inst = mc.mcGetInstance("M6 Toolchange")
local tchangeReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
local rc = mc.mcRegSetValue(tchangeReg,"ShowTchangeDlg")

-- Code to wait for the dialog to end
while(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg") do
?? ?wx.wxMilliSleep(500)
?-- May want to add some code here in the event someone presses stop or kills the program
end
local ReturnValue = mc.mcRegGetValue(tchangeReg)

-- Continue with the toolchanger and you have the return in the register.

?

?

Now in the screen you can put your dialog in a function and check to see if you need to launch it in the PLC script :


local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeActiveReg == nil)then -- put the handle to the toolchange Osig in the global table
?? ?toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)
end
if(tchangeDlogReg == nil)then
tchangeDlogReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
end

if(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState(toolchangeActiveReg) == 1 && dlghandle == nil)then
?? ?
?? ?dlghandle = YourDialogFunction()-- Remember to pass back something from the dialog so we know it has been done
else
?? ?if(mc.mcRegGetValue(tchangeReg) ~= "ShowTchangeDlg" and? dlghandle ~= nil) then
?? ??? ?dlghandle = nil-- kill the dialog so the garbage collector can get it back
?? ?end
end

?

?

This is all untested and 100% can be changed but I think it clearly shows how I would do it :)

?

Hope that helps!

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/27/2023 9:38 AM, Gary wrote:

Ok thanks Brian,

?

I will try them out, by in the screen not sure what screen the frame? The screen load script ?

?

What my real goal was or is, I have a rotary tool changer, I am checking the m6 macro to see if the new tool is in the rack if not the switching to a manual tool change, the dialog was just a thought if the tool not in rack then give the option to manual tool change and continue is the tool is in the tool table an offset it set, or is tool not in the table and or offset not set then jog down and touch off top of part, or the option to use a touch off plate and probe it, leaving the choices up to me hence the frame and buttons..

?

I will most likely need help I am starting to go over my head now… I did try local semaphore = require("semaphore")

but doesn’t seem to be in the library…. And not sure if it was were the directory is located…

?

Thangs Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control


here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?

?


Re: wxlua frame

 

开云体育

We will keep out if this for now ... I sent you an example

______________________________

Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 
On 1/27/2023 12:09 PM, Gary wrote:

Brian,

?

I tried out the mcFileHoldAquire() in the m6 file it did stop there and I was able to jog the axis’s.

But after jogging I hit cycle start button it seemed to get stuck on the next statement that is a ?mcCntlGcodeExecute()? Its didn’t lock up the system but hitting cycle start doesn’t seen to matter just never would exit the m6 script, if I hit cycle stop it would stop and exit the m6 script..

I also tried adding a mc.mcFileHoldRelease() but had no effect..

?

Thanks Gary

?

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control

here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?


Re: wxlua frame

 

开云体育

Hi Gary,

Sorry I was coaching robotics and had a comp this weekend so I was flat out :) The good news is that I had 2 more teems qualify for states! Okay back to work!?


We don't have any real library for semaphores, it's really telling you how you need to architect the system. Let me see if I can make something to show you how I would do it in a screen. But basically we don't allow graphics in the Macro's (Mostly because we didn't see the need and I think this is still the best). How you communicate to the macro's is through registers. The registers are the only way to have thread safe data in Lua to the rest of the system. Having graphics in the Mcodes could and would put the events into the macro's / Gcode thread and we REALLY don't want that! By communicating via registers it will allow you to have your dialog and not have the Gcode interpreter thread plugged up with graphics.


Now onto the solution!


You need to setup a register in the register conifig dialog:

Mine is at the following path "iRegs0/ToolSettings"


So in my M6 macro I would put the following:

local inst = mc.mcGetInstance("M6 Toolchange")
local tchangeReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
local rc = mc.mcRegSetValue(tchangeReg,"ShowTchangeDlg")

-- Code to wait for the dialog to end
while(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg") do
?? ?wx.wxMilliSleep(500)
?-- May want to add some code here in the event someone presses stop or kills the program
end
local ReturnValue = mc.mcRegGetValue(tchangeReg)

-- Continue with the toolchanger and you have the return in the register.



Now in the screen you can put your dialog in a function and check to see if you need to launch it in the PLC script :


local inst = mc.mcGetInstance("M6 Toolchange Dialog")
if(toolchangeActiveReg == nil)then -- put the handle to the toolchange Osig in the global table
?? ?toolchangeActiveReg = mc.mcSignalGetHandle(inst,mc.OSIG_TOOL_CHANGE)
end
if(tchangeDlogReg == nil)then
tchangeDlogReg = mc.mcRegGetHandle(inst,"iRegs0/ToolSettings")
end

if(mc.mcRegGetValue(tchangeReg) == "ShowTchangeDlg" and mc.mcSignalGetState(toolchangeActiveReg) == 1 && dlghandle == nil)then
?? ?
?? ?dlghandle = YourDialogFunction()-- Remember to pass back something from the dialog so we know it has been done
else
?? ?if(mc.mcRegGetValue(tchangeReg) ~= "ShowTchangeDlg" and? dlghandle ~= nil) then
?? ??? ?dlghandle = nil-- kill the dialog so the garbage collector can get it back
?? ?end
end



This is all untested and 100% can be changed but I think it clearly shows how I would do it :)


Hope that helps!

______________________________

Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 
On 1/27/2023 9:38 AM, Gary wrote:

Ok thanks Brian,

?

I will try them out, by in the screen not sure what screen the frame? The screen load script ?

?

What my real goal was or is, I have a rotary tool changer, I am checking the m6 macro to see if the new tool is in the rack if not the switching to a manual tool change, the dialog was just a thought if the tool not in rack then give the option to manual tool change and continue is the tool is in the tool table an offset it set, or is tool not in the table and or offset not set then jog down and touch off top of part, or the option to use a touch off plate and probe it, leaving the choices up to me hence the frame and buttons..

?

I will most likely need help I am starting to go over my head now… I did try local semaphore = require("semaphore")

but doesn’t seem to be in the library…. And not sure if it was were the directory is located…

?

Thangs Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control

here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?


Re: Where are the Mach4 screen sets?

 

开云体育

Thank you Chuck!

Have a great weekend,

Bertho

?

From: [email protected] <[email protected]> On Behalf Of Chuck Kahler
Sent: 27 January, 2023 0:27
To: [email protected]
Subject: Re: [MachCNC] Where are the Mach4 screen sets?

?

Bertho,

?

Here’s the Laser screen you’re looking for.

?

Trever sent it to me a while back.?

?

Happy lasering,

Chuck

?

?

-sent from my iphone --

?

?



On Jan 26, 2023, at 3:11 PM, Bertho <boman33@...> wrote:

?

?

Hi Trevor,

Oops, I now see that I misspelled your email address.

?

I am looking for a copy of the laser cutting screen for Mach4.

?

Best Regards,

?

Bertho Boman

Bertho Boman

President/CEO

Vinland Corporation

11600 NW 20th Street, Fort Lauderdale, Florida 33323, USA

+1 (954) 475-9093

ISO-9001 & ISO-13485 (Medical design/Manufacturing) certified

Manufacturing Plant: 1700 NW 65th Ave, #3, Fort Lauderdale, Florida

1977 – 2022? Our 45th? year in business

?

?

?

From: boman33@... <boman33@...>
Sent: 16 January, 2023 14:28
To: 'TrevorW@...' <TrevorW@...>
Subject: FW: [MachCNC] Where are the Mach4 screen sets?

?

Hi Trevor,

Can you please send me the Mach4 laser cutting screen that Brian mentioned?

Bertho Boman

----------------------------------------

We just did a laser cutting screen. Send Trevor a message and ask about it.

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/16/2023 11:58 AM, Bertho wrote:

Thanks Brian for a fast reply,

I have been modifying the screens for Mach3 so the next step has to be Mach4 screen.

I am surprised that there are not screens for routers and laser cutters.

People used to upload Mach3 screens, and I expected the same thing to happen with Mach4 screen.

I have modified a CNC milling screen and I was looking for a laser cutting screen.

?

Take Care, Stay Well & Safe,

?????? Bertho

?

From: [email protected] <[email protected]> On Behalf Of Brian Barker
Sent: 16 January, 2023 8:14
To: [email protected]
Subject: Re: [MachCNC] Where are the Mach4 screen sets?

Hi,

Some of the screen sets shown are not available and some are just some that we did for fun. The video was more to show what you can do not what you can download. Having said that if you see something that you really like we can show you how we did it.

?

Thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/15/2023 8:44 AM, Bertho wrote:

The YouTube Mach4 demo:

Shows many included Mac4 screen sets.?

The download and the website only show three.?

The search function appears to be broken for Mach4.

I found a link to lots of Mac3 screens.

Where are all the Mach4 screen?

?

Take Care, Stay Well & Safe,

?????? Bertho

Attachments:


Re: Where are the Mach4 screen sets?

 

开云体育

Brian,

I am in the process of moving Mach4 to a new computer and at the same time switching to the Ethernet Smooth Stepper.

When I have it up and running I will get you feedback.

Have a great weekend,

Bertho

?

From: [email protected] <[email protected]> On Behalf Of Brian Barker
Sent: 27 January, 2023 8:39
To: [email protected]
Subject: Re: [MachCNC] Where are the Mach4 screen sets?

?

If you are playing with the new screen that we have for laser I would like to know what your thoughts are on it. We are getting ready for this to go out into the wild!

Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/27/2023 12:26 AM, Chuck Kahler wrote:

Bertho,

?

Here’s the Laser screen you’re looking for.

?

Trever sent it to me a while back.?

?

Happy lasering,

Chuck

?

?

-sent from my iphone --

?

?



On Jan 26, 2023, at 3:11 PM, Bertho <boman33@...> wrote:

?

?

Hi Trevor,

Oops, I now see that I misspelled your email address.

?

I am looking for a copy of the laser cutting screen for Mach4.

?

Best Regards,

?

Bertho Boman

Bertho Boman

President/CEO

Vinland Corporation

11600 NW 20th Street, Fort Lauderdale, Florida 33323, USA

+1 (954) 475-9093

ISO-9001 & ISO-13485 (Medical design/Manufacturing) certified

Manufacturing Plant: 1700 NW 65th Ave, #3, Fort Lauderdale, Florida

1977 – 2022? Our 45th? year in business

?

?

?

From: boman33@... <boman33@...>
Sent: 16 January, 2023 14:28
To: 'TrevorW@...' <TrevorW@...>
Subject: FW: [MachCNC] Where are the Mach4 screen sets?

?

Hi Trevor,

Can you please send me the Mach4 laser cutting screen that Brian mentioned?

Bertho Boman

----------------------------------------

We just did a laser cutting screen. Send Trevor a message and ask about it.

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/16/2023 11:58 AM, Bertho wrote:

Thanks Brian for a fast reply,

I have been modifying the screens for Mach3 so the next step has to be Mach4 screen.

I am surprised that there are not screens for routers and laser cutters.

People used to upload Mach3 screens, and I expected the same thing to happen with Mach4 screen.

I have modified a CNC milling screen and I was looking for a laser cutting screen.

?

Take Care, Stay Well & Safe,

?????? Bertho

?

From: [email protected] <[email protected]> On Behalf Of Brian Barker
Sent: 16 January, 2023 8:14
To: [email protected]
Subject: Re: [MachCNC] Where are the Mach4 screen sets?

Hi,

Some of the screen sets shown are not available and some are just some that we did for fun. The video was more to show what you can do not what you can download. Having said that if you see something that you really like we can show you how we did it.

?

Thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/15/2023 8:44 AM, Bertho wrote:

The YouTube Mach4 demo:

Shows many included Mac4 screen sets.?

The download and the website only show three.?

The search function appears to be broken for Mach4.

I found a link to lots of Mac3 screens.

Where are all the Mach4 screen?

?

Take Care, Stay Well & Safe,

?????? Bertho

Attachments:


Re: wxlua frame

 

开云体育

Brian,

?

I tried out the mcFileHoldAquire() in the m6 file it did stop there and I was able to jog the axis’s.

But after jogging I hit cycle start button it seemed to get stuck on the next statement that is a ?mcCntlGcodeExecute()? Its didn’t lock up the system but hitting cycle start doesn’t seen to matter just never would exit the m6 script, if I hit cycle stop it would stop and exit the m6 script..

I also tried adding a mc.mcFileHoldRelease() but had no effect..

?

Thanks Gary

?

?

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control

here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?


Re: wxlua frame

 

开云体育

Ok thanks Brian,

?

I will try them out, by in the screen not sure what screen the frame? The screen load script ?

?

What my real goal was or is, I have a rotary tool changer, I am checking the m6 macro to see if the new tool is in the rack if not the switching to a manual tool change, the dialog was just a thought if the tool not in rack then give the option to manual tool change and continue is the tool is in the tool table an offset it set, or is tool not in the table and or offset not set then jog down and touch off top of part, or the option to use a touch off plate and probe it, leaving the choices up to me hence the frame and buttons..

?

I will most likely need help I am starting to go over my head now… I did try local semaphore = require("semaphore")

but doesn’t seem to be in the library…. And not sure if it was were the directory is located…

?

Thangs Gary

?

Sent from for Windows

?

From: Brian Barker
Sent: Friday, January 27, 2023 8:36 AM
To: [email protected]
Subject: Re: [MachCNC] wxlua frame

?

Hi Gary,

What you will need to do is put this code in the screen (where graphics are done). In your M6 set a register to a value that will trigger the dialog in the screen. You will need a spinlock checking to see when your dialog is done (set some other register stating that the Macro needs to continue) . We do have some other tools to hold a macro (mcFileHoldAquire) but it's a bit more advanced (This is the tool that allows the manual tool change to work) and what is also doing the the work for the mcCntlWaitOnCycleStart command. Try that out and tell me how it works for you. If you would like a hand doing it I am more than happy to assist you with the programming. I think this would be a cool router feature :)

?

thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/26/2023 7:00 PM, Gary wrote:

----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine module script
-- Runs from a button script
----------------------------------------------------------
inst = mc.mcGetInstance()
local path = mc.mcCntlGetMachDir(inst)
package.path = path .."\\Modules\\?.lua;"

??? --mach4ProbeMenu module
package.loaded.mach4ProbeMenu = nil
pb = require "mach4ProbeMenu"
?? ?
pb.M6Menu()



----------------------------------------------------------
-- frame with 4 buttons inside a Coroutine modual script
-- this goes into the modules folder
----------------------------------------------------------
------------------------------------------------------------------------------------
-- Module to be called with button script
-- So far i have not been able to get to run correct being called from a g code file
------------------------------------------------------------------------------------
local M6Control = {}

function M6Control.M6Menu()

local function button1Event(event)
??? coroutine.wrap(function()
??????? -- code for button 1 event
??? end)()
end

local function button2Event(event)
??? coroutine.wrap(function()
??????? -- code for button 2 event
??? end)()
end

local function button3Event(event)
??? coroutine.wrap(function()
??????? -- code for button 3 event
??? end)()
end

local function button4Event(event, frame)
??? coroutine.wrap(function()
??? Abort()
??? frame:Destroy()
??????? -- code for button 4 event
??? end)()
end

local function main()
??? -- Create a new frame
??? local frame = wx.wxFrame(wx.NULL, wx.wxID_ANY, "My Frame",
??????????????????????????? wx.wxDefaultPosition, wx.wxSize(340, 400))

??? -- Create Text above each button
??? local text1 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Button:\nTool must be in the Tool Table and offset set Swap tool out then Press Manual",
??????????????????????????????? wx.wxPoint(20, 10), wx.wxSize(150, 100))
??? local text2 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Touch:\nSwap tool out then Jog Z down to part surface use a feeler gauge, then Press Manual Touch",
??????????????????????????????? wx.wxPoint(20, 70), wx.wxSize(150, 100))
??? local text3 = wx.wxStaticText(frame, wx.wxID_ANY, "Manual Probe:\nSwap tool out then put your touch off plate on top of part, Z will move down to above part surface and probe part, After Pressing Manual Touch",
??????????????????????????????? wx.wxPoint(20, 150), wx.wxSize(150, 100))
??? local text4 = wx.wxStaticText(frame, wx.wxID_ANY, "Abort:\nPress abort only if you cannot do a tool swap it will exit and also will disable the machine stop all code from running",
??????????????????????????????? wx.wxPoint(20, 250), wx.wxSize(150, 100))

??? -- Create buttons
??? local button1 = wx.wxButton(frame, wx.wxID_ANY, "Manual",
??????????????????????????????? wx.wxPoint(200, 20), wx.wxSize(100, 30))
??? local button2 = wx.wxButton(frame, wx.wxID_ANY, "Manual Touch",
??????????????????????????????? wx.wxPoint(200, 90), wx.wxSize(100, 30))
??? local button3 = wx.wxButton(frame, wx.wxID_ANY, "Manual Probe",
??????????????????????????????? wx.wxPoint(200, 180), wx.wxSize(100, 30))
??? local button4 = wx.wxButton(frame, wx.wxID_ANY, "Abort",
??????????????????????????????? wx.wxPoint(200, 270), wx.wxSize(100, 30))

??? -- Connect button events
??? button1:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button1Event)
??? button2:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button2Event)
??? button3:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, button3Event)
??? button4:Connect(wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) button4Event(event, frame) end)

-- Show the frame
frame:Show(true)
end

local co = coroutine.wrap(main)
co() -- start the coroutine

function Abort()
--frame:Destroy()
wx.wxMessageBox("Abort")
end
wx.wxGetApp():MainLoop()
end

--M6Control.M6Menu()

return M6Control

here is an example of the code i have been trying, i wanted to call the frame when doing a tool change, based on checking some registers that may be set..
and only call the frame if need be...

Thanks gary

?


Re: Where are the Mach4 screen sets?

 

开云体育

Brian,

As it turned out, this laser screen was not intended for the way I am using my laser. So I cannot provide you any comments on it.

Keep up the good work,
Chuck
?

-sent from my iphone --



On Jan 27, 2023, at 5:38 AM, Brian Barker <brianb@...> wrote:

?

If you are playing with the new screen that we have for laser I would like to know what your thoughts are on it. We are getting ready for this to go out into the wild!

Brian


______________________________

Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 
On 1/27/2023 12:26 AM, Chuck Kahler wrote:
Bertho,

Here’s the Laser screen you’re looking for.

Trever sent it to me a while back.?

Happy lasering,
Chuck


-sent from my iphone --



On Jan 26, 2023, at 3:11 PM, Bertho <boman33@...> wrote:

?

?

Hi Trevor,

Oops, I now see that I misspelled your email address.

?

I am looking for a copy of the laser cutting screen for Mach4.

?

Best Regards,

?

Bertho Boman

Bertho Boman

President/CEO

Vinland Corporation

11600 NW 20th Street, Fort Lauderdale, Florida 33323, USA

+1 (954) 475-9093

ISO-9001 & ISO-13485 (Medical design/Manufacturing) certified

Manufacturing Plant: 1700 NW 65th Ave, #3, Fort Lauderdale, Florida

1977 – 2022? Our 45th? year in business

?

?

?

From: boman33@... <boman33@...>
Sent: 16 January, 2023 14:28
To: 'TrevorW@...' <TrevorW@...>
Subject: FW: [MachCNC] Where are the Mach4 screen sets?

?

Hi Trevor,

Can you please send me the Mach4 laser cutting screen that Brian mentioned?

Bertho Boman

----------------------------------------

We just did a laser cutting screen. Send Trevor a message and ask about it.

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/16/2023 11:58 AM, Bertho wrote:

Thanks Brian for a fast reply,

I have been modifying the screens for Mach3 so the next step has to be Mach4 screen.

I am surprised that there are not screens for routers and laser cutters.

People used to upload Mach3 screens, and I expected the same thing to happen with Mach4 screen.

I have modified a CNC milling screen and I was looking for a laser cutting screen.

?

Take Care, Stay Well & Safe,

?????? Bertho

?

From: [email protected] <[email protected]> On Behalf Of Brian Barker
Sent: 16 January, 2023 8:14
To: [email protected]
Subject: Re: [MachCNC] Where are the Mach4 screen sets?

Hi,

Some of the screen sets shown are not available and some are just some that we did for fun. The video was more to show what you can do not what you can download. Having said that if you see something that you really like we can show you how we did it.

?

Thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/15/2023 8:44 AM, Bertho wrote:

The YouTube Mach4 demo:

Shows many included Mac4 screen sets.?

The download and the website only show three.?

The search function appears to be broken for Mach4.

I found a link to lots of Mac3 screens.

Where are all the Mach4 screen?

?

Take Care, Stay Well & Safe,

?????? Bertho

Attachments:


Re: Where are the Mach4 screen sets?

 

开云体育

If you are playing with the new screen that we have for laser I would like to know what your thoughts are on it. We are getting ready for this to go out into the wild!

Brian


______________________________

Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 
On 1/27/2023 12:26 AM, Chuck Kahler wrote:

Bertho,

Here’s the Laser screen you’re looking for.

Trever sent it to me a while back.?

Happy lasering,
Chuck


-sent from my iphone --



On Jan 26, 2023, at 3:11 PM, Bertho <boman33@...> wrote:

?

?

Hi Trevor,

Oops, I now see that I misspelled your email address.

?

I am looking for a copy of the laser cutting screen for Mach4.

?

Best Regards,

?

Bertho Boman

Bertho Boman

President/CEO

Vinland Corporation

11600 NW 20th Street, Fort Lauderdale, Florida 33323, USA

+1 (954) 475-9093

ISO-9001 & ISO-13485 (Medical design/Manufacturing) certified

Manufacturing Plant: 1700 NW 65th Ave, #3, Fort Lauderdale, Florida

1977 – 2022? Our 45th? year in business

?

?

?

From: boman33@... <boman33@...>
Sent: 16 January, 2023 14:28
To: 'TrevorW@...' <TrevorW@...>
Subject: FW: [MachCNC] Where are the Mach4 screen sets?

?

Hi Trevor,

Can you please send me the Mach4 laser cutting screen that Brian mentioned?

Bertho Boman

----------------------------------------

We just did a laser cutting screen. Send Trevor a message and ask about it.

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/16/2023 11:58 AM, Bertho wrote:

Thanks Brian for a fast reply,

I have been modifying the screens for Mach3 so the next step has to be Mach4 screen.

I am surprised that there are not screens for routers and laser cutters.

People used to upload Mach3 screens, and I expected the same thing to happen with Mach4 screen.

I have modified a CNC milling screen and I was looking for a laser cutting screen.

?

Take Care, Stay Well & Safe,

?????? Bertho

?

From: [email protected] <[email protected]> On Behalf Of Brian Barker
Sent: 16 January, 2023 8:14
To: [email protected]
Subject: Re: [MachCNC] Where are the Mach4 screen sets?

Hi,

Some of the screen sets shown are not available and some are just some that we did for fun. The video was more to show what you can do not what you can download. Having said that if you see something that you really like we can show you how we did it.

?

Thanks
Brian

?

______________________________
?
Brian Barker
Engineering / Development
ArtSoft | Newfangled Solutions
Livermore Falls, Maine (USA)
Webpage: 

On 1/15/2023 8:44 AM, Bertho wrote:

The YouTube Mach4 demo:

Shows many included Mac4 screen sets.?

The download and the website only show three.?

The search function appears to be broken for Mach4.

I found a link to lots of Mac3 screens.

Where are all the Mach4 screen?

?

Take Care, Stay Well & Safe,

?????? Bertho

Attachments: