PDA

View Full Version : Shopbot Code Geeks - request for unique file



Mayo
06-19-2012, 06:47 PM
I've tried editing two existing Shopbot files to come up with what I'm trying to do but I get lost in the code and I'm not experienced enough doing this to actually understand what I'm doing.

What I want to accomplish sounds relatively simple. And I think it could be a useful program for a lot of Botters.
I want to make the Shopbot report to me what my actual material thickness is, instead of having to use a micrometer on my material.

I've looked at the Z-Zero program and the Probe program, and they both contain parts of what I think would be necessary, but they also contain a lot of unnecessary code.

Here's how I think the program should work:
Find table surface Z location (possibly just using the existing Z-Zero program).
Put material on the table.
Move X and Y and Z to new position over the material surface.
Move Z down until Z-Zero plate is contacted.
The Z location is now the material thickness plus the Z-Zero plate thickness.
Subtract the Z-Zero plate thickness from this new Z location.
Display this number on screen - it should be the material thickness.
Esc or Enter to close file.

Here's what I copied and pasted from the Probe file into a new file
but frankly it's incomplete and laughable to anyone who really knows this Shopbot code. I'm sure it's not going to do what I'm expecting. If anyone wants to tinker with this or write something much simpler from scratch that would be cool.


'Initialize

SA, 'absolute increment mode
SL, 'clear all variables in memory
&zmax=-2 'maximum probe depth
&surfacetol=2 'change to greater than approx. material thickness

'Get user-entered table surface position

&safeclear = 1

INPUT "X Starting Position ->" &xstart
INPUT "Y Starting Poistion ->" &ystart

'Moving to start location
JZ, &safeclear
MS, .75, .6

'Check to make sure Z-Plate makes contact
PAUSE .1
IF %(51)=1 THEN GOTO CONTINUE1
'Z-Plate Not Working ----> EXITING !
PAUSE
END


CONTINUE1:
'Z-Plate Working ----> Start? (OK to continue)"
PAUSE


DOWN_CYCLE:
ON INPUT(1,1)
IF %(51) = 0 THEN GOTO CLEAR_FOR_DOWN 'Make sure we are really above at Start of Down
ON INPUT(1,0) GOTO CONTACT 'Set up response to contact
MZ, &zmax 'DOWN HERE ... looking for basic bottom
END ' -->expected -off- hit bottom


CONTACT:
ON INPUT(1,0) '**need to clear here to prevent bounce
PRINT "Table surface recognized"
Pause 3
MZ, %(3)+&surfacetol 'Pulls up a bit to control unnecessary bouncing on a flat surface

ON INPUT(1,1) GOTO Material_Z 'starts second Z-Plate detection sequence on surface of material
MZ, &safeclear 'but start UP until we are clear ...

'No Clearance or Problem with Z-Plate!
PAUSE
END 'If we don't get clear we'd better stop !


MATERIAL_Z:
'Place Z-Zero Plate on surface of material
'Get in Position over Z-Plate
INPUT "X Material Position ->" &xmaterial
INPUT "Y Material Poistion ->" &ymaterial

'Check to make sure Z-Plate makes contact
PAUSE .1
IF %(51)=1 THEN GOTO CONTINUE1
'Z-Plate Not Working ----> EXITING !
PAUSE
END


Like I said, I'm sure this is not right, and I got lost in it after this.

dana_swift
06-19-2012, 07:14 PM
Sounds like a useful routine. You are getting quite close, so why not finish it yourself, then you know how to go on to the next project from there.

My advice is to build/test each section in sequence when it is working the way you want go to the next operation.

So first operation is "zero on the table height". Does that work correctly?
Wait for the user to acknowledge the material is in place then hit ok. Does that work correctly? If not, you know the first part is not the problem, etc.
Then touch off the top of the material BUT DONT SET A NEW ZERO.. just store the value you came up with. Does that work?

Subtract the ZZero plate thickness (its stored in a variable already for you) and now you know the material thickness. Get that working correctly before going to the next step.

