Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: DazTheGas on June 29, 2015, 05:03:41 AM

Title: Activate input
Post by: DazTheGas on June 29, 2015, 05:03:41 AM
In the lua examples directory there is an example of activating an output from script, is there a way to activate an input from script, I am setting up a diagnostic screen but really don't want the machine running whilst testing some of the features I am working on.

In particular I want to use mc.ISIG_JOGXN

DazTheGas
Title: Re: Activate input
Post by: dude1 on June 29, 2015, 06:04:40 AM
it think its the same as output

mc.ISIG_INPUT0

mc.OSIG_OUTPUT0
Title: Re: Activate input
Post by: Screwie Louie on June 30, 2015, 01:07:30 AM
Got this to work in the sim, whereas the DRO's will not move and the button will let you toggle the input signal without actually moving the axis.

Button Down Script:
     local inst = mc.mcGetInstance()
     mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGXN), 1)
     mc.mcJogVelocityStop (inst, 0)

Button Up Script:
     local inst = mc.mcGetInstance()
     mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGXN), 0)
Title: Re: Activate input
Post by: DazTheGas on June 30, 2015, 02:53:34 AM
Screwie to the rescue :-),

ive tried using the code from example in all different ways to no avail ended up with using mc.mcJogVelocityStart(inst, 0, -1) to start then mc.mcJogVelocityStop (inst, 0) to stop, but this then need a load of if and then statements for jog mode etc, but now its a simple as

Button down evt
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGXN), 1)

Button up evt
mc.mcSignalSetState (mc.mcSignalGetHandle (inst, mc.ISIG_JOGXN), 0)

as you can see theres no need to keep declaring the mach instance as my whole enviroment is now scripted in wxlua without using the editor buttons etc

cheers screwie....

DazTheGas
Title: Re: Activate input
Post by: dude1 on June 30, 2015, 03:06:42 AM
two ways to do the same thing but whats better
Title: Re: Activate input
Post by: DazTheGas on June 30, 2015, 03:21:24 AM
two ways to do the same thing but whats better

by using mc.ISIG_JOGXN mach4 will sort out if we are in continuous mode or step, the other way has 2 functions 1 for continuous the other for increment so extra code is needed for each axis to determine what state we are in.

DazTheGas
Title: Re: Activate input
Post by: Screwie Louie on June 30, 2015, 04:03:27 AM
could be mach machine state....changing the state if possible? This may sound like a simple solution but everybody and every machine is different. This is a neat puzzle....
Title: Re: Activate input
Post by: Screwie Louie on June 30, 2015, 02:23:19 PM
nevermind my last comment about changing the state...it's retarded.