Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: nissan20det on February 09, 2016, 12:05:50 AM

Title: Mach3 VB Script Help
Post by: nissan20det on February 09, 2016, 12:05:50 AM
Hey guys so I'm wanting to write up my own code for that piezo probe I made. Was wondering if any of you code stuff yourself and could give me a hand.

I'm pretty familiar with arduino coding but I see that Vb script is a bit different. So far what I got is working but I want to do 3 passes when finding a circles center. I would like the first pass to be around F10 then after the machine touches 3 or 4 points at first, I would like the second pass to move around F30 but slow to f4 when a declared distance from touching is passed. Then same with third pass but slow to F1, when say .030" from touching.

Would any of you know how to code that. I don't need you to write the entire code, but just an example of how to make a slow zone in VB script format.

Thanks, Zach
Title: Re: Mach3 VB Script Help
Post by: ger21 on February 09, 2016, 12:15:29 AM
You just change the feedrate in the script.

Code "F4"
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 09, 2016, 01:42:50 AM
No Im saying I set it to move till probe touched at F10 but when close to the edge, say .1" slow to F5..... like this but in VB format. This is close, I got most this from a touch plate and just made my own. It most likely needs changes.

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again" 'this goes in the status bar if aplicable
   Else
Code "G90 G31 X-7 F10"     'Is that right? or should I be using a G1
While IsMoving()
Wend                                  'Whats Wend for?
Call SetDro (X,0)    'Is this Right?? want to set X Dro to Zero
Code "G90 G31 X7 F10
While IsMoving()
Wend
XMax = GetVar(?)     'What is the Var for X's Dro?
XMax/2 = XZero
Code "G90 G31 XXzero F10"     'Would this work?
Code "G90 G31 Y-3 F10"
While IsMoving()
Wend
Call SetDro (Y,0)        'Is this Right??
Code "G90 G31 Y3 F10
While IsMoving()
Wend
YMax = GetVar(?)    'What is the Var for X's Dro?
YMax/2 = YZero
Code "G90 G31 YYzero F10"     'I  Dont think this is right
Code "G90 G31 X-7 F30"
While IsMoving(
if X<.1(Setfeedrate F5) )  'how do I change feed rate while moving like soft limit?
Wend
Call SetDro (X,0)    'Is this Right?? want to set X dro to zero
Code "G90 G31 X7 F30
While IsMoving(
if X>.1-XMax(Setfeedrate F5))
Wend
XMax = GetVar(?)      'What is the Var for X's Dro?
XMax/2 = XZero
Code "G90 G31 XXzero F10"     'Dont think this is right
ode "G90 G31 Y-3 F30"
While IsMoving(if Y<.1(Setfeedrate F5))
Wend
Call SetDro (Y,0)    'Is this Right??
Code "G90 G31 Y3 F30
While IsMoving(
if X>.1-YMax(Setfeedrate F5))
Wend
YMax = GetVar(?)      'What is the Var for X's Dro?
YMax/2 = YZero
Code "G90 G31 YYzero F10"     'I  Dont think this is right
Code "G90 G31 X-7 F30"
While IsMoving(
if X<.02(Setfeedrate F2) )    'how do I change feed rate while moving like soft limit?
Wend
Call SetDro (X,0)      'Is this Right?? want to set X dro to zero
Code "G90 G31 X7 F30
While IsMoving(
if X>.02-XMax(Setfeedrate F2))
Wend
XMax = GetVar(?)       'What is the Var for X's Dro?
XMax/2 = XZero
Code "G90 G31 XXzero F30"     'Dont think this is right
Call SetDro(X,0)                   
Code "G90 G31 Y-3 F30"
While IsMoving(if Y<.02(Setfeedrate F2))
Wend
Call SetDro (Y,0)       'Is this Right??
Code "G90 G31 Y3 F30
While IsMoving(
if X>.02-YMax(Setfeedrate F2))
Wend
YMax = GetVar(?)       'What is the Var for X's Dro?
YMax/2 = YZero
Code "G90 G31 YYzero F30"     'I  Dont think this is right
Call SetDro(Y,0)
Code "G1 Z3 F20"     'Is this what My code should be instead of G90 G31?
Message "Circle Center Found"
Title: Re: Mach3 VB Script Help
Post by: stirling on February 09, 2016, 07:06:40 AM
You may be over-complicating things. If we look at your various probe directions as being north, south, east and west. You seem to be going west, east, south, north, then again and then again.

Might be better if you did west, west, west, east, east, east etc. etc.

HOWEVER - Although some say for improved accuracy you should probe TWICE, once at some speed and then again at a a lower speed, I can't see any value in doing it THREE times.

You also shouldn't use the values in the DROs as your trip points. You should read the parameters 2000 (X) and 2001 (Y).

Here's a trivial example of a 1 shot probe which assumes you've placed the probe roughly at the centre of your circular pocket (you need to replace ? with some number):

code "G31 X?" 'where ? is some number guaranteed to get you to the circumference
while isMoving()
  sleep 10
wend
tripX = getVar(2000) 'variable tripX now holds the exact point of the trip

Now if you want to probe again, you'd just reverse a bit past the trip point and do exactly the same again.

Disclaimer: If any of the above breaks anything (including your heart) - you get to keep the pieces.

Title: Re: Mach3 VB Script Help
Post by: RICH on February 09, 2016, 08:34:12 AM
 FWIW,

There is a lot of info on probing and no need to reinvent the wheel, but,  different scripting tips by different users is always worth noteing.
My personal VB skills are low on the ability scale.

- Have a look at the Mach mill manual for G31 command and note that there is an example code for probing a hole by Art.
- I have a pdf about probing ( written for my lathe screen use but still applies ) and can shed light about probing only once or multiple times.

RICH
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 09, 2016, 12:31:29 PM
Just remember that once you trip you cannot imediately reprobe in another direction you have to back off the trip point before you can use G31 again.

G91
G31  X10  ( Probe X Right)
G0 X-.050 ( Back off to untrip probe)
G31 X-10  ( Probe X Left)

Also there is really no need to double or triple tap with teh G31 (;-)

And as Stirling mentioned you may be severvely overthinking the process . The only hting you need to keep in account is the amount of overrun your particular probe has before it is damaged.  Normal that type of sensor has little to no overun capability before it breaks something. The probeing process will alwyas have some overrun as teh machine comes to a safe stop on trip. The slower your accel rate is and teh faster you probe the more overrun you will see.
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 09, 2016, 04:19:06 PM
This is what i was going after- https://www.youtube.com/watch?v=_ZDlyLI_jbc (https://www.youtube.com/watch?v=_ZDlyLI_jbc)

Rich- I'm not sure If I was looking at the right manual but It was section 10.7.12.3, What is all that N010 coding? I've never seen that. So in that manual it said a G31 will move till tripped then back off slightly. Is this enough to just have the next line of code to do a G31 - move in opposite direction or do I need a G1 -move to fully pull off before the next G31 command?

Well I really like the idea of at least two passes, as well the second pass going faster and slowing down. Okay so let me know this looks...

Where are all these codes located? Like x being 2000 Y 2001 and Probe switch being 818? Cuz I also saw Probe can be 22, is there a list somewhere?

Thanks guys I really appreciate the help!

And Ill most likely test this code with a soft copper tube using conductivity.


Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again" 'this goes in the status bar if aplicable
   Else
Code "G91 G31 X-7 F8"     'Is this right now with G91?
While IsMoving()
Wend                                          'Whats Wend for? Still not sure what this is for
Xmin = GetVar(2000)                                 
                 Do I need a G1 pull off command here , as well as after every trip?
Code "G91 G31 X7 F8"
While IsMoving()
Wend
XMax = GetVar(2000)   
XMax-Xmin = XZero
Code "G1 XXZero F30"     'To return to center should I just use a rapid or liniear move instead of G31?
   'as well is calling a variable in a code line acceptable?
Code "G91 G31 Y-3 F8"
While IsMoving()
Wend
YMin = GetVar(2001)
Code "G91 G31 Y3 F8"
While IsMoving()
Wend
YMax = GetVar(2001)   
YMax-YMin = YZero
Code "G1 YYZero F30"     
Code "G91 G31 X-7 F30"
While IsMoving(
if X<.95*XMin(Code F2))  'I would still like the second pass to move fast then slow, even if complicated I just like the idea. 
    'Whats the command to set feed rate by its self? (Code F5)?
Wend
XMin = GetVar(2000)   
Code "G91 G31 X7 F30
While IsMoving(
if X>.95*XMax(Code F2))
Wend
XMax = GetVar(2000)     
XMax-XMin = XZero
Code "G1 XXZero F30"     
ode "G91 G31 Y-3 F30"
While IsMoving(
if Y<.95*YMin(Code F5))
Wend
YMin = GetVar(2001)
Code "G91 G31 Y3 F30
While IsMoving(
if X>.95*YMax(Code F5))
Wend
YMax = GetVar(2001)     
YMax-YMin = YZero
Code "G1 YYZero F30"   
Message "Circle Center Found"
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 09, 2016, 04:53:35 PM
The G31 does NOT stop and back off. You must back off teh switch before issueing another G31 or else you WILL get an error.  

