Hello Guest it is November 27, 2021, 05:56:52 AM

Author Topic: Cannot Make Incremental Jog work with some "If" parameters!  (Read 405 times)

0 Members and 1 Guest are viewing this topic.

Offline jevs

*
  •  315 315
    • View Profile
Cannot Make Incremental Jog work with some "If" parameters!
« 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.

Code: [Select]
[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).
« Last Edit: August 23, 2019, 11:26:50 PM by jevs »

Offline jevs

*
  •  315 315
    • View Profile
Re: Cannot Make Incremental Jog work with some "If" parameters!
« Reply #1 on: August 24, 2019, 12:05:07 AM »
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 :)

Offline Chaoticone

*
  • *
  •  5,626 5,626
  • Precision Chaos
    • View Profile
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!