Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: KentCNC on February 14, 2021, 03:55:00 PM
-
Where can I find the definitions for the Mach4 signals?
I see the following in Lua code: return Read_Signal(1142)
I need to know which signal 1142 is associated with.
-
Hi,
try this post:
https://www.machsupport.com/forum/index.php?topic=40051.0 (https://www.machsupport.com/forum/index.php?topic=40051.0)
Craig
-
That post did not have the answer I was looking for, but it was very informative. Thank you.
-
Hi,
I had a look for that variable number also, but couldn't find it either.
I am not aware of anymore authoritative source either. NFS's response is usually along the lines that the assignment of a pound variable number
for a given piece of data is at NFS's sole discretion and is likely to change over time. They claim any and all useful data is covered by the
ENUMS, and they are in turn NOT affected should at some later date a pound variable number be changed.
If you do discover what it refers to please post it so we can update the lists......its people contributing what they have discovered that those lists exist at all.
Craig
-
The easiest way to check this is to go into your machine.ini profile and search for 1142. Looks like its for the spindle forward output
-
This is all defined in the header file that we have in the build. I can give you that here ... nothing special!
If people would use the mc.<name> it would make the code much more readable... BTW with some Lua code we can output all the names with the values :)
-
I am new to Mach4 and am trying to get modBus working for my Hitachi VFD. Nothing like biting off a difficult problem to start with. PMC is what generates that number. I see that in this section of code: "return mcSignal(1142)". What is the appropriate way to access that signal?
-
I think I need to make a Lua script to process them all .... I think that would be a cool thing to have. Give me a little time and I will make something up.
I am trying to setup a new PC so I am trying to move a ton of junk around. But the new thread rippers are COOL!
Thanks
Brian
-
I wouldn't encourage this use of Mach Lua API but here is a function that works:
inst = mc.mcGetInstance()
profile = mc.mcProfileGetName(inst)
machDirectory = mc.mcCntlGetMachDir(inst)
local mINIFilePath = machDirectory .. "\\Profiles\\" .. profile .. "\\Machine.ini"
function findSignalByNumber(sigNum)
for line in io.lines(mINIFilePath) do
if signalFound then
local signalDesc = string.match(line, 'Desc') and true or false
if signalDesc then
description = line:gsub('Desc=', '')
mc.mcCntlSetLastError(inst, 'Signal' .. tostring(sigNum) .. ': ' .. tostring(description))
signalFound = false
break
end
else
signalFound = string.match(line, 'Signal' .. tostring(sigNum)) and true or false
end
end
end
findSignalByNumber(1142)
The output prints in the History log
-
I am very new to Mach4 and Lua so am undoubtedly going to ask some very naïve questions.
Can I replace this code:
Read_Signal(1142)
With this:
Read_Signal(mc.MC_SPINDLE_FWD)
-
Let me clarify my question. I know from looking at the ini file that signal 1142 is associated with Spindel_Fwd. Assuming that is true, can I replace this:
Read_Signal(1142)
with this:
Read_Signal(mc.MC_SPINDLE_FWD)
Or do I simply reference the signal state using "mc.MC_SPINDLE_FWD" and drop the Read_Signal portion?
-
it would be mc.OSIG_SPINDLE_FWD.