AND just for the record you do not gain any accuracy by slowing down or double tapping (;-)

The N010 is just a line number statement in Gcode.It is not required but can be used.

Also remember that you are moving in incremental values BUT teh stored variables (2000 & 2001) are absolute values of position. That will effect your math depending on the quadrant you are currently working in.

You are getting closer (;-) TP

Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 09, 2016, 05:10:07 PM
LOL thanks, And Yea accuracy or not I think it looks cool hahaha

Okay updated with pulloffs set at 98% of Mins, After every Max recording Is a G1 to XZero/YZero so I only need them on the Min's right?

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91 G31 X-7 F8"     'Is this right now with G91?
While IsMoving()
Wend                                          'Whats Wend for? Still not sure what this is for
Xmin = GetVar(2000)                                 
Code "G1 X.98*XMin F8"                would this work?
Code "G91 G31 X7 F8"
While IsMoving()
Wend
XMax = GetVar(2000)   
XMax-Xmin = XZero
Code "G1 XXZero F30"       'as well is calling a variable in a code line acceptable?
Code "G91 G31 Y-3 F8"
While IsMoving()
Wend
YMin = GetVar(2001)
Code "G1 Y.98*XMin F8"
Code "G91 G31 Y3 F8"
While IsMoving()
Wend
YMax = GetVar(2001)   
YMax-YMin = YZero
Code "G1 YYZero F30"     
Code "G91 G31 X-7 F30"
While IsMoving(
if X<.95*XMin(Code F2))  'I would still like the second pass to move fast then slow, even if complicated I just like the idea. 
    'Whats the command to set feed rate by its self? (Code F5)?
Wend
XMin = GetVar(2000)
Code "G1 X.98*XMin F8"   
Code "G91 G31 X7 F30
While IsMoving(
if X>.95*XMax(Code F2))
Wend
XMax = GetVar(2000)     
XMax-XMin = XZero
Code "G1 XXZero F30"     
ode "G91 G31 Y-3 F30"
While IsMoving(
if Y<.95*YMin(Code F5))
Wend
YMin = GetVar(2001)
Code "G1 X.98*YMin F8"
Code "G91 G31 Y3 F30
While IsMoving(
if X>.95*YMax(Code F5))
Wend
YMax = GetVar(2001)     
YMax-YMin = YZero
Code "G1 YYZero F30"   
Message "Circle Center Found"
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 09, 2016, 05:34:04 PM
You cannot mix CB variable code inside of Gcode calls. You will have to seperate them .

Also you have problem with your return to zero math and mixing inc moves with abs values.

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: RICH on February 09, 2016, 05:57:47 PM
BR549,

Quote
AND just for the record you do not gain any accuracy by slowing down or double tapping (;-)

But,
You will minimize the overtravel into the piece and the  force you are putting on the probe.
If it's slow on the approach you also have  a  little time to stop the probing should it go wrong for some reason,
hasn't happened to me yet, but one of these days ....you never know........
I also fooled with my expensive probe, piece of poop it is, and depending on the approach speed it triggers differently.
Not a Mach thing but rather a probe problem.

Don't want to confuse, so back to sidelines to continue learning....... ;)

RICH
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 09, 2016, 06:21:51 PM
HIYA Rich we did testing on probes and speed years ago with art.  IF you have a 3 point pivoted probe , and most low end probes are' the ONLY difference we saw was in the radial direction that you probed in in relation to the probe. THAT is a physical thing with teh motion of teh wabble plate on teh three pivot points. ALL 3 point wobble plates have teh same problem.

What is being refered to here is the need for a second pass or double tap. But if that is what he wants not a problem (;-).  I have seen a LOT of different approaches to this over the years always room to add one more (;-)

Actually it is NICE to see someone actually working on their OWN routines these days.  COOL (;-)

(;-) TP

Title: Re: Mach3 VB Script Help
Post by: BR549 on February 09, 2016, 07:50:22 PM
Actually  this does bring up a good point IS there ONE spot a USER can go to to get ALL teh manuals that have been generated for Mach3 over teh years. OR are they still scattered about ???

Preferrably we need 2 sites in case we loose this one one day when Mach3 does go away permanently .

Just a thought, (;-) TP
Title: Re: Mach3 VB Script Help
Post by: RICH on February 09, 2016, 08:01:17 PM
"All" the manuals....not really, maybe the ones ArtSoft generated.
I would include the ones in Member's Doc's.

Would be nice if someone summarized all the threads and made a book.
If you search a subject you can sure spend a lot of time reading.
Just search probing if one wants some nighttime reading.

BTW, Yes it's nice to follow a users  work as you never what they will come up with.
Different minds look at things differently for sure.

Keep up the good work guy's,

RICH
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 09, 2016, 11:27:05 PM
BR549
Quote
You cannot mix CB variable code inside of Gcode calls. You will have to seperate them .

Also you have problem with your return to zero math and mixing inc moves with abs values.

Okay, Well what is I do? I would need to individually input the Min/Max's as well the XZero/YZero's. So I would have to change XMax to something to go in the Gcode line. A Char?

And for my Zero math would this work better? XZero = (((Xmax*.5)/(XMin*.5))*2)
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 10, 2016, 12:23:05 AM
Fixed all the syntax errors that popped up and I got this. Still says error but wont show a line. And I looked everywhere and cant find how to put a Var in a Code line. So I really need help with that.

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91 G31 X-7 F8"   
While IsMoving()
Wend                                         
Xmin = GetVar(2000)                                 
Code "G1 X.98*XMin F8"                 
Code "G91 G31 X7 F8"
While IsMoving()
Wend
XMax = GetVar(2000)   
XZero = (((Xmax*.5)/(XMin*.5))*2)
Code "G1 XXZero F30"       'as well is calling a variable in a code line acceptable? Need help with these lines
Code "G91 G31 Y-3 F8"
While IsMoving()
Wend
YMin = GetVar(2001)
Code "G1 Y.98*XMin F8"
Code "G91 G31 Y3 F8"
While IsMoving()
Wend
YMax = GetVar(2001)   
YZero = (((Ymax*.5)/(YMin*.5))*2)
Code "G1 YYZero F30"     
Code "G91 G31 X-7 F30"
While IsMoving()
If X<.95*XMin then SetFeedRate(F2) 
Wend
XMin = GetVar(2000)
Code "G1 X.98*XMin F8"   
Code "G91 G31 X7 F30"
While IsMoving()
If X>.95*XMax Then SetFeedRate(F2)
Wend
XMax = GetVar(2000)     
XZero = (((Xmax*.5)/(XMin*.5))*2)
Code "G1 XXZero F30"     
ode "G91 G31 Y-3 F30"
While IsMoving()
If Y<.95*YMin Then SetFeedRate(F2)      '<--- Do I need the () of While IsMoving to be around my If Then? Or is just before the Wend okay?
Wend
YMin = GetVar(2001)
Code "G1 X.98*YMin F8"
Code "G91 G31 Y3 F30"
While IsMoving()
If X>.95*YMax Then SetFeedRate(F2)
Wend
YMax = GetVar(2001)     
YZero = (((Ymax*.5)/(YMin*.5))*2)
Code "G1 YYZero F30" 
SetDro(XaxisDRO,0)
SetDro(YaxisDRO,0)
Code "G0 G53 Z-4" 
Message "Circle Center Found"
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 10, 2016, 12:58:31 AM
I saw these in the mach program manual would either work?

Example:
‘ Example M6End macro
‘ Define some constants
Xaxis = 0
Yaxis = 1
Zaxis = 2
‘ Move all axes back to where they were before the toolchange
Xpos = GetToolChangeStart(Xaxis)
Ypos = GetToolChangeStart(Yaxis)
Zpos = GetToolChangeStart(Zaxis)
Code “G00 X” & Xpos & “ Y” & Ypos & “ Z” & Zpos
‘ Wait for move to complete
While IsMoving()
 Sleep 100
Wend

So If I did
Code "G1 X" & XZero "F30"   ??

or this?

‘ Set a variable 1234 to our target position of 2.3456
SetVar(1234, 2.3456)
‘ Now move X to our target position
Code “G0 X #1234”
‘ Or, another way…
Code “G0 X “ & GetVar(1234)

So maybe I can do
Code "G1 X" &etVar(XMin) "F30"

??
Title: Re: Mach3 VB Script Help
Post by: stirling on February 10, 2016, 04:45:54 AM
So If I did
Code "G1 X" & XZero "F30"

That is the most usual way.

watch your concatenation operators though, the line as written will fail.
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 10, 2016, 11:17:11 AM
You are almost there (;-)   You can build a mixed string but you have to concatenate each piece together. These are just different examples

Code"G1 X" & Xzero & "F30"         

Or

Code"G1 X" & GetVar(2000)  & "F30"


Also remember when you go to do the math to find center it will depend on what quadrant you are in as to how it needs to be. The math for each quadrant may be different. SO you also need to be able to identify teh quadrant you are actually in (;-)