My suggestion is not to leave the bit on top of the material because its basically in a bind at that point. Have it move 1" above the material as its easy to subtract 1 in your head.

You can display the actual material thickness value with a print statement. Get that working even if the bot is one inch above that.

This stuff is confusing at first, but the mud clears. Its kind of like learning how to use the bot itself. But if you can adjust the SBC code to do your bidding you become a power user. You can make it do almost anything YOUR WAY.

What I tell my programming students is never copy code, look at it and see how it works, then write it yourself. Then you know what it is doing. Someone elses code may be better than yours, but you will get better with experience. Avoiding the experience creates a forever confused operator.

If you copy and modify code you become 100% responsible for any bugs in it and any damage it may do. Since you are going to be responsible, you might as well be the one who knows whats going on in the code.

Also dont try to write an entire program. Just write the first bit, test it. Only when it is working correctly go to the next step. If you do that, you can write ANYTHING. If you dont, well.. if my own experience is a guide I get nowhere at all. I have to start over and follow my own recommendations.

If you have a problem with a specific step, thats when you get the most useful help from us on the fourm, or TS, learning how it really works, hot how you THINK it works.

I'm glad to see you gave it a shot already.

Give it another one..

Keep us posted.

D

jimboy
06-20-2012, 12:24 AM
i have such a program if you need it. i agree with dana tou should try it on your own first

Mayo
06-20-2012, 04:08 AM
Thanks for the responses Dana and James.
Taking it one step/section at a time makes sense.

Now that I've found the Programming Handbook PDF on the Shopbot web site I think things will be a little easier. My old Ver. 2.01 manual was not as clear as the newer PDF file.

david_beede
07-21-2013, 08:49 AM
I also have a need for this kind of file, but don't have many programming chops.

I'm using a variation on Scott Worden's program/custom cut file to move my machine to various jigs on the table. I'd like to find out the relative height of each jig bed to my Table Based Coordinates, so I can do a bit change and set the zero for the jig location before going there. Hope that makes sense.

I have a question about an approach to this issue.
Is there a way that i could modify the z-zero program so that it zeroed the bit WITHOUT saving it to the "TBC" / Table Based Coordinates?

If so, I could use it to re-zero to any surface, position the bit at zero, then use the "ST" command to revert to Table Base Coordinates and the displayed bit position would tell the relationship of that surface to my home TBC position.

Thanks for any tips or insights into this...
David

Gary Campbell
07-21-2013, 09:13 AM
Mayo...
I also agree with Dana & Jim. Here is a copy of one I used a few years back. I will asterisk the lines that only applied to my system that you do not need. Change variables to the OEM usage and you should be good to go.

start file:::

'GC SURFACE HEIGHT READER
'must have the GC_variables file in use!!!!!!
'WILL NOT RUN ON OEM SHOPBOT VARIABLES
'
'+++USER ACCEPTS FINAL RESPONSIBILITY FOR USE OF THIS PROGRAM!!!+++++++++
'+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++
'Created by Gary G. Campbell Copyright 11/19/09 Any Modification, Copying or Distibution without permission is unlawful
'+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++
' UNITS = INCHES
CN,90
SA,
SF,0
VN,0
'+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++=
' THE PROGRAM
'+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++
'
**CN,60 'save existing speeds
'
READ_Z:
MSGBOX(INSTALL CLIP AND HIT ENTER WHEN OVER PLATE and READY to READ,0,PLACE ZERO PLATE UNDER BIT)
If %(51) = 1 THEN GOTO CLOSED_EXIT
VS,,.5,,,,3
ON INPUT(1,1) GOTO HIT_Z
MZ,-12
GOTO FAILED_EXIT
HIT_Z:
ON INPUT(1,1)
**PLAY D:\SbParts\Touch Beep.wav
PAUSE .1
JZ,%(3) + 0.5
'
SECOND_TIME:
&z_hit = 0
&mtl_hgt = 0
If %(51) = 1 THEN GOTO CLOSED_EXIT
VS,,.25,,,,3
ON INPUT(1,1) GOTO HIT_Z_2
MZ,-12
GOTO FAILED_EXIT
HIT_Z_2:
ON INPUT(1,1)
**PLAY D:\SbParts\Touch Beep.wav
&z_hit = %(3)
&mtl_hgt = &z_hit - &Z_plate
PAUSE .1
**CN,67
**CN,61
VN,1
PRINT "MATERIAL HEIGHT IS ", &mtl_hgt
'
MSGBOX(PRESS ENTER TO EXIT,0,*****HEIGHT READ********)
VD
END
'
'+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++
' SUBS
'+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++
'
'
CLOSED_EXIT:
MSGBOX(PROBLEM WITH SWITCH *EXITING*,0,INPUT 1 STATUS)
**CN,68
**CN,61
END
'
FAILED_EXIT:
MSGBOX(DID NOT MAKE CONTACT *EXITING*,0,INPUT 1 STATUS)
**CN,61
END
'

