Hello Guest it is April 23, 2024, 09:07:26 PM

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 - Ya-Nvr-No

371
Mach4 General Discussion / Re: Variables reading and writing
« on: May 17, 2014, 12:30:34 PM »
have not see anything other than what Mach4 provides
TP I too wrote a plugin years ago for that very same purpose.

also I use the iReg0 register (instance) I can read and write to it from other external scripts, such as a Wizzard that can read the Axis DRO's or pass and set feed rates

372
Mach4 General Discussion / Variables reading and writing
« on: May 17, 2014, 12:05:25 PM »
Been mucking around looking in to reading and writing to variables and trying to figure out the variable#'s
Reality, I was trying to find a way to set the persistent dro's so when I restart it has the same dro coords as when it shut down.
not sure where it picked these from but can not seem to reset them, as the data is held in the xml file not the machine.ini

There has to be a way to write them to memory on shutdown or maybe write them to a file and then read the file and fill the variables with the stored locations.

-- inst 0 is the hobby version 0 is the only one, the pro versions will have more capabilities and Mach4 can then run multiplies instances.
-- this was placed under a button click to read and set, step thru and experiment.
inst= 0

--how to read variables
local valx = mc.mcCntlGetPoundVar(inst, 5021);
local valy = mc.mcCntlGetPoundVar(inst, 5022);
local valz = mc.mcCntlGetPoundVar(inst, 5023);
local vala = mc.mcCntlGetPoundVar(inst, 5024);

--how to set variables (in this case to zero)
mc.mcCntlSetPoundVar(inst, 5021, 0);
mc.mcCntlSetPoundVar(inst, 5022, 0);
mc.mcCntlSetPoundVar(inst, 5023, 0);
mc.mcCntlSetPoundVar(inst, 5024, 0);


-- this is a listing of a lot of the variables I found. As you can see there is a pattern to some like kinds
not all as most of course are zero's and there are a lot of them. Your numbers will vary for most.
I labeled some I could get a handle on. Others will have to wait for Documentation.
Writing a while loop to read all the variables > 0 and then writing to a text file or even a wizard is in the plans.

2132=900
2134=10

3005 =200
3101 =3.141592
3102 =2.718282
4001=10
4002 =170
4003 =900
4004 =911
4005 =940
4006 =200
4007 =400
4008 =490
4009 =500
4010 =990
4011 =150
4012 =1
4013 =610

--my machine always defaults to these #' on startup
5021=0.254 --machine coordinate x
5022=1.27 --mc y
5023=1.27 --mc z
5024=50.8 --mc a

5025=453.571429 --not sure what this number is

5110= headshift x
5111= hs y
5112= hs z
5113= hs a
5114= hs b
5115= hs c

5201= workshift x
5202= ws y
5203= ws z
5204= ws a
5205= ws b
5206= ws c

5221= g54x
5222= g54y
5223= g54z
5224= g54a
5225= g54b
5226= g54c

5241= g55
5261= g56
5281= g57
5301= g58
5321= g59
--and on and on they go as blocks of 20

7785=tool 1 Length
7786=Length wear
7788=1/2 Diameter
7789=1/2 Dia wear

7795=tool 2
7805=tool 3
7815=tool 4
7825=tool 5
7835=tool 6
7845=tool 7
7855=tool 8
7865=tool 9
7875=tool 10
8375=tool 60
8775=tool 100
8785=tool 101
9775=tool 200
9785=tool 201
9795=tool 202
-- and these go on in blocks of 10

10275=tool 250 Length
10276=length Wear
10278=1/2 Dia
10279=1/2 Dia wear

10315=tool 254 Length
10316=length Wear
10318=1/2 Dia
10319=1/2 Dia wear

15000=2418317446859018500000000000000000000000000000000000000000000000000000000000000
15001=2418347089633870200000000000000000000000000000000000000000000000000000000000000
15002=2418376732408721800000000000000000000000000000000000000000000000000000000000000
--up to variable 15038 with those in variations

below are some screen shots of where to look at your variables
and yes you can have multiple ranges and multiple display groups displayed
Pin it to keep them on the top of screen.

--just a random lot of variables and the values
15043=92
15045=17
15046=90
15047=91
15048=94
15049=20
15050=40
15051=49
15052=50
15053=98
15054=15
15055=54
15056=64
15057=97
15058=69
15059=-1.#QNAN0
15060=-1.#QNAN0
15061=-1.#QNAN0
15063=13
15064=10
15065=900
15067=-1
15068=-1
15069=-1
15102=-1
15104=-1
15105=-1.#QNAN0
15106=-1.#QNAN0
15107=-1.#QNAN0
15108=-1.#QNAN0
15109=-1.#QNAN0
15110=-1.#QNAN0
15111=-1.#QNAN0
16127=5000
16288=3600
16293=5



