Hello Guest it is March 19, 2024, 06:34:23 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TPS

2171
code "g00 a" + CStr(s)

2172
VB and the development of wizards / Re: Keystroke Trapping
« on: June 21, 2017, 08:34:16 AM »
hi,
i am not sure what you are trying to do, but if you are in a Screen you can
define two button's one witch has the Hotkey F1 and th other Shift F1.
than you can run two seperate scripts-

Thomas

2173
VB and the development of wizards / Re: do user button
« on: June 21, 2017, 08:29:33 AM »
hi,
i am not 100% sure, but i think you can not run a oembutton from vb script.

a Workaround would be to use doOEMButton(301) witch runs the macro witch is set by SetTRiggerMacro,
and then you can run the macro from different "places".
Thomas

2174
Hi,

have you tryed to use DoButton(9) insted of DoOEMButton(1009).
this button is used in the Standard Screen set.

Thomas

2175
hi Jeff,

i am not realy sure, what you like to do, but if i understand you right something like this should work:

lets say you like to modify OEMdro2000 and you hit the "key" 1 on your virtual Keyboard the VBmakro for KEY1 could
be something like this:

Code: [Select]
Sub Main

  ActValue = GetOEMDro(2000)

  If ((ActValue  <= 9) AND (ActValue  > 0)) Then
    ActValue = ActValue * 10
    GoTo write
  End If

  If ((ActValue  <= 99) AND (ActValue  > 0)) Then
    ActValue = ActValue * 100
    GoTo write
  End If

  If ((ActValue  <= 999) AND (ActValue  > 0)) Then
    ActValue = ActValue * 1000
    GoTo write
  End If

  If ((ActValue  <= 9999) AND (ActValue  > 0)) Then
    ActValue = ActValue * 10000
    GoTo write
  End If

  If ((ActValue  <= 99999) AND (ActValue  > 0)) Then
    ActValue = ActValue * 100000
    GoTo write
  End If

write: ActValue=ActValue+1 'Key 1 was pressed

SetOEMDro(2000,ActValue)

End sub
code not tested, just written down.

Thomas









2176
something new ?

2177
ok then something like this should be closer:
Code: [Select]
Sub Main()
'Global variables declaration

Dim CCWPos as Integer
Dim CWPos as Integer


NewTool = GetSelectedTool()
OldTool = GetCurrentTool()

While NewTool > 8
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

If NewTool = OldTool Then'Compare between actual tool and requested tool
   Else
   End If
If NewTool > 8 Then'requested tool higher then tool numbers
   Else
   End If
If NewTool < 1 Then'tool number to low
   Else
   End If

code("m05")
   Call ZatcPosition
   Call AtcIn'Activate air cylinder valve to put old tool back to carrousel
   Call Unclamp'Spindle: Tool Unclamp
   Call AtcDown'lowers atc
   Call LeastTravel'determine the least travel to move and Turns CW or CCW
   Call AtcUp'raises atc
   Call Clamp'Spindle: Tool Clamp
   Call AtcOut'retracts atc
   Call SetUserDRO (1200,NewTool)'Store new tool as actual tool value
SetCurrentTool( NewTool )

End Sub

Function ZatcPosition()'Move to Z tool position and wait until position reached
   code("G53")'Move in Absolute Machine coordinates
   code("G00 Z-1") 'Z value as to be checked for exact match with carrousel height
   While(IsMoving())
      Sleep(100)'temporisation entre while++
   Wend
End Function

Function AtcIn()'Put old tool back to carrousel
      ActivateSignal(OUTPUT4)'Move carrousel air cylinder to the tool change position adjust output# to match atc slide
      code("g04 p01")
End Function

Function Unclamp()'Spindle: Tool Unclamp
       ActivateSignal(OUTPUT6)'Release the tool, adjust output number for drawbar output
code("g04 p01")'pause
End Function

Function AtcDown()'lowers atc to rotate
   ActivateSignal(OUTPUT5)'solonoid to lower atc
   code("G04 p01")'pause
End Function

'Sequence to determine the least travel to move for TC, CW or CCW
Function LeastTravel()
   NewTool = GetSelectedTool()
   OldTool = GetCurrentTool()
 
    NTool = 8 ' Number of tools changer holds
   CWPos = GetSelectedTool() - GetCurrentTool() ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTools
   End If
   CCWPos = NTools - CWPos
   If CWPos < CCWPos Then
      Call CW()
   Else
      Call CCW()
   End If
End Function

Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   ActivateSignal(OUTPUT7)'Turns the AC Motor On
   Deactivatesignal(output8)'atc motor revirsing relay
   Sleep(50)

For x=0 To CWPos
           While IsActive(input1)'Wait for INPUT1 is off
Sleep(10)
   Wend
           While NOT IsActive(input1)'Wait for INPUT1 is on
Sleep(10)
   Wend
           While IsActive(input1)'Wait for INPUT1 is off 
Sleep(10)
   Wend
           While NOT IsActive(input1)'Wait for INPUT1 is on
Sleep(10)
   Wend
            x=x+1
        Next x
    CTPos=x
   DeactivateSignal(OUTPUT7)
   Deactivatesignal(output8)'atc motor revirsing relay
End Function

Function CCW()'Rotation CCW
   Dim y As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   Activatesignal(output8)'atc motor revirsing relay
   ActivateSignal(OUTPUT7)'Turns the AC Motor On
    Sleep(50)
   
  For y=0 To CCWPos
           While IsActive(input1)'Wait for INPUT1 is off
Sleep(10)
   Wend
           While NOT IsActive(input1)'Wait for INPUT1 is on
