Hello Guest it is April 18, 2024, 10:24:48 AM

Author Topic: LUA code seems to disable the machine?  (Read 1793 times)

0 Members and 1 Guest are viewing this topic.

LUA code seems to disable the machine?
« on: January 28, 2017, 03:58:13 PM »
I am having a strange issue I can't seem to get my head around.  I have the ESS which works fine, and I also have the Pokeys Plugin which I have been attempting to turn into a pendant.  Much of that works as well.

I have defined Port3-Pin16 on the ESS as SERVO ON, then inside of MACH4, i define Enable#2 as SERVO ON.

I use a relay enabled by Port3-Pin16 to enable the servo drivers, that all works perfect.  I can run gcode and that all works the servos are enabled.

Now when I move my Axis selector switch on my pendant that disables MACH4?

If I don't touch the pendant the message "No Axis Selected" prints on the console.  I just put these messages in to verify it was seeing the switches.  I can even comment out those messages for like the A Axis, the next switch position next to OFF, but it still disables MACH4.

If I enable Mach4 after this happens then I can use the pendant and jog the given axis.  I must be doing something wrong here and can't seem to figure out where I went wrong.


Any help or suggests are welcome, I am sure I did something stupid.  I remember this code all working before?



ESS Port3-Pin16 defined as SERVO ON
Mach4 Enable#2 SERVO ON

LUA code

if XSelect == 1 then
      mc.mcMpgSetAxis(inst,0,0)  -- X Axis
      mc.mcCntlSetLastError(inst,"X Selected")
      mc.mcSignalSetState(PenHandleLED,1)
                mc.mcCntlSetLastError(inst,"Handle LED ON")
   elseif YSelect == 1 then
      mc.mcMpgSetAxis(inst,0,1)  -- Y Axis
      mc.mcCntlSetLastError(inst,"Y Selected")
      mc.mcSignalSetState(PenHandleLED,1)
   elseif ZSelect == 1 then
      mc.mcMpgSetAxis(inst,0,2)  -- Z Axis
      mc.mcCntlSetLastError(inst,"Z Selected")
      mc.mcSignalSetState(PenHandleLED,1)
   elseif ASelect == 1 then
      mc.mcMpgSetAxis(inst,0,3)  -- A Axis
       mc.mcCntlSetLastError(inst,"A Selected")
      -- mc.mcSignalSetState(PenHandleLED,1)
   elseif OFFSelect == 1 then
      mc.mcMpgSetAxis(inst,0,-1)  -- No Axis
      mc.mcCntlSetLastError(inst,"No Axis Selected")
                mc.mcSignalSetState(PenHandleLED,0)
    end
Re: LUA code seems to disable the machine?
« Reply #1 on: January 28, 2017, 04:46:11 PM »
This clearly has something to do with the MACH4 enable outputs.

I think the first six enables are linked to the motors, you can delay their outputs in the motor tab.

I tried to change to enable #8, but when you enable MACH4 that output does not change.  Clearly I don't understand how the enables work in MACH4, and there is nothing in the preliminary manual.


Anyone understand what is really supposed to happen with the enable outputs?

Thanks

Russ
 
Re: LUA code seems to disable the machine?
« Reply #2 on: January 28, 2017, 07:14:33 PM »
Well after playing with this issue for hours and running many experiments it appears to be something with the Pokeys plugin.

I can configure MACH4 to use Enable#0 and that turns on my relays to enable the servo drives.  That works perfect and I can run gcode from there with no issues.

I can then turn some knobs on my pendant for feedrate and spindle control and they work perfect without issue.

Then when I attempt to turn the axis selection knob from No Axis to A axis this disables the machine and turns off the enable relay immediately.  Other buttons on the pendant will do exactly the same thing.

I then went into the screen script and commented out the lines that get executed if it sees the A selection input fire, so no setting the axis, no messages, no nothing, it still disables the machine immediately.

I have been working on this pokeys pendant for many months now and some of it works fine, in fact I thought I had it all working except the LED Matrix2, which the Polabs team is working on but apparently there are even more bugs than I had originally thought.

I guess no one else is playing with the Pokeys to setup a pendant for Mach4.

Russ
Re: LUA code seems to disable the machine?
« Reply #3 on: January 29, 2017, 09:42:01 AM »
Well I am actually embarrassed to post the solution.  What happened is I had my LUA code look at a Pokey input put where the Pendant ESTOP was connected.  At some point when I was changing wires in the control box I must have pressed the ESTOP button on the pendant.  The LUA code in the signal script was executing and as soon as I would enable the pendant the  machine would become disabled.  What took me so long to figure this out is MACH4 did not issue any message like ESTOP, the enable button just flashed.  So I added an additional LUA statement mc.mcCntlSetLastError(inst,"Pendant ESTOP Pressed") right after it issues the ESTOP so I know where it came from.

if PenStop == 1 then
      mc.mcCntlEStop(inst)
end

Feeling pretty stupid at this point, I was pretty certain I had all of this stuff working.  :)