Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: KentCNC on February 14, 2021, 03:55:00 PM

Title: Signal Number Definitions
Post 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.



Title: Re: Signal Number Definitions
Post by: joeaverage on February 14, 2021, 09:42:17 PM
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
Title: Re: Signal Number Definitions
Post by: KentCNC on February 14, 2021, 11:08:15 PM
That post did not have the answer I was looking for, but it was very informative. Thank you.
Title: Re: Signal Number Definitions
Post by: joeaverage on February 14, 2021, 11:42:16 PM
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


Title: Re: Signal Number Definitions
Post by: SwiftyJ on February 15, 2021, 03:09:37 AM
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
Title: Re: Signal Number Definitions
Post by: Brian Barker on February 15, 2021, 10:23:20 AM
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 :)
Title: Re: Signal Number Definitions
Post by: KentCNC on February 17, 2021, 11:19:23 AM
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?
Title: Re: Signal Number Definitions
Post by: Brian Barker on February 17, 2021, 11:43:17 AM
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
Title: Re: Signal Number Definitions
Post by: compewter_numerical on February 18, 2021, 02:22:24 AM
I wouldn't encourage this use of Mach Lua API but here is a function that works:

Code: [Select]
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
Title: Re: Signal Number Definitions
Post by: KentCNC on February 18, 2021, 11:54:38 AM
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)

Title: Re: Signal Number Definitions
Post by: KentCNC on February 18, 2021, 05:12:00 PM
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?
Title: Re: Signal Number Definitions
Post by: smurph on February 19, 2021, 12:42:02 AM
it would be mc.OSIG_SPINDLE_FWD.