Ok, this is my first post, so don't scream at me too much please. I've worked for a major CNC company for 8 years now and decided To get a hobby machine. Long story short, I'm trying to get the mach software to act similar to the controller I'm used to,,Gulp,, the 91000 Supercontroller by Thermwood. I'm familiar with VB so I wanted to run my first attempt by everyone so they can tell me if I'm an idiot. The following code is for a tool length measuring setup. The sensor would be similar to the touch probe I've seen on here only upside down. Anyway, here's the code. Rip it to shreds if need be. Thanks in advance.
REM This macro measures the tool
REM 03/00/08
Dim xposition as double 'absolute x position of the center of the sensor
Dim yposition as double 'absolute y position of the center of the sensor
Dim switchtable as double 'distance from the top of the sensor to the top of the table
Dim switchinput as single 'switch input number
Dim zposition as double 'absolute position of tool at sensor top
Dim machinez as single 'absolute z machine coordinate dro call value
Dim toolnumber as single 'active tool toollength Dro call value
toolnumber = 836
machinez = 85
REM ************************************
REM ******User definable variables******
REM ************************************
xposition =
.
?
yposition =
.
?
switchtable = ?.
?
switchinput = ?
REM ************************************
REM ***End of User definable variables**
REM ************************************
Code "G59 P0" 'Machine coordinates
Code "G90" 'Absolute positioning
Code "T1" 'Tool 1 call, can be removed for tool changer
Code "G00 X[xposition] Y[yposition]" 'Move to sensor position in X and Y
Do
Code "G01 z-.1 F45" 'Move Z down in .1 increments until
Loop While Isactive(switchinput) = true 'sensor input becomes low
Do
Code "G01 z.01 F45" 'Move Z up in .01 increments until
Loop While Isactive(switchinput) = False 'sensor input becomes high
Do
Code "G01 z-.001 F45" 'Move Z down in .001 increments until
Loop While Isactive(switchinput) = true 'sensor input becomes low
Do
Code "G01 z.0001 F45" 'Move Z up in .0001 increments until
Loop While Isactive(switchinput) = False 'sensor input becomes high
zposition = GetOEMDRO(machinez) 'read absolute Z position
zposition = (zposition + switchtable) 'Add absolute Z and sensor height
SetOEMDRO(toolnumber) = zposition 'set active tools new toollength
Code "G59 P0" 'Machine coordinates
Code "G90" 'Absolute positioning
Code "G0 Z0" 'Move to absolute Z zero
Code "G0 X0 y0" 'Move to absolute X and Y zero