Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: Tarak on April 28, 2007, 07:06:53 AM

Title: How in VB to ensure the script changes to Machine coords or work coords??
Post by: Tarak on April 28, 2007, 07:06:53 AM
I think I've looked everywhere (obviously not)
I'm trying to press a button to zero my grinding wheel, then it changes the offset to suit, as per below:

1 Set grinding wheel at zero (approx -37.3 in machine coords) (I've successfully done this)
2 press button ZERO WHEEL (I've successfully done this)
3 changes to machine coords (I can't work out how to do this, at the moment I'm doing this manually)
4 copy's the value in machine coords to a second DRO, but a positve value. (I've got it copying, just not in a positive value)
5 change back to work coords (I can't work out how to do this, at the moment I'm doing this manually)
6 Moves out to home switch (I've successfully done this)
7 Copies the value from the second DRO into the work coords (I've successfully done this)
8 Voilla!!

I'm trying to take a negative value from one DRO and put the same value into another DRO, but a positive value.
The way I do this on a cnc is as follows, I'm just can't get the syntax correct for VB.

#1=-10.00
X[#1-[#1*2]]

This is as far as I've gotten

'change to machine coords here
y=GetDRO(1)
While IsMoving()
Wend
SetOEMDRO(1202,y)
'change to work coords here
DoButton( 23 )
While IsMoving()
Wend
y=GetUserDRO(1202)
CODE "G92Y" &y   

Thanks
Title: Re: How in VB to ensure the script changes to Machine coords or work coords??
Post by: Graham Waterworth on April 29, 2007, 02:29:49 AM
To convert a negative number to positive in VB use ABS(n)

e.g. A=Abs(-123.456)

A=123.456

you can also do this

CODE "G92 Y" & ABS(GetDRO(84)) ' read machine Y dro

Graham.
Title: Re: How in VB to ensure the script changes to Machine coords or work coords??
Post by: Tarak on April 29, 2007, 03:47:18 AM
Thanks, Graham.
I ended up using your code like this:
CODE "G92Y" &Abs(y)
I still can't work out how to get it to change from Work to Machine coords and visa versa.
The standard button that switches inbetween work and machine coords is OEM code 256, I just don't know how to work out what this code does?
Title: Re: How in VB to ensure the script changes to Machine coords or work coords??
Post by: Graham Waterworth on April 29, 2007, 04:18:26 AM
Have you tried DoButton(256)

Graham.
Title: Re: How in VB to ensure the script changes to Machine coords or work coords??
Post by: Tarak on April 29, 2007, 07:35:11 AM
Thanks again Graham, it worked using DoOEMButton(256).