I also do not call the CB variables as Xmin , Xmax   because depending on teh quad that might not be the case and it could be confusing. I use X1 X2 , Y1 Y2. 
Title: Re: Mach3 VB Script Help
Post by: stirling on February 10, 2016, 12:19:03 PM
@Terry - one post then I'll back out  ;)

@nissan20det - Can I make a suggestion: It's a classic beginner's mistake to try to code the whole thing straight off.

I'd suggest you do little test snippets at a time and test as you go.

test your

Code: [Select]
Code "G91 G31 X-7 F8"
While IsMoving()
Wend
Code"G1 X" & GetVar(2000)  & "F30"

I think you'll find it doesn't do what you think it does. (don't use your real probe to test this ;))
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 10, 2016, 12:54:34 PM
HI Ian, Very good advice.   I agree take simple steps coding and testing as you go. The first thing I do is get teh motion correct then work on the math.

And just a note  (;-) Ian has helped me a great deal working with Mach3 (;-) His programming advise is HIGHLY valued here.  

Another tip , you are working in 2 motion modes G91 (Inc) and G90 (Abs) don't get them mixed up when you go to move (;-) each has it's own advantages/Disadvantages. AND you can do this several different ways (;-) so there is really no right way or wrong way IF the end results are correct.
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 10, 2016, 03:35:37 PM
Thanks for the help guys, really appreciate it!

Quote
Code "G91 G31 X-7 F8"
While IsMoving()
Wend
Code"G1 X" & GetVar(2000)  & "F30"

I think you'll find it doesn't do what you think it does. (don't use your real probe to test this Wink)

Yes!! I will definitely be testing with something else, i mentioned earlier I was gonna test with a small copper pipe chucked.

As for what I think the code you wrote would do, im not sure id a g31 will stop ones probe input is triggered, if not then it would move X 7in in - direction, stop at 7 and that's it. If you have If GetOemLed(825) = 0 Then your code it would move the same and stop if triggered then just sit there. Your telling it to G1 X to X's current location. 

Is that right?
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 10, 2016, 04:31:36 PM
And iif

If GetOemLed(825) = 0 Then
X1 = GetVar(2000)
Code "G91 G31 X-7 F8"
While IsMoving()
Wend
Code"G1 X" & X1 & "F30"

That would move 7 or until triggered then return to starting X position.

Right
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 10, 2016, 06:02:11 PM
Actually X1 would not have a value or would have teh previous value  from a previous G31.

#2000 would NOT be set untill after teh g31 is run. So in your example there is NO telling where it would end up.

AND because you did not switch back to G90 after the G31 ran the next move would be an inc move not abs. AND teh #2000 value IS an Abs position.

Clear as mud HUH ? (;-)
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 10, 2016, 09:27:15 PM
Ha-ha okay so the GetVar(2000) it getting the last G31's pobe dro amount, I thought it was to get that the X current position. That's why I was confused ... Okay so hows this:

If GetOemLed(825) =0 Then
Code "G90 G31 X-7 F8"
While IsMoving()
Wend
X1 = GetVar(2000)
Code "G1 X" & X1*.98 & "F8"         
Code "G90 G31 X7 F8 "            ' if I do these as G91 would that keep me in Inc ? Or should I change the G1 to G0? But then I can't input a feed rate the right?  Or keep it G90 and G1?
While IsMoving()
Wend
X2 GetVar(2000)
XZero = (((X2*.5)/(X1*.5))*2)
Code "G1 X" & XZero & "F30
etc.
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 10, 2016, 11:04:07 PM
You will want to do the probing in INC (G91)mode. You hve to gather teh trip point values for both sides of teh circle. ( X1 ,X2 )You can then do a positional move in INC after you proper calculate the value you need to move OR simply switch  to ABS (G90) mode to do a positional move to Center of space. Then switch back to INC to do teh next G31 call and repeat as needed.



Code "G91"             ' Switch to INC mode
Code" G31 X-7 F8"   'Probe in X- direction
While IsMoving()
Wend
X1 = GetVar(2000)      ' Collect X1 trip position
While IsMoving()
Wend
Code " G0 X.050"         ' Back off switch in X + direction
While IsMoving()
Wend
Code " G31 X14 F8"      ' Probe X + Direction
While IsMoving()
Wend
X2 = GetVar(2000)       '  Collect X2 trip position
While Ismoving()
Wend
Xc =( X2 - X1)             ' This assumes you are in Quandrant 1
While IsMoving()
Wend
Code" G90"                 ' Switch to ABS mode
Code" G0 X" & Xc         ' Move to X center position


Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 05:31:34 AM
Okay I see... Well I'm confused with one thing and you worng about another but so was I

Why after
X1 GetVar(2000)
Do you have
While IsMoving()
Wend
?

It's not moving so what say do nothing wile moving

And for finding Xc X1-X2 won't work  is X1=-2 and X2 = 2. You get -2-(+2) or -2-2 how ever you see it and end up with -4 not 0. Now my ((X1*.5)/(X2*.5))*2 is also wrong..

This is correct for any position.
Xc = (X1+X2)/2

As well this line won't work
Code "G0 X.050"
Mesuring a 1" circle you may be at -3.25 getting your first (2000)Var so to back off to .050 would move out of the circle.
That's why I had it like this which should work I believe.
Code "G91"            
Code" G31 X-7 F8"  
While IsMoving()
Wend
X1 = GetVar(2000)      
Code " G0 X" & .98*X1        
While IsMoving()
Wend
Code " G31 X14 F8"      
While IsMoving()
Wend
X2 = GetVar(2000)      
Xc =(X1 + X2)/2
Code "G0 X" & Xc

Code" G90"                 ' Switch to ABS- do this line on my last move back to center after second pass? Or every XcYc
Code" G0 X" & Xc
Title: Re: Mach3 VB Script Help
Post by: Tweakie.CNC on February 11, 2016, 06:39:09 AM
Quote
Why after
X1 GetVar(2000)
Do you have
While IsMoving()
Wend
?

It's not moving so what say do nothing wile moving

It's just one of those things you learn to love about Mach3 interpreting Cypress Enable - it is always best to tell it to wait until one operation is completed before moving on to the next (it is unimportant if anything is actually moving or not).

Tweakie.
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 03:17:19 PM
understood but that will not help you.

When you call While IsMoving() Wend that While statement will be skipped if not moving. If all axis are stationary then when you get to that line of code it will pull a False, skip it, then move to the next line. If you really want it to wait then you should use WScript.sleep(500) half second pause. that will wait.

But this is also code, this runs Very Very fast and very accurate. and Arduino at 16Mhz can process each line in less then 2 microseconds. I'm not sure if mach uses your computers processor speed or not but that's in GHZ. My PC is at 4.97GHZ, So thats nano seconds.

But on a coding line, to make a variable equal to a already stored number, wouldn't need a delay to update. Now maybe wile updating the DRO or something visual, that may take some time and you may want to pause. Even a really long math equation wouldn't need a delay, the computer will not go to the next line of code till the current has been completed. Back to the visual update, a line of code may send a Msg Box out and not actually show till another 27 lines of code have been processed. so yes a pause is needed at times but for a variable to get a value I dont think one is necessary.

  Not to rain on your parade and I might be wrong here but its what I  understood and I don't think that line will benefit you their.
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 11, 2016, 05:56:41 PM
(;-) WHile Ismoving is NOT just about MOVING it is about anytime MACH3 is doing something.  ALSO there is a problem with Mach 3 and CB spawning multiple threads at teh same time and loosing control over teh exact order of execution. SO it is left to teh programer to maintain order of execution in most cases.

You have a LOT to learn about Mach3 Grasshopper.

Another thing you MUST keep in mind is that mach3 is a GCODE motion controller. It is NOT a general purpose motion controller driven by scripting . Macros mixed with Gcode was an afterthought . MOST other controllers went with conditional Gcode instead of Macro interfaces to teh Gcode and in doing so can be much more stable AND FASTER in Gcode execution.

NOW once you learn how Mach3 works and learn most of the quircks MUCH can be done with it.  Just keep in mind that teh sampling rate of teh macros is ONLY 10 hz VERY SLOW as compared to other forms of motion control. SO by its own working Mixed Gcode macro can be very slow to function.

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: RICH on February 11, 2016, 06:01:37 PM
Relative to    While Ismoving ()  and Wend        there is a rather long thread / discussion  about it.
Can find my notes on that thread or the thread itself. No I don't remember all the specifics.

BR549, ring any bells???

RICH
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 11, 2016, 06:02:06 PM
Now another thing Sleep() is NOT just about waiting it also frees up teh CPU during a wait state and can allow OTHER processes to run while the wait is going on OTHERWISE teh wait can HOG all teh CPU resources and nothing else can happen.

(;-) TP

Title: Re: Mach3 VB Script Help
Post by: RICH on February 11, 2016, 06:04:12 PM
Your summarizing nicely Terry........ :-*

RICH
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 11, 2016, 06:16:10 PM
hIYA RICH. There were MANY discussions on it in past years.  BUT seeing how it will never ever be worked on again I don't see any point in cranking the discussion back up again. (;-)

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: RICH on February 11, 2016, 06:26:40 PM
Understand, don't want a discussion on it, but said differently, If one scripts  the ....following....things will work as intended......well for later versions of Mach anyway.

Carry On, ;)

RICH
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 06:30:48 PM
OKAY OKAY So I was wrong my bad. I guess I have alot of reading up to do on this.

So BR549, Are you saying a Sleep() function is better to use than While IsMoving() Wend, because it will allow the Previous lines to finish executing?

Also, Do I need to recall G91 after I call a G0? Or is calling G91 once at the start okay?

Hows this

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91"
Code "G31 X-7 F8"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
While IsMoving()
Wend                                   
Code "G0 X" & .98*X1               
Code "G31 X7 F8"
While IsMoving()
Wend
X2 = GetVar(2000)
While IsMoving()
Wend   
Xc = (X1 + X2)/2
Code "G0 X" & XC       'as well is calling a variable in a code line acceptable? Need help with these lines
Code "G31 Y-3 F8"
While IsMoving()
Wend
Y1 = GetVar(2001)
While IsMoving()
Wend
Code "G0 Y" & .98*Y1
Code "G91 G31 Y3 F8"
While IsMoving()
Wend
Y2 = GetVar(2001)
While IsMoving()
Wend   
Yc = (Y1 + Y2)/2
Code "G0 Y" & Yc   
Code "G31 X-7 F30"
While IsMoving()
If X<.95*X1 Then SetFeedRate(F2) 
Wend
X1 = GetVar(2000)
While IsMoving()
Wend
Code "G0 X" & .98*X1   
Code "G31 X7 F30"
While IsMoving()
If X>.95*XMax Then SetFeedRate(F2)
Wend
X2 = GetVar(2000)
While IsMoving()
Wend   
Xc = (X1 + X2)/2
Code "G0 X" & Xc     
ode "G31 Y-3 F30"
While IsMoving()
If Y<.95*YMin Then SetFeedRate(F2)      '<--- Do I need the () of While IsMoving to be around my If Then? Or is just before the Wend okay?
Wend
Y1 = GetVar(2001)
While IsMoving()
Wend
Code "G0 Y" & .98*Y1
Code "G31 Y3 F30"
While IsMoving()
If X>.95*YMax Then SetFeedRate(F2)
Wend
Y2 = GetVar(2001)
While IsMoving()
Wend     
Yc = (Y1 + Y2)/2
Code "G0 Y" & Yc 
SetDro(XaxisDRO,0)
SetDro(YaxisDRO,0)
Code "G0 G53 Z-4" 
Message "Circle Center Found"
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 11, 2016, 06:36:31 PM
Another thing to keep in mind IS Mach3's scripting language is Cypress Basic . It is NOT Visual Basic(VB) 

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: RICH on February 11, 2016, 06:38:21 PM
Nissan......,
Not saying your wrong / whatever.
Rather,
Trying to get some of the knowledge available to you for the script.
You'll be even more dangerous than me in no time at all,  :D

RICH
 
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 07:07:36 PM
LOL Rich no offence taken at all bud! Just saying I know my place here... I got alot to learn C++ is way different
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 07:12:19 PM
Okay this doesnt work I'm in test phase as we speak.... touches and stops great but the last line doesnt work it just keeps going + forever

Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91"
Code "G31 X-7 F8"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
While IsMoving()
Wend                                   
Code "G0 X" & X1*.98

Do I need a X3?

X3 = X1 * .98
then
Code "G0 X" & X3

???



okay this worked

Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91"
Code "G31 X-7 F8"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
While IsMoving()
Wend
X3 = X1*.90                                   
Code "G0 X"&X3         
End If

easier way?
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 07:39:40 PM
Okay This is reading all in MM What command do I say at the top to state this is Inchs?
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 11, 2016, 07:51:50 PM
OK I gotta ask (;-) WHAT is the X1*.90 move about ?

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 11, 2016, 07:59:24 PM
Is your Machine setup in Inches or MM ??  Look on the main RUN screen top right that is the modal line Do you see a G20 or a G21 listed ??

(;-) TP

Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 09:05:07 PM
G20   And the X1*.90 is to move X to 90% of X1's value. That seems to be better termanolagy than X-.05 if X is at 3inchs thats a 3.05" move not .05".

Okay heres the code I have and heres a video of what its doing I so lost.

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then      
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91"
Code "G31 X-7 F13"    
While IsMoving()
Wend                                          
X1 = GetVar(2000)
Sleep(200)             ' I put these here to stop machine gitters, and wow I know now what you mean by this code runs slow!
X3 = X1*1
Sleep(30)                                    
Code "G0 X" & X3
While IsMoving()
Wend
Code "G31 X7 F13"
While IsMoving()
Sleep(100)
Wend
X2 = GetVar(2000)
Sleep(200)  
XC = X1 + X2
Sleep(90)
Xc = XC*.5
Code "G0 X" & -Xc      
While IsMoving()
Sleep(100)
Wend              
Code "G31 Y-3 F13"
While IsMoving()
Wend
Sleep(90)
Y1 = GetVar(2001)
Sleep(200)
Y3 = Y1*.1
Sleep(30)
Code "G0 Y" & Y3
While IsMoving()
Wend
Code "G31 Y3 F13"
While IsMoving()
Sleep(100)
Wend
Sleep(90)
Y2 = GetVar(2001)
Sleep(200)  
YC = Y2 + Y1
Sleep(90)
Yc = YC*.5
Code "G0 Y" & -Yc    
End If




Ill post the video in 10 min closing up shop
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 11, 2016, 09:44:00 PM
OK Remember when I mentioned that teh #2000 is an ABS position value ???   I was not kidding(;-)  The value you are getting could be a very high value NUMBER wise.  Without warping your brain with the math it is easier to make teh backoff move in INC  .050 will always be .050.   X1*.90 could end up being anything depending on WHERE you were on the table.

I am thinking you do not fully understand Abs and Inc terms in Gcode ?

IF you are in G20 mode then you ARE in inch mode.

Not quite sure what you mean by Machine jitters BUT if Sleep() cures it you have other problems.

Also rememeber what Stirling said START with simply moves , perfect them then add another section of code , test tune and repeat. You are trying to do it all at one time without fuilly understanding what it is doing. Kaos at best.

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 11:15:11 PM
BR 549 that's exactly what I was doing.. Like 4 lines at a time then add 4 more...

So I must not understand what ABS and INC are or teh lol.   If I increase the .98 on X3=X1*.98 to 1,2,3,4 or 5 the back off amount increases, If I lower .98 to .1 it decreases the back off. For Y its opposite ??

AS well
XC = X1+X2
Xc= XC*.5 ' I also tired Xc = XC/2 these do the same and work but i can tell its slightly off center

 these dont work
 Xc = X1+X2/2
Xc = (X1+X2)/2

You can see the jitter part I was talking about when it backs off Y's first touch. This has only ever happened with moving in Script. Never during a program or jog

https://www.youtube.com/watch?v=OyMWOmd8VPI (https://www.youtube.com/watch?v=OyMWOmd8VPI)
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 11, 2016, 11:38:32 PM
And I thought GetVar(2000) will set the variable to the Machine coordinates DRO value at the point the probe was triggered... I must be way off ???

Oh as well the line I was getiign a backward movement

Code"G0 X" & Xc
   Then I changed it to this and it fixed it but I know I shouldn't have to
Code"G0 X" & -Xc
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 12, 2016, 02:50:50 AM
 
well I think I got this abs inc figured out, all I had to do was think about it and wow this helps alot hahaha

Abs to me is absolute placement X7 moves to 7" not 7" long

Inc Is X7 will move X 7" is that right?

If so I thought G0 was abs so if you want to back off .050" and your at .350" you need to say G0 .300
In this case my X3=X1*.98 would always work  .100*.98 = .98 I would have backed off .020 in this case and 98% in all others. I do agree thats not enough I like .9 better.

You guys said G90 is abs G91 is inc so stick with one. So I should be changing my G0's to G1's and then just do .050. that now makes since to me altho why did the G0 X1*.98not work?? is it because im taking 98% of an inc move? So if I changed the first line to G90 would that equation then work?


Title: Re: Mach3 VB Script Help
Post by: Tweakie.CNC on February 12, 2016, 03:37:09 AM
Quote
You guys said G90 is abs G91 is inc so stick with one. So I should be changing my G0's to G1's and then just do .050. that now makes since to me altho why did the G0 X1*.98not work?? is it because im taking 98% of an inc move? So if I changed the first line to G90 would that equation then work?

I think you may be getting confused between G90, G91 and G0, G1 ??

I think you may also be getting confused regarding Mach3 handling equations within the Gcode line (if you are not then I certainly am).

Tweakie.
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 12, 2016, 09:41:46 AM
WHy does your X1*90 move not work ???  Easy you are trying to do an inc move with an abs position value NOT an inc value.

Take this example. Lets move to teh far side of the table so the example will be dramatic. Teh hole you are probing is 1" diam

Your first leg of the probe doing a center of circle trips at X95. So that makes your X 1 = 95.0000   OK   X3 = (95.0000 * .90) = 85.5

Your routine is STILL in INC mode so when you go to Code"G0 X "& X3 it will MOVE right 85.5 "  AND you just broke your probe.

HAD you actually been testing as you created each line you would have seen this right off teh bat (;-)  .

Also I did not finish the Formula to find center of a circle for a reason. It was to make you think about what you were creating.

There are 2 basic ways to work teh formula.  From an  INC approach OR  ABS approach. THAT would be your choice . But each takes a different way of doing it.


You are missing a LARGE block of basic knowledge for using Gcode. Trying to create a high end macro WITHOUT that knowledge is like trying to do Algebra without understanding the basic rules of Algebra. It will not make any sense.

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 12, 2016, 03:26:08 PM
Ha-ha okay well I must be lost on g90 and g91.

But I thought I was in abs??
If not how can I set this to be all in abs.

As well in the video is seems the X3=.90*X1 moves correctly in abs as I thought, moving 10%. The line Y3=.90*Y1 moves 98% so that's in Inc obviously. Can someone explain where in the code it goes from abs at the X equation and then switch's to inc at the Y?

As well why is my first X3 move moving in and if I said G91 at the begining
Title: Re: Mach3 VB Script Help
Post by: RICH on February 12, 2016, 04:09:09 PM
You may want to consider purchasing the book, CNC Handbook Programming by Peter Smid.
You don't read it, but rather, study it. It is an excellant resource to have and refer to.

RICH
Title: Re: Mach3 VB Script Help
Post by: RICH on February 12, 2016, 04:46:14 PM
Think about this......................maybe in this fashion.

I am Mach the controller and can't see anything you are doing and when you first start me
up I will keep track of every axis move you make. I dont know anything about your machine, unless of course you have given me some info to do on start-up.
So to keep track I have a point to start from and will continue doing so until you tell me otherwise.To do this I will use what is called Machine coordinate's, just keeping track of
your every move because I don't trust you to keep me from getting lost.

If I am at XYZ=0, and you say move to X=100, you told me to send the info out to make a
move in the X positive direction, hey pal, you also told me that you want to work in absolute mode in your configuration,so......Okey dockey i will move the axis to a location 100 units from X.

Now, you just told me that now you want to move 10 units, Okey Dockey. I will move you to
X=10.

Quit yelling at me! I did exactly what you asked, I only know what you tell me and I don't make mistakes!
So watch your language!
Don't you ever look at the info on the top of my screen. Sorry I can't speak or see.

Look, if what you wanted to do is move  just 10 units, then why don't you talk to me properly.
SO

In the future .....................

G90
GO X=100  You'll go to Coordinate X=100

But if you want to move forward 10 units, then
G91
GO X=10 you will go to Cooordinate X=110

OR

G90
G0 X=110

ANd if you decide later on that you are all confused, not me ....you, and want to start from where
i am at and do it all over again.

G90
G0 X=0
 
I am not to smart, but I do obey what you define and tell me.
So quit yelling at me!

Got to go walk my imaginary puppy,    :)
RICH
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 12, 2016, 05:08:18 PM
Okay I got it so far!

