365
« on: December 04, 2016, 06:04:53 PM »
The return code from the controller (32670) is divided by 330 to give 99, I based this on velocity etc being set by percentage which I believe is the best approach, totally agree with NOT having 2 controllers ;-)
So just a few pointers to help you on your quest, I have downloaded and tested your script but unfortunately it kills any other form of jogging in mach4 - IE jog buttons and even the shuttle. You could do with setting some more 'if' statements.
You dont have to run everything in 1 timer, windows is an event driven os so use what is required.
There are many ways of retrieving a registry try
return mc.mcRegGetValueLong(hreg) instead of converting strings with tostring
Heres a few snippets from my script.
local mInst = 0
-- Enable
Xenabled = 0
JogRate = 0
Enable_Panel = wx.wxPanel( wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize)
Enable_Timer = wx.wxTimer(Enable_Panel)
-- Velocity
Vel_Panel = wx.wxPanel( wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize)
Vel_Timer = wx.wxTimer(Vel_Panel)
-- DPad
DPad_Panel = wx.wxPanel( wx.NULL, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxDefaultSize)
DPad_Timer = wx.wxTimer(DPad_Panel)
As you can see its possible to run many timers, these are a few and the only timer that is running const is the enable timer which is looking/waiting for the left trigger, on the left trigger value being over 150 it starts all the other timers and on release stops them.
Enable_Panel:Connect(wx.wxEVT_TIMER, function (event)
if GetXin("LTR_Val") > 150 and Xenabled == 0 then
JogRate = mc.mcJogGetRate(mInst, mc.X_AXIS)
EStop_Timer:Start(50)
DPad_Timer:Start(100)
Vel_Timer:Start(100)
LTH_Timer:Start(100)
RTH_Timer:Start(100)
BTN_Timer:Start(100)
Xenabled = 1
elseif GetXin("LTR_Val") < 50 and Xenabled == 1 then
DPad_Timer:Stop()
Vel_Timer:Stop()
EStop_Timer:Stop()
LTH_Timer:Stop
RTH_Timer:Stop()
BTN_Timer:Stop()
Xenabled = 0
mc.mcJogSetRate(mInst, mc.X_AXIS, JogRate)
mc.mcJogSetRate(mInst, mc.Y_AXIS, JogRate)
mc.mcJogSetRate(mInst, mc.Z_AXIS, JogRate)
end
end)
As you can see after releasing the left trigger my jograte is returned to what it was before and throughout the script is lots and lots of if and more if`s with the main goal of keeping overheads towards the gui at a minimum when the controller is not in use.
Must be time for a choccy biccy now ;-)
DazTheGas