Hello Guest it is April 27, 2024, 05:40:01 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 - nickkinsman

Pages: « 1 2
11
So, I finally finished terminating all the wires and tried the code.  I am not seeing action when I call for a tool change in MDI. 

I've checked the signal out to trigger the changer works (Output2), signal in from the changer is set to 'active' when it is moving (Input2), all verified in Mach diagnostics.

I did a stepthru of  the code in the VB editor, and it actually triggered the toolpost once!!! But then never again ???  Sooooo close.....When I open Mach, I've set the tool mdi to '1' as the starting spot.  Then I was doing a T202 M06 to call for tool two.   I have the config set to 'auto' on toolchange options.  PS - I took out the 'then' pieces, I was getting a compile error - I looked at the Mach guides and they didn't seem to be needed for a 'While' command set.

I would really appreciate if someone could take a look at the code and verify if it all looks good, here is the exact code that is in the macros/Lathe/M6start file:

'M6Start.m1s
Sub Main()
selectedTool = GetSelectedTool()
currentFace = (GetCurrentTool() - 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 (100)
   DeActivateSignal(Output2) 'deactivate momentary command

   While IsActive(Input2) 'wait for turret to stop
      Sleep (100)
   Wend
Next

SetCurrentTool selectedTool 'not forgetting to update to the new tool 

End Sub   


12
VB and the development of wizards / Re: VB Script for toolchanger
« on: March 24, 2014, 01:31:52 PM »
Thank you very much for revisiting the coding - your 2nd interpretation is exactly right.  I will load up this and give it a go, I'll respond back on how it all works out, probably not for a couple weeks as I am still in the hookup stage, terminating all the wires for the controls so I still have to get that done before I can test much for this.  I'll make sure to respond on how it goes so anyone else can reference that it works for the future - unclosed threads is one of my pet peeves as it makes using the information very hard!

Did get the Viper servo's powered up last night though, so making progress!

13
VB and the development of wizards / Re: VB Script for toolchanger
« on: March 20, 2014, 03:11:28 PM »
I confess after noodling it for awhile, that I can't figure out how to replace the array with the INT(tool / 3) function in the coding.  I understand the While section and what that does, but I admit that I don't know what I shoud replace or not in the 'Dim' and array section, setting up the While section to do the changes. 

Another question too, can I use 0 as the base tool?  I looked in Mach and it reserves the 0 position and you can't add to it?

Thanks for helping.  PS, I took out that redundant code!
Nick


14
VB and the development of wizards / Re: VB Script for toolchanger
« on: March 19, 2014, 12:33:36 PM »
Thanks for checking it out.  Can you elaborate on the function you describe, INT(tool/3)?  I assume that is nearest integar of tool number divided by 3, but I don't see how that would work - tool 1/3 = face1, tool 2/3 =face1, tool3/3= face1?

The real purpose of the check command on rotation was for the looping of multiple rotation steps, to be sure it doesn't 'push the button' again before it is seated at the end of prior loop, as this messes with the toolchanger.  but I agree it is pretty redundant when we are already checking for motion at the end of the while loop before proceeding.

Thanks.
Nick

15
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 2