YEP just as I thought, Hopelessly lost in LOGIC again(;-) I have tried various ways that I could think of to tie it together but NOT.
THe original intention was to fill in the dros on the page to match up the slots and tool#. Then press the initialize Button to set the system VARs .
In A program the first T# would set the Next Tool Up dro. Then the m6start will transfer the NTU over to the Tool In Spindle dro. As the next T3 is read it will again fill in the NTU dro. As the NTU dro changes then the BRAINS will trigger a holding relay to RELEASE and start a motor to turn the carousel. The Brains will then monitor the encoder on the carousel untill it sees the proper ID code then STOP the motor and lock the carousel in position.
THen the m6start macro would do the actual swap based on the t#s being held by the
macro
So far i have everything working BUT the actual hotswapping of the DROs.
Listed are the parts of the m6start macro I have to work with: THe brains part I have not listed.
********************************************************************************
********************************************************************************
Tool = GetSelectedTool() '* Original code in M6start from mach
Setcurrenttool(tool)
Setuserdro(1300,tool)
'***************************************************************
Option Explicit '* Code to run hotswap
Const numTools=8
Dim currentTool As Integer
Dim selectedTool As Integer
Dim selectedSlot As Integer
Dim crlf As String
Dim msg As String
Dim i As Integer
' what is the selected tool?
selectedTool = GetSelectedTool()
' in which slot in the carousel is the required tool?
selectedSlot = GetVar(1000 + SelectedTool)
' remind ourselves what the current tool is
currentTool = GetVar(1000)
' stick the current tool in the selected tool's slot
SetVar(1000 + currentTool, selectedSlot)
' remember for next time which tool we're now using
SetVar(1000, selectedTool)
' tell Mach which tool is selected
SetCurrentTool( selectedTool )
' dump the carousel state for our reading Pleasure
crlf = Chr(13) & Chr(10)
If currentTool = 0 Then
msg = "Getting tool " & selectedTool & " from slot " & selectedSlot
Else
msg = "Swapping tool " & currentTool & " for tool " & selectedTool & " in slot " & selectedSlot
End If
msg = msg & crlf & crlf
'for each tool
For i=1 To numTools
If i = selectedTool Then
msg = msg & "Tool " & i & " is in the spindle" & crlf
Else
msg = msg & "Tool " & i & " is in slot " & GetVar(1000 + i) & crlf
End If
Next
'******************************************************************************
'* Last piece of code to update DROs
'* assuming your first gcode var is #1000 and your slot 1 DRO number is 1000 AND
'* that you use consecative vars and DROs (which would be weird if you didn't)
numTools=8
gcodeVarBase=1000 '* (or whatever i.e. 1 less than the first you use)
droBase=1149 '* (or whatever i.e. 1 less than the first you use)
for tool = 1 to numTools
slot = GetVar(gcodeVarBase + tool)
SetUserDRO(droBase + slot, tool)
next
*********************** For now I am at a stalemate that is limited by my faulty programer GENE If you can help out please do and please notate for better understanding if you can.
Thanks (;--) TP