Hello Guest it is September 29, 2020, 11:00:13 AM

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 - smurph

Mach4 General Discussion / Re: Connecting to Mach4
« on: February 11, 2017, 08:20:08 PM »
Delphi can run time link to DLLs, right?  Just pull in the functions from MachIPC.dll.  The API docs are in the docs folder.  It will be the same as pulling in C functions from WINAPI.  There is no COM in Mach4 as it is designed to be platform independent. 

Two functions that a remote app should use that are not documented in the API documentation:

MACHAPI int MACH_APIENTRY mcIpcInit(const char *ipAddr)
MACHAPI int MACH_APIENTRY mcIpcCleanup(void)

mcIpcInit() is the first thing that should be called by the application.  The parameter is the IP address of the Mach instance to control. for app running on the same machine as Mach. 

mcIpcCleanup() is the last thing your app should call before shutting down. 


Mach4 General Discussion / Re: Unknown word where unary operation could be
« on: February 11, 2017, 08:06:18 PM »
I would check the file and make sure there are no UNICODE characters in it.  G code is ASCII only. 


Mach4 General Discussion / Re: Preload-Tool Macro
« on: February 11, 2017, 08:02:14 PM »
N10 T10 (Load first tool)
N20 M6 (change to T10)
N30 T12 (load next tool)
N100 M6  (change to T12)

Something like that? 

You can accomplish the preload by making a T macro.  Call it t.mcs and drop it into your profile's macro folder. 

The file's contents:
Code: [Select]
function t(tool)
inst = mc.mcGetInstance('T macro');
local msg = "Tool Changer Selecting tool #" ..  tostring(tool)
mc.mcCntlSetLastError(inst, msg);
        -- You must do something with tool here.  Send to PLC, etc...

if (mc.mcInEditor() == 1) then
    t(10); --simulate T10

Every time the interpreter executes a block with T in it, this macro will run.


Mach4 General Discussion / Re: Variables and Parameters list
« on: January 31, 2017, 02:52:03 PM »
For #3, The Renishaw routines need a place to store settings.  e.g. probe tip diameter.  They ask you to provide them a range of G code variable in the 500-999 range.  These variables get saved across machine restarts.  But many G code programmers also use this range.  So they ask the person installing the probe routines where these settings should reside so as not to conflict with other settings.  Finding this information will be like finding a needle in a haystack.

To convert the code, you must have a full understanding of two machines!!  The machine where the code came from AND Mach (Fanuc 21i).  For example, I don't know what #50601 is!!!  Further more, why would it be EQ 1?  These are the questions will come up and they will have to be answered by the person converting the code.  #26 is, and always will be, a local variable that has the contents of the Z word.  #26 is pretty much universal.

As for the list of G code variables, the Fanuc 21i parameter manual has every one on them listed.  e.g.  #5061 is the X probe position (skip position).  There is also lots of information on the net such as: http://www.machinetoolhelp.com/Applications/macro/macro_variables.html  We patterned after a Fanuc so as to be compatible.  We don't implement every one of their parameters because some just don't pertain to our system at all (like ROM option bits, etc...).  But the ones for probing are implemented precisely so that the Renishaw Fanuc probing routines will work. 

As for documentation, we just haven't done it.  Why?  There is plenty of Fanuc documentation out there and we would be just duplicating that anyway.  Whole books have been written on the subject.  One great source for Macro B programming is Peter Smid's book "Fanuc CNC Custom Macros".



Mach4 General Discussion / Re: Variables and Parameters list
« on: January 31, 2017, 12:33:55 AM »
A Fanuc 21i will do what you need.  I used the Renishaw probing software installation program to generate the probing subprograms.  It asks questions about the control.

1. How many tools (you can set this in Mach to anything, but you had better use Fanuc standard values of 99, 299, and 999!).
2. What cutter comp memory type (Mach uses type C).
3. Where to put Renishaw settings in general program variables, etc..

If those subprograms were not generated for a 21i with type C mem, then it is going to be VERY difficult to munge everything to work. 

Also, you need a Mach 4 Industrial license to turn on the needed Macro B functionality to use the Renishaw probe routines.

