Hello Guest it is April 18, 2024, 09:45:37 PM

Author Topic: Auto tool Zero - macro questions  (Read 10995 times)

0 Members and 1 Guest are viewing this topic.

Auto tool Zero - macro questions
« on: November 07, 2014, 12:59:28 PM »
Auto tool Zero - macro questions

I have found a link to http://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf

And I was wondering where should I post questions related to Macros?

Example:

Code: [Select]
PlateThickness = 0.500
Plate = PlateThickness * 0.0393700787402     ' mm * 0.0393700787402 = inches

Code "(Z axis is now zeroed)"       & Plate  'puts this message in the status bar
Message "Auto Tool Zero Running "   & Plate  'puts this message in the status bar
MsgBox "Auto Tool Zero Running "    & Plate  'puts this message in a message box

However,,, the Code "(Z axis is now zeroed)"       & Plate  'puts this message in the status bar

results in a "Bad character used  , Block = (Z axis is now zeroed)0.0196850393701

As I find programming fun and relaxing when I have some friends by my side.

Again:  I was wondering where should I post questions related to Macros?
Secondly, does anyone know why the Code syntax has failed?
Again thank you for your kind words and your helpful tips and tricks.. you are appreciated
more than you will ever know during our struggle with the start-up learning curve.

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Auto tool Zero - macro questions
« Reply #1 on: November 07, 2014, 02:39:15 PM »
Try this:

Code "(Z axis is now zeroed"       & Plate & ")"  'puts this message in the status b
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Auto tool Zero - macro questions
« Reply #2 on: November 07, 2014, 04:52:09 PM »
Thanks Buddy ;-)
Again thank you for your kind words and your helpful tips and tricks.. you are appreciated
more than you will ever know during our struggle with the start-up learning curve.
Re: Auto tool Zero - macro questions
« Reply #3 on: November 07, 2014, 08:26:02 PM »
Ok this is what I think I understand:

I have scratch build my own X31 X Y31 X Z4 CNC machine however I have no idea how
to run it. Currently, I am not using the tool array and I am trying to change
the tool in the middle of a project and have a bit/end mill of a different length
return to the exact cutting depth and continue cutting.

I have no Idea what is wrong my guesswork, the new install of mach 3 configurations, the safe_Z, or the
Auto tool zero script that I have picked peaces from here and there and frankly have no idea
what came from where at this point.

I believe this is what I click on within the mach 3 desktop

(1) Load G-Code
(2) Move to work 0.0.0
(3) Zero x y z
(4) Regen
(5) Cycle start
     Until a M6 tool change
(6) In the Tool Information area Click on [REMEMBER]
(7) JOG to a place above your work 0.0.0
(8) Replace end mill/bit
(9) Place the TOUCH PLATE on top of work 0.0.0
( 10 ) In the Tool Information area Click on [AUTO TOOL ZERO]
( 11 ) In the Tool Information area Click on [REMEMBER]
( 12 ) CLICK [Cycle start] or press Alt-R

I have no clue.. so if I am missing something please point me in the right direction

This is what I have for a Auto Tool Zero script that is suppose to be able to
tell if the G-Code that I downloaded was scripted using inches or mm and
adapt the Auto Tool Zero script to continue in a non-conflicting manner.
Well that is what I am trying to attempt.

Code: [Select]
                                              'AUTO TOOL ZERO MACRO
                                              'Use at your own risk
                                              'Special thanks to ger21, cnczone.com, and machsupport.com
                                              'for assisting Edoctoor in the creation of this auto tool zero macro
                                              'designed for the simple hobby CNC machine with a touch plate
                                              'attached to pin 11 of your BOB (Break Out Board)
                                              'It is also necessary to configure CONFIG > PORTS & PINS > INPUT SIGNALS
                                              'PROBE CHECKED; PORT # 1; PIN NUMBER 11; ACTIVE LOW CHECKED
                                   
                                              'My units are in INCHES so I configured my Safe Z
                                              'as follows:
                                              'CONFIG > Safe_Z Setup
                                              'GLOBAL SETTINGS
                                              'CHECKED Allow Safe_Z Moves
                                              'CHECKED SafeZ DRO is in Machine Coordinates
                                              'Safe_Z -0.25
                                              'OPTIONAL
                                              'CHECKED Goto SafeZ when Stop button is hit.

