Hello Guest it is April 25, 2024, 12:50:35 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 »
31
Mach4 General Discussion / Re: PLC Script not updating all registers?
« on: March 01, 2023, 08:30:43 AM »
Hi, it looks like you are not reading the value of the register before performing calculations. You are performing calculations on the handle of the register which is just a number.. hence why everything executes correctly.

See below

Code: [Select]
---------------------------------------------------------
--          scale VFD readbacks
---------------------------------------------------------

local iVoltsHANDLE=mc.mcRegGetHandle(inst,"MbVFD/R_VFDVolt_V");

local iVolts = mc.mcRegGetValue(inst, iVoltsHANDLE) ----------------Missing this

local hVolts=mc.mcRegGetHandle(inst,"iRegs0/MbVFD/Volts_S");
local readBackVolts=iVolts/10;                                  ---------------- Now calculations will be performed on the value of the register just read
mc.mcRegSetValue(hVolts,readBackVolts);

32
Mach4 General Discussion / Re: Script Debugging
« on: March 01, 2023, 08:19:03 AM »
Instead of using mc.mcAxisGetPos for getting the xstart and ystart position, use mc.mcAxisGetMachinePos. You are currently getting the axis position for the current work offset and then using these positions with G53 which moves the machine in machine coordinates.

By using mc.mcAxisGetMachinePos, you will get the start positions in machine coordinates and then the G53 will work correctly.


33
Mach4 General Discussion / Re: Keyboard jogging safety
« on: February 27, 2023, 05:03:45 PM »
You can use the following screen API call to get the active window name - scr.GetActiveWindowText(). You can monitor this in the PLC script and disable the keyboard output when it's not the name of the main GUI window. You can get the name of the main GUI with the following register "core/global/GuiName"

34
Mach4 General Discussion / Re: how Fire up the timer on screen set
« on: December 14, 2022, 04:28:30 PM »
Hi, you can use:

scr.SetProperty(“tmr(1)”, “Command”, “START”)

Be sure to use the name of the timer in your screen. I’m guessing STOP works as well to stop it

35
Mach4 General Discussion / Re: touchscreen shut down button
« on: December 14, 2022, 12:07:17 PM »
You can use:

scr.Exit(false)

36
Mach4 General Discussion / Re: PLC Inputs
« on: December 04, 2022, 12:34:33 PM »
Which type of button are you using to activate input 1?

37
Mach4 General Discussion / Re: How to remember DRO and Fixtures in Mach4?
« on: November 19, 2022, 05:35:23 AM »
You can use mc.mcFixtureSaveFile(inst) to save the fixture offsets file. So you can add this to the end of any button script that you use to set the offsets

38
Mach4 General Discussion / Re: Sound in Mach4
« on: September 26, 2022, 03:15:26 PM »
Try this...just replace the path with the path to your sound

Code: [Select]
local sound = wx.wxSound("C:\\Windows\\Media\\chimes.wav", false)
sound:Play(wx.wxSOUND_ASYNC)

39
Mach4 General Discussion / Re: M6 toolchange Lua script help?
« on: September 06, 2022, 04:30:48 PM »
You have done pretty well so far! In the API docs it gives API usage for Lua and C/C++(I think) looks like you are using the C/C++ version. Below is what you need for lua.

mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON)

You also don’t need to define variable types with lua, so where you have:
int axis = mc.Z_AXIS
It can just be:
axis = mc.Z_AXIS

But really you don’t need the above as you can use mc.Z_AXIS and mc.MC_ON directly in the API call

Hope this helps..

40
Mach4 General Discussion / Re: lua in Mach 4
« on: August 22, 2022, 01:47:00 PM »
That is just the same as the example I posted earlier in this thread, in fact the link you posted is sort of out of date now as there are better ways.  Oh well..

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