Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: amnon on October 21, 2014, 01:05:38 AM

Title: GetVar(2002)
Post by: amnon on October 21, 2014, 01:05:38 AM
Hay,

Code "G31Z-10 F100" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit

Could some one explain me why is that when I put MsgBox ZProbePos I have always 0

Regards
Amnon
Title: Re: GetVar(2002)
Post by: TPS on October 21, 2014, 02:59:22 AM
hope you are putting the value into MSGbox like this:

MsgBox cstr(ZProbePos)

should work. i do it in the same way.

regards Thomas
Title: Re: GetVar(2002)
Post by: amnon on October 21, 2014, 05:07:23 AM
Thank's

What does "cstr" mean

Regards
Amnon
Title: Re: GetVar(2002)
Post by: TPS on October 21, 2014, 05:54:25 AM
Hi,

cstr converts numbers to string, because msgbox can only display string.
look here: http://www.machsupport.com/help-learning/product-manuals/

for vb script manuals
Title: Re: GetVar(2002)
Post by: ger21 on October 21, 2014, 07:05:00 AM
You usually don't need to convert to a string to put something in a messagebox.
Title: Re: GetVar(2002)
Post by: TPS on October 21, 2014, 09:49:36 AM
You usually don't need to convert to a string to put something in a messagebox.

you are right with the example above.

but only in this case:
Test = 1234.5
MsgBox Test

not in this case:
Test = 1234.5
MsgBox "Test = " + CStr(Test)

Thomas

Title: Re: GetVar(2002)
Post by: ger21 on October 21, 2014, 09:57:39 AM
Correct, if you want both string and numeric data, you need to convert all to sting data as you've shown.
Title: Re: GetVar(2002)
Post by: stirling on October 21, 2014, 10:39:58 AM
depends on which concatenation operator you use (+ or &)

Test = 1234.5
MsgBox "Test = " & Test

is fine.
Title: Re: GetVar(2002)
Post by: ger21 on October 21, 2014, 10:49:08 AM
Also correct. :)
Title: Re: GetVar(2002)
Post by: amnon on October 22, 2014, 06:51:15 AM
How macro knows that after :

Code "G31Z-10"
While IsMoving()
Wend

Z axis should be put into 2002(ZProbePos)
ZProbePos = GetVar(2002)

Respect
Amnon
Title: Re: GetVar(2002)
Post by: stirling on October 22, 2014, 07:30:18 AM
post your macro
Title: Re: GetVar(2002)
Post by: amnon on October 22, 2014, 12:13:03 PM
Code: [Select]
code "g90"

ChX = GetUserDRO( 1200 )
ChY = GetUserDRO( 1201 )
ChZ = GetUserDRO( 1202 )
Feed = GetDRO(18)

Code "G53 G00 Z-0.1" 'Move the tool all the way up
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend

Code "G31 Z" & Z-100 & "f100" 'Z move down untill hit

While IsMoving()
Wend

ZposOld = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G53 G00 Z-0.1"'Z move all way up

While IsMoving()
Wend

MsgBox ("Insert the new tool")
MsgBox ("Ok to finish tool change")

Code "G53 G00 Z-0.1" 'Move the tool all the way up
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position

While IsMoving()
Wend

Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position

Code "G31 Z" & Z-100 & "f100" 'Z move down untill hit

While IsMoving()
Wend

ZposNew = GetVar(2002) 'Get the Position that the Porbe hit at
Offs = ZposOld - ZposNew

Call setdro (2,Offs)   'Set the value of the DRO to the value that is in "Offs"
Code "G53 G00 Z-0.1"   'or hoever high you want to go to get up safely off the probe

MsgBox ("Ok to return to program")


Code "G00 x0 y0"


My intention is to understand step by step what is going on in each line, and make my own macro.
I change tools manually - Kress, and my tool height measurement is in the same location, so I have to measure each tool twice to calculate difference.
Maybe there is a easier way to do this?

Respect
Amnon
Title: Re: GetVar(2002)
Post by: stirling on October 22, 2014, 02:50:24 PM
your original post asked about MsgBox ZProbePos always printing 0

Not only is there no call to MsgBox in this code there is also no variable called ZProbePos