curiousboi Posted April 28, 2006 Share Posted April 28, 2006 (edited) Public Function moveToHome() As BooleanDim value, ValueX, ValueY, ValueZ, ValueU As LongmoveToHome = FalsereadyStatus = FalsebusyStatus = TrueIf (checkSuccess(P1240MotAxisParaSet(boardNum, Z_axis, 0, 251, convertSpeed(30, Z_axis), 2000000, 260000, 500000))) Then If (checkSuccess(P1240MotCmove(boardNum, Z_axis, &H0))) Then 'Move Z in a clockwise direction value = 0 Do While ((value And &H4) <> &H4) 'Do loop if Z Limit switch still not reached checkSuccess (P1240MotRdReg(boardNum, Z_axis, RR2, value)) DoEvents Loop If (checkSuccess(P1240MotStop(boardNum, Z_axis, 4))) Then 'Do immediate stop on Z axis Do While (P1240MotAxisBusy(boardNum, Z_axis) <> SUCCESS) 'Loop while Z motor is still spinning Loop If (checkSuccess(P1240MotCmove(boardNum, Z_axis, &H4))) Then 'Move Z in anticlockwise direction value = 0 Do While ((value And &H8) <> &H8) 'Do loop if Z Home Limit switch still not reached checkSuccess (P1249MotRdReg(boardNum, Z_axis, RR5, value)) DoEvents Loop If (checkSuccess(P1240MotStop(boardNum, Z_axis, 4))) Then 'Do immediate stop on Z axis Do While (P1240MotAxisBusy(boardNum, Z_axis) <> SUCCESS) 'Loop while Z motor is still spinning Loop If (checkSuccess(P1240MotHome(boardNum, Z_axis))) Then Do While (P1240MotAxisBusy(boardNum, Z_axis) <> SUCCESS) 'Loop while Z motor is still spinning Loop If (checkSuccess(P1240MotAxisParaSet(boardNum, X_axis Or Y_axis, 0, StartVelocity, convertSpeed(30, X_axis Or Y_axis), MaXVelocity, AccelSpeed, AccelRate))) Then If (checkSuccess(P1240MotCmove(boardNum, X_axis Or Y_axis, 0))) Then 'move X and Y motors in clockwise direction ValueX = 0 ValueY = 0 Do While (((ValueX And &H4) <> &H4) Or ((ValueY And &H4) <> &H4)) checkSuccess (P1240MotRdMutiReg(boardNum, X_axis Or Y_axis, RR2, ValueX, ValueY, ValueZ, ValueU)) If ((ValueY And &H4) = &H4) Then checkSuccess (P1240MotStop(boardNum, Y_axis, 2)) End If If ((ValueX And &H4) = &H4) Then checkSuccess (P1240MotStop(boardNum, X_axis, 1)) End If DoEvents Loop Do While (P1240MotAxisBusy(boardNum, X_axis Or Y_axis) <> SUCCESS) Loop If (checkSuccess(P1240MotCmove(boardNum, X_axis Or Y_axis, 3))) Then 'Move X and Y motors in anti-clockwise direction ValueX = 0 ValueY = 0 Do While (((ValueX And &H8) <> &H8) Or ((ValueY And &H800) <> &H800)) checkSuccess (P1240MotRdMutiReg(boardNum, X_axis Or Y_axis, RR4, ValueX, ValueY, ValueZ, ValueU)) If ((ValueY And &H800) = &H800) Then checkSuccess (P1240MotStop(boardNum, Y_axis, 2)) End If If ((ValueX And &H8) = &H8) Then checkSuccess (P1240MotStop(boardNum, X_axis, 1)) End If DoEvents Loop Do While (P1240MotAxisBusy(boardNum, X_axis Or Y_axis) <> SUCCESS) Loop If (checkSuccess(P1240MotHome(boardNum, X_axis Or Y_axis))) Then Do While (P1240MotAxisBusy(boardNum, X_axis Or Y_axis) <> SUCCESS) Loop moveToHome = True End If End If End If End If End If End If End If End If End If End If readyStatus = True busyStatus = FalseEnd FunctionDoes Anyone know what the se of the checksuccess and convertSpeed for??This is a 3-axis epoxy,using P1240 chipboard to control it... Edited April 28, 2006 by curiousboi Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now