Hello Guest it is March 28, 2024, 12:30:34 PM

Author Topic: Tool Auto Zero Script  (Read 17508 times)

0 Members and 2 Guests are viewing this topic.

Tool Auto Zero Script
« on: March 18, 2017, 09:57:41 PM »
OK, I know there is probably an easy answer for this.  And I have searched but have been unable to find one. 

I added a single jack to my machine so I could plug my probe & touch plate in as needed.  My problem is the probe is a Normally Close function and the touch plate is a Normally Open function.  Now I suppose I could just go to "Ports & Pins" config and change the probe input from Active High to Active Low as needed.  But there's got to be a more elegant solution.

I'm pretty sure I can't modify G31 so does anyone know of a Auto Tool Zero script that doesn't use G31?  Something I could modify so the touch test condition from Active to Not Active.  What have other people done? 

Thanks

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Tool Auto Zero Script
« Reply #1 on: March 19, 2017, 07:59:43 AM »
There was a thread here a week or two ago with a circuit to connect the two devices to a single input.
Another option is to create two Mach3 profiles.
And a third option is to use a Brain, to trigger the probe input when another input is triggered, so they can be wired to separate inputs.
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Tool Auto Zero Script
« Reply #2 on: March 19, 2017, 11:40:53 AM »
There was a thread here a week or two ago with a circuit to connect the two devices to a single input.
Another option is to create two Mach3 profiles.
And a third option is to use a Brain, to trigger the probe input when another input is triggered, so they can be wired to separate inputs.
Thanks!

   The two profile method, (at least for me) is much like changing the input from active high to active low everytime I want to change probes. Very messy.
   
   In my searches I hadn't seen the circuit discussion. Being a electronics nerd, that has appeal. I'll look that one up.
   
  The Brain approach intrigues me.  Know zip about programming Brains makes me interested in this approach just for the learning adventure.  
  First thoughts - It shouldn't be that hard to program some sort of flip/flop that would monitor an input and change the probe input state on a monitored input change of state.  
  Second thoughts:
             1. I would need a "Probe tool changed" button so I could tell the brain this is the new "non-active state". Is there a way for the brain to automatically tell the tool was changed?
             2. The brain would need to run continually to accommodate wizards and such. Would that eat up processing resources?
             3. Would the delay between detecting monitored input change of state and changing the probe input state be sufficiently short not to impact location accuracy or cause tool or probe damage?

   So, any suggestions on the logic needed to program a Brain?

Thanks again,
Kelvin

Sent from my SM-P900 using Tapatalk
Re: Tool Auto Zero Script
« Reply #3 on: March 19, 2017, 09:48:57 PM »
Got to love brains! 

The fix was pretty simple, though I have hit one snag.  I need to add a button that does nothing more than toggles state when pressed, i.e. from true to false or 1 to 0.  Something the brain can check.  I've been through all the OEM codes.  How do you make a button that doesn't do anything but change state when pressed?

Offline Tweakie.CNC

*
  • *
  •  9,196 9,196
  • Super Kitty
    • View Profile
Re: Tool Auto Zero Script
« Reply #4 on: March 20, 2017, 03:09:23 AM »
Perhaps something like this ...

If IsOutputActive(OUTPUT5) Then
DeActivateSignal(OUTPUT5)
Else
ActivateSignal(OUTPUT5)
End If

Tweakie.
PEACE
Re: Tool Auto Zero Script
« Reply #5 on: March 20, 2017, 08:37:28 PM »
OK, I'm stumped.

I disabled the probe input and enabled OEM Trig #2 as the new probe input.  I wrote a simple button VB to toggle an UserLED1001 between 1 & 0.  And wrote a simple brain to XOR that with the OEM Trig #2 input and export the results to the "Probe Input".  Now I can invert the input to accommodate what ever probe I plug in, (XYZ probe, touch plate, etc.)  I've watched it in the brain and it works as expected.

This is my toggle button VB:
  
     Dim ProbeStateLED As Integer
         ProbeStateLED = 1001
         If GetUserLED (ProbeStateLED) Then
            SetUserLED(ProbeStateLED,0)
         Else
            SetUserLED(ProbeStateLED,1)
         End If


