Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crashes tool bit into bed #5

Open
Ksaor21 opened this issue Jun 12, 2023 · 13 comments
Open

crashes tool bit into bed #5

Ksaor21 opened this issue Jun 12, 2023 · 13 comments

Comments

@Ksaor21
Copy link

Ksaor21 commented Jun 12, 2023

After zeroing with plate, we go to start a file and instead of raising the Z it drives it into the bed. Do you have any suggestions for this?

@tachoknight
Copy link
Owner

So the zero-finder program works insofar as it finds zero for X, Y, and Z, but when you run your own job it crashes into the bed, right?

@Ksaor21
Copy link
Author

Ksaor21 commented Jun 12, 2023 via email

@tachoknight
Copy link
Owner

tachoknight commented Jun 13, 2023 via email

@Ksaor21
Copy link
Author

Ksaor21 commented Jun 13, 2023

' ========================================================================================
' X, Y, and Z Zero'ing tool for PS1's Shopbot (www.pumpingstationone.org)
' Version 2.0; 1/13/2020
' ========================================================================================

' Give the user a chance to exit the program if they didn't intend to run it,
' or they're not ready to (e.g. the tool isn't positioned above the plate)
MSGBOX(Is the tool positioned above the upper part of the plate?, YesNo, Ready to Zero?)
IF &msganswer = "No" THEN GOTO EndOfProgram

' We want to make sure the bit is not spinning when running this program...
' Make sure the spindle RPMs are set to zero
TR,0
' And turn off the spindle
C7

' ****************************************************************************************
' Initialization of variables
' (Because it's nice to know what all the variables are ahead of time)
' ****************************************************************************************

' Set the scale we'll use
&SCALE = 1

' Used in calculating where Z should be
&zBottom = 0

' The thickness of the aluminum plate
&PLATE_THICKNESS = .497

' The size of the top part of the plate where Z is found (and then we move off from there)
' heading towards absolute X 0 (i.e. the front of the shopbot as it's positioned at PS1)
&TOP_PLATE_LENGTH = 3.24

' This is the length of the entire plate
&FULL_PLATE_LENGTH = 4

'
' A D J U S T M E N T S
' These two variables are for 'tweaking' the X and Y due to irregularities in the
' plate. These are very very piece-specific and if you make your own, it's likely
' you'll end up wanting to use these variables as well.
'
&xAdjustment = 0.008
&yAdjustment = 0.138
&zAdjustment = 0.0
'
'&xAdjustment = 0.044
'&yAdjustment = 0.072
'&zAdjustment = 0.030

' ****************************************************************************************
' First we need to figure out if we're in preview mode, or in tool
' mode. The program does nothing useful in preview mode
' ****************************************************************************************

&currentMode = %(22)
IF &currentMode = 1 THEN GOSUB InPreviewMode

' ****************************************************************************************
' Okay, we're not in preview mode, so on with the show...
' ****************************************************************************************

' Load the custom variables file from Custom Cut 90
C#,90

' Get Speed Limits of the machine
' This subroutine sets the following
' variables:
' &TopApproachSpeed = .25
' &TopJogSpeed = 3.5
' &first_move = -2
' &second_move = 2

IF %(25) = 0 THEN GOSUB GetInchSpeedLimits

' TEMPORARY: Haven't figured out the metric values yet
IF %(25) = 1 THEN GOSUB MetricNotYet

'------------------------------------------------------------------------------
' Set up our X and Y speeds
'------------------------------------------------------------------------------

' Okay, now we have to get the current settings of the machine
' The System Variables are documented on page 36 of the
' Part File Programming Handbook for the OpenSBP Language
&start_XYmove_Speed = %(71) ' MoveSpeed X
&start_XYjog_Speed = %(76) ' JogSpeed X

' Now we're going to set up the X and Y speeds and
' if they exceed the max, we'll just set them to the
' max
' XYapproach_Speed is the speed we set the machine to
' use when approaching the plate (i.e. when we want to
' move slowly)
&XYapproach_Speed = &start_XYmove_Speed
IF &XYapproach_Speed > &TopApproachSpeed THEN &XYapproach_Speed = &TopApproachSpeed

' This is the speed we use to move quickly around the
' plate where we're not attempting to take measurements
&XYtempJog_Speed = &start_XYjog_Speed
IF &XYtempJog_Speed > &TopJogSpeed THEN &XYtempJog_Speed = &TopJogSpeed

' Now actually set the speed of the machine
' XY Move Speed, Z Move Speed, A Move Speed, B Move Speed, XY Jog Speed, Z Jog Speed, A Jog Speed, B Jog Speed
VS, &XYapproach_Speed,,,,&XYtempJog_Speed '... and assign slower speeds