Message "Auto Tool Zero Running"              'Puts this message in the status bar

                                              'Change the following to configure for your CNC
                                              'CHANGE THE FOLLOWING TO CONFIGURE THIS SCRIPT FOR YOUR CNC
                                              '==========================================================
                                              '==========================================================
                                   
                                              'The example below is for a TOUCH PLATE which is 1/2 inch in height
                                   
                                              'If your UNITS of measure for your TOUCH PLATE is Imperial/inches make Inches = 1
Inches = 1                                    'If your UNITS of measure for your TOUCH PLATE is Metric/mm       make Inches = 0

PlateThicknessUnits = 0.500                   'Change 0.500 UNITS to your plate height; Then adjust for final accuracy

                                              'The example below is for a TOUCH PLATE WHICH is 12.7 mm in height
                                              'If your UNITS of measure for your TOUCH PLATE is Metric/mm       make Inches = 0
                                              'Inches = 0                         
                                              'Change 12.7 UNITS to your plate thickness; Then adjust for final accuracy
                                              'PlateThicknessUnits = 12.7
                                   
                                              'The example below will move the Z axis (PlateThicknessUnits + 0.500) above the
                                              'the work part; Because my units are in inches that means that it will
                                              'move 1" inch above the work and 0.500 inch above the TOUCH PLATE.
                                             
ZRetractHeight = PlateThicknessUnits + 0.500  'Change 0.500 UNITS to be a safe distance above the TOUCH PLATE
                                         
                                              '==========================================================
                                              '==========================================================

                                              'Get the current state of your CNC
                                              '==========================================================

                                              'Is your G-Code Imperial or Metric?
                                   
If GetOEMLED(801) Then                        'On = The G-Code loaded is in Imperial Measure, INCH
      If Inches Then           
            'Message "G-Code Inches and Touch Plate height is Inches"
            PlateThickness = PlateThicknessUnits
            Message "Auto Tool Zero Running - Place your " & PlateThicknessUnits & " inch plate in position."   'puts this message in the status bar
      Else           
            'Message "G-Code Inches and Touch Plate height is mm"
            PlateThickness = PlateThicknessUnits * 0.0393700787402
            Message "Auto Tool Zero Running - Place your " & PlateThicknessUnits & " mm plate in position."     'puts this message in the status bar
      End If
Else                                          'Off = The G-Code loaded is in Metric Measure, mm
      If Inches Then           
            'Message "G-Code mm and Touch Plate height is Inches"
            PlateThickness = PlateThicknessUnits * 25.4
            Message "Auto Tool Zero Running - Place your " & PlateThicknessUnits & " inch plate in position."   'puts this message in the status bar
      Else           
            'Message "G-Code mm and Touch Plate height is mm"
            PlateThickness = PlateThicknessUnits
            Message "Auto Tool Zero Running - Place your " & PlateThicknessUnits & " mm plate in position."     'puts this message in the status bar
      End If
End If         
 
CurrentFeed = GetOemDRO(818)                  'Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48)                 'Get the current G90/G91 state
CurrentGmode = GetOemDRO(819)                 'Get the current G0/G1 state
 
                                              'Start Auto Tool Zero Script
                                              '==========================================================
                                   
If GetOemLed (825)=0 Then                     'Check to see if the probe is already grounded or faulty
DoOEMButton (1010)                            'zero the Z axis so the probe move will start from here
Code "G4 P3"                                  'this delay gives me time to get from computer to hold probe in place
Code "G90 G31Z-4. F4"                         'probing move, can set the feed rate here as well as how far to move
While IsMoving()                              'wait while it happens
Wend
ZProbePos = GetVar(2002)                      'get the exact point the probe was hit
Code "G0 Z" &ZProbePos                        'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness)
Sleep 200 'Pause for Dro to update.
Code "G1 Z" &ZRetractHeight & " F50"          'put the Z retract height you want here, must be greater than the touch plate thickness