But if you have to try, the 21i Fanuc manual will give you any parameter or variable location you are looking for as far as probing is concerned.  A possibly easier solution would be to just duplicate the Renishaw subprograms' functionality by writing your own subprograms.


Mach4 General Discussion / Re: Can i edit or add to a Predefined Macro?
« on: January 26, 2017, 07:40:30 PM »
The G code interpreter will take M03, m03, M3, or m3 and turn them all into m3.  So when looking for a macro, it will use m3.  Much simpler than looking for all 4 variations.

Using the constants is a very good idea.  Because if we change the value of the constant, it will not require you to change your code.  :)

The return code is simply discarded and garbage collected if it is not used.  However, I strongly suggest checking for error codes!  Not only is it a good programming practice, it could have bearing on whether or not you loose a finger or not!  Yikes!  In truth, it is not necessary all of the time.  But if you get into the habit, it is going to pay dividends in the future for sure.

All of the API functions have their possible return codes documented and I'd say that the majority are correct.  In the event that we messed up, I prefer to test for inverse success.  e.g.

if (mc.mcSpindleSetDirection(inst, mc.MC_SPINDLE_FWD) ~= mc.MERROR_NOERROR) then
   --handle any failure!


Mach4 General Discussion / Re: Can i edit or add to a Predefined Macro?
« on: January 26, 2017, 06:18:38 PM »
The macros (and functions inside them) should be lower case and leading zeros dropped.  m03, M03, m3, or M3 is accepted by the interpreter, but it gets low cased and leading zeros dropped shortly there after.  Windows is not case sensitive but LUA is.  Everything ought to be case sensitive.  Everything on the planet, except Windows, IS!!!! 

If you write a custom m3 macro, it replaces the stock actions of m3.  So you must provide all functionality you desire in the custom m3 macro.  See the doc on mc.mcSpindleSetDirectio().


Mach4 General Discussion / Re: Send Email
« on: January 24, 2017, 04:45:03 AM »
It is asking you to find the required module.  Simply pick smtp.lua.  When the require keyword is used in a LUA script, think of it as "including" that script.  Also think of:

local smtp = require("/socket.smtp")

as short hand for:

local smtp = require(cpath .. "/socket/smtp.lua")

For port 587, that will require SSL.  I think there was a post on here somewhere that deals with using SSL along with the sokets smtp module.  Search around for it.  I worked with Chaoticone on getting that working at some point, but I do not remember the details. 


Mach4 General Discussion / Re: 24 Position Side Mount Tool Change Macro
« on: January 23, 2017, 04:22:25 PM »
rc is the function return code.  Ideally, you should check the rc to determine success or failure of the API call instead of assuming that it worked.  You know what they say about assumptions.  :)  f an API function succeeds, it will return a rc of mc.MERROR_NOERROR.

For example:

RequestedTool, rc = mc.mcToolGetSelected(inst)
if (rc ~= mc.MERROR_NOERROR) then
    mc.mcCntlSetLastError(inst, "Error getting selected tool!")


Mach4 General Discussion / Re: 24 Position Side Mount Tool Change Macro
« on: January 23, 2017, 03:20:32 PM »
For machines that don't have a 1:1 for tool number to pod, use the tool table's pocket feature.  

pocket , rc = mc.mcToolGetData(Inst, mc.MTOOL_MILL_POCKET, tool);


rc = mc.mcToolSetData(Inst, mc.MTOOL_MILL_POCKET, tool, pocket);

pseudo code:

RequestedTool, rc = mc.mcToolGetSelected(inst)
CurrentTool, rc = mc.mcToolGetCurrent(inst)
pocket , rc = mc.mcToolGetData(Inst, mc.MTOOL_MILL_POCKET, RequestedTool);
retrieve tool from pocket
rc = mc.mcToolSetData(Inst, mc.MTOOL_MILL_POCKET, RequestedTool , 0); -- tool is in spindle.
put current tool in the requested tool's old pocket
rc = mc.mcToolSetData(Inst, mc.MTOOL_MILL_POCKET, CurrentTool , pocket); -- old tool is in the new pocket.

Before the first run, make sure the tool table has the correct pocket numbers for eash tool.