Hello Guest it is March 28, 2024, 10:20:50 AM

Author Topic: How in VB to ensure the script changes to Machine coords or work coords??  (Read 3827 times)

0 Members and 1 Guest are viewing this topic.

Offline Tarak

*
  •  229 229
    • View Profile
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
« Last Edit: April 28, 2007, 11:52:41 PM by Darc »

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
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.
« Last Edit: April 29, 2007, 02:36:51 AM by Graham Waterworth »
Without engineers the world stops

Offline Tarak

*
  •  229 229
    • View Profile
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?

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Have you tried DoButton(256)

Graham.
Without engineers the world stops

Offline Tarak

*
  •  229 229
    • View Profile
Thanks again Graham, it worked using DoOEMButton(256).