Hello Guest it is April 28, 2024, 06:28:40 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - peter g

Pages: 1 2 »
1
Mach4 General Discussion / Re: Mach4 Enable/Disable Script
« on: August 27, 2021, 02:20:45 PM »
Hi,

Never mind I found a script for it.

Peter

2
Mach4 General Discussion / Re: Mach4 Enable/Disable Script
« on: August 27, 2021, 11:57:04 AM »
I use one button to toggle enable on the control panels here in the shop.
Just put the code in the signal library in the screen load script.
I modified my code so one input will enable mach and the other will disable mach.

[mc.ISIG_INPUT6] = function (state)
    if (state == 1) then
       local inst = mc.mcGetInstance();
        mc.mcCntlEnable(inst,1)
   end
end,

[mc.ISIG_INPUT7] = function (state)
    if (state == 1) then
       local inst = mc.mcGetInstance();
        mc.mcCntlEnable(inst,0)
   end
end,

Thanks for you help this worked.

Do you know if its possible to do the same for M07(mist on) M08(coolant on) M09(off)?

Peter

3
Mach4 General Discussion / Mach4 Enable/Disable Script
« on: August 27, 2021, 09:04:03 AM »
Hey Everyone,

I would like 2 physical button 1 to enable and the other to disable. These would replicated the onscreen "Enable" and "Disable" button in mach4. Is there a script to assign one of the inputs in Mach 4 to be an "Enable" button?

Peter

4
Mach4 General Discussion / Re: Mach 4 question
« on: August 27, 2021, 07:41:07 AM »
Hi,
I am really not sure what the issue is as I haven't seen this issue before. The only thing I could think of is either Mach 4 demo has some limitations or the setting have been setup incorrectly.

Peter

5
Mach4 General Discussion / Re: Start Cycle with a Push Button in Mach4
« on: August 26, 2021, 01:42:26 PM »
I used this code to use an external button to cycle start. I also have one for cycle stop and feed hold.
Code below:

-------------------------------Cycle Start-------------------------------

[mc.ISIG_INPUT16] = function (state)      --If you are not using INPUT16 for Cycle Start change it.
    InputCycleStart()
    end,

---------------------------------------------------------------
-- The Input Signal for a Cycle Start Occurred.
---------------------------------------------------------------

function InputCycleStart()
    CycleStart()
    mc.mcCntlSetLastError(inst, "Cycle Start")
end

6
Mach4 General Discussion / Re: Mach 4 question
« on: August 26, 2021, 11:17:34 AM »
Hi Toshio,

if you have the probe setup correctly in the config page when its activated you should see it light up on the "diagnostics" tab. I have attached a screen shot. The LED light should turn on when the probe is activated.

Screenshot link : https://imgur.com/aqIOl6g

Peter

7
Mach4 General Discussion / Re: Mach 4 question
« on: August 25, 2021, 07:02:32 PM »
Hi, I am not familiar with this issue. It could be because you are using the demo mode and if I remember it has some limitation or something. Are you able to see the property when its activated in the machine diagnostics page?

Peter

8
Mach4 General Discussion / Re: Mach 4 question
« on: August 25, 2021, 10:28:56 AM »
Hi Toshio,

I am not sure I understand your question?

Peter

9
Mach4 General Discussion / Re: Mach 4 question
« on: August 24, 2021, 11:21:33 AM »
Hey,

So I have got it working. I am able to use the physical switches to select axis and jog rates. I intend on using a Siemens PLC with a HMI I have lying around and use the screen to have button to select the "x" axis "y" axis and "z" axis as well as "x1" "x10" and "x100". If I have enough spare inputs I will also add "Cycle Start" "Feed Hold" and more. The code above does work I just had a loose connection:)

Thanks for your help

Peter

10
Mach4 General Discussion / Re: Mach 4 question
« on: August 24, 2021, 10:52:35 AM »
---------------------------------------------------------------
-- Monitor the switches on the Pendant.
-- We break the three different mechanical switches into three separate function calls, since each function has a separate job.
-- We don't need to assign the MPG wheel since Mach handles that for us.
---------------------------------------------------------------
SigLib = {


    [mc.ISIG_INPUT10] = function (state)   --If you are not using INPUT10 for the Axis Selection X, change the INPUT#!!!!
        PendantAxisChange()                     --This is called if there is a change with the Pendant's Axis Selection Switch Posion X
    end,


    [mc.ISIG_INPUT11] = function (state)   --If you are not using INPUT11 for the Axis Selection Y, change the INPUT#!!!!
        PendantAxisChange()                     --This is called if there is a change with the Pendant's Axis Selection Switch Posion Y
    end,


    [mc.ISIG_INPUT12] = function (state)   --If you are not using INPUT12 for the Axis Selection Z, change the INPUT#!!!!
        PendantAxisChange()                     --This is called if there is a change with the Pendant's Axis Selection Switch Posion Z
    end,

-------------
    [mc.ISIG_INPUT13] = function (state)       --If you are not using INPUT6 for theX1 Selection, change the INPUT#!!!!
        PendantSpeedChange()                      --This is called if there is a change with the Pendant's Rate Selection Switch X1
    end,


    [mc.ISIG_INPUT14] = function (state)       --If you are not using INPUT7 for the X10 Selection, change the INPUT#!!!!     
        PendantSpeedChange()                     --This is called if there is a change with  the Pendant's Rate Selection Switch X10
    end,


    [mc.ISIG_INPUT15] = function (state)       --If you are not using INPUT8 for the X100 Selection, change the INPUT#!!!!     
        PendantSpeedChange()                     --This is called if there is a change with the Pendant's Rate Selection Switch X100
    end,

-------------
    [mc.ISIG_INPUT16] = function (state)     --If you are not using INPUT9 for the Pendant EStop Switch, change the INPUT#!!!!     
        PendantEStopChange()                     --This is called if there is a change with the Pendant's EStop Switch
    end,


-------------

--These next three are not part of the Pendant code, but show you a few more options for inputs

[mc.ISIG_INPUT17] = function (state)       --Performs a Cycle Start

InputCycleStart()

end,

 

[mc.ISIG_INPUT18] = function (state)       --Performs a Cycle Stop

InputCycleStop()

end,

 

[mc.ISIG_INPUT19] = function (state)       --Performs a reset

InputReset()

end
}

 

