3
« on: November 22, 2023, 06:33:04 PM »
I tried in vain to use "wait = coroutine.create(TestButton)". Does it go in the "Clicked Script". I can't find it in the screen or script manual. Could you say a little more about how it is used, where it goes, or what manual it's in. I don't mind reading them.
I can put "TestButton()" in for the "clicked script" and it finds the function in the Screen Load Script (I added it there). The problem is that the axes do not get zeroed. The machine jogs and the function goes to completion (the last line executes) without errors but these two lines do nothing.
mc.mcAxisSetPos(inst, 0, 0)
mc.mcAxisSetPos(inst, 1, 0)
The button does not find the function if it's in the modules directory and I do get an error that it's nil.
I would make a code window in the post as other do, if I knew how. Sorry.
The code-
function TestButton()
--Move axis 1/2 bit diameter in X+ and Y+
--Set current position as X and Y zero in work coordinates
--Get bit diameter and set jog distance
local strBitDiam = scr.GetProperty("JogToValue", "Value")
local AxisJog = tonumber(strBitDiam) / 2
local strAxisJog = tostring(AxisJog)
-- Jog controller 0 in the X and Y axes;
mc.mcJogIncStart(inst, 2, 1)
mc.mcJogIncStart(inst, 0, AxisJog)
mc.mcJogIncStart(inst, 1, AxisJog)
--Put code in MDI to show step
--This does execute
scr.SetProperty("mdi1", "Value", "After jog")
-- Set local coordinates to zero for the X and Y axes
--These do not execute, or at least values do not get zeroed. No error returned.
mc.mcAxisSetPos(inst, 0, 0)
mc.mcAxisSetPos(inst, 1, 0)
--Put code in MDI to show step
--This does execute
scr.SetProperty("mdi1", "Value", "After zeroing")
end