Hello Guest it is June 17, 2019, 09:39:16 AM

Author Topic: End VB ! (script that is)  (Read 4292 times)

0 Members and 1 Guest are viewing this topic.

Offline H2

*
  •  26 26
    • View Profile
End VB ! (script that is)
« on: March 17, 2009, 03:44:14 PM »
Using the M6start vb for a tool changer and have that working.  What I would like to add to the script is two things.

     1. If the machine goes into an E-stop or hit's a limit to end the vb script.

     2. When the m6start vb is run for the first time (fresh machine) I would like it to verify what tool is in the spindle.

I am trying to learn the VB but I am not finding a way to apply the codes I can find (Wiki /Forum), and there always seems to be more! Any help with the above situation and or resources would be appreciated.

Just closing up a retrofit on an Intelitek PLM2000 it is a bench top and I can't tell you how much this list and Brian in particular has helped to make it all happen. 

All the best, Henry
« Last Edit: March 17, 2009, 03:49:52 PM by H2 »

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: End VB ! (script that is)
« Reply #1 on: March 19, 2009, 02:26:17 AM »
Henry

I use VB quite a bit, but usually only in Macros, in that I write the VB script ( eg thinning down a rod in the lathe, taking finish dianeters and lengths from a DRO's page that I have included) but to get round your first point, I then include then macro in a GCode script.

This might be very simple e.g. G21  M2001 and means when I restart, the GCode picks up the VB script again.

The trouble with VB is that when you start it, the program runs, right through, so if you stop, and then restart, unless you have something to pick up the VB script again, it won't start.

The second point is fairly easy, and would be a matter of altering the button script, to include a call to read the present tool number OEM dro. The DRO's remember the information, even when the machine is switched off.

Your VB would read something like  - prestoolno= GetOEMDro(***). What you choose to do with that is dependent on your tool change routine - I assume it is just to let your tool changer know where it is. You could have this printing a warning on the screen, or moving the tool changer to the correct "slot" if it not there.
Not me driving the engine - I'm better looking.

Offline H2

*
  •  26 26
    • View Profile
Re: End VB ! (script that is)
« Reply #2 on: March 19, 2009, 10:30:32 AM »
Thank you for the response.  My ability at the moment to use VB is VERY limited - just getting started and I thought the retrofit was tough!

I understand what you are saying about adding the G code to the script but maybe I phrased something wrong - what happened is while the machine was in the tool change script the machine lost some steps and started to take a walk on me so I hit the e-stop.  When I reset Mach and came out of the physical e-stop the VB script continued running where it left off - taking a walk! What would be nice in the script if possible is.

During the running script if an e-stop, reset or limit occurs abort / end the vb script.

Looking over some of the VB information - and correct me if I am wrong - the VB seems to execute each line of code similar to G code and not have a running memory to keep track of a potential E-stop or limit?

On the second issue I think it solved itself with your clarification of the DRO remembering information even after being shut off.... that will accomplish the same goal.

Thank you for your help
All the best, Henry 


Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: End VB ! (script that is)
« Reply #3 on: March 20, 2009, 04:24:50 PM »
Yes!

The way I understand VB to work  (and I may be wrong if some of the lads tell us differently) VB is not part of Mach 3, in that it operates a little independently of the standard GCode program. It sort of stands apart, and feeds in lines of GCode into the system, until it's program is finished, and then hands you back to the standard GCode program reader.

Hence, for instance, you can have a bit of trouble on certain moves, and you have to include a "while IsMoving" line, to make the VB wait until the last line it sent to the machine has executed, and then it sends the next line.

It may be that the whole of your VB script can be included in a "while not EStop" condition so that the program will stop, if EStop trips. This would automatically drop the program through to the end of the script, and return you to the GCode program.The only problem with that is, I don't know whether VB checks the condition after each line of it's own program, or finishes the chunk of program before checking the condition again.

I am only thinking aloud here - and may be way off the mark. I will try and write something e.g. a counting program, and see if I can get that to stop when EStop is pushed.

Keep on with Scripts - they are very useful and a great assett to the Mach 3 capability. The majority of my maching uses scripts, particulary the lathe, where a lot of time is spent on repetative thinning down of shafts, wheels, etc. i.e. the same cut, just repeated many times.

Not me driving the engine - I'm better looking.

Offline Hood

*
  •  25,843 25,843
  • Carnoustie, Scotland
    • View Profile
Re: End VB ! (script that is)
« Reply #4 on: March 20, 2009, 05:00:40 PM »
What you could possibly have is a macropump watching for an E-Stop and if its seen then do OEM button 322.
Not sure if its a good thing to do or not though so proceed with caution.
Hood

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: End VB ! (script that is)
« Reply #5 on: March 20, 2009, 05:10:20 PM »
I have just knocked up this script to prove the theory.

The program counts in the message window, and as soon as the EStop is pressed it stops the VB.

I cycled it in 10's to see if it would count to the nearest 10, but VB seems to check the condition after each line.

I couldn't see the message on my Mill xml - I used my lathe xml

I used three lines of GCode to run it - G21 - M1100 - M30
Not me driving the engine - I'm better looking.

Offline H2

*
  •  26 26
    • View Profile
Re: End VB ! (script that is)
« Reply #6 on: March 20, 2009, 05:28:57 PM »
Wow - Thank you , I will try the M1100 script and see if it works on my mill.

I looked at the M1100 code and to be honest I haven't got a clue what it does ;-)I  am a babe in the woods on the VB.

Hood -
The macro pump idea is interesting...

I will report back Thanks again!  Henry 

Offline H2

*
  •  26 26
    • View Profile
Re: End VB ! (script that is)
« Reply #7 on: March 20, 2009, 05:56:04 PM »
jimpinder - Excellent!

Your theory and M1100 worked on my mill. 

Now the question is - is it possible that you can explain how your M1100 code translates to something I can learn from and put into my code?

Thank you!, Henry

Offline jimpinder

*
  •  1,233 1,233
  • Wakefield, West Yorks, UK
    • View Profile
Re: End VB ! (script that is)
« Reply #8 on: March 21, 2009, 06:05:33 AM »
Henry - All the DRO's and LEDs used on Mach 3 have an associated OEM number - and Hood provided a list of these at the top of the main page. It is very useful, and you need to copy it.

The way I approached the problem was - when you press the E Stop what happens - the reset LED starts flashing.
The code for the reset LED is 800, so if you look at that you can tell whether the machine is stopped awaiting reset or not.

The line "Stillgoing = Not GetOEMLed(800)" means look at the reset led, and if it is NOT on, then we are stillgoing (stillgoing (a variable) becomes true), if it is on, then stillgoing becomes false. This is the key to the whole program, the rest is just counting and displaying on the screen, so I can see if it is running or not.

"While stillgoing" and its associated "Wend" encompass the whole program, and as we found, stillgoing is checked on a regular basis, and if it becomes false, the program drops to the bottom of the page, and shows the legend "Reset pressed" so we know the VB script has stopped.

Code generates GCode for Mach 3, as you probably know, but inside the code asterisks, anything in () is printed on the display line of Mach 3. I use this on a fairly regular basis to let me know where the VB script is, becasue (if it is a long, or repetative script) I like to know how far through the program is.

Not me driving the engine - I'm better looking.

Offline H2

*
  •  26 26
    • View Profile
Re: End VB ! (script that is)
« Reply #9 on: March 22, 2009, 06:12:27 PM »
jimpinder,

Apologies for the delay getting back to you - I have been trying to get my head around the information you provided and waiting for the light to come on but the room is still dark ;-)

If the following was added to the toolchanger code after the variables - it would work?

Stillgoing = 1
 While Stillgoing
 Stillgoing = Not GetOEMLed(800)
 Wend
 Code "(Reset pressed)"

The VB appears simple but I am missing something basic to understand it just yet ;-)

I appreciate your help, Henry