Hello Guest it is April 27, 2024, 11:40:00 PM

Author Topic: Connect a button for tool change  (Read 1132 times)

0 Members and 1 Guest are viewing this topic.

Connect a button for tool change
« on: October 10, 2023, 04:50:54 AM »
Hello,
I'm pretty new on the CNC world and I get more confused the more I dive into it. I've been working on a CNC for 3 months now and got to change software from Mach3 to Mach4. I have a button on the spindle connected to one of the inputs from the ESS and I need to active output1 when this button is pressed. I've been searching on internet but didn't get any clue. Do someone knows how to connect an input with an output?
Really thanks
Re: Connect a button for tool change
« Reply #1 on: November 12, 2023, 06:21:00 AM »
I believe it is quite straightforward

You need to use the PLC script and monitor the input signal. eg see the code below

Code: [Select]
local Button_Input= mc.ISIG_INPUT1 --define the variable for the input
local output_1 = mc.OSIG_OUTPUT1 -- define variable for output

-- get handles and states (states will be helpful to check if inputs outputs are active, use a message box, make it a comment )
local hsig_input = mc.mcSignalGetHandle(inst, Button_Input) --
local Button_Input_State= mc.mcSignalGetState(hsig_input )
local hsig_output = mc.mcSignalGetHandle(inst, output_1)
local output_1_State= mc.mcSignalGetState(hsig_input )

if (Button_Input_State== true) then
mc.mcSignalSetState(hsig_output ,TRUE)
end



I think that will do it, maybe someone else have a better way. Maybe the PMC would be faster.
Check the documentation for scripting and PMC