Hello Guest it is March 29, 2024, 05:55:56 AM

Author Topic: Mach 4 Reference sequence Question  (Read 983 times)

0 Members and 1 Guest are viewing this topic.

Mach 4 Reference sequence Question
« on: November 11, 2018, 04:49:26 AM »
Hi,

is there any possibility to get a output signal from Mach4 who shows the status if the Machine is referenced on all axis?
I have a Signal Pillar which shows me the State of the Machine, if it is Enabled, a ToolChange is needed or if it´s in EStop Condition.
But i don´t know how i can get the Status of a Complete Reference Sequence. Single Axis Referenced signals are easy.


hope someone can help me


Thanks Sven
Re: Mach 4 Reference sequence Question
« Reply #1 on: November 11, 2018, 12:59:25 PM »
Hi,
yes there is a way to establish whether is referenced, its in the API.chm which is found in your Mach4 Docs
folder:

LUA Syntax:
homed, rc= mc.mcAxisIsHomed(
      number mInst,
      number axisId)

Description:
Check to see if axis has been homed.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Reference sequence Question
« Reply #2 on: November 11, 2018, 03:37:16 PM »
Thanks so far, but my problem is i don´t know anything about Lua Programming.
How can i get this type of Signal to an output of my controller? That all axes are homed?
 
Re: Mach 4 Reference sequence Question
« Reply #3 on: November 11, 2018, 06:24:03 PM »
Hi,
the real strength of Mach4 is the facility with which it can be programmed to do such things. The greatest weakness of Mach4
is that you have to program it to do unusual things.

I must be said that Mach4 as it is doesn't require the feature you want.....it can machine parts in absence of that feature no trouble.

If you want some particular feature then you will have to program it and therefore learn about Lua and Mach's modular structure.
There is a learning curve. Remember if you don't like it.....the reason you're doing it is because you want some specific thing not
otherwise provided for.

Having stood on my soapbox and possibly scared you; what you want to do is easy.

How much do you know about Mach's structure? In particular can you open the Screen Editor and navigate to the Screen Load script,
the PLC script etc? If this is unfamiliar to you there are some videos covering it released by NFS in recent months. Unfortunately
the re-direct feature of the forum is on the blink so I can't link you to it.

In this case you need to put a few lines of code in the PLC script. The PLC script is somewhat analogous to the macro pump in Mach3.
The PLC script runs every few milliseconds. What you what it to do is ask the question 'is the machine referenced....if so turn on an output....if not
turn the output off'. This will run hundreds of times a second and so the output will reflect the state of the machine virtually continuously.

For the purpose of writing code I would recommend opening the Zero-Brane editor and creating a new file within your profile...something like
/TempWorkFile. It gives you the chance to write the code and have the Lua compiler compile the code checking for errors. You can also use the debugger
to run the code for test purposes. Once you have code that you think is going to work THEN copy and paste it into your PLC script.

I'll write some code and post it soon.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach 4 Reference sequence Question
« Reply #4 on: November 11, 2018, 06:48:54 PM »
Hi,
this is some code I have written, as I suggested to you I have written it in a temporary folder. It compiles OK and I have
single stepped through it with the debugger and it appears to work.

May I suggest copying this into your temporary folder and step through it with the debugger. Once you are happy with it THEN
copy it into the PLC script.

Code: [Select]
local inst=mc.mcGetInstance()
local xhomed,rc=mc.mcAxisIsHomed(inst,mc.X_AXIS)
local yhomed,rc=mc.mcAxisIsHomed(inst,mc.Y_AXIS)
local zhomed,rc=mc.mcAxisIsHomed(inst,mc.Z_AXIS)
local outhandle=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT5)
if (xhomed==1 and yhomed==1 and zhomed==1) then
mc.mcSignalSetState(outhandle,1)
else
mc.mcSignalSetState(outhandle,0)
end

Craig
« Last Edit: November 11, 2018, 06:51:35 PM by joeaverage »
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'