399
« on: November 09, 2017, 07:50:37 PM »
I am not at this stage trying to jog anything. I am trying to get the jog increment changed programatically so that later I can use a xBox to change it and have the xBox and the keyboard have the same increments all the time. Every time I change the increment I play a wav file that tells me what increment I have selected. Since my Lua panel code was unsuccessful I just added a button to refine the tests.
Attached are two pics, one of the dro with dro code set to Current Jog Incr. and the button with code below. If you open the register diagnostic window and pin it like the second photo you can see the registers change.
Here is the button script
local NewInc=0
local i=0
local mInst=mc.mcGetInstance()
local CurInc = mc.mcProfileGetInt(mInst,"Preferences","JogIncSet",0) --Get the previously saved setting in profile to hold our current inc number
local SetInc = mc.mcProfileGetDouble(mInst,"Preferences","JogInc",0.00) -- fetch our inc value from the profile JogInc + 2 say = [Preferences][JogInc2]
--check to see if the JogInc exists
for i = 1 , 10 ,1 do
if SetInc == mc.mcProfileGetDouble(mInst,"Preferences","JogInc"..tostring(i),0.00)then
mc.mcCntlSetLastError(mInst,"Matched "..tostring(SetInc).." - "..tostring(i))
NewInc=i
end
end
--did we find a match
if NewInc==0 then
mc.mcCntlSetLastError(mInst,"current setting does not match")
end
--choose the next increment
if NewInc==10 then
NewInc=1
else
NewInc=NewInc+1
end
CurInc=NewInc
SetInc = mc.mcProfileGetDouble(mInst,"Preferences","JogInc"..tostring(CurInc),0.00)
--this is where I assumed it would be the same as typing a new value in but it isn't
scr.SetProperty('droJogInc',"Value",tostring(SetInc)) --set the dro to the distance to jog
--save the profile updated information
mc.mcProfileWriteInt(mInst,"Preferences","JogIncSet",CurInc) --set our profile to new CurInc
mc.mcProfileWriteDouble(mInst,"Preferences","JogInc",SetInc) --set our profile to new SetInc
--[[assumed the above would change the registers but it doesn't so do it, this was commented out to test
whether the button code changed the registers but it didn't while a manual entry of a jog increment key press did
same as Scott's for i,0,5 example
--]]
mc.mcJogSetInc(mInst, mc.X_AXIS, SetInc) -- set inc for axis
mc.mcJogSetInc(mInst, mc.Y_AXIS, SetInc) -- set inc for axis
mc.mcJogSetInc(mInst, mc.Z_AXIS, SetInc) -- set inc for axis
mc.mcJogSetInc(mInst, mc.A_AXIS, SetInc) -- set inc for axis
mc.mcJogSetInc(mInst, mc.B_AXIS, SetInc) -- set inc for axis
mc.mcJogSetInc(mInst, mc.C_AXIS, SetInc) -- set inc for axis
mc.mcProfileFlush(mInst)
mc.mcProfileReload(mInst)
-- local s=tostring(CurInc)
-- mc.mcCntlSetLastError(mInst,s)
do a couple of jog increment presses, then jog, and then do a couple of button presses and a couple of jogs and you will see that the even though the
values have been written to the prfile and the registers changed the jog is still what ist was set to before the button presses
All this really proves is that Programatically entering a new value in a jog dro does not have the same effect as entering a value manually. And shows that writing to the profile and registers does not have the same effect as using the Jog cycle increment key.
Or did I miss something here?
RT