Hello Guest it is May 11, 2024, 12:38:18 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 - Cbyrdtopper

891
Mach4 General Discussion / Re: Output Control
« on: May 06, 2015, 01:33:55 PM »
You said something about a button.  I don't know about a button.  But in a macro you can look at this thread.  "having trouble with Lua Script"  It'll show you how to turn on an output via macro.

892
Mach4 General Discussion / Re: Having trouble with Lua Script
« on: April 29, 2015, 03:55:28 PM »

Here is my code that I am trying to do.  Like it says below.  Turning off a solenoid.  Waiting for it to move back and hit the switch.  Then turn on output 2 which will be a solenoid.  Wait for the switch and then display a message. 
This code works when I step through it, however when I try and run it Via MDI it locks up Mach 4 and closes it.  ANY IDEAS???
-Chad

--TEST CODE INPUTS AND OUTPUTS!!
--Example of a solenoid shutting off and waiting for the switch.
--Turn on output 1 and wait for switch then display message.

function m1002()

local rc = 0;
local inst = 0; -- mc.mcGetInstance(mInst)

-- Turns off output 1
hsig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1); 
mc.mcSignalSetState(hsig, 0); --sets OUTPUT_1 to False

-- Turns off output 2: SOLENOID 1
hsig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT0); 
mc.mcSignalSetState(hsig, 0); --sets OUTPUT_0 to False
--Messages are written like this.
mc.mcCntlSetLastError(inst, "Output 2 Off");

function Input1IsFalse () --Solenoid 1 back switch.
    hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT1);  --set hsig variable to handle input 1
    sigState = mc.mcSignalGetState(hsig);
    if sigState == 0 then
        return true; --Not active yet.
    else
        return false; --Input is active.
    end
end --Input1IsFalse

while Input1IsFalse() do
mc.mcCntlSetLastError(inst, "Solenoid 1 is Moving.");
end  --waits until input1 is true

mc.mcCntlSetLastError(inst, "Solenoid 1 is back.");

-- Turns on output 1
hsig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1); 
mc.mcSignalSetState(hsig, 1); --sets OUTPUT_1 to True

function Input2IsFalse () --Output 1 is active switch.
    hsig, rc = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT2);  --set hsig variable to handle input 2
    sigState = mc.mcSignalGetState(hsig);
    if sigState == 0 then
        return true; --Not active yet.
    else
        return false; --Input is active.
    end
end --Input2IsFalse

while Input2IsFalse() do
mc.mcCntlSetLastError(inst, "Output1 is turing on.");
end  --waits until input2 is true


mc.mcCntlSetLastError(inst, "Output 1 ON");

end --This is for the end of the function m1002()

--This next part does not have to be in here
--it is for testing and steping through macros
--it runs the macro in Mach 4 fine without it.
if (mc.mcInEditor() == 1) then
   m1002()
end

893
Mach4 General Discussion / Re: Having trouble with Lua Script
« on: April 29, 2015, 08:33:08 AM »
Sorry.  I just figured it out.  It has a drop down to Standard Names and then you can put in a custom name, then in the Mach config. choose the ESS and it will have the drop down with your custom name in it.  Works great!! Thanks again for your help.
If I have any more questions I really hope you don't mind me asking on this thread! 
Again, Thanks for all the help!!!
-Chad

894
Mach4 General Discussion / Re: Having trouble with Lua Script
« on: April 29, 2015, 08:25:59 AM »
Okay.  So I'm working on the inputs/outputs portion of what you've helped me with.  I have them written in the macro and have a general understanding of the syntax.  But how to I get Mach 4 and the ESS on the same page as far as what outputs and inputs there are.  I am getting drop downs for motor jogging, coolant,  homes, over travel, and etc; I'm not seeing anything as far as Input 1, 2, 3 .... and Output 1,2,3....  Do I have to name them something?

895
General Mach Discussion / Re: Sub Code(“SAVE_XML”)
« on: April 28, 2015, 03:00:58 PM »
That's what I was trying to do inside the macro.  Update my XML.  What about the separate data file?  For my tool magazine positions other than DROs on the screen?  Or just an update of what I have?

896
General Mach Discussion / Re: Sub Code(“SAVE_XML”)
« on: April 28, 2015, 08:10:38 AM »
What I am looking for is a way to save my tool magazine positions.  I have a 24 tool magazine and it changes 2 tools at once.  So I am having to keep track of different magazine positions constantly for tools.  I am using DROs on a custom screen and it works great.  But we're afraid of power failure and losing tool positions in the magazine.  This code would be more of a convenience for us if we can get it to work.  Is there anything special I have to do?  I have it written Code(“SAVE_XML”).  Is this correct?  I'll try it again and look at the date and time to see if it is doing what is should. 

Thanks
-Chad

897
General Mach Discussion / Sub Code(“SAVE_XML”)
« on: April 27, 2015, 05:50:05 PM »
According to Mach3 Version 3.x Macro Programmers Reference Manual you can save your XML in a macro.  I can't seem to get this to work in my macros.  Sub Code(“SAVE_XML”) this is

what is said to use to do this. 

Anyone ever use it?

--Chad

898
Mach4 General Discussion / Re: Having trouble with Lua Script
« on: April 27, 2015, 08:11:03 AM »
Okay Gerber Baby. That works great!! Thanks!!  ;D  Gonna try the input and output states now!!
-Chad

899
Mach4 General Discussion / Re: Having trouble with Lua Script
« on: April 24, 2015, 12:10:25 PM »
Okay,  with this code I can get it to work when I hit 'Run' in the macro menu.  I don't have to step through it or anything.  I just hit run and it works.  However, when I switch over to Mach 4 and put it in G Code or MDI line it doesn't do anything.  Does the macro have to be saved a certain way?  It is saved as "m1000.mcs"  or in a certain folder.  It is in the macro folder.  Any Ideas?

function m1000()

local mInst = 0;
local rc = 0;
local inst = mc.mcGetInstance(mInst);

mc.mcCntlMdiExecute(inst, "G00 X5 Y5 \nZ5");

end

if (mc.mcInEditor() == 1) then
    m1000()
end

900
Mach4 General Discussion / Re: Having trouble with Lua Script
« on: April 24, 2015, 11:56:00 AM »
Okay.  Got something to work finally! Thanks!!  But I can only get it to work when I step through my macro. AND I have to have the 'end' right after the
 function M1002 () otherwise it skips to the end and does nothing.  I am having another problem with running the macro in my MDI line in Mach 4.  I put the 'end' at the end of the macro and where it works when I step through the macro and I get nothing in Mach 4.  Also, earlier I would hit cycle start on the MDI line and it was giving me errors in the message for something in a totally different macro than the one I was trying to run.  Any thoughts on these problems?
Thanks Again!!!
-Chad