david_beede
07-21-2013, 10:34 AM
Gary - Thanks for sharing that. I'll study on it. Sounds like you have a custom "my variables" variation you're using?

UPDATE: As I was playing with my Zzero file, I noticed the commands for "Contact1:" didn't save the location to Table Base Coordinates, so I was able to substitute that line in "Contact2:"
This actually worked fine....

Then, with a little poking around I found an older/historic [2007 maybe?] zzero file that didn't save to the TBC. So that must be a more recent feature of the zzero routine.

So using the modified Zzero [or the older file] to zero to the jig surface, or mystery material in question
Then use the ST command - voila! the location displays the material thickness + the safe Z amount [or you could move the Z to "O" before hitting ST, if you prefer not do the math of subtracting the safe z distance - then the position display is the actual thickness]

Hope that makes sense... probably seems like a funny workaround to avoid actually doing much programming, but when I discover I can do what I want to do by just understanding a program I already have... I love it.

srwtlc
07-21-2013, 10:52 AM
David,

I know that my original 'offsets' file didn't didn't quite work for you, but when the commented out Z axis references were in play, I was able to track the Z axis location from jig to jig also. Table base Z was initially set at start up and then each jig. I just didn't use that part much an commented it out.

I do like your ST change though instead of my convoluted math/system variables. ;)

david_beede
07-21-2013, 12:07 PM
David,

I know that my original 'offsets' file didn't didn't quite work for you, but when the commented out Z axis references were in play, I was able to track the Z axis location from jig to jig also. Table base Z was initially set at start up and then each jig. I just didn't use that part much an commented it out.

I do like your ST change though instead of my convoluted math/system variables. ;)

Hey Scott - Yes, as you see I've been using the ST command a lot, now that I've learned what it can do for me.

One of the reasons your position program was misbehaving for me is that I was using an old Zzero program that did NOT write the Z to Table Base Coordinates, so whenever I re-zeroed at a new jig station then went home... the Z location display would change back to the Table Base Coordinates, confusing the heck out of me. It's all a little clearer now that I see the new Zzero was writing to TBC.

One thing I didn't mention is that my way of finding thicknesses only works if I've already zeroed to the home surface and stored that in the Table Base Coordinates. I had to physically position the Prim Router at zero in x&y&z and my aux router at zero/surface of table then hit Z4 & ZT.

I was able to tweak Gary's "surface finder" program to work on my machine and it's sweet. The main difference is that the thickness shows up in a very official looking window on the screen rather than reading it from the display box and it does the zplate thickness math. I'll have to find a Custom Cut for that one.

Next issue for me is I'd like to use the bottom of a copper pipe cap I have mounted to my bot table as a "touch off" Zeroing location. Since the cup is below the table surface I thought i could just enter a negative number for the Z-plate thickness in my variables, but it seems it won't take a negative number. [At least not -1.011] Anyone know why not?