While IsMoving ()
Wend
Code "(Z axis is now zeroed)"                 'puts this message in the status bar
Code "F" &CurrentFeed                         'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if applicable
End If
If CurrentAbsInc = 0 Then                     'if G91 was in effect before then return to it
Code "G91"
End If
If CurrentGMode = 0 Then                      'if G0 was in effect before then return to it
Code "G0"
End If   

For now I just want to get someone to give me some feedback and tell me what I am doing wrong
or what I have scripted wrong in order to cut this project found here

Currently, the Z axis looses consistency and I am not sure if I have my motor control too fast and I have lost steps
or what but every time I get something new to throw in the garbage.

Many thanks in advance

Again thank you for your kind words and your helpful tips and tricks.. you are appreciated
more than you will ever know during our struggle with the start-up learning curve.

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Auto tool Zero - macro questions
« Reply #4 on: November 07, 2014, 11:00:38 PM »
First, it's really not a good idea to run both inch and mm g-code in Mach3, and expect the auto zero to work in both scenarios.

If you must do this, you're better off to have two separate machine profiles (xml's), one for inches and one for mm's.

My macro is designed to work in both inch and metric modes, because I sell it to people all over the world, and it needs to be reliable for all. But I can tell you that if your machine is set up in inches, and your running metric g-code, problems will occur.

In your macro, you have the plate thickness coded in. You then attempt to change the thickness, based on the current units.
However, your probing moves, and feedrates, are all in inches. To do what your attempting, you'd need to duplicate the entire macro, in both inches and mm's.

Because you are writing the macro for YOU, make it reliable for YOU.
If your Native Units in Mach3 are inches, then force the macro to auto zero in inches.

Check for inches or mm's, and save the value.
Something like:
unitflag = getoemled(801)

Code "G20"      ' Set to inches

' Insert macro here

if unitflag = 0 then      'return to metric mode
Code "G21"
end if

This eliminates the need to swap units in your macro.

As for your workflow...

The "Remember" button tells Mach3 to remember your current position, so that you can return to it with the "Return" button later.
Did you intend mean to type "Return" in Step 11? If not, then steps 6 and 11 are doing nothing.

Otherwise, I think it looks OK. But I've never worked like that so I can't be sure. My M6 macro automatically handles steps 7-11. I only need to change the tool.


It sounds like you Z axis is losing position, which has nothing to do with your auto zero macro.

What stepper drives are you using, and what motors and voltage?
What are your velocity and acceleration in motor tuning for the Z axis?
What pitch is the Z axis screw?

Without knowing any of the above information, the first thing I would try is reducing the Z acceleration by 50%.

Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Auto tool Zero - macro questions
« Reply #5 on: November 08, 2014, 12:38:07 PM »
Ok, I have re-thought everything and have discovered that you have done a lot of work and that you are willing to help those that do not buy your screen sets; because of this I have considered the amount of work that I would have to do to re-learn this all again after obtaining your screen set.

I have decided to buy your product due to the amount of support that you provided.

I will be buying your products and downloading your free stuff promptly.

Many thanks in advance,

Doug
« Last Edit: November 08, 2014, 12:42:34 PM by edoctoor »
Again thank you for your kind words and your helpful tips and tricks.. you are appreciated
more than you will ever know during our struggle with the start-up learning curve.

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Auto tool Zero - macro questions
« Reply #6 on: November 08, 2014, 01:25:35 PM »
Thanks.

If you ever want to make the 2 hour drive across the border, you're more than welcome to come by and ask all the questions you want. I just can't guarantee that I'll have all the answers :)
It'll have to be after the first of the year, though, as I'm a bit busy right now.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Auto tool Zero - macro questions
« Reply #7 on: November 08, 2014, 10:31:00 PM »
Thanks a million.

I have never read such great documentation in my life. I have to assume that the years of reading confusing posts on a forum has taught you to write clear and concisely.

I spend all my time with my wife on weekends and therefore will not have time to review and run your screenset and its additional auto tool zero features... not to mention the other features; cross hairs etc... that I was both very interested in.. and very surprised to discover.

Again thanks a million
 
Again thank you for your kind words and your helpful tips and tricks.. you are appreciated
more than you will ever know during our struggle with the start-up learning curve.