Exploring ShopBot Part Files 2 …

In the last Bill’s corner we learned how to manually create part files by typing in commands, and to automate the process using the Part File Assembler. Now I know you all agree with me that this could be pretty powerful stuff, but what can we really do with it that we can’t do just as easily by just creating the file in Part Wizard?

So let’s say you already had a part file that you created in Part Wizard that you use all the time…maybe a 12”x12” FOR SALE sign for a real estate company. One week they call you and say they need 6 of them…what do you do! You’ve got a handful of options. You could always open up Part Wizard, open the saved design (you did save it, didn’t you?), then copy it 6 times, move the copies around so that they fit on your material, and create a new part file. Seems like a lot of extra work, especially since the design part has already been done. And what if the next order was for 11 or some other number…you would sure be doing a lot of extra work every time you re-created the files. There has to be an easier way.

Well, you could throw a piece of plywood onto the table, sit down at the computer, and type FP, forsale.sbp to cut the first sign. When that one was done you could move 12” down the sheet…either with the keypad or with an MX, 12,0 command…and then run the file again. But how would you tell the ShopBot software to do that? You could re-zero the tool where you wanted to cut the new file and then run it again normally, but there are some problems with doing it that way. The first one is that you’ll lose your personal reference point on the tool and won’t know the tool’s location just by looking at it…it might be in the middle of the table but the tool might think it’s at 0,0. Your ShopBot still knows where the “real” 0,0 is because it’s saved with your Table Base Coordinates, but it might not be obvious to you if you wanted to send it to some other place on the table.

The other problem is one called “accumulated error” and happens when a number is rounded off a bunch of times. Just about all calculations in life are rounded a little bit…sometimes up and sometimes down…which generally doesn’t make much difference. But if more are rounded up than down (or vice versa), after a while the error can mount up. So constantly re-zeroing really isn’t the best thing to do.

Offset Mode and Master Files

A better way would be to move down to the new starting point with the MX, 12,0 command and then run the sign file in 2d OFFSET mode by typing FP, selecting the file again, and then selecting 2d offset in the fillin sheet. 2d OFFSET mode acts like a temporary re-zeroing, so that the file cuts as if the current tool location is 0,0 without actually changing it to 0,0. You can also select 3d offset, which works the exact same way but also offsets in the Z-axis. After the first sign had cut you could type MX, 24,0 and repeat the process. It would work great but you would be pretty much tied to the computer for the time that the signs were cutting. What we need to do is to automate the process so that it will run un-attended and you can do something else while it’s cutting.

The way that works the best is to create a “Master File”, either manually or using the Part File Assembler, that does all the moving and file calling for you. A Master File uses a combination of Jog (or Move) commands to position the tool at the new start point, and matching FP commands with the Offset parameter (the 6th one), set to “2” for 2D offset (or “1” for 3D offset). The commands to cut our first hypothetical For Sale sign 12″ from our 0,0 position would look like…

J2, 12, 0
FP, forsale.sbp,,,,,2

..and here’s a sample of a Master file that you could use to cut all 6 signs…

J2, 0, 0
FP, forsale.sbp,,,,,2
J2, 12, 0                  ‘ the Y offset isn’t needed here … it just makes it more consistent
FP, forsale.sbp,,,,,2
J2, 24, 0
FP, forsale.sbp,,,,,2
J2, 36, 0
FP, forsale.sbp,,,,,2
J2, 48, 0
FP, forsale.sbp,,,,,2
J2, 60, 0
FP, forsale.sbp,,,,,2

If you saved this new file and ran it in preview it would look something like this..

pf2_1b

Offset mode also comes in REALLY handy for cutting files out of odd-shaped pieces of scrap material, because you can move to a clear spot and cut the file there without knowing beforehand where that location is. Offset Mode cutting works best…for me at least…if you create your files with the 0,0 location at the lower-lefthand corner of the part because you ALWAYS know where the corner of a blank is but you have to FIND it’s center. With some thought you can place the 0,0 point of your drawing in the center of the part or just about anywhere else.

One other option is to use the “S_nest.sbp” file that’s included your Sbparts folder. It uses a series of questions to create an “array”..a pattern of rows and columns…of locations that a part file will be cut. It’s VERY handy if you want to fill a sheet full of copies of a file, but may be a little bit of overkill if you just need to cut a couple of copies of something. It also only works if you can use a “regular” cutting pattern…one that has even rows and columns.

As you can see Offset Mode and Master Files have a lot of uses, and you can stop reading here if you want and will have a very handy new tool in your ShopBot toolbox. You can easily expand the power of these Master files by using more of the ShopBot commands, so take a break for a little while, play with running some files in Offset mode and maybe create a Master file or two. Then when you’re feeling refreshed and recharged come back and we’ll introduce “variables” and the INPUT statement that will let us customize our Master Files without having to do as much re-writing.

What’s a variable? The answer varies…

Welcome back. Let’s get back in the swing of things by backing up a couple of articles. Remember our example part file from the first “Exploring Part Files” article…
‘ Our sample file could be used to drill a series of half inch deep holes
‘ Zero the Z-axis at the top of the material

‘ Written by Bill May 4, 2006

MZ, 0.5            ‘ lift to a safe Z height
J2, 1, 1           ‘ Jog to X = 1 and Y = 1
MZ, -0.5           ‘ plunge the Z-axis to –0.5 to drill hole
MZ, 0.5            ‘ lift bit to safe height

JX, 2              ‘ Jog to the next hole
MZ, -0.5
MZ, 0.5

JX, 3              ‘ and the next
MZ, -0.5
MZ, 0.5

JX, 4              ‘ the last hole
MZ, -0.5
MZ, 0.5

