Hello Guest it is April 26, 2024, 09:15:19 AM

Author Topic: Little help with a script please?  (Read 392 times)

0 Members and 1 Guest are viewing this topic.

Little help with a script please?
« on: February 20, 2023, 10:26:52 PM »
ESS with Mach 4. I have a problem during startup where in some situations during different stages of abnormal times, if my VFD is running but my PC crashes or similar, my VFD will be commanded to run, at full speed. The VFD will stop once Mach 4 is loaded. Its rare but I dont like it. I have placed a button on my run screen to enable power to the PWM converter with redundancy, ie loss of power = no power to my PWM converter.

In addition I want to activate the main pneumatics with the same button. So, output 2 pins with one button.

I thought this script would work but it wont:

-- Main Spindle PWM Board and Pneumatics Enable
inst = mc.mcGetInstance()
local hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT2)
local state, rc = mc.mcSignalGetState(hSig)
if state == 1 then
    mc.mcSignalSetState(hSig, 0)
else
    mc.mcSignalSetState(hSig, 1)
end

I am able to remove the script and just have an output on the button, works, but not 2 outputs, so wrote this script. Well copy/paste anyway.

The other weird thing, if I try to use a script to on/off an output, I have to press or hit the button twice for any action. double click for on double click for off. Weird. A little help please? Just want to have 2 output pins off the same button. Only needing a single click on/off. Looking forward to hearing what I am doing wrong. Thanks
Re: Little help with a script please?
« Reply #1 on: February 20, 2023, 10:38:46 PM »
Just to update I have been able to assign an output for 1, AND a script for output 2. But the script still asks for a double click to activate on/off. Such fun ha. Actually, this user abilities to edit the screen is pretty cool.
« Last Edit: February 20, 2023, 10:41:45 PM by boydage »
Re: Little help with a script please?
« Reply #2 on: February 21, 2023, 02:36:22 PM »
Hi,
I see:

Code: [Select]
local hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
local hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT2)

You have assigned hSig the value of the handle to Output#1, and then in the next line overwritten it with the handle of Output#2????
If you want to address the two outputs then you'll need to handle variables.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Little help with a script please?
« Reply #3 on: February 23, 2023, 11:23:23 PM »
Ok thanks. I need to research more. To fix I did it mechanically.