Hello Guest it is April 19, 2024, 04:42:56 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.


Topics - nickkinsman

Pages: 1
1
VB and the development of wizards / VB script converstion to Mach4
« on: January 19, 2019, 12:57:35 PM »
Hello!

I am in process of upgrading my Lathe to Mach4.  Unfortunately I have a non-standard toolchanger that was part of the original commercial machine.  With a lot of forum help I was able to get a VB script that works the toolchanger perfectly, and now I need to make it work in Mach4 if I want to upgrade.  It is a 4-position horizontal rotary tool changer, air activated, which only rotates one direction (counterclockwise as viewed from above). I have a VBscript for Mach3 which was developed with forum help and it works perfectly. I am looking to migrate this to Mach4. Any help with converting this would be great. Following so some background info on how it works to help understand the VB script.

The turret has one each input and output switches. Output 2 is a momentary relay which starts the toolchanger to cycle one 90 degree step. Input 2 is active when air pressure is missing (checked at beginning of script) and also is active while turret is cycling between steps. Tools are assigned by basis of each face (some faces can hold more than one tool, so tool in same face is given next number increment of plus 4). A math function is used to calculate the current face and face requested, (ToolNumber-1) Mod 4, and also to calculate number of steps needed (see below).

'M6Start.m1s

If IsActive(Input2) Then
MachMsg ("Connect Air Pressure to Turret!!","Turret Index Warning",MachMsgTypeOK)
End If

selectedTool = GetSelectedTool()
currentTool = GetCurrentTool()
currentFace = (currentTool - 1) Mod 4
targetFace = (selectedTool - 1) Mod 4

'rotate turret required number of "clicks"
For click = 1 To (targetFace - currentFace + 4) Mod 4 'rotate accounting for rollover

ActivateSignal(Output2) 'activate momentary command to rotate
Sleep (500)
DeActivateSignal(Output2) 'deactivate momentary command and wait for movement signal
Sleep (1500)
While IsActive(Input2) 'wait for turret to stop
Sleep (100)
Wend
Next

'not forgetting to update to the new tool
SetCurrentTool selectedTool

Any help would be appreciated.
Thanks!

2
VB and the development of wizards / VB Script for toolchanger
« on: March 17, 2014, 02:06:38 PM »
Hello;

I'm setting up Mach3 to run a lathe with a 4 position toolpost on it.  I've generated a pass at the VB script with the help of a friend (I'm no programmer) and I wanted to see if someone could proof it and see if it would work.  I just downloaded & configured Mach3, so it would be used on the most current version.  Here are the specs on the toolchanger and what I am attempting to do.

-4 position changer, air actuated so it only spins in one direction (CW, in case it matters).  Added complexity is the changer can hold multiple tools on a single face.  The changer only moves 1 step at a time, and requries another input to progress another step - always in the same direction.  i.e. it has 4 faces, to get from face 2 back to face 1, it has to progress 3 steps.

It recieves a 24V momentary (pushbutton type) signal which tells it to start actuating, and it finishes 1 step with no other input, automatically seats.  It also has a 24V feedback signal that changes state between seated, or turning.  (I'm not sure of the exact state between the two, still have to check).  

What I thought to do with the code was build a table that would equate a tool to a face, numbering the tools around the holder sequentially 3 times (giving option for 3 tools on a face) and equating that tool number to a face 1 through 4.  This way the code could get the current tool and find out what face that equated too, get the requsted tool - what face that equated too, then run the loop to step the toolchanger around until the values were equal.


Here is the script:
Sub Main
              Dim currentLocation As Integer
              Dim targetLocation As Integer
              Dim currentToolID As Integer
              Dim targetToolID As Integer
              Dim tool (13) As Integer

              tool (0) = 0
              tool (1) = 1
              tool (2) = 2
              tool (3) = 3
              tool (4) = 4
              tool (5) = 1
              tool (6) = 2
              tool (7) = 3
              tool (8) = 4
              tool (9) = 1
              tool (10) = 2
              tool (11) = 3
              tool (12) = 4

              currentTool = GetCurrentTool()
              targetTool = GetSelectedTool()
              
              currentLocation = tool(currentTool)
              targetLocation = tool(targetTool)

              While currentLocation <> targetLocation
                            If Not IsActive(InputX) Then
         ActivateSignal(OutputX)
                                   Sleep (250) 'Signal index pin for 0..25sec
                                DeActivateSignal(OutputX)
                                While IsActive(InputX) Then
                                                 Sleep (50) 'Allow toolchanger to seat
                                  Wend

                                currentLocation = currentLocation + 1
                                If currentLocation > 4 Then
                                              currentLocation = 1 'resets current location back to 1 since completed 1 revolution
                                End If
      End If
              Wend
End Sub


One question we had that is important is will Mach3 return an integer when presented with the GetCurrentTool?  If not I need to know what it sends so I can decode it!
Thanks, feedback appreciated!

Pages: 1