I have it displaying all the values in dros 1,2,3,4, for X1,X2,XC,Xc so I can see what its doing.

but this works!!!! yay

Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G90"
Code "G31 X-7 F13"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
SetDro(1,X1)
Sleep(200)                                 
Code "G91 G0 X.050"                   
While IsMoving()
Wend
Code "G31 X7 F13"
While IsMoving()
Sleep(100)
Wend
X2 = GetVar(2000)
SetDro(3,X2)
Sleep(200)   
XC = X2 - X1
SetDro(3,XC)
Xc = XC/2
SetDro(4,Xc)
Sleep(90)
Code "G91 G0 X" & -Xc                     
End If
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 12, 2016, 05:40:18 PM
Code "G31 Y-3 F13"   
While IsMoving()
Wend                                         
Y1 = GetVar(2000)
Sleep(200)                                 
Code "G91 G0 Y.050"                   
While IsMoving()
Wend
Code "G31 Y3 F13"
While IsMoving()
Sleep(100)
Wend
Y2 = GetVar(2000)
Sleep(200)
SetDro(2,Y1)
SetDro(3,Y2)
Sleep(50)   
YC = Y2 - Y1
Sleep(50)
Yc = YC/2
SetDro(4,YC)
SetDro(5,Yc)
Sleep(90)
Code "G91 G0 Y" & -Yc                     
End If