---------------------------------------------------------------

-- The Input Signal for a Cycle Start Occurred. This is not needed for the rest of the pendant example

---------------------------------------------------------------

function InputCycleStart() --This will do a cycle start because of a button push

     CycleStart()

     mc.mcCntlSetLastError(inst, "Input Cycle Start")

end

 

---------------------------------------------------------------

-- The Input Signal for a Cycle Stop Occurred. This is not needed for the rest of the pendant example

---------------------------------------------------------------

function InputCycleStop() --This will do a cycle stop because of a button push

     CycleStop()

     mc.mcCntlSetLastError(inst, "Input Cycle Stop")

end

 

---------------------------------------------------------------

-- The Input Signal for a Reset Occurred. This is not needed for the rest of the pendant example

---------------------------------------------------------------

function InputReset() --This will do a Reset because of a button push

     mc.mcCntlReset(inst)

     mc.mcSpindleSetDirection(inst, 0)

     mc.mcCntlSetLastError(inst, "Input Reset")

end



--In Mach's Config tab for MPGs, if you don't have the ESS's encoder for the pendant assigned to MPG#7, change the 7 to the number you are using:
local MachMpgNumberForPendant = 1

local PendantStepSize = 0.001 --This is in your Mach4's units, mm or Inches, whichever one you have it set to
local PendantDistanceX1 = PendantStepSize * 1    --Multiply by one
local PendantDistanceX10 = PendantStepSize * 10    --Multiply by ten
local PendantDistanceX100 = PendantStepSize * 100    --Multiply by one hundred

--These shouldn't need to be modified, but they reduce the amount of apparently random numbers in the code:
local UnmapMPG = -1         --Use this one for when Axis selector switch is set to OFF
local AxisNumber_X = 0       -- Linear axis X (one of six coordinated motion axes)
local AxisNumber_Y = 1       -- Linear axis Y (one of six coordinated motion axes)
local AxisNumber_Z = 2       -- Linear axis Z (one of six coordinated motion axes)
--Coordinated motion means all six coordinated axes get to the destination point at the same time.
--Not coordinated with motion means that axis can be doing whatever, whenever.  Like a conveyor belt that is always running.




---------------------------------------------------------------
-- The Pendant's EStop switch changed...
-- This will process the Pendant's EStop Switch
-- THIS ESTOP SHOULD BE CONSIDERED A COURTESY SIGNAL, since it based on softare
-- You should still have a EStop that is pure hardwre that can disconnect power.

--If you start Mach with the button pressed in, it will not work when you need to press it!
---------------------------------------------------------------
function PendantEStopChange()

    local hPendantEStop
    local PendantEStop
   
    hPendantEStop, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT9)     --If you are not using INPUT9 for the Pendant EStop Switch, change the INPUT#!!!!   
    PendantEStop, rc = mc.mcSignalGetState(hPendantEStop)
       
    if (PendantEStop == 1) then
        mc.mcCntlEStop(inst)  --Activate the EStop signal in Mach
        mc.mcCntlSetLastError(inst, "Pendant EStop Activated")   --Show a message in the Screen Set
    else
        mc.mcCntlSetLastError(inst, "Pendant EStop Cleared")  --Show a message in the Screen Set
    end 
end



