Hello Guest it is April 25, 2024, 07:02:04 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 - smurph

811
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".

Steve

Steve

812
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.

Steve

813
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!
end

Steve

814
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().

Steve

815
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. 

Steve

816
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!")
end

Steve

817
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);

and

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.

Steve
 

818
Mach4 General Discussion / Re: Lua
« on: January 23, 2017, 02:11:22 AM »
The max value of the analog input is determined by the ADC used on the hardware. 

10 bit == 0 to 1023 for a 1024 count range
12 bit == 0 to 4095 for a 4096 count range
14 bit == 0 to 16383 (16384 range)
16 bit == 0 to 65535 (65536 range)

This is called the ADC resolution.  To get the analog input value as a percentage, just divide the value by the total range. 

percent = value / range

For example, if the ADC is 10 bit and the value is 512, then:

512/1024 == .5 (or 50%).

Now you can play with some numbers to arrive at solutions to common problems.  For example (and just for kicks), say you want to know the voltage present at the ADC given its' integer value.  For the above value of 512 that yields 50% and a VCC voltage of 3.3v:

3.3 * .5 == 1.65v. 

So going back to main problem at hand, we now want to know what 50% of a range is.  Say 50 to 150.  The formula for that is:

val = (percent * (max - min)) + min

Where percent is a decimal representation of a percentage.  e.g. .5 for 50%

(.5 * (150 - 50)) + 50 == 100.

Steve

819
Mach4 General Discussion / Re: Question on Toolpath?
« on: January 22, 2017, 06:24:15 PM »
Unfortunately, not at this time.  :(

Steve

820
Mach4 General Discussion / Re: Errors in Machine.ini file
« on: January 19, 2017, 09:09:56 PM »
As long as the code looks for the misspelled keys, then it doesn't matter.  If you correct the spelling in the .ini file, then you get hosed.  :)

Steve