Hello Guest it is March 28, 2024, 06:59:50 AM

Author Topic: Can I Lockout Mach 4 unless correct post processor is used?  (Read 1540 times)

0 Members and 1 Guest are viewing this topic.

Can I Lockout Mach 4 unless correct post processor is used?
« on: October 10, 2018, 05:04:52 PM »
I have three custom CNC machines all running Mach 4.  They all have slight differences and I have created a post processor for each machine.  (I use Visual Mill 6.0).  I would like to setup each machine so that it will only run if the corresponding post processor was used to generate the gcode file.  This will help eliminate the inevitable situation where I forget to change to the post processor when generating the gcode file. Is there a standard way of doing this, or does anyone have suggestions for me.

Thanks!
Re: Can I Lockout Mach 4 unless correct post processor is used?
« Reply #1 on: October 10, 2018, 07:57:32 PM »
Add a comment to your post “ HEY STUPID THIS IS FOR XYZ NOT ZYX OR YZX!!!”

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Can I Lockout Mach 4 unless correct post processor is used?
« Reply #2 on: October 11, 2018, 07:45:24 AM »
You could do what Gary said then when you load the Gcode look at the whatever line number and if it doesn't equal the unique string close the Gcode and pop up a message box saying why it closed. All of the API calls needed to do it exist.

buff, rc = mc.mcCntlGetGcodeLine(number mInst, number LineNumber)
rc = mc.mcCntlCloseGCodeFile(number mInst)

Or, save the unique files with a unique identifier in the name or to a unique location for each machine. You can get the name including the location with.......

buf, rc = mc.mcCntlGetGcodeFileName(number mInst)

Lots of ways to do it. Just think about how you want it to work and do it.
« Last Edit: October 11, 2018, 07:57:05 AM by Chaoticone »
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Can I Lockout Mach 4 unless correct post processor is used?
« Reply #3 on: October 11, 2018, 08:35:36 AM »
I have included a unique comment at the top of each of the post processors as Gary suggested.  This works, but only if i am at looking at my own comments.  Unfortunately I don't trust myself that much.

I think Chaoticone is going the direction I would like to implement.  I'm not very confident of my coding abilities but I'm going to dig in and see how far I can get.  I'll probably have lots more questions.

Thanks!
Re: Can I Lockout Mach 4 unless correct post processor is used?
« Reply #4 on: October 11, 2018, 10:28:10 AM »
local buff, rc
buff,rc= mc.mcCntlGetGcodeLine(number mInst, number LineNumber)
local i
i=string.find(buff,'My Unique Processor Name')
if i==nil then
  rc = mc.mcCntlCloseGCodeFile(number mInst)
end
Re: Can I Lockout Mach 4 unless correct post processor is used?
« Reply #5 on: October 11, 2018, 06:08:05 PM »
local buff, rc
buff,rc= mc.mcCntlGetGcodeLine(number mInst, number LineNumber)
local i
i=string.find(buff,'My Unique Processor Name')
if i==nil then
  rc = mc.mcCntlCloseGCodeFile(number mInst)
end

I think I'll eventually be able to work through what all this means.  (my formal programming in college was FORTRAN entered with punch cards in the early 80s and I have only dabbled in other languages a bit over the years!)

However, let me ask a more basic question to start.  When I press the "Load G Code" button on the screen "something" is executed which loads the file.  Then I want to do the test above to see if the Post Processor is a match.  Where do I find this "something" that is executed to load the file?  If I go to the "Operator" menu and select "Edit Screen" and click the "Load G Code" button, in the properties box I see a Left Up Action is "Gcode Load".  How do I find this "Gcode Load" so that I can modify it?  I'm not sure I'm understanding the overall structure of where things are and how they are related.
Re: Can I Lockout Mach 4 unless correct post processor is used?
« Reply #6 on: October 11, 2018, 10:36:15 PM »
I think Charis wants to know where to put this code.  I don't know where to put it myself... maybe the cycle start button?  Or make it a function and run it on a G Code load?  I'm not sure where I would put it myself.
Chad Byrd

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Can I Lockout Mach 4 unless correct post processor is used?
« Reply #7 on: October 12, 2018, 10:02:38 AM »
You can test for the correct file in PLC script. You can't put it in a buttons script because all of it's events would have already ran (pretty sure but didn't test to be honest). If there is a Gcoded loaded signal you might be able to make it a function and run it when that singlas state changes. Would be a better place than the PLC script but I didn't take time to look for or test that either.

Below is a script to do what you want. It looks for the string "Test" beginning at the second and ending at the 5 position on line 0 (Very first line of Gcode). The reason it starts a the second position is the first will be a ; or (.

Anyway, place the script in the PLC script after the inst variable is defined. Add the line "(Test)" (minus quotes) as the very first line of your Gcode and play with it. Once you are comfortable with it you can comment out the line writing to the error label and uncomment the line that pops up a message box.

Code: [Select]
local curGcode, rc = mc.mcCntlGetGcodeFileName(inst)
if  (curGcode ~= lastGcode) then -- Gcode files changed
lastGcode = curGcode
if (curGcode ~= "") then --A gcode file is loaded
--mc.mcCntlSetLastError(inst, "curGcode (" .. curGcode .. ")")
local buff, rc = mc.mcCntlGetGcodeLine(inst, 0)
local s,e = string.find (buff, "Test")
if (s ~= 2) or (e ~= 5) then --The start and/or end of the unique identifier is not in the right place or it doesn't exist
local rc = mc.mcCntlCloseGCodeFile(inst)
mc.mcCntlSetLastError(inst, "File closed due to incorrect format " .. buff)
--wx.wxMessageBox("File closed due to incorrect format " .. buff)
end
end
end
« Last Edit: October 12, 2018, 10:07:14 AM by Chaoticone »
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!