Hello Guest it is September 15, 2019, 05:20:03 AM

Author Topic: Mach3 VB Script Help  (Read 12565 times)

0 Members and 1 Guest are viewing this topic.

nissan20det

• 88
Re: Mach3 VB Script Help
« Reply #50 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

RICH

• 7,358
Re: Mach3 VB Script Help
« Reply #51 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

RICH

• 7,358
Re: Mach3 VB Script Help
« Reply #52 on: February 12, 2016, 04:46:14 PM »

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!
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
« Last Edit: February 12, 2016, 04:50:23 PM by RICH »

nissan20det

• 88
Re: Mach3 VB Script Help
« Reply #53 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
« Last Edit: February 12, 2016, 05:13:48 PM by nissan20det »

nissan20det

• 88
Re: Mach3 VB Script Help
« Reply #54 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

RICH

• 7,358
Re: Mach3 VB Script Help
« Reply #55 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

nissan20det

• 88
Re: Mach3 VB Script Help
« Reply #56 on: February 12, 2016, 07:26:30 PM »
hahaha duh ... I missed the 2001 thanks Rich

nissan20det

• 88
Re: Mach3 VB Script Help
« Reply #57 on: February 12, 2016, 09:32:04 PM »
Alright another video ... SoSo close

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
« Last Edit: February 12, 2016, 09:34:41 PM by nissan20det »

nissan20det

• 88
Re: Mach3 VB Script Help
« Reply #58 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"   ElseCode "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()WendCode"G90"Code "G31 X7 F20"While IsMoving()Sleep(100)WendX2 = GetVar(2000)XF2 = 1.95*GetOemDro(800)Sleep(200)   XC=X2-X1Sleep(90)Xc = XC/2+.05Sleep(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()WendCode "G90"Code "G31 Y3 F20"While IsMoving()Sleep(100)WendY2 = GetVar(2001)YF2 = 1.95*GetOemDro(801)SetDro(3,YF2)Sleep(200)   YC=Y2-Y1Sleep(90)Yc = YC/2Sleep(90)Code "G91 G0 Y" & -YcWhile IsMoving()Wend Sleep(90)Code "G90"Code "G0 X" & XF1While IsMoving()WendCode "G31 X-3.5 F4"Sleep(150)X1 = GetVar(2000)While IsMoving()WendCode "G91 G0 X" & XF2 While IsMoving()Wend Code "G90"Code "G31 X3.5 F4"While IsMoving()WendX2 = GetVar(2000) Sleep(200)   XC= (XF2/2)+X2-X1Sleep(90)Xc = XC/2Code "G91 G0 X" & -Xc While IsMoving()Wend Sleep(90)Code "G90"Code "G0 Y" & YF1While IsMoving()WendCode "G31 Y-3.5 F4"Sleep(150)Y1 = GetVar(2001)While IsMoving()WendCode "G91 G0 Y" & YF2 While IsMoving()Wend Code "G90"Code "G31 Y3.5 F4"While IsMoving()WendY2 = GetVar(2001) Sleep(100)   YC= (YF2/2)+Y2-Y1Sleep(90)Yc = YC/2SetDro(4,YC)SetDro(5,Yc)Code "G91 G0 Y" & -YcSetDro(XaxisDRO,0)                                ' when i added all these line from here to End If its wigging outSetDro(YaxisDRO,0)Code "G0 G53 Z-4"  Message "Circle Center Found"                   End If`
« Last Edit: February 12, 2016, 10:12:44 PM by nissan20det »

BR549

• 6,886
Re: Mach3 VB Script Help
« Reply #59 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
« Last Edit: February 12, 2016, 10:30:13 PM by BR549 »