PDA

View Full Version : Clean Up Routine with Variables



handh
01-17-2008, 11:29 AM
Here is my first attempt of writing a file. It is a clean up routine that I have been working on which allows you to enter your material thickness which you z zeroed to the top of the material with. So if you are using 3/4 or 1/2 material or what ever it might be it will do the math and let you run the router 1/8 above the bed. It also has a couple of warnings in case you forgot that you had zeroed to the table top to allow you to cancel the file. It also has a place to allow you to enter the move speed so if the table is extra dirty you can slow it down or speed up for a quick pass if it is pretty clean. I want to say thanks to Ryan for some of his help. Ok here is a question that I have, is there anyway to do a if statement so that instead of putting warning messages in the file, I could ask the question is your z zero to the top of material or to the bottom of material and then do the math in the file. Does anyone know if this is possible. Here is the file so who ever is interested can look at what I have done and edit it for your own use. Beware, this is my first attempt so test before use.

Thanks,
Jeff

handh
01-17-2008, 11:31 AM
Forgot to add the file attachment.
CleanUp_Variables

4595 (4.7 k)

bill.young
01-17-2008, 12:01 PM
Hey Jeff,

Look at the Programming Handbook in the "C:\Program File\ShopBot\Developer Tools" folder for information on the MSGBOX command. It lets you customize a message box in a couple of ways and then test for the button that the user clicked.

I'm not sure many people have played with it...we haven't gotten any feedback on it at least...so let me know how it works out.

Bill

srwtlc
01-17-2008, 12:51 PM
INPUT "Is your Z zeroed to the (T)op or (B)ottom of the material?" &answer

IF &answer = T THEN GOTO Top
IF &answer = B THEN GOTO Bottom

Top:
'Top routine here


Bottom:
'Bottom routine here

srwtlc
01-17-2008, 12:53 PM
MSGBOX works great too, but it's a yes, no, ok, cancel, etc. type situation.

handh
01-17-2008, 05:36 PM
Thanks, Scott

I got it to work like that. Check out the file and let me know what you think.
ShopBot CleanUp

4596 (9.0 k)

beacon14
01-17-2008, 08:54 PM
Jeff,

You are off to a great start. Writing code really lets you get the most out of your machine. Find or get your copy of the ProgHand.pdf and read up. Adding a GOTO statement will let you avoid having to copy the entire machining section twice.

Good luck and have fun.

handh
01-17-2008, 09:34 PM
David,

Yes I have the ProgHand.pdf and I wish it gave more examples of what it is trying to tell you. Ok, one thing that you said, adding a GOTO statement will let you avoid having to copy the entire machining section twice. I don't know if I follow you or not. I tried to not seperate the Top and Bottom routines,

Like this

IF &answer = T THEN GOTO Top
IF &answer = B THEN GOTO BOTTOM


Top:
INPUT "Enter Material Thickness in Decimals" &MATERIAL_THICKNESS
&CLEANUP_VARIABLE = &MATERIAL_THICKNESS - 0.125
&CLEANUP_PASS = &CLEANUP_VARIABLE * -1


Bottom:
&CLEANUP_PASS = .125



And then I had the rest of the file after this. It wouldn't run right, every time it would run the Z at .125, so I did the file like I have it written in the file I posted and it works, so what could I have done different to not had to copy the machining section twice?

Thanks,

paco
01-17-2008, 11:50 PM
Keep at it Jeff!

If you're curious, you can study this code (http://pacosarea.blogspot.com/2007/02/surfacing-along-axis-shopbot-routine.html) a bit. There's some of David B.'s code (and Mike Richard) in it!


4597

handh
01-18-2008, 08:46 AM
Thanks Paco,

I went and printed it off and downloaded the file and I will read on it and play around with it some. I'm always wanting to learn new stuff.

Thanks,
Jeff

beacon14
01-18-2008, 10:03 AM
That's because after the "top" commands are read the program continues down the list and then runs the "bottom" commands. Here are a couple of ideas/examples for you.

First method: change the "bottom" command to an IF statement, so it will only change the variable when appropriate

IF &answer = T THEN GOTO Top
IF &answer = B THEN GOTO BOTTOM

Top:
INPUT "Enter Material Thickness in Decimals" &MATERIAL_THICKNESS
&CLEANUP_VARIABLE = &MATERIAL_THICKNESS - 0.125
&CLEANUP_PASS = &CLEANUP_VARIABLE * -1

Bottom:
IF &answer = B THEN &CLEANUP_PASS = .125

Second method: use a GOTO to direct the flow around the "bottom" commands:

Top:
INPUT "Enter Material Thickness in Decimals" &MATERIAL_THICKNESS
&CLEANUP_VARIABLE = &MATERIAL_THICKNESS - 0.125
&CLEANUP_PASS = &CLEANUP_VARIABLE * -1

GOTO Machine

Bottom:
&CLEANUP_PASS = .125

Machine:

Third method: eliminate the GOTOs enitirely

&MATERIAL THICKNESS = 0
IF &answer = T THEN INPUT "Enter Material Thickness in Decimals" &MATERIAL_THICKNESS

&CLEANUP_PASS = 0.125-&MATERIAL_THICKNESS

The goal of most programmers is to complete the task with the fewest lines of code necessary. It makes for the most elegant and smallest file and is easier to troubleshoot. So let's go back to your original INPUT statement:

INPUT "Enter material thickness, (enter 0 if Z is zeroed to the table)" &MATERIAL THICKNESS

&CLEANUP_PASS = 0.125-&MATERIAL_THICKNESS

handh
01-18-2008, 01:28 PM
Thanks David,

That was really helpful information. I liked the GOTO Machine idea. Here is the updated version. Let me know if you all see anything that I can do to improve. I tested the variables and all seems to work great. This will really keep us from getting into the table during a cleanup routine, since the file that I had been using was just made for 3/4 material, and we use alot of different thicknesses.

Jeff
CleanUp_Variables_2

4598 (4.7 k)

bill.young
01-18-2008, 01:34 PM
Hey guys,

Jeff had a good idea about having more programming examples so I've added a section to the "ShopBot software" part of the wiki to hold them. I've only added a little bit of info so far...feel free to jump in.

http://shopbotwiki.com/index.php?title=ShopBot_Software

Bill

handh
01-18-2008, 04:42 PM
After thinking about this a little more, I decided to add a little more to it. This version allows you to decide if you want to run the file to raster on the x axis or the y axis and I cleaned up code some. Seems that all works right. Let me know if you all find anything wrong with this. I'm sure most people know all of this but this is so interesting to me. Also if any of you want to save it as a custom cut just resave the file as Custom_.sbc were _ is the number of the cut that you want it to be and place it in your custom cuts folder and that makes it very handy.

Jeff


4599 (5.0 k)

srwtlc
01-18-2008, 11:50 PM
As you noticed, GOTO's don't return like a GOSUB does so you need a END as the last thing in the GOTO if you're done after that and with a GOSUB you need a RETURN so it goes back to where it branched off from.

END ';-)