Hello Guest it is March 28, 2024, 04:07:19 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 »
1
VB and the development of wizards / Re: VB script converstion to Mach4
« on: April 27, 2019, 07:40:50 AM »
reuelt;

Thank you very much, I will take a look at debugging and try running it! 

Not sure if it matters but I am running an ethernet smoothstepper with PMDX 126 BOB. 

Thanks again.

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

3
VB and the development of wizards / Re: VB Script for toolchanger
« on: April 14, 2014, 12:37:00 PM »
OK!  I will have to settle for not really understanding it, but it certainly works!!  Good thing there are others out there that do.  

And the machmsg thing is pretty sweet too!

Finally, Mach3 does seem to be retaining the last tool loaded, so that takes care of having to set the initial tool in the DRO as well!!  Perfect.

Again, thank you very much Ian for sticking with it and helping me thru my ignorance!  You are the role model for what a forum moderator should do!

Nick

4
And we have a winner  :)

Turns out the 'turret rotating' signal, Input2, was not latching fast enough, so the 'While' command was not taking effect becuase there was not enough delay between the output signalling and the while.  In essence it was skipping right on and doing further 'clicks' while the turret was still in motion.  I also added a MachMsg as an initial step, as lack of air pressure also drives the Input1 active, so it reminds me to connect air pressure if I ask for a toolchange without air connected.  Since I turn off the air in my garage, this is pretty handy.

Again, thanks for alll the help.  Here is the final working code from my M6Start.m1s file, for anyone's reference.  Again this is a 4-position rotary toolpost on a lathe which holds multiple tools, and I am numbering my tools sequentially counterclockwise around the holder (as you look at it with bird's eye view).  Holder rotates clockwise.

'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

SetCurrentTool selectedTool 'not forgetting to update to the new tool



5
VB and the development of wizards / Re: VB Script for toolchanger
« on: April 10, 2014, 02:28:57 PM »
OK, I think I understand the Mod function (Modulus) in Mach3 VB script, figured I'd post it here in case someone else needs to reference;

For 'a Mod b',

If a<b, uses full 'a' value as product.  i.e. '2 mod 3' = 2.  (this is what was confusing me).
If a > or = b, divide 'a' by 'b' and the remainder is your product.  i.e. for '9 mod 4', 4 goes into 9 twice evenly (8 ), with a remainder of 1 so 1 is the product.

Hope this helps, it was confusing me, but now it is all clear!   :D

And Stirling, you are absolutely right, it all works out correctly!  

Nick

6
VB and the development of wizards / Re: VB Script for toolchanger
« on: April 10, 2014, 10:44:49 AM »
I'll do that and see what the responses are. 

So, in summary, the mod function doesn't care if it is 'a mod b' or 'b mod a', it just takes the remainder after dividing into the larger number? (That is what I meant by acting like a divisor, depending if the first integar is larger than second, would be a fraction at the start.)

Nick

7
VB and the development of wizards / Re: VB Script for toolchanger
« on: April 10, 2014, 08:27:16 AM »
Hello Stirling;

I was able to get the code to work, my stupidity - had it in the generic lathe config vs. the one for my lathe.  So great news there anyway!!

But...it only gives me 1 step of the turret no matter what tool I try to change to.  i.e. - start with tool 1 in the DRO, ask for tool 3, it does only 1 step.

I started to research the MOD command today because I would like to understand it better, but I am a little stumped on how the math works, for instance using the 1--> 3 example;

current face = (1-1) mod 4 = 0div4 = 0, ok good so far
target face = (3-1) mod 4 = 2div4= 0, remainder of 0.5 = 1? (partial remainder?), answer should be 2 though, correct?

Does the Mod command act like a divisor, where a Mod b = a/b (and uses the remainder)?  And how does it work for fractional numbers?  I'm going off wikipedia here, I could not find a good example in the manuals, especially for fractional. 

Thanks.
Nick


8
VB and the development of wizards / Re: VB Script for toolchanger
« on: April 09, 2014, 11:56:07 AM »
Well, I am glad to hear it is working for someone, that is a big positive!!!

I'll run thru your steps tonight verbatim and give it another try.  I certainly can see why it would not work on step thru as no tool change on the inital step is asked for, so it skips the clicks.  Anyway, here's fingers crossed!

Thanks.
Nick

9
VB and the development of wizards / Troubleshooting
« on: April 09, 2014, 09:43:43 AM »
OK, so...no solution yet....

I tried a bunch of iterations with the code and here is what I found;

As written, still no action.  When I FIRST opened Mach3 and immediately opened the VB editor and did a step-thru of the code, it stepped thru the 'For' section and did 1 toolchange step.  After that, it no longer will step thru the 'For' section, it skips right over it every time.  

Then I went into MDI, changed the tool to '1' in the DRO.  Did a T202 M6.  The computer bings, and the tool immediately changes to 2.  No action at all on the toolchange.  It acts like it is not reading the code, or if it is, it is immediatley skipping to the end.  I checked again, the toolchange is set to 'auto'.

I then looked at the code to try some things - I deleted the 'Mod 4' at the end of the 'for' statement on a whim and tried the step thru.  With that gone, it steps thru the 'for' statement, and I was able to verify that all the steps in the for statement work perfectly.  Every time I step thru, it completes a tool change very well.  The only modification I made was to increase the sleep time on the output signal, as it takes a moment for the input signal to latch on start of the toolchange.  So that's good.

I reapplied the 'Mod 4' portion and tried to do stepthru, still no tool change, it skips right over the 'for' section.  

I also retried to do a toolchange in the MDI, (both with and without the Mod 4) still no action.  

In summary, it seems like the issue may be in the counting statements at the start of the code, or in the 'For' statement line, is the only thing I can think of, as the actual toolchange seems to work well.  I don't really understand teh MOD command and what it is doing, so I'm not sure how to troubleshoot it.

Just to check, I am running the trial verison of Mach to proof it out before I buy the full license, is there a limitation on the toolchange function?  I know threading was not enabled but I didn't think toolchange was an issue.  

Thanks.  

10
VB and the development of wizards / Re: VB Script for toolchanger
« on: April 08, 2014, 08:27:15 AM »
No problem, again very appreciative that you took the time to help me work it out!  Good learning experience for me too. 

OK, I'll try it again, I tried several times, the only time I saw action was when I stepped thru the code in the VB editor once, it triggered a move.  But then any time I tried a step thru again, it did not trigger.  It could be possible too maybe I don't have enough time on the sleep for the output signal 'button push' and it's not initializing fast enough....I'll check that too. 

When I took out the 'then' the VB editor step thru worked, and I did get that one movement one time, but could not get it to work again. Now that I am noodling it a bit it's probably a timing issue on the signal....I'll try some iterations of sleep time and see what it does. 

And yes, agree with you I figured I would have to tell it what tool it has on startup - I thought Mach would keep the tool as there is a 'persistant tool'  setting in Mach config, but it doesn't seem to remember  :(

I took out the first while statement because the latching of the signal is very good, it does not latch until fully seated, so I figured was not necessary.  Initially I wasn't sure if it only signaled on motion or not, but it turned out that it doesn't signal until the changer is fully seated. 

Thanks, Nick

Thanks for looking at it! 

Pages: 1 2 »