Hello Guest it is December 07, 2019, 01:43:40 PM

Author Topic: New to this....  (Read 3542 times)

0 Members and 1 Guest are viewing this topic.

New to this....
« on: March 03, 2008, 04:12:46 PM »
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

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: New to this....
« Reply #1 on: March 03, 2008, 08:11:54 PM »
Here is a copy of the Tool setter macro from the wiki:

How to Get Data From a probe Cycle
When a Probe Cycle is done (G31) the point that the probe contacts the material is saved in Mach. The DRO's WILL NOT be the correct probe position! The reason the DROs will not be in the correct pos is because the axis can not stop instantly. Once the probe is pressed the axis must decelerate to a stop past the point where the probe hit. The correct probe position is saved as a "Var". The Vars are as follows:

Var(2000) = X
Var(2001) = Y
Var(2002) = Z

To Get the data in VB use GetVar().

[edit]Note
As of this writing (April 30, 2007), the current release of Mach 3 does not adjust the value of Var(2002) with the G43 H## tool length. So you will need to do this in your code yourself.

You may decide to copy the probe's length from the tool table into a user parameter, such as #999, and then use Var(999) to adjust the value returned by Var(2002). When Mach 3 is upgraded to account for tool lengths, you can use your old programs, unedited, by setting #999 to zero.

This kind of adjustment will be needed anyway to compensate for the stylus's radius when probing in the X and Y directions. For the greatest accuracy, you may decide to use different radii for +X, +Y, -X, and -Y. Choosing a set of user parameters for these radii that are common in all of your programs will let you avoid distributed program edits when the probe's stylus is replaced.


--------------------------------------------------------------------------------

VB Probe Example:

Code "G31 Z-4.0 F20"

While IsMoving()
Wend

ZProbePos = GetVar(2002)'This will get the data from the probe

You can set up a Tool measurement position on your table, and send the Z probpos to the tool offset dro, and then do a dobutton to set the amount.

The Wiki is your friend.............

Scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: New to this....
« Reply #2 on: March 04, 2008, 09:05:49 AM »
Thanks for the response.  I've been going through the wiki and any other information that I can.  I guess you can blame me for trying to reinvent the wheel.  The machines I'm used to working with do not use a G31 but use a sub program that is very similar in respects to the code I posted.  I say it all the time, it's easier to learn a new system if you don't know the old one.  I guess this time someone else get's to say it about me.