This is the Touch off VB I found on here and attached to the "Auto Tool Zero" button.

      CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
         PlateThickness =0.059
         ProbeFeed = 5
         Code "G90 F" &ProbeFeed
         If GetOemLed (825)=0 Then
            Code "G4 P2" 'Time to get to the z-plate
            Code "G31Z-5 F" &ProbeFeed
            While IsMoving()
            Wend
              Code "G4 P0.25"
              ZProbePos = GetVar(2002)
              Code "G0 Z" &ZProbePos
           While IsMoving ()
           Wend
             Call SetDro (2, PlateThickness)
             Code "G4 P0.5" 'Pause for Dro to update.
             Code "G0 Z0.25" 'Change the Z retract height here
             Code "(Z axis is now zeroed)"
             Code "F" &CurrentFeed
           Else
              Code "(Z-Plate is grounded, check connection and try again)"
           Exit Sub
           End If


The brain is:

OEMLED:1001 ---- No Op - |EOR |
OEMTRIGGER#2 - No Op - |       | ------- Probe Switch


Now my problem.  If I toggle my button so the Probe input is active and run the auto zero script I get a "probe grounded" message, (as expected).  But when I try to run the auto zero script with everything normal I get a "No probe active" error message.  What's that from?  The fact I don't have the probe input active in ports & pins config?  If so, is there  a way around this?

Thanks,
Kelvin
« Last Edit: March 20, 2017, 08:46:34 PM by KelvinG »

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Tool Auto Zero Script
« Reply #6 on: March 20, 2017, 09:38:34 PM »
Quote
In my searches I hadn't seen the circuit discussion. Being a electronics nerd, that has appeal. I'll look that one up.


http://www.machsupport.com/forum/index.php/topic,34230.msg237721.html#msg237721
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Tool Auto Zero Script
« Reply #7 on: March 20, 2017, 10:26:17 PM »
Quote
In my searches I hadn't seen the circuit discussion. Being a electronics nerd, that has appeal. I'll look that one up.


http://www.machsupport.com/forum/index.php/topic,34230.msg237721.html#msg237721
Thanks!  Once you told me about it I did find it.  It's plan B if I can't fix my problem by typing on a keyboard.

I'm guessing the "probe not active" error I'm getting has to do with the G31 command and the Probe input in Mach3 not being set to enable.  Though I'm holding out hope some Mach3 guru knows of a work around.

Kelvin

Sent from my SM-P900 using Tapatalk
Re: Tool Auto Zero Script
« Reply #8 on: March 21, 2017, 01:27:58 PM »
Hi My name is Gerhard and I am using my cnc machine for a while now. I have changed to a uss smoothstepper board and is busy setting up a z zero touch plate. However I experience problems. First of all the zero plate works well in the test when the positive wire is not connected to my cnc machine end mill. (I hold it in my hand) and when I touch the zero touch plate it stops and retract like it should. When I connect the positive to my end mill it act as if it has touched the plate (active low) and only retracts.

I have changed the 4,7k resister to a 200 ohm resister to get 4,7 volt on the output (touch plate and positive) however when the positive is connected to the end mill it only retracts as if it has touched the zero touch plate. The touch plate is lying on a sacrifice sheet so there cannot be a connection with the end mill. When the positive is connected to the end mill the voltage between positive and negative is still 4.7 volts.

Your help will be appreciated.

I am using the following script:-
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

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-100. F100" '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, 15.0) ' change .060 to your plate thickness and then adjust for final accuracy
Sleep 200 'Pause for Dro to update.
Code "G1 Z1. F1300" '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   


Re: Tool Auto Zero Script
« Reply #9 on: March 21, 2017, 03:18:11 PM »
Hi My name is Gerhard and I am using my cnc machine for a while now. I have changed to a uss smoothstepper board and is busy setting up a z zero touch plate. However I experience problems. First of all the zero plate works well in the test when the positive wire is not connected to my cnc machine end mill. (I hold it in my hand) and when I touch the zero touch plate it stops and retract like it should. When I connect the positive to my end mill it act as if it has touched the plate (active low) and only retracts.

I have changed the 4,7k resister to a 200 ohm resister to get 4,7 volt on the output (touch plate and positive) however when the positive is connected to the end mill it only retracts as if it has touched the zero touch plate. The touch plate is lying on a sacrifice sheet so there cannot be a connection with the end mill. When the positive is connected to the end mill the voltage between positive and negative is still 4.7 volts.

Your help will be appreciated.

I am using the following script:-
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

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-100. F100" '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, 15.0) ' change .060 to your plate thickness and then adjust for final accuracy
Sleep 200 'Pause for Dro to update.
Code "G1 Z1. F1300" '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
Hi Gerhard,
  I'm no expert my first guess would be you need to switch the polarity of your touch plate. Touch plate positive and isolated from your machine.  The connection to your machine negative.

Kelvin

Sent from my SM-P900 using Tapatalk