'------------------------------------------------------------------------------
' Set up our Z speeds
'------------------------------------------------------------------------------

' Now we're going to do similar stuff for the Z axis

&start_Zmove_Speed = %(73) ' MoveSpeed Z

&new_Zmove_Speed = .25

'Set thickness and pull-up distance
&zBottom = &PLATE_THICKNESS * &SCALE
&zup = &my_ZzeroSafeZ * &SCALE

' ****************************************************************************************
' Okay, here we go....
' ****************************************************************************************

'Save start X and Y positions for use with centering
&start_X_pos = %(1) ' Location X
&start_Y_pos = %(2) ' Location Y

'Set paramaters
SA 'Set tool to Absolute mode

'Limits are deactivated here, automatically reset to original state when file ends
VN, 0 'Deactivate the limit switch functionality on input #3
SF, 0 'Deactivate software limits

' ----------------------------------------------------------------------------------------
' Z - A X I S Z E R O I N G
'
' Note that we're zeroing to the top of the plate, which we'll use as the basis for the
' calculations that will really set Z-zero.
' ----------------------------------------------------------------------------------------

GOSUB TEST_CLEAR 'Check for clear

' Set-up the contact switch action ...
ON INP(&my_ZzeroInput,1) GOSUB Zcontact 'this is where we'll go on contact with plate

VS, , &new_Zmove_Speed
&little_plunge = %(3) - 2

' Start continuous plunge ... looking for contact to occur
MZ, &little_plunge

' Contact! Save the position in the save_Z_dist variable
&save_Z_dist = %(3)

' ----------------------------------------------------------------------------------------
' X - A X I S Z E R O I N G
'
' Note that, similar to Z-Axis zeroing above, we are not actually setting the zero here,
' but finding the X-edge of the plate, which we'll use for calculation
' ----------------------------------------------------------------------------------------

'Set tool to Relative Mode because we want to move around based on where we currently are
SR

' Check for clear
GOSUB TEST_CLEAR

' Set the move speed
MS, &start_XYmove_Speed

'
' Do the right side first
'

' First we want to move off a bit in the positive X to clear the plate,
' we assume that the bit was placed somewhere in the middle of the top of
' the plate, so we do not add any additional distance to move in case we are
' close to the edge of the machine, in which case we do not want to trigger
' any limit switches
MX, &TOP_PLATE_LENGTH

' And now go back to being slow
MS, &XYapproach_Speed

' And now we want to go to the Z location and a little lower
&ZLocationForXTest = &zBottom - &zup - .30
VS, , &new_Zmove_Speed
MZ, &ZLocationForXTest

' Now we set up the contact switch action again ...
ON INP(&my_ZzeroInput, 1) GOSUB XContactRight ' this is where we'll go on contact with plate
' Record the position of the bit on the left side of the plate
&right_X_pos = %(1)
' Then we start moving in the positive X ( the * -1 for that)
MX, &TOP_PLATE_LENGTH * -1

'
' Now we move to do the left side
'

' We're still touching the plate, so let's move it back
' a little
MS, &XYapproach_Speed
MX, .25

' Okay, we have the position on the right side of the plate.
' Now we want to find the position on the left side of the plate, so
' we will be able to determine the diameter of the tool for better positioning

' First lift the tool an inch to clear the plate
VS, , &new_Zmove_Speed
MZ, 1

' Set the move speed
MS, &start_XYmove_Speed

' Move past the plate plus 1 inch
MX, (&FULL_PLATE_LENGTH + 1) * -1

' And now go back to being slow
MS, &XYapproach_Speed

' And now we want to go to the Z location and a little lower
&ZLocationForXTest = &zBottom - &zup - .60
VS, , &new_Zmove_Speed
MZ, &ZLocationForXTest

' First set the contact switch action ...
ON INP(&my_ZzeroInput, 1) GOSUB XContactLeft 'this is where we'll go on contact with plate
' Record the position of the bit on the left side of the plate
&left_X_pos = %(1)
' Then we start moving in the positive X until
' we hit the plate in which case we'll go into XContactLeft
MX, &TOP_PLATE_LENGTH

'
' Calculating tool diameter:
' Okay, we have the left and right sides. Now we're going to figure out the
' diameter of the tool by doing:
'
' (right_X_pos - left_X_pos) - FULL_PLATE_LENGTH
'

&toolDiameter = (&right_X_pos - &left_X_pos) - &FULL_PLATE_LENGTH
' And now we want the radius
&toolRadius = &toolDiameter / 2.0

