1448
« on: February 20, 2015, 12:55:49 PM »
Yo cannot use the word ROUND as a variable it is an internal math function. Change that word to something else. I changed it to Turn.
maxtool = 6 '# of tools in turret
extraAngle = 6 'Extra angle added to turret rotation
Turn = 360 'One turn in degrees of turret
oldtool = getcurrenttool 'Tool # before rotation
newtool = GetOEMDRO(824) 'Get Tool #
Angle = Turn/maxtool 'Angle of rotation i.e. 60 degrees
number = GetOEMDro(824) 'Get Tool #
Code "G91" 'Incremental Distance Mode
If GetOEMDRO(824) = 0 Or GetOEMDRO(824) >6 Then
number1 = Question("What is current tool # ?")
Call SetOEMDRO(824,number1)
Call SetOemDro(803,number1*Turn/maxtool) '803 = A Turret DRO
Exit Sub
End If
number=number+1 'add 1 to the #
If nummer>maxtool Then number=1 'check if tool # is 6
'After executing the next line the X- and Z- DRO's display random figures.
'I do not know why.
Call SetOEMDRO(824,number) 'Set tool # in DRO
'now calculate the rotation angle of turret
If number=1 Then Call SetOemDro(803,0)
ToolChange = GetOEMDRO(803) 'Get A position
ToolChange = (Turn/maxtool)+extraAngle 'Tool-change turret 60 + 6 CW
Code "G0 A" & ToolChange 'execute rotation CW
code "G0 A" & -6 '6 steps CCW
While IsMoving()
Wend
Call SetOEMDro(803,((number-1)*Turn/maxtool))
Code "G90" 'back to Absolute Distance Mode