Welcome, Guest. Please login or register.
Did you miss your activation email?
July 10, 2014, 09:11:12 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
  Show Posts
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 »
1  Mach Discussion / Mach4 General Discussion / Re: Screen Set Ideas on: July 08, 2014, 07:13:11 AM
How to pass a number to a function and get or set variables. Note: Your dro names have to be consistent to write to them, because I am using the concant feature to add the number to the dro's name. I have a read function in the PLC and a write function button
Lot of messing with, but now its just one line of code to add new ones in the future.

Code:
function SCR_getset(varnum)
    local inst = mc.mcGetInstance();
    local varvalue = 0;
    varvalue = mc.mcCntlGetPoundVar(inst, varnum);
    scr.SetProperty('drovar'..varnum, 'Value', tostring(varvalue)); --Concant dro&number
end

function GetVariablePoundDouble(varnum)
     local inst = mc.mcGetInstance();
     local varvalue = 0;
     local val = 0;
     varvalue = mc.mcProfileGetDouble(inst , 'drovar'..varnum , tostring(varnum), val);
     mc.mcCntlSetPoundVar(inst, tonumber(varnum), varvalue);
end

function GetVariablePoundInt(varnum)
     local inst = mc.mcGetInstance();
     local varvalue = 0;
     local val = 0;
     varvalue = mc.mcProfileGetInt(inst , 'drovar'..varnum , tostring(varnum), val);
     mc.mcCntlSetPoundVar(inst, tonumber(varnum), varvalue);
end

function SetVariablePoundDouble(varnum)
    local inst = mc.mcGetInstance();
    local varvalue = 0;
    varvalue = mc.mcCntlGetPoundVar(inst, tonumber(varnum));
    mc.mcProfileWriteDouble(inst ,'drovar'..varnum, tostring(varnum),varvalue);
end

function SetVariablePoundInt(varnum)
    local inst = mc.mcGetInstance();
    local varvalue = 0;
    varvalue = mc.mcCntlGetPoundVar(inst, tonumber(varnum));
    mc.mcProfileWriteInt(inst ,'drovar'..tostring(varnum),tostring(varnum),varvalue);
end

function GetPoundDroVariables()
    SCR_getset(1); --pass number to function
    SCR_getset(3901);
end

function VariableRead()
     GetVariablePoundDouble(1);
     GetVariablePoundInt(3901);
end

function VariableWrite()
     SetVariablePoundDouble(1);
     SetVariablePoundInt(3901);
end
2  Mach Discussion / Mach4 General Discussion / Re: Screen Set Ideas on: July 06, 2014, 01:01:56 PM
As a note to all:
Under the History button there is a 'Save' option button
Found that I had to create a history.txt file in the mach4 root folder for it to write to the file.
3  Mach Discussion / Mach4 General Discussion / Re: Screen Set Ideas on: July 06, 2014, 11:44:46 AM
Been working on a universal function that writes to a file either the lathe or mill tool tables, based on mode.

(note: to nick) all mach4 tool data starts at variable 7781; so 7781-7790 is tool #1

the numbers in my graphics tables don't mean anything in this case, I just used them as fillers to get the routine to work.
but it does include any tool that has a description


//Tool Numbering
#define TOOLS_START 7781      //Start of Tools in Parameter list
#define TOOL_INC 10           //Inc from tool to tool in the param list

#define TOOL_MILL_X           0 //X offset
#define TOOL_MILL_X_W         1 //X Wear offset
#define TOOL_MILL_Y           2 //Y offset
#define TOOL_MILL_Y_W         3 //Y Wear offset
#define TOOL_MILL_HEIGHT      4 //Tool height offset
#define TOOL_MILL_HEIGHT_W    5 //Height wear Offset
#define TOOL_MILL_POCKET      6 //Tool changer pocket
#define TOOL_MILL_RAD         7 //Rad for comp
#define TOOL_MILL_RAD_W       8 //wear offset for comp

#define TOOL_LATHE_X          0 //X offset
#define TOOL_LATHE_X_W        1 //X Wear offset
#define TOOL_LATHE_Y          2 //Y offset
#define TOOL_LATHE_Y_W        3 //Y Wear offset
#define TOOL_LATHE_Z          4 //Z offset
#define TOOL_LATHE_Z_W        5 //Z wear offset
#define TOOL_LATHE_POCKET     6 //Pocket # (may not be needed)
#define TOOL_LATHE_TIPRAD     7 //Tip Rad for comp
#define TOOL_LATHE_TIPDIR     8 //Tool tip DIR
#define TOOL_LATHE_TOOLSLIDE  9 //AxisSlide number  and - for reversed
4  Mach Discussion / Mach4 General Discussion / Re: Screen Set Ideas on: July 04, 2014, 11:44:02 AM
Came across this reference document thought it was a good resource for Lua 5.1
5  Mach Discussion / Mach4 General Discussion / Re: Mach4 Printer Port Discussions on: June 22, 2014, 08:16:07 AM
Rich aren't you in the man cave in the basement? As long as the washer and dryer is not down there she doesn't care how it looks.  Cheesy But I'm sure she still shakes her head.

laptops work for saving space, not like they all have to be running at the same time or on a network. Learned years ago that one computer cant do it all so have dedicated laptops/computers now.
6  Mach Discussion / Mach4 General Discussion / Re: Mach4 Printer Port Discussions on: June 22, 2014, 07:16:29 AM
Hell Art, I would have thought you had a computer with every OS for testing   Grin make your wife proud!  Shocked
7  Mach Discussion / Mach4 General Discussion / Re: Mach4 Printer Port Discussions on: June 22, 2014, 07:01:42 AM
did you run the vcredist_x86.exe installer first?
8  Mach Discussion / Mach4 General Discussion / Re: Screen Set Ideas on: June 19, 2014, 11:28:24 AM
How to control states and led's

local SpinCCW = scr.GetProperty('ledSpindleCCW','Value','Value',0);
local SpinCW = scr.GetProperty('ledSpindleCW','Value','Value',0);

if (SpinCCW == "1") then
    scr.SetProperty('btnSpindleCCW', 'Label', 'SpindleCCW ON');
    scr.SetProperty('ledSpindleOFF', 'Value', '1');
    scr.SetProperty('btnSpindleOFF', 'Label', 'Spindle ON');
elseif (SpinCW == "1") then
    scr.SetProperty('btnSpindleCW', 'Label', 'SpindleCW ON');
    scr.SetProperty('ledSpindleOFF', 'Value', '1');
    scr.SetProperty('btnSpindleOFF', 'Label', 'Spindle ON');
else
    scr.SetProperty('btnSpindleCW', 'Label', 'SpindleCW OFF');
    scr.SetProperty('btnSpindleCCW', 'Label', 'SpindleCCW OFF');
    scr.SetProperty('ledSpindleOFF', 'Value', '0');
    scr.SetProperty('btnSpindleOFF', 'Label', 'Spindle OFF');
end
9  Mach Discussion / Mach4 General Discussion / Re: Mach4 Printer Port Discussions on: June 17, 2014, 08:27:36 AM
Hi Tweakie

trying to follow your diagrams, is this correct? Not at all an electronics expert.
Plus when I see this, I get a little confused why you pass a single signal to both sides of an "and gate", when you already have the logic.
10  Mach Discussion / Mach4 General Discussion / Re: Screen Set Ideas on: June 16, 2014, 07:55:13 AM
Feed and Speed control with buttons and hot keys (F keys) working.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 »
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!