When I put Y in the exact same it cant do the math

Y1=-.5453
Y2=-.5453
YC=.9581
Yc=0

Title: Re: Mach3 VB Script Help
Post by: RICH on February 12, 2016, 05:56:50 PM
Hint.......

X is to 2000 as Y is to......... as Z is to.......
Page 10-17, G31  section 10.7.12.1 in the Manual
Last paragraph

RICH
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 12, 2016, 07:26:30 PM
hahaha duh ... I missed the 2001 thanks Rich ;)
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 12, 2016, 09:32:04 PM
Alright another video ... SoSo close

https://www.youtube.com/watch?v=vYaTfCyu-Ko (https://www.youtube.com/watch?v=vYaTfCyu-Ko)


Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G90"
Code "G31 X-7 F30"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
Sleep(200)                                   
Code "G91 G0 X.10"
XF1 = .87*GetOemDro(800)
While IsMoving()
Wend
Code"G90"
Code "G31 X7 F30"
While IsMoving()
Sleep(100)
Wend
X2 = GetVar(2000)
XF2 = 1.8*GetOemDro(800)
Sleep(200)   
XC=X2-X1
Sleep(90)
Xc = XC/2+.05
Sleep(90)
Code "G91 G0 X" & -Xc             
Code "G31 Y-3 F30"   
While IsMoving()
Wend                                         
Y1 = GetVar(2001)
Sleep(200)                                 
Code "G91 G0 Y.10"
Code "G90"
YF1 = .87*GetOemDro(801)                   
While IsMoving()
Wend
Code "G31 Y3 F30"
While IsMoving()
Sleep(100)
Wend
Y2 = GetVar(2001)
YF2 = 2.7*GetOemDro(801)
SetDro(3,Y2)
Sleep(200)   
YC=Y2-Y1
Sleep(90)
Yc = YC/2
Sleep(90)
Code "G91 G0 Y" & -Yc
While IsMoving()
Wend
Sleep(90)
Code "G90"
Code "G0 X" & XF1
While IsMoving()
Wend
Code "G31 X-3.5 F4"
Sleep(150)
X1 = GetVar(2000)
While IsMoving()
Wend
Code "G91 G0 X" & XF2
While IsMoving()
Wend
Code "G90"
Code "G31 X3.5 F4"
While IsMoving()
Wend
X2 = GetVar(2000)
Sleep(200)   
XC= (XF2/2)+X2-X1
Sleep(90)
Xc = XC/2
Code "G91 G0 X" & -Xc

While IsMoving()
Wend
Sleep(90)
Code "G90"
Code "G0 Y" & YF1
While IsMoving()
Wend
Code "G31 Y-3.5 F4"
Sleep(150)
Y1 = GetVar(2001)
While IsMoving()
Wend
Code "G91 G0 Y" & YF2
While IsMoving()
Wend
Code "G90"
Code "G31 Y3.5 F4"
While IsMoving()
Wend
Y2 = GetVar(2001)
Sleep(200)   
YC= (YF2/2)+Y2-Y1
Sleep(90)
Yc = YC/2
Code "G91 G0 Y" & -Yc
                   
End If

It works like this but I dont know Why Y has to be 2.5??

Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G90"
Code "G31 X-7 F30"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
Sleep(200)                                   
Code "G91 G0 X.10"
XF1 = .87*GetOemDro(800)
While IsMoving()
Wend
Code"G90"
Code "G31 X7 F30"
While IsMoving()
Sleep(100)
Wend
X2 = GetVar(2000)
XF2 = 1.8*GetOemDro(800)
Sleep(200)   
XC=X2-X1
Sleep(90)
Xc = XC/2+.05
Sleep(90)
Code "G91 G0 X" & -Xc             
Code "G31 Y-3 F30"   
While IsMoving()
Wend                                         
Y1 = GetVar(2001)
Sleep(200)                                 
Code "G91 G0 Y.10"
YF1 = .87*GetOemDro(801)
SetDro(2,YF1)                   
While IsMoving()
Wend
Code "G90"
Code "G31 Y3 F30"
While IsMoving()
Sleep(100)
Wend
Y2 = GetVar(2001)
YF2 = 2.5*GetOemDro(801)
SetDro(3,YF2)
Sleep(200)   
YC=Y2-Y1
Sleep(90)
Yc = YC/2
Sleep(90)
Code "G91 G0 Y" & -Yc
While IsMoving()
Wend
Sleep(90)
Code "G90"
Code "G0 X" & XF1
While IsMoving()
Wend
Code "G31 X-3.5 F4"
Sleep(150)
X1 = GetVar(2000)
While IsMoving()
Wend
Code "G91 G0 X" & XF2
While IsMoving()
Wend
Code "G90"
Code "G31 X3.5 F4"
While IsMoving()
Wend
X2 = GetVar(2000)
Sleep(200)   
XC= (XF2/2)+X2-X1
Sleep(90)
Xc = XC/2
Code "G91 G0 X" & -Xc

