Hello Guest it is December 11, 2019, 05:37:22 AM

Author Topic: MPG strange behavior  (Read 1167 times)

0 Members and 1 Guest are viewing this topic.

Offline mark4

*
  •  147 147
    • View Profile
MPG strange behavior
« on: April 12, 2018, 12:35:53 AM »
hello
i have a strange problem this is my setup. mach4,Ethernet smooth stepper, intel nuc with windows 10, ace 22 plc modbus over usb.
so the only job the plc has is to control two rotary switches one for axis X,Y,Z and A and one for X1,X10,X100 increment.
sometimes the axis will be set to say Y and X will jog. when you see this behavior all you need to do is flip the switch to one of
the other axises and back and it will jog on the proper axis. this usually happens after homing. the problem is i haven't been able to
successfully recreate the problem on demand so i cant tell whats wrong. if i were to guess i think it looses its way and doesn't look at the switch again if that makes sense. i am going to attach my screen load script please look at my switches and see if there is a problem. also i need to have an off position for the axis rotary switch and am not sure how to program that so when all switches are off mpg is off and no jog or the arrow buttons are active either would work for my setup.
thank you
mark
Re: MPG strange behavior
« Reply #1 on: April 12, 2018, 08:19:01 AM »
Your code, to me, looks fine.  When I set up MPGs I usually put something in the PLC script that way I know it is going to read my switches.  Sometimes,
I've noticed having switches in one position, I need to "update" the signal, like you have had to, so I put the function in the PLC script to always update.
You could do the same here, since you set up two functions to switch the Axis and Increment.  Just take out your messages, otherwise it will put the message into the log thousands and thousands of times, and then put your two functions right into the PLC script. 
No more code than you have, you won't notice any difference in the speed of the PLC run. 

------------------------
--Mark 4-12-18
--MPG Settings
AxisSelect()
IncSelect()
------------------------
Chad Byrd

Offline mark4

*
  •  147 147
    • View Profile
Re: MPG strange behavior
« Reply #2 on: April 13, 2018, 11:21:27 PM »
thanks for the reply i think i follow you but where would the
------------------------
--Mark 4-12-18
--MPG Settings
AxisSelect()
IncSelect()
------------------------
go. does that make lua look in the plc script for the functions.
mark

Re: MPG strange behavior
« Reply #3 on: April 13, 2018, 11:44:11 PM »
Hi,
I think what Chad means is you put the function calls in the PLC script so they get repeated but the function definitions can stay in the screen load script. All functions in the screen load script are available to be called from
any where in the GUI.

As you have written it the function AxisSelect() gets called only when ISIG_INPUT10 through ISIG_INPUT13 are changed as monitored by the signal library. Chad reccommendes that they be called at every pass
of the PLC script. In fact you could delete ISIG_INPUT10 thru ISIG_INPUT13 from the signal library, the PLC will run dozens of times per second so having the input signals monitored is somewhat redundant.

Chad also mentions taking out the messages so the log does not becomes dominated by endless repetitions of  confirmation of AxisSelect() function calls. I'm just not quite sure how he means to do that...
if your still listening Chad I'd like to know how you do that.

Craig
My wife left with my best friend...
     and I miss him!
Re: MPG strange behavior
« Reply #4 on: April 14, 2018, 12:44:16 AM »
Hey Craig,
What would you like to know? 
Chad Byrd
Re: MPG strange behavior
« Reply #5 on: April 14, 2018, 12:47:26 AM »
Hi Chad,
just wondering how you do this, I've put functions in the PLC script before and just about made the log unusable as a result.

Quote
Just take out your messages, otherwise it will put the message into the log thousands and thousands of times, and then put your two functions right into the PLC script. 

Craig
My wife left with my best friend...
     and I miss him!
Re: MPG strange behavior
« Reply #6 on: April 14, 2018, 12:49:50 AM »
You mean, how to send out only 1 message in the log?
Chad Byrd
Re: MPG strange behavior
« Reply #7 on: April 14, 2018, 01:33:40 AM »
Hi,
yeah that would be cool.

Craig
My wife left with my best friend...
     and I miss him!
Re: MPG strange behavior
« Reply #8 on: April 14, 2018, 01:39:52 AM »
All my stuff is at work, so I will have to double check Monday to be sure I have this correct.   But I can give you the overview.
I use #VARS .  Since there are hundreds we can use that aren't being used.   I choose a section of them to be "message vars"

For example.  
MPGX = mc.mcSignalGetHandle(instead, mc.ISIG_INPUT1)
MPGXState = mc.mcSignalGetState(MPGX)

if MPGX == 1 then
    MPG set to x
    if VARS# == 0 then
        Message. -- message first ,then set VARS# to 1
        Set VARS to 1
    end
else
Set VARS# to 0 --resets to 0
end

I'll check my syntax again Monday.  But I think you get the gist.
Let me know.
Chad Byrd
Re: MPG strange behavior
« Reply #9 on: April 14, 2018, 01:40:45 AM »
I'm typing on my phone.   Excuse all the syntax errors.
Chad Byrd