373
Mach4 General Discussion / Creating a Probe File
« on: May 15, 2014, 08:28:06 PM »
--Inspired by Nicks (Bodini) Tool table exporter
--Place under a button
--can be called from a probe input in the future development

local AXIS_X = mc.mcAxisGetMachinePos(inst,0);
local AXIS_Y = mc.mcAxisGetMachinePos(inst,1);
local AXIS_Z = mc.mcAxisGetMachinePos(inst,2);

filename = "ProbeData.txt";

file = io.open(filename,"a"); -- create new file or add to it
ProbeData = string.format("X%4.4f Y%4.4f Z%4.4f \n",AXIS_X, AXIS_Y, AXIS_Z);
file:write(ProbeData)

file:close()

374
Mach4 General Discussion / Re: Export tool table
« on: May 15, 2014, 06:12:17 PM »
Nick is the new expert on the block  :)

Great job, and thanks
worked first time no problem at all, as advertised
Cut and paste to a button script

375
Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 15, 2014, 12:49:16 PM »
That's my point if you don't post your code, we are just guessing what your issue might be.

Sharing brings to light issues other might want to learn from too.

If ya don't want to share, pull your own hair.  ;D

its just a joke... chill  8)

376
Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 15, 2014, 10:34:21 AM »
write a script under a button and test by stepping thru it

CASE = "yes";
case = "no"
Case =1
CasE =2
a=a

you bet it is case sensitive

377
Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 15, 2014, 08:44:27 AM »
--i put this in the screen load script and I don't see any issues calling it from any place   ::)

function ReadReg(regName)
    local inst= mc.mcGetInstance();
    mc.mcCntlSetLastError(0, 'ReadReg = ' .. tostring(ReadReg));
    local hReg = mc.mcRegGetHandle(inst, regName);
    local val = mc.mcRegGetValue(hReg);
    return(val);
end

function WriteReg(regName, val)
    local inst= mc.mcGetInstance();
    mc.mcCntlSetLastError(0, 'WriteReg = ' .. tostring(WriteReg));
    local hReg = mc.mcRegGetHandle(inst, regName);
    mc.mcRegSetValue(hReg, val);
end

378
Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 14, 2014, 04:50:54 PM »
id say by the look of it, you cannot local inst mc.mcGetInstance() more than once in the same over all button script
the functions would have to be in the load script area and you call them from there
if they are in the same overall function you call it at the top once

please post as code this is a pita to follow

379
Mach4 General Discussion / Re: MACH4 - Modbus
« on: May 14, 2014, 01:39:41 PM »
I just created a m40.mcs and called it up with a mdi and It works for my address's
 change address to suit your named ones.


function m40()

local inst= mc.mcGetInstance();

local hRhr1 = mc.mcRegGetHandle(inst, "modbus0/Rhr1");
local valRhr1 = mc.mcRegGetValue(hRhr1);
local hRhr2 = mc.mcRegGetHandle(inst, "modbus0/Rhr2");
local valRhr2 = mc.mcRegGetValue(hRhr2);
local hRhr3 = mc.mcRegGetHandle(inst, "modbus0/Rhr3");
mc.mcRegSetValue(hRhr3, valRhr1 + valRhr2);

function ReadReg(regName)
    local hReg = mc.mcRegGetHandle(inst, regName);
    local val = mc.mcRegGetValue(hReg);
    return(val);
end

function WriteReg(regName, val)
    local hReg = mc.mcRegGetHandle(inst, regName);
    mc.mcRegSetValue(hReg, val);
end

valRhr1 = ReadReg("modbus0/Rhr1");
valRhr2 = ReadReg("modbus0/Rhr2");
WriteReg("modbus0/Wsr3", valRhr1 + valRhr2);

end

if (mc.mcInEditor() == 1) then -- as Steve said this works in the editor for debugging the m40 function only
    m40()
end

380
Mach4 General Discussion / Re: ScreenSet Question
« on: May 14, 2014, 12:09:58 PM »
I'm running a 5' x 10' router with Mach4 and ESS now

and working on a new setup now with Art's Darwin pp
I did do a bench test and did get working one nema 23 stepper to prove Darwin worked as advertised.
So they are very close.
Start saving bottles, almost time to turn them in.