Hello Guest it is April 18, 2024, 05:46:12 AM

Author Topic: Auto Tool Zero Help with USB Joypad  (Read 2858 times)

0 Members and 1 Guest are viewing this topic.

Auto Tool Zero Help with USB Joypad
« on: May 01, 2012, 10:43:21 PM »


Greetings to all.
This is my code for Auto Tool Zero
CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
PlateThickness =12

If GetOemLed (825)=0 Then
DoOEMButton (1010)
Code "G4 P3" 'Time to get to the z-plate, 3 seconds
Code "G90 G31 Z-20 F600" ' probing move, can set the feed rate here as well as how far to move
While IsMoving()
Wend
ZProbePos = GetVar(2002)
Code "G1 Z" &ZProbePos
While IsMoving ()
Wend
Call SetDro (2, PlateThickness)
Sleep(120)
Code "G0 Z20" 'Change the Z retract height here to what you want, must be higher than touch plate
Code "(Z axis is now zeroed)"
Code "F" &CurrentFeed 'returns to prior feedrate
Else
Code "(Z-Plate is grounded, check connection and try again)"
End If
Exit Sub
 


works perfectly, my problem is I have a USB joypad and I can not
activate the Auto Tool Zero function from the USB Joypad.
code for Joypad file M800

If SL And (Button = BE) Then
 DoOEMButton 1017
Message "Goto Zero"
End If
If SL And (Button = BW) Then
DoOEMButton 707
Message "Auto Tool ZEro"
End If
End



Change the code many times but I have good results, thanks for help
thank you very much
pedropin

Offline area51

*
  •  102 102
    • View Profile
    • Joakim's Technical Explorations
Re: Auto Tool Zero Help with USB Joypad
« Reply #1 on: May 02, 2012, 08:36:20 PM »
Hi Pedropin

If you move the script code for Auto Tool Zero into M800 I think it will work.
Something like (in M800):

Code: [Select]
Sub AutoToolZero()
    ' Code for Auto Tool Zero
    ' ...
End Sub

If SL And (Button = BE) Then
    DoOEMButton 1017
    Message "Goto Zero"
End If

If SL And (Button = BW) Then
    Call AutoToolZero() ' Call the sub with zero code
    Message "Auto Tool ZEro"
End If

Mach will not allow calling a script from a script and gives no error when trying.

- Area51