Daniellyall,
You have provided a good description of the process you want to create, so I can speak to that and provide a process for you to follow to create a solution.
Your process makes a good general example as it is a bit complicated due to the number of dependencies. Because of that, you should consider doing a flow chart as a first step and make sure you have all of the combinations accounted for.
In the coding, you will handle the dependencies with nested statements. The code fragment that I posted previously was in response to someone else's post which was quite simple and had no dependencies.
Here is a code fragment that demonstrates the solution you need:
-- ****************** JoyStick Jogging Routine *******************
if JoyStickActive == '1' then
SpeedX, rc = mc.mcRegGetValue(JoyStick_X_RegHandle);
SpeedY, rc = mc.mcRegGetValue(JoyStick_Y_RegHandle);
--ByteZ, rc = mc.mcRegGetValue(JoyStick_Z_RegHandle);
if JoyJogHoldX == '0'then
if SpeedX ~= 0 then
IsJoggingX, rc = mc.mcJogIsJogging(inst,0)
if SpeedX > 0 then
DirectionX = 1;
end
. . . . . AND SO ON
Please keep in mind that this is a fragment and not a program. However it demonstrates one (of several) methods that are applicable to your project. only the 'functions' that begin with 'mc.mc' are specific to MACH4. The rest is typical variables and logic.
The basic process is to first collect the data into variables and then plug those into the logic.
In the example above (which is actual code from my PLC),
'JoyStickActive' is a variable that is set 'true' if the I/O line that carries that signal is high (value of 1 or true).
'JoyJogHoldX' is 'true' if the X axis is on hold (the joystick controls all axis simultaneously, so 'disabling' one axis allows fine positioning of a single axis).
'SpeedX' is a variable that contains the desired jogging speed.
'DirectionX' is self explanatory.
In this fragment, you can see the actual code used to collect the data from MACH. Of particular interest to you would be the variable 'IsJoggingX' and how and where it gets it's value from.
So, you will create your own variables using descriptive names and use the appropriate MACH4 function to fill the variables with the date. Then arrange your nested conditional statements (if this , then do that). Finally, when all of the conditions are met, you perform the action.