---------------------------------------------------------------
-- The Pendant's Speed switch changed... Reconfigure appropriate settings in Mach4 
--This will process the Pendant's Rate/Speed Selection Switch
---------------------------------------------------------------
function PendantSpeedChange()
   

    --Variable prep first for handles
    local hX1
    local hX10
    local hX100
   

    --Variable prep for signal values
    local Step1
    local Step10
    local Step100
   
    hX1, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT13)       --If you are not using INPUT6 for theX1 Selection, change the INPUT#!!!!
    Step1, rc = mc.mcSignalGetState(hX1)
   
    hX10, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT14)       --If you are not using INPUT7 for the X10 Selection, change the INPUT#!!!!  -- X10 Port 3 Pin 4
    Step10, rc = mc.mcSignalGetState(hX10)
   
    hX100, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT15)       --If you are not using INPUT8 for the X100 Selection, change the INPUT#!!!!
    Step100, rc = mc.mcSignalGetState(hX100)
   
    local msg
       
    if (Step1 == 1) then
        mc.mcMpgSetInc(inst, MachMpgNumberForPendant, PendantDistanceX1 )
        msg = "Jog Distance X1 = " .. PendantDistanceX1
        mc.mcCntlSetLastError(inst, msg)  --Show a message in the Screen Set

    elseif (Step10 == 1) then
        mc.mcMpgSetInc(inst, MachMpgNumberForPendant, PendantDistanceX10)
        msg = "Jog Distance X10 = " .. PendantDistanceX10
        mc.mcCntlSetLastError(inst, msg)  --Show a message in the Screen Set

    elseif (Step100 == 1) then
        mc.mcMpgSetInc(inst, MachMpgNumberForPendant, PendantDistanceX100)
        msg = "Jog Distance X100 = " .. PendantDistanceX100
        mc.mcCntlSetLastError(inst, msg)  --Show a message in the Screen Set
    end
   
   
end

   
   
---------------------------------------------------------------
-- The Pendant's Axis switch changed... Reconfigure appropriate settings in Mach4 and turn the Pendant LED ON/OFF
--This will process the Pendant's Axis Selection Switch
---------------------------------------------------------------
function PendantAxisChange()
 
    --Variable prep first for handles
    local hAxis_X  --Position X on Pendant Switch
    local hAxis_Y  --Position Y on Pendant Switch
    local hAxis_Z  --Position Z on Pendant Switch
   
    --Variable prep for signal values, MAKE SURE YOU MATCH THE ONES IN HERE WITH THE ONES JUST ABOVE
    local SelectAxis_X
    local SelectAxis_Y
    local SelectAxis_Z
   
    hAxis_X, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10)   --If you are not using INPUT0 for the Axis Selection Switch X, change the INPUT#!!!!
    SelectAxis_X, rc = mc.mcSignalGetState(hAxis_X)
   
    hAxis_Y, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT11)   --If you are not using INPUT1 for the Axis Selection Switch Y, change the INPUT#!!!!
    SelectAxis_Y, rc = mc.mcSignalGetState(hAxis_Y)
   
    hAxis_Z, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT12)   --If you are not using INPUT2 for the Axis Selection Switch Z, change the INPUT#!!!!
    SelectAxis_Z, rc = mc.mcSignalGetState(hAxis_Z)

    --This is the Pendant's LED, and it will be ON when an axis is active on the Pendant's switch
    local hLedForActivePendantAxis
    hLedForActivePendantAxis, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)-- Pendant LED Port 3 Pin 1
       
       
   
    --Now actual axis Selection Switch processing code

    if (SelectAxis_X == 1) then
        mc.mcMpgSetAxis(inst, MachMpgNumberForPendant, AxisNumber_X)    --Map the MPG to control the X Axis
        mc.mcCntlSetLastError(inst, "X Axis Selected")  --Show a message in the Screen Set
        mc.mcSignalSetState(hLedForActivePendantAxis, 1)       --Turn the Pendant's LED ON to show an axis is active
       
    elseif (SelectAxis_Y== 1) then
        mc.mcMpgSetAxis(inst, MachMpgNumberForPendant, AxisNumber_Y)    --Map the MPG to control the Y Axis
        mc.mcCntlSetLastError(inst, "Y Axis Selected")  --Show a message in the Screen Set
        mc.mcSignalSetState(hLedForActivePendantAxis, 1)       --Turn the Pendant's LED ON to show an axis is active

    elseif (SelectAxis_Z== 1) then
        mc.mcMpgSetAxis(inst, MachMpgNumberForPendant, AxisNumber_Z)    --Map the MPG to control the Z Axis
        mc.mcCntlSetLastError(inst, "Z Axis Selected")  --Show a message in the Screen Set
        mc.mcSignalSetState(hLedForActivePendantAxis, 1)       --Turn the Pendant's LED ON to show an axis is active

    else
        --None of the Axis Switch inputs are active, so unmap the MPG from all axes (by assigning an invalid axis -1)
        mc.mcMpgSetAxis(inst, MachMpgNumberForPendant, UnmapMPG )     --Unmap the MPG, so it won't control any axes
        mc.mcCntlSetLastError(inst, "NO Pendant Axis Selected")  --Show a message in the Screen Set
        mc.mcSignalSetState(hLedForActivePendantAxis, 0)           --Turn the Pendant's LED OFF to show no axis is active
    end
   

end

 


--We will now call the  three functions we made

--This is so the functions  will be initalized to the current pendant values

--When the Screen is loaded by Mach4


PendantEStopChange()
PendantSpeedChange()
PendantAxisChange()

Pages: 1 2 »