While IsMoving()
Wend
Sleep(90)
Code "G90"
Code "G0 Y" & YF1
While IsMoving()
Wend
Code "G31 Y-3.5 F4"
Sleep(150)
Y1 = GetVar(2001)
While IsMoving()
Wend
Code "G91 G0 Y" & YF2
While IsMoving()
Wend
Code "G90"
Code "G31 Y3.5 F4"
While IsMoving()
Wend
Y2 = GetVar(2001)
Sleep(100)   
YC= (YF2/2)+Y2-Y1
Sleep(90)
Yc = YC/2
SetDro(4,YC)
SetDro(5,Yc)
Code "G91 G0 Y" & -Yc
                   
End If
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 12, 2016, 10:01:30 PM
Okay This works exactly how I wanted it to   NVM!!!!!

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G90"
Code "G31 X-7 F20"   
While IsMoving()
Wend                                         
X1 = GetVar(2000)
Sleep(200)                                   
Code "G91 G0 X.10"
XF1 = .87*GetOemDro(800)
While IsMoving()
Wend
Code"G90"
Code "G31 X7 F20"
While IsMoving()
Sleep(100)
Wend
X2 = GetVar(2000)
XF2 = 1.95*GetOemDro(800)
Sleep(200)   
XC=X2-X1
Sleep(90)
Xc = XC/2+.05
Sleep(90)
Code "G91 G0 X" & -Xc             
Code "G31 Y-3 F20"   
While IsMoving()
Wend                                         
Y1 = GetVar(2001)
Sleep(200)                                 
Code "G91 G0 Y.10"
YF1 = .87*GetOemDro(801)
SetDro(2,YF1)                   
While IsMoving()
Wend
Code "G90"
Code "G31 Y3 F20"
While IsMoving()
Sleep(100)
Wend
Y2 = GetVar(2001)
YF2 = 1.95*GetOemDro(801)
SetDro(3,YF2)
Sleep(200)   
YC=Y2-Y1
Sleep(90)
Yc = YC/2
Sleep(90)
Code "G91 G0 Y" & -Yc
While IsMoving()
Wend
Sleep(90)
Code "G90"
Code "G0 X" & XF1
While IsMoving()
Wend
Code "G31 X-3.5 F4"
Sleep(150)
X1 = GetVar(2000)
While IsMoving()
Wend
Code "G91 G0 X" & XF2
While IsMoving()
Wend
Code "G90"
Code "G31 X3.5 F4"
While IsMoving()
Wend
X2 = GetVar(2000)
Sleep(200)   
XC= (XF2/2)+X2-X1
Sleep(90)
Xc = XC/2
Code "G91 G0 X" & -Xc
While IsMoving()
Wend
Sleep(90)
Code "G90"
Code "G0 Y" & YF1
While IsMoving()
Wend
Code "G31 Y-3.5 F4"
Sleep(150)
Y1 = GetVar(2001)
While IsMoving()
Wend
Code "G91 G0 Y" & YF2
While IsMoving()
Wend
Code "G90"
Code "G31 Y3.5 F4"
While IsMoving()
Wend
Y2 = GetVar(2001)
Sleep(100)   
YC= (YF2/2)+Y2-Y1
Sleep(90)
Yc = YC/2
SetDro(4,YC)
SetDro(5,Yc)
Code "G91 G0 Y" & -Yc
SetDro(XaxisDRO,0)                                ' when i added all these line from here to End If its wigging out
SetDro(YaxisDRO,0)
Code "G0 G53 Z-4" 
Message "Circle Center Found"                   
End If
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 12, 2016, 10:15:04 PM
Not quite fixed yet (;-) You are getting better BUT you are missing a couple of critical things (;-) that are going to bite you when you are not looking .

It would seem that you are always around X0Y0 when you start. Move far away from there and test your routine an you may see the problem show up.

You want your routine to be able to run from anywhere and still work and be accurate.

With you latest example Goto Y0 X-10 and then RUN your routine. Tell me what happens on the very first probe move (;-).

Also just a note XC and Xc in CB is the exact same thing. CB is NOT case sensitive.

Also you are adjusting your values to fit the particular instance (;-) . IF you are at a different position it may or may not work and MAY break your probe.

Also you need to get that thought of a % of a move out of your head it is NOT your friend in this case. (;-)

One more note, It is best to be at LEAST .050" from teh trip point when you call teh G31 function into play.

(;-) You still do not have a grip on Inc(G91) and Abs (G90)

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: RICH on February 13, 2016, 06:45:12 AM
Trying to be additive to TP's reply #59.
The questions below may impact what and how you do script. Actually they should be asked before one starts.

-------------------------------------------------------------------

What do you want to accomplish with the probing?
OR
Why am I probing the hole?


What data/info do you want and what do you want to do with the info after probing is done?
OR
How and when will the info be used?


What is the probing based on?

Configuration ( understand it's impact on what you are doing )
- Units
- absolute / incremental
- referenced or not referenced machine
- What coordinate system are you in? Machine / Part
- Initialization String
- Work Offset
- Default feed rate

Do you want to automate some manual moves in addition to just probing
before / after the probing?

Do you want the probing to be functional for any condition?

RICH
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 13, 2016, 07:04:59 PM
I get what all your saying but its just wigging oout. I just tried to run the program and it worked great when
I fired up the system and tried 5 times, then out of no where it starts going opposite ways on a G31 call???? I have G90 above it say G31 X-3.5 F20 and it moves POS?? I swear I get to the last 3 lines 10 time and it wigs out.. this time was only half way through..

I do get the ),) or ),-10 thing. Right now it only works at 0,0 But I wanna get that working then worry about any placement on table
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 13, 2016, 07:21:55 PM
Here is a issue I'm running into... It looks like placement changes every thing, can someone explain this. See notes in code

Code "G90"
Code "G31 X-7 F20"   
While IsMoving()
Sleep(200)
Wend                                         
X1 = GetVar(2000)
Sleep(90)                                   
Code "G91 G0 X.10"
While IsMoving()
Sleep(100)
V1=GetOemDro(800)                  'Here
Wend
XF1 = GetOemDro(800)               'and here should equal the same number??
Sleep(90)                                          'V1 shows -.6846 which is right           
SetDro(2,V1)                                     'XF1 shows +.7418 AAAAAHHH Im so lost
SetDro(3,XF1)
Code "G31 X7 F20"
While IsMoving()
Sleep(400)
Wend
X2 = GetVar(2000)
XF2 = 2.2*GetOemDro(800)
Sleep(90)   
XC1=X2-X1+.05
Sleep(90)
XC2 = XC1/2
Sleep(200)
Code "G91 G0 X" & -XC2   

Code "G90"
Code "G31 Y-3 F20"   
While IsMoving()
Sleep(90)
Wend                                         
Y1 = GetVar(2001)
Sleep(90)                                   
Code "G91 G0 Y.10"
YF1 = .87*GetOemDro(801)
While IsMoving()
Sleep(90)
Wend
Code "G90"
Code "G31 Y3 F20"
While IsMoving()
Sleep(150)
Wend
Y2 = GetVar(2001)
YF2 = 2.3*GetOemDro(801)
SetDro(4,YF2)
Sleep(200)   
YC1=Y2-Y1
Sleep(90)
YC2 = YC1/2
Sleep(120)
Code "G91 G0 Y" & -YC2

While IsMoving()
Sleep(150)
Wend
Sleep(90)
Code "G90"
Code "G91 G0 X" & XF1
While IsMoving()
Wend
Code "G31 X-3.5 F4"
Sleep(150)
X1 = GetVar(2000)
While IsMoving()
Wend
           
End If 



Tried it a second time with the bottom XF1 move changed to V1 and now
V1=-.5957
XF1=-.5417

Then I switched it back to XF1 since that last mesument was correct and now it works WTF!!!
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 13, 2016, 07:29:55 PM
OH well Just A remembered I havent downloaded the real licensed version on this computer its the pirated one, may that where the glitchs are coming from????
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 13, 2016, 07:31:00 PM
Do I just save my XML and download the licenced version and place that in C:/Mach? so I dont have to reprogram everything?
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 13, 2016, 07:37:38 PM
The problem is your code is wacked out and simply wrong in so many ways , not teh machine (;-)

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 13, 2016, 08:00:19 PM
Please inform me Why V1 should not equal XF1 in this case I would love to hear this.
Does Wend Change something?

Okay well Licensed version got rid of glitchs as well program is running smoother.