' ----------------------------------------------------------------------------------------
' Y - A X I S Z E R O I N G
'
' Note that, similar to Z-Axis zeroing above, we are not actually setting the zero here,
' but finding the Y-edge of the plate, which we'll use for calculation
'
' ----------------------------------------------------------------------------------------

SR
MS, &start_XYmove_Speed

' Okay, as of right now we're sitting on the right edge of the plate somewhere. First
' we want to back off by an inch...
MX, -1

' Now we want to move in -Y the length of the plate
MY, &FULL_PLATE_LENGTH * -1

' Now put us inside the plate in the X axis
MX, 2.5

' And now go back to being slow
MS, &XYapproach_Speed

GOSUB TEST_CLEAR 'Check for clear

'First set the contact switch action ...
ON INP(&my_ZzeroInput,1) GOSUB Ycontact 'this is where we'll go on contact with plate
'Then start the move in Y
MY, &TOP_PLATE_LENGTH

' ****************************************************************************************
' Okay, we have the X, Y, and Z values as they currently stand; let's move to what
' we think 0,0,0 should be
' ****************************************************************************************

' We're still touching the plate in Y, so let's move back .25
MY, -.25
PAUSE 1
' Next move Z up to a safe spot
MZ, 2
PAUSE 1

' And put us back in absolute mode
SA

' And we need neither dilly nor dally getting there...
MS, &start_XYmove_Speed

' Now let's move to the right Y

' Where are we?
&NowY = %(2)
' Now move back to the edge plus 1 inch (the width of the lower plate)
MY, &NowY + .5 + &yAdjustment
PAUSE 1

'MY, &NowY + 1 + &yAdjustment
'PAUSE 1

' Now move to the X plus 1 inch (the width of the lower plate) + the
' tool radius
&myNewX = &save_X_dist + .5 + &xAdjustment + &toolRadius
'&myNewX = &save_X_dist + 1.0 + &xAdjustment + &toolRadius

MX, &myNewX
PAUSE 1
' And then we move the Z to 0
MZ, 0
PAUSE 1

' Now set the X, Y, and Z at this spot
z3
'VA, 0, 0, %(3),,,,,,,
PAUSE 1

MSGBOX(All Done. I am now going to move the bit out of the plate. Have a nice day., 48, Finished)

' And lift the tool 2 inches to clear the plate
MZ, 2

' ****************************************************************************************
' This is the end of the program
' ****************************************************************************************
EndOfProgram:
END

' ****************************************************************************************
' C O N T A C T R O U T I N E S
' ****************************************************************************************

' ----------------------------------------------------------------------------------------
' Z Contact
' ----------------------------------------------------------------------------------------

Zcontact:
' This is our subroutine for action on hitting the plate

' VA - Values for Axis Locations
VA, ,, &zBottom + &zAdjustment ,,,,,0          'Set final Z location and Zero Table Base Coordinate
PAUSE 1
VS, ,&start_Zmove_Speed   ' Slow it down a bit  
JZ, &zup                  ' Pull-up to safe height

RETURN

' ----------------------------------------------------------------------------------------
' X Contact
' ----------------------------------------------------------------------------------------

' This is our subroutine for action on hitting the plate on the left side
XContactLeft:
ON INP(&my_ZzeroInput, 1) 'Set switch to nothing to turn off
&left_X_pos = %(1)
&save_X_dist = %(1)
PAUSE 1
MX, -1 ' Move back out for another pass
ON INP(&my_ZzeroInput, 1) GOTO Xagain
' Now start moving back to the plate until we touch, in which
' case we'll jump immediately into Xagain
MX, &second_move
END

' This is our subroutine for action on hitting the plate on the right side
XContactRight:
ON INP(&my_ZzeroInput, 1) 'Set switch to nothing to turn off
&right_X_pos = %(1)
PAUSE 1
MX, 1 ' Move back out for another pass
ON INP(&my_ZzeroInput, 1) GOTO Xagain
' Now start moving back to the plate until we touch, in which
' case we'll jump immediately into Xagain
MX, &second_move * -1
END

Xagain:
ON INP(&my_ZzeroInput, 1) 'Set switch to nothing to turn off
PAUSE 1
RETURN

' ----------------------------------------------------------------------------------------
' Y Contact
' ----------------------------------------------------------------------------------------

Ycontact:
'This is our subroutine for action on hitting the plate
ON INP(&my_ZzeroInput,1) 'Set switch to nothing to turn off
&save_Y_dist = %(2)
PAUSE 1
MY, -1 '&start_X_pos 'Move back out for another pass
ON INP(&my_ZzeroInput,1) GOTO Yagain
MY, &second_move
END

