STOP CNC CRASHES! Intelligent Tool Check!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi folks it seems crazy in this day and age that a cnc machine could crash because you never entered the tool height shouldn't it know similarly if the tool height and cam and the tool height in your machine are really different shouldn't we be able to check that we can so let's walk through what's happening both in fusion 360 on the machine control and the javascript side of modifying the post we'll make this post available if you're less interested in learning and more interested in just having it and i want to do this for linuxcnc as well aka pathpilot and we're going to have to do it a little bit differently than we did on the kind of fanuc based haas type post so let's do that together as an example of learning some more post tweaking we're actually going to start in the haas mill operators manual i'm going to search for 2001 and that brings me to the macros variable table we can see the range of 2001 to 2200 is the tool length offsets this is great because haas makes it really easy to check this the length value in the haas control of tool five becomes macro variable 2005 similarly the length on tool 8 macro variable 2008 lt is fancy code for less than and then this value comes from fusion 360. we'll dive in deeper in a minute so what this line says is whatever the tool length value is for tool five if it's less than 3.3253 then generate this alarm with this comment tool five is too short so what's great is if the value is zero because it was never touched off it will trip this alarm we'll do a recap at the end talk about what this code does and doesn't do so you can tweak it as you see fit here is the snippet of code that does this tool length check sequence we've got it fairly well commented let's break it down and show you why it's not that intimidating remember from the macro variables section of the haas manual tool length offsets start at 2001. we want to create a variable called first length var of 2000. we'll come back to that in a second we then create a variable the tool table and we loop through looking to see how many tools there are because if we have six different tools used we need six if statements and what we do is we write that if statement that we saw from the posted code across multiple different lines we concatenate it together it just makes it easier for the programming we start with an if the pound to access the macro variable and then we use that 2000 variable but we add to it whatever tool number we are so this whole line right here will ultimately read something like pound 2005 for tool five there's the lt for the less than and then this is where we really tie into the fusion 362 library we grab the tool body length and the tool holder length body length comes from this variable right here length below holder the link below holder is the only one that actually adjusts how far the tool protrudes below the face of your tool holder itself and then tool dot holder length grabs a dimension from the holder so you do need to have the correct holder applied to your tool for this to work and finally the text to throw the error pound 3000 which if we hop back into our haas pdf and scroll down we can see that pound 3000 is a programmable alarm we're also adding the comment just to clarify to the operator what exactly is going on that whole if statement is then looped however many number of tools that there are with one exception which is if the tool type equals tool probe it will not conduct this length check we do that with the continue command in javascript which says skip the rest of the code in this instance of the loop but stay in the loop so it'll index to the next tool the really nice thing about the haas control here is that because each tool has a macro variable for its height that we can access at any time it means this post can easily create as many if statements as needed to automatically check behind the scenes at the beginning of the program with linux cnc aka pathpilot we don't have the same type of macro variables for each individual tool in the machine control so instead what we're going to do is we're going to wait until each tool change and that tool height is applied and we'll check it then so let's figure out how to do that the first thing we want to do is post our code and take a look at where we want to insert this new code i want it right after this t8 g43 line because that g43 g-code is what applies the 8h which is the height offset for that tool two ways that we can figure out where to insert that code if i'm lucky searching for 43 will show me where i need to be and sure enough if we look at this line write block t plus the tool number so t 8 g format g43 g43 h format center so this is the section if that doesn't work and oftentimes it doesn't card here really cool technique that we go over using visual studio code where you can actually click on the posted g-code and it will tell you what section of the post made that line of g-code so let's get our bearings in this section of the code i think we can start right here if we take a look at this line and we move up to the first section we see this if insert tool call and sure enough if i click on the open bracket you can see that that whole section of code goes down to here so this section of the post deals with calling a new tool but before we write any real code i'm just going to test that so i'm going to say write comment jws testing we'll save that post our code and we should have a comment after every tool change we've got one for the first one and scroll down we've got the same comment after the second one perfect next up i googled linux cnc variables and as if they call them parameters so we jump down to the parameter section starting with 5104 is the tool offsets for x y and z so 5403 will be the z offset of the current tool hopping back into the haas post let's copy and paste most of that if statement that we already wrote in linux c and c the if statement needs to be inside of a subroutine so we need to start with this o number so we'll type o 100 on the haas post we used this section of the code so that it resolved to something like pound 2003. well we know in linuxcnc it's always going to be the same variable it's going to be pound 5403. we can move the less than to this line that line doesn't change we just need to then close it off this code won't work at the machine but it should post so let's see how we get along so we still have our comment and then we have this this line forgot a space between the less than and the number let's fix that i'll add a space after the lt before the end quote we'll need to end the subroutine and then we need to decide what we want to happen if the tool fails the test or if it's too short i'm going to do two things i'm going to put in a dwell or a pause it's not necessary but i like it and then we're also going to trigger a proper path pilot warning that will both end the program and tell the operator what happened we want the dwell to be a g4 p1 for a one second dwell we'll write that by doing writeline g format dot format four so that puts in the g4 and then we'll say plus p1 we can also make use of the linux cnc message command which has in my opinion a bit of a strange nomenclature it's msg comma what you want it to say and all that's in parentheses so we'll say write line open paren we'll start our quote and then we'll do another param because we want this parent to actually be in the posted code message comma please recheck tool now let's make sure this works and then we need to make some improvements but it reads that if the z height variable is less than the value we get from fusion do a one second dwell and then send this message i forgot the end paren there as well so fix those two things now we need to fix the subroutine nomenclature and we want to improve the message the reason we need to fix the subroutine nomenclature is that you can't have the same subroutine number multiple times in a program and this section of code is going to get looped with each tool change so we can't just say oh 100 and we can't hard code this into the post so we're going to add a variable var jws loop we're going to use that variable as the name of the subroutine to easily make it unique we'll use the tool number well we have that code right here format dot format tool number i'm going to first add 10 to it so that it becomes a value that ultimately ends up being in the hundreds and then instead of saying write line o 100 we'll say right line plus jbs loop so that'll start with the o that we need and then it'll add in the value of jws loop which is 10 plus the current tool number so if it was tool eight it would actually come out as 1 0 8 versus say 18 and then it'll resume our if statement see if that works awesome 0 108 make that same change to the end if and finally i want a better path pilot warning that tells the operator exactly what happened so instead of just saying please recheck tool we're going to say please recheck tool and we'll paste in our tool number again and plus height so if that all goes well for tool five it should say please recheck tool five height so tool eight in this example 0-108 if the value is less than this fusion value of that tool body length plus holder dwell and message please recheck tool eight height i got one thing wrong on the parens there and then 0 108 and if we'll fix that one goof so we already looked at tool eight let's jump down to make sure it's working on tool five in this example t5 h5 o105 if 5403 is less than the fusion value pause and please recheck tool five height one more missing space caught me but i think we're good one last addition that i almost forgot add the right line m format format mformat.format30 that puts the m30 in in the event the tool does fail the test and that will force the program to reset and then load that program up in pathpilot right now i've got both the tools set to be too short so this should fail immediately when it looks at tool eight which has a length of five inches we need it to actually be five point four seven four inches cycle start and sure enough program resets we have a status alert in yellow and it says please recheck tool height eight we go ahead and change tool eight to be long enough to pass the test and go back it will now complete that op go to tool five it'll ask us to put tool five in the spindle but when we do so same issue here tool five was too short program ends and we get an alarm that says please recheck 205 height this program checks to see that the tool meets a minimum length i could totally see shops wanting to rewrite it to make sure the control value isn't zero meaning you've at least touched the two off or you could set it to a bracketed range to make sure that the tool isn't more than say 100 different shorter or taller that could really help long-term process reliability also a big shout out and thank you to cj abraham over at autodesk for helping troubleshoot some of this javascript code but as always folks hope you learned something hope you enjoyed we've got more post processor resources over on the nyc cnc website otherwise take care see you soon [Music] you
Info
Channel: NYC CNC
Views: 15,470
Rating: 4.9020042 out of 5
Keywords: fusion 360, how to, cnc, machine shop, nyc cnc, DIY, machining, milling, CAD, cnc machining, cnc milling, learn cnc, john saunders, manufacturing entrepreneurship, provencut, CAM toolpaths, saunders machine works, fixture plates, modular workholding, post processor, linux cnc post processor, pathpilot, fanuc control, macro variable, g code editing, tool length alarm, tool height, cnc crash
Id: Rnx097pD51I
Channel Id: undefined
Length: 12min 59sec (779 seconds)
Published: Wed Sep 15 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.