Thank you guys so much Im ganna make you all a free piece and mail it to you lol
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 13, 2016, 09:12:19 PM
YOu are the type that does not listen and is unwilling to learn (;-). You cannot seem to shake that % of a move move thing you have going on in your head. NOW you are even trying to LIE to teh machine by changing teh DRO values to BEND its will to MAKE it do what you want.

It ain't NEVER gonna happen this way sport  . You were given teh working code long ago all you had to do was finish the equation to find Center of 2 points and you blew all that off because it did not fit your% of a move move thingy (;-)

Sad part is if your were really cleaver there is another working example of teh Center of circle code right here on this site. Probably MORE than one at that.

I suggest you stop what you are doing and go back and learn basic Gcode controlling of your machine. Then when you fully understand Inc and Abs modes AND teh quadrant MATH and after you have read all the ink off all teh pertanent manuals on macro programing give this another shot. It ain't rocket science it is basic Gcode Macro programming. It is meant to be very simple and IF you understand Gcode and basic programming it is.

Good Luck, And may the Force be with you (;-)TP
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 13, 2016, 09:39:48 PM
And YES  just for the record I do know why you are getting 2 different values for V1 and XF1. V1 is captured while the axis is moving and teh XF1 is taken AFTER the axis has stopped. It is just doing exactly what you told it to do.

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 14, 2016, 12:31:04 AM
Well I cant find Teh stuff anywhere What does that stand for? and for the math other the -3 and +3 not being 0 or 3 away but 6 what other math is there?

Maybe a link?
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 14, 2016, 01:16:42 AM
Okay I thought about it real hard, I haven't tried this yet but I think Im getting there. Only thing I worry about is it being able to do the math right. I know for a fact my equations are right if all variables are in abs... I swear this has gatta be close.

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G90"
Code "G31 X-7 F20"   
While IsMoving()
Sleep(200)
Wend                                         
X1 = GetVar(2000)
Sleep(90)
XF1 = X1*.9   'this is to set my X G0 fast point to stop 90% from edge on second pass,If I did X1+.05 it could add it if X1 is Positive, It wouldn't work anywhere                                                     
Sleep(90)
Code "G91 G0 X.10"
While IsMoving()
Sleep(90)                 
Wend
Sleep(90)                                               
SetDro(3,XF1)              ' these are not to confuse the machine, there just telling me my variables, I dont use  A B and C while doing this test ill remove later
Code "G31 X7 F20"
While IsMoving()
Sleep(250)
Wend
X2 = GetVar(2000)
XF2 = X2*.9
Sleep(90)   
XC1 = X1+X2   'X2-X1 this doesnt work if X2=8 X1=-3 -3(-)+8=-11  So this would not work anywhere on table...this does->(-3+8)/2=5/2=2.5
XC2 = XC1/2
Sleep(200)
Code "G0 X" & XC2
While IsMoving
Sleep(250)
Wend   
Code "G31 Y-3 F20"   
While IsMoving()
Sleep(200)
Wend                                         
Y1 = GetVar(2001)
Sleep(90)
YF1 = Y1*.9
Sleep(90)                                   
Code "G91 G0 Y.10"
While IsMoving()
Sleep(90)
Wend
Code "G90"
Code "G31 Y3 F20"
While IsMoving()
Sleep(200)
Wend
Y2 = GetVar(2001)
Sleep(90)
YF2 = Y2*.9
Sleep(90)
SetDro(4,YF2)
Sleep(90)   
YC1=Y1+Y2
Sleep(90)
YC2 = YC1/2
Sleep(90)
Code "G0 Y" & YC2
While IsMoving()
Sleep(200)
Wend
Sleep(90)
Code "G0 X" & XF1
While IsMoving()
Sleep(200)
Wend
Code "G31 X-3.5 F4"
While IsMoving()
Sleep(200)
Wend
X1 = GetVar(2000)
Sleep(90) 
Code "G0 X" & XF2
While IsMoving()
Sleep(200)
Wend
Code "G31 X3.5 F4"
While IsMoving()
Sleeo(200)
Wend
X2 = GetVar(2000)
Sleep(90)   
XC1= X1+X2
Sleep(90)
XC2 = XC1/2
Sleep(90)
Code "G0 X" & XC2       
End If
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 14, 2016, 03:36:45 PM
O another thought, when you fetch X value 2000 in a G31 call, say its Negative, will it make the variable you assign Neg, or just assign the value?

You guys say to read up about all this, I really cant find much litterateur out there about teh quadrant math or really anything in depth its all basic stuff which I've read lot's. Could you guys hook me up with a link maybe?
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 14, 2016, 08:10:55 PM
well I made an adjustment to this after making a Z touch plate script. That I got to work great!! heres the touch plate script then adjustmants
Code: [Select]
PlateThickness = 0.030
Message "Auto Zeroing Z Axis"
If GetOemLed(825)<>0 Then
Message"Probe Grounded, Check Connection And Try Again"
Else
Code"G91 G31 Z-5 F4"
While IsMoving()
Sleep(200)
Wend
Z1= GetVar(2002)
Sleep(90)
Code "G0 Z" & Z1
While IsMoving()
Sleep(100)
Wend
SetDro(2,PlateThickness)
Code(G91 G0 Z.97)
Message "Z Axis Tool Zeroed"
End If

Code: [Select]
Message "Finding Circle Center"
CurrentFeed = GetOemDRO(818)
 If GetOemLed (825) <> 0 Then     
      Message "Z-Plate is grounded, check connection and try again"
   Else
Code "G91 G31 X-7 F20"   
While IsMoving()
Sleep(200)
Wend                                         
X1 = GetVar(2000)
Sleep(90)
XF1 = X1*.9   'this is to set my X G0 fast point to stop 90% from edge on second pass,If I did X1+.05 it could add it if X1 is Positive, It wouldn't work anywhere                                                     
Sleep(90)
Code "G91 G0 X.10"
While IsMoving()
Sleep(90)                 
Wend
Sleep(90)                                               
SetDro(3,XF1)              ' these are not to confuse the machine, there just telling me my variables, I dont use  A B and C while doing this test ill remove later
Code "G91 G31 X7 F20"
While IsMoving()
Sleep(250)
Wend
X2 = GetVar(2000)
XF2 = X2*.9
Sleep(90)   
XC1 = X1+X2   'X2-X1 this doesnt work if X2=8 X1=-3 -3(-)+8=-11  So this would not work anywhere on table...this does->(-3+8)/2=5/2=2.5
XC2 = XC1/2
Sleep(200)
Code "G0 X" & XC2
While IsMoving
Sleep(250)
Wend   
Code "G91G31 Y-3 F20"   
While IsMoving()
Sleep(200)
Wend                                         
Y1 = GetVar(2001)
Sleep(90)
YF1 = Y1*.9
Sleep(90)                                   
Code "G91 G0 Y.10"
While IsMoving()
Sleep(90)
Wend
Code "G91 G31 Y3 F20"
While IsMoving()
Sleep(200)
Wend
Y2 = GetVar(2001)
Sleep(90)
YF2 = Y2*.9
Sleep(90)
SetDro(4,YF2)
Sleep(90)   
YC1=Y1+Y2
Sleep(90)
YC2 = YC1/2
Sleep(90)
Code "G0 Y" & YC2
While IsMoving()
Sleep(200)
Wend
Sleep(90)
Code "G0 X" & XF1
While IsMoving()
Sleep(200)
Wend
Code "G91 G31 X-3.5 F4"
While IsMoving()
Sleep(200)
Wend
X1 = GetVar(2000)
Sleep(90) 
Code "G0 X" & XF2
While IsMoving()
Sleep(200)
Wend
Code "G91 G31 X3.5 F4"
While IsMoving()
Sleeo(200)
Wend
X2 = GetVar(2000)
Sleep(90)   
XC1= X1+X2
Sleep(90)
XC2 = XC1/2
Sleep(90)
Code "G0 X" & XC2       
End If
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 14, 2016, 09:12:34 PM
NOPE not yet you just traded one problem for another.

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 15, 2016, 02:09:48 AM
Crap.. Okay let me work on this a bit..
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 15, 2016, 09:07:51 AM
Thee are 4 quadrants in CNC work based on X0Y0 being the point of origin.  Top Right, Top LEft,Bottom Left,Bottom Rightalso known as Q1,Q2,Q3,Q4.

Q1 =  X+ & Y+
Q2 = X- & Y+
Q3 = X- & Y-
Q4 = X+ & Y-

There is also the possiblility that you could work in 1 or MORE quuadrants at teh same time where there would be any comibinations of teh XY values.

MOST people work inside of  Q1 for a good reason. Being X+ & Y+ it makes the math VERY easy and very consistant. I suggest you do the same at this point. That would put your POE (point of origin, X0 Y0) at teh lower left of your work and NONE of your work extends out of that quadrant.

Things should make a little more sense at that point math wise.

You are still having a problem with ABS and INC values and how you are using them.  You have to keep the 2 values seperate in your head as each has to be treated differently when you use them to move somewhere.

Your % of a move move is still going to bite you in teh rear. You need to get rid of it and work that move  out another way.