Yagain:
ON INP(&my_ZzeroInput,1) 'Set switch to nothing to turn off
PAUSE 1
'msgbox (save_Y_dist is now &save_Y_dist, 48, Debugging)
RETURN

' ****************************************************************************************
' General purpose routines
' ****************************************************************************************

TEST_CLEAR:
&cleared = &my_ZzeroInput + 50
IF %(&cleared) = 1 THEN PAUSE 3
IF %(&cleared) = 1 THEN GOTO NO_CLEAR
RETURN

NO_CLEAR:
'Reset the orginal speeds
VS, ,&start_Zmove_Speed
VS, &start_XYmove_Speed,,,,&start_XYjog_Speed
'Contact did not clear for some reason. Exiting.
PAUSE
END

' Function that sets the speed limits in imperial
GetInchSpeedLimits:
&TopApproachSpeed = .25
&TopJogSpeed = 3.5
&second_move = 2
RETURN

' Function that tells the user the program is not going to work in preview mode
InPreviewMode:
' If we're here, that means we're in preview mode, which is kinda pointless
' for this program
MSGBOX(You are currently in preview mode which won't work with this program. Check that the ShopBot is switched on., 16, Preview Mode Detected)
PAUSE
END

' Function that exposes to the user the fact that I am bad at metric/imperial conversion
' math
MetricNotYet:
MSGBOX(Can't do metric just yet. Sorry about that. :(, 48, Metric...oooh...um...hmmm...)
PAUSE
END

@Ksaor21
Copy link
Author

Ksaor21 commented Jun 13, 2023

We took your file off github and use the Shop Bot edit to alter the script. all we changed was parameters for your xyz block. At the end of the script I noticed the way it zeros axis is different from what I am accustomed to. 'VA, 0, 0, %(3),,,,,,, . what does the %3,,,,,, mean and do? My next attempt is to comment out that line as you can see in the code and try running a z3 instead. I wouldn't think it would make a difference, but we are using a Alpha model Shop Bot with the 48x96 bed.

Really appreciate you getting back to me so quick about this!

@Ksaor21
Copy link
Author

Ksaor21 commented Jun 13, 2023

This is the file we have been trying to run after doing a xyz home, its just a simple single hole but it does require a tool change with our ATC, could that maybe be causing a issue. I've run the same file without doing the xyz script and it works just as it should.

Again, I really appreciate any insight, help you can provide. This setup really is a brilliant idea and is going to save us a lot of prep time if I can get it figured out.

'----------------------------------------------------------------
'SHOPBOT ROUTER FILE IN INCHES
'GENERATED BY PARTWorks
'Minimum extent in X = 23.000 Minimum extent in Y = 0.000 Minimum extent in Z = -0.125
'Maximum extent in X = 119.000 Maximum extent in Y = 48.000 Maximum extent in Z = 0.000
'Length of material in X = 96.000
'Length of material in Y = 48.000
'Depth of material in Z = 0.125
'Home Position Information = Bottom Left Corner, Material Surface
'Home X = 0.000000 Home Y = 0.000000 Home Z = 0.500000
'Rapid clearance gap or Safe Z = 0.200
'UNITS:Inches
'
IF %(25)=1 THEN GOTO UNIT_ERROR 'check to see software is set to standard
SA 'Set program to absolute coordinate mode
CN, 90
'New Path
'Toolpath Name = Profile 2
'Tool Name = End Mill (1/8")

&PWSafeZ = 0.200
&PWZorigin = Material Surface
&PWMaterial = 0.125
'&ToolName = "End Mill (1/8")"
&Tool =1 'Tool number to change to
C9 'Change tool
TR,18000 'Set spindle RPM
C6 'Spindle on
PAUSE 2
'
MS,1.0,0.5
JZ,0.500000
J3,26.258463,13.595654,0.200000
M3,26.258463,13.595654,-0.010000
CG, ,26.372463,13.709655,0.114000,0.000000,T,1
CG, ,26.486464,13.595654,0.000000,-0.114000,T,1
CG, ,26.372463,13.481654,-0.114000,0.000000,T,1
CG, ,26.258463,13.595654,0.000000,0.114000,T,1
M3,26.258463,13.595654,-0.020000
CG, ,26.372463,13.709655,0.114000,0.000000,T,1
CG, ,26.486464,13.595654,0.000000,-0.114000,T,1
CG, ,26.372463,13.481654,-0.114000,0.000000,T,1
CG, ,26.258463,13.595654,0.000000,0.114000,T,1
M3,26.258463,13.595654,-0.030000
CG, ,26.372463,13.709655,0.114000,0.000000,T,1
CG, ,26.486464,13.595654,0.000000,-0.114000,T,1
CG, ,26.372463,13.481654,-0.114000,0.000000,T,1
CG, ,26.258463,13.595654,0.000000,0.114000,T,1
M3,26.258463,13.595654,-0.040000
CG, ,26.372463,13.709655,0.114000,0.000000,T,1
CG, ,26.486464,13.595654,0.000000,-0.114000,T,1
CG, ,26.372463,13.481654,-0.114000,0.000000,T,1
CG, ,26.258463,13.595654,0.000000,0.114000,T,1
M3,26.258463,13.595654,-0.050000
CG, ,26.372463,13.709655,0.114000,0.000000,T,1
CG, ,26.486464,13.595654,0.000000,-0.114000,T,1
CG, ,26.372463,13.481654,-0.114000,0.000000,T,1
CG, ,26.258463,13.595654,0.000000,0.114000,T,1
M3,26.258463,13.595654,-0.060000
CG, ,26.372463,13.709655,0.114000,0.000000,T,1
CG, ,26.486464,13.595654,0.000000,-0.114000,T,1
CG, ,26.372463,13.481654,-0.114000,0.000000,T,1
CG, ,26.258463,13.595654,0.000000,0.114000,T,1
J3,26.258463,13.595654,0.200000
JZ,0.500000
J3,0.000000,0.000000,0.500000
'
'Turning router OFF
C7
END
'
'
UNIT_ERROR:
CN, 91 'Run file explaining unit error
END

@tachoknight
Copy link
Owner

Out of curiosity, did you make a plate similar to the pics to run the script with?

@Ksaor21
Copy link
Author

Ksaor21 commented Jun 13, 2023 via email

@Ksaor21
Copy link
Author

Ksaor21 commented Jun 14, 2023

I wonder if this could be a firmware issue, this machine is only a year old.

Windows OS = 2, 6.02 Resolution = 1920 X 1080
Total Memory = 16,958,300,160 PRS/PRTalpha/4g P-type = 1
Starting Memory = 10,953,265,152
Available Memory 9,439,559,680
maxFileLines = 10000000 maxStack = 300000( 200000)
586 -1493106682

Control Box Firmware Version = 224
IniVersion = 8.5
Port Number = 3 Speed = 5: 0
Starting Command Line -
User Value (via Registry) -
Last User Command (via Registry) -
Status Byte (in Registry) - 1
Sound = 0 ScreenSaver = 0

Size - - - - (not determined)
CBtype - 16168 BoardVer - 006 CardVer - 204 RouterType - S
ID - ELECTRO IMPU
uC Masks - 32-32-63-63

Supply VDC = 5.00 [4.98 to 5.01] Controller Temp = 36.7
Last Stack Size 0 1
Last Steps Transmitted 0
Last Steps Confirmed 618
Data Over-Runs 0
Buffer Underflow Last Stack 0 Buffer Underflow Total 0

Controller Loc -
0 0 18976 0 0 0 871

q_Freq- 1000.0(hz) Static_ET 2.5(ms) Packet_ET- 17.5(ms;good<20)

@tachoknight
Copy link
Owner

hm, one option for testing would be to let the program zero everything out, then manually move Z up and back down and zero it out manually and see if that makes a difference. Manually setting Z should negate any effects of the plate program.

@Ksaor21
Copy link
Author

Ksaor21 commented Jun 14, 2023

unfortunately, we tried that. Even tried moving the z back to 0 and also xy to the new 0 and then doing a z3 after the xyz finder finishes. It seems like no matter what we do after running your script it makes the z lower into the bed when a file is started. it only goes away if you zero the x y and do a z zero with the plate like one would normally do with machine. It is so weird, we have be en tinkering with this for about 2 days now trying to get it to operate correctly.

Our machine does have the automatic tool changer setup, and I've noticed it does not run the atc script to see what bit is in collet after we run xyz finder. Maybe that's something to do with it?

I appreciate you getting back to us and trying to help! we are totally stumped over here haha

@tachoknight
Copy link
Owner

I admit I didn't even know there was an ATC for the shopbot; we don't have that so it's hard to say whether it has anything to do with it, but it seems possible that maybe there's a command that the ATC doesn't like; maybe there's a special command for it.

I'll try to investigate your file and the documentation, but I'm on vacation on a bike so I'll get to it when I can.

@Ksaor21
Copy link
Author

Ksaor21 commented Jun 14, 2023

No rush on it, we had some down time and saw this and was like o wow this would be perfect. Appreciate ya! look into at your leisure, if you feel like it! I was hoping it was just something stupid we overlooked but I too am thinking it has to do with the ATC.
Have a good trip!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants