Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 12:56:12 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  How in VB to ensure the script changes to Machine coords or work coords??
Pages: 1   Go Down
Print
Author Topic: How in VB to ensure the script changes to Machine coords or work coords??  (Read 1048 times)
0 Members and 2 Guests are viewing this topic.
Darc
Active Member

Offline Offline

Posts: 177


View Profile
« on: April 28, 2007, 06: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
« Last Edit: April 28, 2007, 10:52:41 PM by Darc » Logged
Graham Waterworth
Administrator
*
Online Online

Posts: 1,665


West Yorkshire, England



View Profile WWW
« Reply #1 on: April 29, 2007, 01: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.
« Last Edit: April 29, 2007, 01:36:51 AM by Graham Waterworth » Logged

G-Code is on the cutting edge

Autovalues Engineering, CNC machining specialists, Bradford, England
Darc
Active Member

Offline Offline

Posts: 177


View Profile
« Reply #2 on: April 29, 2007, 02: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?
Logged
Graham Waterworth
Administrator
*
Online Online

Posts: 1,665


West Yorkshire, England



View Profile WWW
« Reply #3 on: April 29, 2007, 03:18:26 AM »

Have you tried DoButton(256)

Graham.
Logged

G-Code is on the cutting edge

Autovalues Engineering, CNC machining specialists, Bradford, England
Darc
Active Member

Offline Offline

Posts: 177


View Profile
« Reply #4 on: April 29, 2007, 06:35:11 AM »

Thanks again Graham, it worked using DoOEMButton(256).
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!