Strip it all out but teh first X seires of moves, Get that part working correctly and it GOING to teh exact center of X EVERY time and EVERY position inside of Q1 THEN start adding parts back into your routine.  One set of equations will work ANYWHERE inside of Q1.

STOP writing to teh DROs you do NOT need to do that. IF you really want to know the value or 2000 or 2001 then learn to use the built in Var monitor.

Also remember that WHERE you stop with G31 is NOT teh same as #2000,#2002.

(;-) TP

Title: Re: Mach3 VB Script Help
Post by: BR549 on February 15, 2016, 09:17:10 AM
Thee are 4 quadrants in CNC work based on X0Y0 being the point of origin.  Top Right, Top LEft,Bottom Left,Bottom Rightalso known as Q1,Q2,Q3,Q4.

Q1 =  X+ & Y+
Q2 = X- & Y+
Q3 = X- & Y-
Q4 = X+ & Y-

There is also the possiblility that you could work in 1 or MORE quuadrants at teh same time where there would be any comibinations of teh XY values.

MOST people work inside of  Q1 for a good reason. Being X+ & Y+ it makes the math VERY easy and very consistant. I suggest you do the same at this point. That would put your POE (point of origin, X0 Y0) at teh lower left of your work and NONE of your work extends out of that quadrant.

Things should make a little more sense at that point math wise.

You are still having a problem with ABS and INC values and how you are using them.  You have to keep the 2 values seperate in your head as each has to be treated differently when you use them to move somewhere. IF you are going to use an INC value to move you must be in G91 mode and IF you are going to use an ABS vlaue to move you must be in G90 mode.

Your % of a move move is still going to bite you in teh rear. You need to get rid of it and work that move  out another way.

(;-) TP

Title: Re: Mach3 VB Script Help
Post by: RICH on February 16, 2016, 11:35:29 AM
Quote
You guys say to read up about all this, I really cant find much litterateur out there about teh quadrant math or really anything in depth its all basic stuff which I've read lot's. Could you guys hook me up with a link maybe?

TP's reply #75 is the equivilant for what you would find in one of the beginning chapters of the book I suggested you get / read / study. Additionaly he gives you practical reason for use of that info.

Why was the book suggested......because its a highly regaurded proffessional reference for CNC by one of the best CNC authors. You will fumble around looking at all kinds of info from different sites, different books / articles / for answers to basic stuff, and it can go on forever, and you will not have gained the basic knowledge that you should have. That's because your looking for an answer rather than the understanding.
The MAch reference manuals are about the specifics of MACH software and fall short on the the topic of CNC and assumes you have basic knowledge.

Let's assume that you understand the G90, G91, G31, G0 & G1  Mach Coordinates, etc.

++++++++++++++++++++++

So now you desire to do some programming...well welcome to another new learning curve!
It would be nice if one had some programming experience and a lot of the info listed below will not provide program teaching, but, they are resource you should have on hand.

1. Macro3 Macro Programmers Reference Manual
2. Mach2 Customisation Guide
3. MachScreen
4. OEM Series Button, DRO, and LED Numbers

There is a lot to be learned by having a read of posts and replies in the following:
You may even find a wizard or Macro that does what you want.  ;D
- VB and the development of wizards
- Share your GCode
- MACH TOOL BOX

Lot of ways to do things and looking at scripting done by others is very helpfull.
You can look at the VB script to see how it was done or what it is meant to do. Have a look under Operator tab in Mach and you'll see the following to look at scripting:
- Edit Button Script
- Ccode Var Monitor
- VB Script Editor
- look at some macro's in the macro folder of where Mach  is installed.
I listed Mach Screen as you will find associated scripts for buttons etc.

You asked........... ;)
RICH
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 16, 2016, 07:39:56 PM
LOL Rich I have already done everything you posted but go buy that book.. well two you posted I havent seen so thank you lol

Thats how I learned C++ is reading code, and a library. I cant find one bit of code online for mach 3 other than 3 or 4 touch plate scripts. I might not be typing in the right things but Im talking 22hrs at least of looking, reading, thinking.

As of your Q1,Q2,Q3,Q4 I already understood that. Machine Coords are always in Q1, I work in Q1, I zero holes 0,0... 4 quadrants, That means a equation in the wrong quadrant would add instead of subtract ect... Can someone just explain why the % equation wont work?? 98% of a Neg is a Neg. as well the (X1 + X2)/2 No matter the quadrant the answer is always the center. You can make any of those two(X1 or X2) Neg or Pos and it always comes out center?? How im I screwing this up!!

Give me an example of numbers that you plug into my equations that come out wrong. That would make me understand
Title: Re: Mach3 VB Script Help
Post by: ger21 on February 16, 2016, 07:52:00 PM
I was curious myself about the quadrant thing. No matter what quadrant you work in, the math should always be the same..
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 17, 2016, 01:22:48 AM
Machine corrds are NOT always in Q1 and you are NOT simply working in Q1 IF you are probing at X0Y0 1 leg of X COuld be in Q1 and the second leg could be in Q2 OR several different combinations of Quadrants.

Either way YOU are working in Work corrd not machine corrds and all teh math is based on Work Coords(G90) or inc values (G91)

A classic example of teh %problem  . Remember you are dealing with an abs positional value (#2000). IF X1 = 1.000 then X1* .90 = .9 so your slow zone would be .10" and that seems resonable    NOW if you were probing at X30 then using the same formula  X1 *.90 = 27 so that gives you a slow zone of 3" .  The entire idea is to make everything consisitant . With using % it will depend on WHERE you are on teh table as to teh value you get.

You want your back off values to always be the same and teh Slow Zone distance to always be the same distance so that ANY variable induced by the probe will cancel itself out .

Gerry have you tried teh math based on teh exact same move (Center of X )  Do it in Q1 where both vlaues are + then do it in Q2 where both values are - and teh offset distance from Zero inverts but your probing routine order of moves stays teh same ( Probe left then right)

You will run into teh same problem solving angles for G68 rotation as the formula changes from Quad to Quad. You have to TEST teh values to find out what Quad you are actual in so you can use the correct formula.

IN this case (Center of X)  

IF X1 >0 AND X2 >0 then you are in Q1
If X1 <0 AND X2 <0 then you are in Q2

IF X1 <0 AND  X2 >0 then you are in both Q1 and Q2

In the case of Center of X in Q1

G91 G31 X-10  ( Probe left)
Assume X1 =3
G91 G31 X20  ( probe right)
 and X2 =6
X2-X1 = X3  ( Distance between X1 and X2)
     X3 = 3"
X3/2 = X4    ( 1/2 distance = distance from either of teh refpoints to teh center point)
     x4 = 1.5"
x1 + x4 = x5 ( Move from an ABS Ref point(X1) over to the center point)
     X5 = X4.5
G90
G0 X4.5   ( moves you to the center of X)

This will work no matter where you are in Q1 as long as you do not move outside of Q1.

To find a slow down zone

X2-X1 = X3
X3/2 = X4
X4-.050 = X5
X5 =1.450

or

(((X2-X1)- .100) /2) = 1.45


Just a thought, (;-) TP


Title: Re: Mach3 VB Script Help
Post by: BR549 on February 17, 2016, 01:15:34 PM
Nissan you are correct with teh (X1+X2)/2  that will work in all quads. I was doing it in my head and SHOULD have done it on paper. It will solve for center of 2 abs positions even across Quads.  My appologies

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 17, 2016, 01:47:44 PM
BUT that just seems to PUSH teh Quad problem to the next part of teh puzzle , Solving for teh inc move value from teh center point tot eh end point.

I solved that up front based on Q +/-  and it changed for Q1 to Q2.  It seems you still have to deal with Q any way you do it. Either up front or at teh tail end.

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: BR549 on February 17, 2016, 02:17:43 PM
OK It is doable on teh back end as well.

(;-) TP
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 28, 2016, 06:08:17 AM
Okay I got side tracked for a bit. I was working on this tonight and I think I got it. It works off machine(Like Dros do what they should). This is used for me to square one of my clamps on my table, I don't have any of my clamps keyed so I have to dial them in straight every time I take them off. But my goal with this is to measure my most positive side then my most negative side and try and get them to zero out but with a probe not a dial indicator. That way, I tell it how wide to test and it'll touch, back off, move over, touch, back off,  retract Z and tell me the values. I can then tap my clamp left or right and just click the yes or no when the "Is fixture is squared?" question pops to run it again and again till I have it zeroed. Lol beats manually moving it left then forward by .0001 increments then zeroing then going to the other side and repeating 5 times. Now I just sit back and smack with a mallet. YAY!!!

I made one for X and Y


Oh  P.S. one of my Damn Drivers is broke all the sudden. I go to turn it on today and X and Z turn on but Y had no lights at all. I tried plugging the other axis' into it and nothing. tested my voltage getting 35.96V ??? ??? ???
Title: Re: Mach3 VB Script Help
Post by: nissan20det on February 29, 2016, 07:05:38 PM
Here is the tested working versions! YAY!! my first successful script