Hello Guest it is June 04, 2024, 09:50:12 PM

Show Posts

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


Messages - SwiftyJ

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 »
21
Mach4 General Discussion / Re: Macro will not jog mill
« on: November 24, 2023, 03:16:56 PM »
Hi,

Add this function to the screen load script
Code: [Select]
function TestButton()
--Move axis 1/2 bit diameter in X+ and Y+
--Set current position as X and Y zero in work coordinates
local inst = mc.mcGetInstance()
--Get bit diameter and set jog distance
local strBitDiam = scr.GetProperty("JogToValue", "Value")
local AxisJog = tonumber(strBitDiam) / 2
   
-- Jog controller 0 in the X and Y axes;
mc.mcJogIncStart(inst, 2, 1)
coroutine.yield() --Wait for idle state
mc.mcJogIncStart(inst, 0, AxisJog)
mc.mcJogIncStart(inst, 1, AxisJog)
coroutine.yield() --Wait for idle state
   
-- Set local coordinates to zero for the X and Y axes
mc.mcAxisSetPos(inst, 0, 0)
mc.mcAxisSetPos(inst, 1, 0)
end

Add this to clicked script or left up script of a button
Code: [Select]
wait = coroutine.create(TestButton)

22
Initialise it at the start of the Screen Load script, not the PLC script. The Screen Load Script runs once when Mach4 starts

23
You can initialise variables at the top of the screen load script. Don’t make it a local variable though otherwise the PLC script won’t see it

24
You need to make a copy of the screenset you are using as well inside the c:/mach4hobby/screens folder. As you are using the mill profile it will be using the wx4 screenset that you are using. This is where all the lua code is actually stored. After making a copy of the screen file and renaming it, you can load it when you open mach4 through the View menu

25
Mach4 General Discussion / Re: Mach4 Closing
« on: August 26, 2023, 04:47:27 AM »
You can do something like this:
Code: [Select]
function m166()
local inst = mc.mcGetInstance()

--Wait for input0 to go high, timeout 2 seconds
rc = mc.mcSignalWait(inst, mc.ISIG_INPUT0, mc.WAIT_MODE_HIGH, 2)

if (rc == mc.MERROR_TIMED_OUT) then
--Stop the program if timed out
mc.mcCntlMacroStop(inst, rc, "Timeout waiting for signal")
return
end

end

if (mc.mcInEditor() == 1) then
m166()
end

You'll have to adjust it for the signal you're waiting for and the wait mode. There are a few options FALL, HIGH, RISE, NONE, LOW

26
Mach4 General Discussion / Re: Problem with custom M5 macro
« on: August 13, 2023, 05:27:49 AM »
I'm getting the same result as you, trying to execute a custom macro within another macro causes it to hang. You will have to turn off the spindle in the m30 using mc.mcSpindleSetDirection like you did in the m6.. it's probably the better way to do it anyway

27
Mach4 General Discussion / Re: FIFO Drain Error
« on: August 12, 2023, 06:17:58 AM »

28
Mach4 General Discussion / Re: Problem with custom M5 macro
« on: August 10, 2023, 03:15:34 PM »
Can you post your m6 and m30 macro?

29
Mach4 General Discussion / Re: I want to make a runtime time counter
« on: July 23, 2023, 06:20:02 AM »
Hi, you can use wxStopWatch for this. It allows you to pause and resume

https://docs.wxwidgets.org/3.0/classwx_stop_watch.html

30
Mach4 General Discussion / Re: Mach4 Signal Tower script
« on: June 22, 2023, 03:20:12 PM »
Thank you very much for your input!
Can you please share an example script for one LED? (and where to put it)

I have attached an example I did in the PMC. Currently it is configured to turn on Output2 when Tool Change is active, but if you go into the PMC editor and double click 'FYellowLight' you can change it to whatever you have it mapped to.

To get it to work:
  • Copy the file into C:\Mach4Hobby\PMC.
  • Access the PMC editor within Mach4 by going to Configure>PMC. Then load the .pmc file through the File>Open menu.
  • After any changes you need to generate the lua code.
  • Within the PMC editor go to Settings>Code Generator and select 'Lua Code'.
  • Then go to Generate>Generate as and save the lua file.
  • To load the file you need to go into the screen editor, select the top level item in the tree, go to the Properties tab and at the bottom is PMC Objects where you can select the file just generated.

Or just watch this video which I found after typing all that out https://www.youtube.com/watch?v=jVhH9qyjjf0

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