Sleep(10)
   Wend
           While IsActive(input1)'Wait for INPUT1 is off 
Sleep(10)
   Wend
           While NOT IsActive(input1)'Wait for INPUT1 is on
Sleep(10)
   Wend
            y=y+1
        Next y
   CTPos=y
   DeactivateSignal(OUTPUT7)
   Deactivatesignal(output8)
End Function

Function AtcUp()'lifts atc
   DeActivateSignal(OUTPUT5)'relay for solonoid to lower/lift atc
   code("G04 p01")'pause
End Function

Function Clamp()'power drawbar unactivated
   DeactivateSignal(OUTPUT6)'unactivating drawbar relay
End Function

Function AtcOut()'retracts atc
      deActivateSignal(OUTPUT4)'atc retract cylinder relay
      code("g04 p01")
End Function






2178
for the moment i am little bit confused about the ligic of input1 for doing one step of ATC

in the original macro:

--> UNTIL IN4 OR STOPSW
--> REPEAT
--> UNTIL !IN4 OR STOPSW
--> REPEAT
--> UNTIL IN4 OR STOPSW
--> REPEAT
--> UNTIL !IN4 OR STOPSW

it looks like it is ON at the start

then OFF ON OFF ON

to do one step at ATC

please describe the pattern of input1 to do one step.

Thomas

2179
Do Until Not IsActive(input1)
   sleep(10)
Loop

2180
ok made some changes in your code:

Code: [Select]

Sub Main()
'Global variables declaration

Dim CCWPos as Integer
Dim CWPos as Integer


NewTool = GetSelectedTool()
OldTool = GetCurrentTool()

While NewTool > 8
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

If NewTool = OldTool Then'Compare between actual tool and requested tool
   Else
   End If
If NewTool > 8 Then'requested tool higher then tool numbers
   Else
   End If
If NewTool < 1 Then'tool number to low
   Else
   End If

code("m05")
   Call ZatcPosition
   Call AtcIn'Activate air cylinder valve to put old tool back to carrousel
   Call Unclamp'Spindle: Tool Unclamp
   Call AtcDown'lowers atc
   Call LeastTravel'determine the least travel to move and Turns CW or CCW
   Call AtcUp'raises atc
   Call Clamp'Spindle: Tool Clamp
   Call AtcOut'retracts atc
   Call SetUserDRO (1200,NewTool)'Store new tool as actual tool value
SetCurrentTool( NewTool )

End Sub

Function ZatcPosition()'Move to Z tool position and wait until position reached
   code("G53")'Move in Absolute Machine coordinates
   code("G00 Z-1") 'Z value as to be checked for exact match with carrousel height
   While(IsMoving())
      Sleep(100)'temporisation entre while++
   Wend
End Function

Function AtcIn()'Put old tool back to carrousel
      ActivateSignal(OUTPUT4)'Move carrousel air cylinder to the tool change position adjust output# to match atc slide
      code("g04 p01")
End Function

Function Unclamp()'Spindle: Tool Unclamp
       ActivateSignal(OUTPUT6)'Release the tool, adjust output number for drawbar output
code("g04 p01")'pause
End Function

Function AtcDown()'lowers atc to rotate
   ActivateSignal(OUTPUT5)'solonoid to lower atc
   code("G04 p01")'pause
End Function

'Sequence to determine the least travel to move for TC, CW or CCW
Function LeastTravel()
   NewTool = GetSelectedTool()
   OldTool = GetCurrentTool()
   NTool = 8 ' Number of tools changer holds
   CWPos = GetSelectedTool() - GetCurrentTool() ' Assume a CW move
   If CWPos < 0 Then ' CWPos < 0 ==> rtp < atp
      CWPos = CWPos + NTools
   End If
   CCWPos = NTools - CWPos
   If CWPos < CCWPos Then
      Call CW()
   Else
      Call CCW()
   End If
End Function

Function CW()'Rotation CW
   Dim x As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   ActivateSignal(OUTPUT7)'Turns the AC Motor On
   Deactivatesignal(output8)'atc motor revirsing relay
   
   code"g04 p05"
   Do Until IsActive(input1)
sleep(10)
   Loop
      For x=0 To CWPos
         If IsActive(input1) Then
            x=x+1
            While IsActive(input1)'Wait for OEMTrig to de-assert
            Wend
         End If
      Next x
      CTPos=x
   DeactivateSignal(OUTPUT7)
End Function

Function CCW()'Rotation CCW
   Dim y As Integer
   Dim CTPos As Integer 'Carrousel Tool Position Relative to OldTool Position
   CTPos=0
   Activatesignal(output8)'atc motor revirsing relay
   ActivateSignal(OUTPUT7)'Turns the AC Motor On

   code"g04 p05"
   Do Until IsActive(input1)
sleep(10)
   Loop
   For y=0 To CCWPos
      If IsActive(input1) Then
      y=y+1
         While IsActive(input1)'Wait for OEMTrig to de-assert
         Wend   
      End If           
   Next y
   CTPos=y
   DeactivateSignal(OUTPUT7)
   Deactivatesignal(output8)
End Function

Function AtcUp()'lifts atc
   DeActivateSignal(OUTPUT5)'relay for solonoid to lower/lift atc
   code("G04 p01")'pause
End Function

Function Clamp()'power drawbar unactivated
   DeactivateSignal(OUTPUT6)'unactivating drawbar relay
End Function

Function AtcOut()'retracts atc
      deActivateSignal(OUTPUT4)'atc retract cylinder relay
      code("g04 p01")
End Function



please try in vbeditor step in mode and Report Errors, sorry have no Chance to test.
Thomas