Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: jevs on August 23, 2019, 11:24:20 PM
-
Please tell me why this will not work?
I am just trying to make my +Jog physical switch jog the X axis 1 inch when pressed IF the selector switch is in the X position (input 44 is on) and the Step Jog switch is set to x1 (input 19 is on). I am sure this should be and probably will be simple for a couple of you, but something so basic should not be so ridiculous to figure out. The switches are going through a Pokeys 57E and are registering properly with Pokeys Monitor (green when in position or pressed on, and white when not). I have the pokeys input pin number assigned to the same input number in the Mach4 settings.
[mc.ISIG_INPUT51] = function (state)
if(state == 1) then
local inst = mc.mcGetInstance()
local XSelected = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT44)
local axSelX = mc.mcSignalGetState (XSelected)
local x1 = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT19)
local jogSel = mc.mcSignalGetState (x1)
if (axSelX == 1) and (jogSel == 1) then
rc = mc.mcJogIncStart(inst,0,1)
end
end
end,
If I get rid of these lines then it will jog 1 inch, but this defeats what I need:
local inst = mc.mcGetInstance()
local XSelected = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT44)
local axSelX = mc.mcSignalGetState (XSelected)
local x1 = mc.mcSignalGetHandle (inst, mc.ISIG_INPUT19)
local jogSel = mc.mcSignalGetState (x1)
if axSelX == 1 and jogSel == 1 then
Basically omitting the IF stuff where it does not check the other switches, then it will jog an inch. I just cannot get the If statements to work based on the input status of the other two switches no matter what I try so far.
One thing that is irritating is that you cannot use debug, it skips over these siglib and I just seem to get Nil values to show (when I have not created an error trying something).
-
Nevermind....I got it working!
Somehow I lost my pin assignment in the pokeys plugin for 44....or I forgot to turn it on. So simple and so much time wasted. Grr, my fault.
However I am also changing the way I am doing this. I am going to have the jog+ button and Jog- minus Siglib checks call up functions CPJogPlus() and CPJogMinus()......
In all of this digging and pulling hair, I learned how to make the switch state changing go to a function rather than trying to put the code within the siglib.....
This seems like a good win for the night and a good place to go to bed not frustrated :)
-
Good!
This may help
https://www.machsupport.com/forum/index.php?topic=33402.msg232270#msg232270