Hello Guest it is April 19, 2024, 12:54:21 AM

Author Topic: Screen Set Ideas  (Read 184732 times)

0 Members and 2 Guests are viewing this topic.

Re: Screen Set Ideas
« Reply #80 on: June 15, 2014, 10:51:27 PM »
playing around with modbus by passing data in, computing to display results
Re: Screen Set Ideas
« Reply #81 on: June 16, 2014, 08:29:05 AM »
Found that a one second Sleep is needed to give the registers time to fill before I could read them.
Re: Screen Set Ideas
« Reply #82 on: June 16, 2014, 08:55:13 AM »
Feed and Speed control with buttons and hot keys (F keys) working.
Re: Screen Set Ideas
« Reply #83 on: June 19, 2014, 12:28:24 PM »
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
Re: Screen Set Ideas
« Reply #84 on: July 04, 2014, 12:44:02 PM »
Came across this reference document thought it was a good resource for Lua 5.1
Re: Screen Set Ideas
« Reply #85 on: July 06, 2014, 12:44:46 PM »
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
« Last Edit: July 06, 2014, 12:49:02 PM by Ya-Nvr-No »
Re: Screen Set Ideas
« Reply #86 on: July 06, 2014, 02: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.

Update: This has been addressed and fixed in the latest versions.
« Last Edit: July 20, 2014, 06:36:31 PM by Ya-Nvr-No »
Re: Screen Set Ideas
« Reply #87 on: July 08, 2014, 08: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: [Select]
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
« Last Edit: July 08, 2014, 08:20:57 AM by Ya-Nvr-No »
Re: Screen Set Ideas
« Reply #88 on: July 11, 2014, 08:28:25 AM »
Was up late last night working with Steve on the new release, 1889 fixes several of my issues.  :-*

Also got my MPG wizzard buttons to control the axis.  ;D

so I had good day, but missed a lot of sleep ;)

thanks Steve
Re: Screen Set Ideas
« Reply #89 on: July 13, 2014, 01:55:05 PM »
Major pita to format control items, but did get it to move incrementally and continuously  (b axis does not increment, slight bug in the core i'd say).

Update; July 16, 2014: seems that B- incremental just gets ignored but B+ incremental puts the wizzard in a state that needs a Close (not exit) to get it to restart correctly, all the buttons take on the same last commanded move so every button press does the same thing. Odd as hell.  ???

Few items to work out yet but its getting closer. Have to admit Widgets are a tough lesson to learn.

And sure hope someday they create a GUI program to create prettier screens.

Still pretty amazing what can be written in Lua to add features to interact with Mach4.

Update; October 13, 2014: revision 2038, I  just noticed addresses the issue with the B incremental problem I'd found. Cool thanks guys.
« Last Edit: October 13, 2014, 08:12:51 AM by Ya-Nvr-No »