J2, 1, 1           ‘ Jog back to X = 1 and Y = 1
This file is pretty short, and it would be easy to make changes to it. If we wanted to change the depth of the hole to -0.25” instead of -0.5” we would just have to change the 3rd command to MZ, -0.25. And the 6th. And the 9th. And the 12th. But what if we were drilling 100 holes? If we were using the ShopBot editor we could use the find and replace feature to replace every instance of -0.5 with -0.25, but every time we wanted to drill a different depth hole we would have to change all of them. And what would happen if we had a command in our file like..

M3, 3.75, -0.5, -0.5

Unfortunately the Replace function in the editor would change any occurrence of “-0.5”, both the one you wanted…the Z-axis one…and the Y-axis value that you don’t want to change. That’s where variables come in handy.

A variable is just something that represents something else. And you know what; you use them all the time without knowing it. Let’s say you need to figure out the sales tax on something you want to buy. Your total TAX equals the product COST times the sales tax RATE, so if you wrote it as a math formula it would be TAX = COST * RATE. Well, TAX, COST, and RATE are variables because they are symbols that represents a number or value that can change or vary. The TAX on a $15 router bit in Virginia where the RATE is 4.5% will be different than the tax on a $20,000 car in a state with a 6% tax rate.

But how would we use a variable in our example? First we need to tell the ShopBot software that something is a variable, and we do that by picking a unique name for the variable and starting it with the & sign. That means that we could name our variable &x if we wanted to and everything would work, but later on that really wouldn’t tell us very much about what that variable does and what kind of value it holds. It’s a much better idea to pick a name that’s meaningful to you, maybe something like &holedepth. Now every time we want to drill a hole we can replace the line MZ, -0.5 with the line MZ, &holedepth. But wait a minute, how does the ShopBot know what &holedepth represents? It doesn’t on it’s own, we have to tell it. We do this with a line in our part file that says &holedepth = -0.5 in a step that programmers call “initializing” the variable.

There’s one thing you need to be aware of when working with variables in a ShopBot file. ShopBot variables are “persistent”, meaning that they hold their value until they’re either given a new value later on or the ShopBot software is shut down which wipes the slate clean. This can be a very useful feature because you can create a file full of just variables and then load it in any part file with the FP command and you’ll have access to those values. That’s how the ShopBot zeroing files work…in the beginning they load a file named “my_variables.sbc” that’s in your “C:\sbparts\custom” folder. It contains all the settings that are specific to your tool that you entered using the “Setup” Virtual Tool, and these values are then available to any part file that’s run until the tool is shut off. This persistence property of variables can be handy but can also be a problem, especially if you use a variable in a file without giving it a value…without “initializing” it. If you’ve used a variable with the same name in an earlier file then it’s value will carry over…which might be good or might not. Just be aware of it.

Back to work. Let’s re-write our example using a variable for the depth, and while we’re at it let’s change the safe z height to a variable as well. Our file would look like;
‘ Our sample file could be used to drill a series of holes
‘ Zero the Z-axis at the top of the material

‘ Written by Bill May 4, 2006

&zup = 0.5         ‘ safe z height

&holedepth = -0.50 ‘ set cutting depth

MZ, &zup           ‘ lift to a safe Z height
J2, 1, 1           ‘ Jog to X = 1 and Y = 1
MZ, &holedepth     ‘ plunge the Z-axis to –0.5 to drill hole
MZ, &zup           ‘ lift bit to safe height

JX, 2              ‘ Jog to the next hole
MZ, &holedepth
MZ, &zup

JX, 3              ‘ and the next
MZ, &holedepth
MZ, &zup

JX, 4              ‘ the last hole
MZ, &holedepth
MZ, &zup

J2, 1, 1           ‘ Jog back to X = 1 and Y = 1
You can see how much easier this would be to change the cutting depth if it drill 100 holes instead of 4…you would only need to change the value of the variable &holedepth. But wouldn’t it be neat if you could somehow tell your file what the value of that variable is without having to change the file and the re-save it? You can by using the INPUT command.

Asking the person running the ShopBot a question…

The INPUT statement is the ShopBot software’s way of asking you a question and then saving your answer in a variable. Up until now the commands we use have been pretty simple but the INPUT statement has a format that it has to be in to work correctly..what computer programmers call it’s Syntax. You start with the word INPUT (called a keyword in programming-ese) which is followed by the phrase that you want the person running the file to see, surrounded by quotes (“) on each end. Then after the last quote you put the name of the variable that whatever the user types will be stored in. Here’s an example of an INPUT statement that would let the ShopBot user type in a new value for the hole depth, &holedepth
INPUT “How deep do you want to drill the holes?” &holedepth
You can just replace the “initialized” value for &holedepth with this new INPUT line and when a ShopBotter runs that file he would be presented with a box like this…

pf2_2Whatever the ShopBotter typed into the box would be stored in the variable &holedepth. And every time you ran the file you could drill different depth holes, without having to change the file itself…just type in a different number. That might not be all that handy, but let’s say that you needed to drill your holes exactly halfway through your material and the material varied in thickness the way most plywood does. We can modify our example file so that it now asks for the material thickness as a input and then uses the value of that variable to calculate the correct &holedepth value. It might look something like this…
INPUT ” How thick is your material?” &thickness  ‘ set cutting depth
&holedepth = 0 – (&thickness / 2 )               ‘ find half of thickness and subtract from 0 to get cut below surface

Each time we run this hole-drilling we could accurately measure our material and then type in that measurement and all our holes would be the correct depth.

There’s one more use for the INPUT command…it can be used to read values from a text file. We’ll talk about this in an upcoming article on reading and writing text files from within a part file, but in the next article we’ll take what we’ve learned about using variables and the INPUT command (along with some new commands) to make decisions…the IF-THEN statement and looping.

Comments are closed.