Hello Guest it is March 28, 2024, 10:04:59 AM

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 - DazTheGas

391
Mach4 General Discussion / Re: Multiple inputs in LUA script
« on: October 12, 2016, 12:22:09 PM »
Quote
Where are you defining the inst = mc.mcGetInstance(); before getting the hSig's?

OOOppps - I tested the code in my personal editor and forgot the instance is declared automatically so I dont get errors..

try something on these lines

Code: [Select]
--Set Rapid Over Ride Value, 0%, 25%, 50% and 100%
local Input18 = 0                                                           --Clear local Input18
local Input19 = 0                                                           --Clear local Input19
local Input20 = 0                                                           --Clear local Input20
local hSig = 0                                                              --Clear local hSig

local inst = mc.mcGetInstance()

hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT18)
Input18 = mc.mcSignalGetState(hSig) --Get state of input 18

hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT19)
Input19 = mc.mcSignalGetState(hSig) --Get state of input 19

hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT20)
Input20 = mc.mcSignalGetState(hSig) --Get state of input 20

if ((Input18 == 0) and (Input19 == 1) and (Input20 == 0)) then
    mc.mcCntlSetRRO(inst, 100.0) --Set RRO to 100%
elseif ((Input18 == 1) and (Input19 == 0) and (Input20 == 1)) then
     mc.mcCntlSetRRO(inst, 50.0) --Set RRO to 50%
elseif ((Input18 == 0) and (Input19 == 0) and (Input20 == 1)) then
     mc.mcCntlSetRRO(inst, 25.0) --Set RRO to 25%
elseif ((Input18 == 1) and (Input19 == 0) and (Input20 == 0)) then
     mc.mcCntlSetRRO(inst, 0.0) --Set RRO to 0%
end

If I get time later I will look at some debugging for ya.

DazTheGas

392
Mach4 General Discussion / Re: Multiple inputs in LUA script
« on: October 12, 2016, 02:11:37 AM »
Well ive run the script on my machine and the code works fine, try a bit of debug info in the the script to see what part is not working on your screen.

DazTheGas

393
Mach4 General Discussion / Re: Mach 4 Macro with Lua script
« on: October 11, 2016, 04:19:39 PM »
A brief outline on what you are trying to do will help

DazTheGas

394
Not sure if this may help  http://www.machsupport.com/forum/index.php/topic,33270

DazTheGas

395
Mach4 General Discussion / Re: Screen buttons - Actions and Scripts
« on: September 29, 2016, 12:20:41 PM »
If you take a look in the docs directory you will find the api.chm with all the commands in that are used within the GUI,

IE to zero an axis you would need to look at the axis section and use mc.mcAxisSetPos(number inst, number axisId, number val)

you can gain a lot of insight of using commands by looking in the modules and examples directory and reading the codes there.

DazTheGas

396
Mach4 General Discussion / Re: Macro - Pause until input triggered
« on: September 29, 2016, 03:14:27 AM »
That is correct, 0 is the same as mc.MERROR_NOERROR just like in the command 1 is the same as mc.WAIT_MODE_HIGH, these have been defined in C but can be accessed by the leading mc.

DazTheGas

397
Mach4 General Discussion / Re: Macro - Pause until input triggered
« on: September 28, 2016, 11:51:21 AM »
yay you lot have been busy, glad its working for you now.

DazTheGas

398
Mach4 General Discussion / Re: Macro - Pause until input triggered
« on: September 27, 2016, 04:50:31 PM »
The only problem I can see is if your home switch is also the limit this could cause mach4 to disable, just as a thought have you thought of using something like mc.mcCntlGcodeExecuteWait(inst, "G0 Z-1 F50") this will halt the gcode.
I have been looking into the mc.mcSignalWait and all works well when using any of the ISIG_INPUT0 to 63 etc but not working on anything else???

DazTheGas

399
Mach4 General Discussion / Re: Macro - Pause until input triggered
« on: September 27, 2016, 02:58:57 PM »
Cant remember of top of my head but think macros and gcode run in a different lua instance than the gui??

DazTheGas

400
Mach4 General Discussion / Re: Macro - Pause until input triggered
« on: September 27, 2016, 11:32:59 AM »
Your trying to wait for a signal handle not a signal id like mc.OSIG_ZHOME

Try something like this but signal should be the INPUT of your Z Home

Code: [Select]
mc.mcSignalWait(inst, mc.ISIG_MOTOR0_PLUS, WAIT_MODE_HIGH, 20)
DazTheGas