Best way to home opposite direction to second switch

Mach3 and Mach4 questions, tips and topics can be posted here
Post Reply
User avatar
djreiswig
4.5 Star Elite Contributing Member
4.5 Star Elite Contributing Member
Posts: 1937
Joined: Thu Nov 19, 2015 10:02 pm
Location: SE Nebraska

Best way to home opposite direction to second switch

Post by djreiswig »

I park the Y axis on the opposite side of my table as where my homing switch is located. I was hoping I could put a second switch and make a macro with a homing move in the opposite direction, but it doesn't look like this is possible. So I started playing around and here is what I came up with. I haven't mounted the switch, but I changed my home switch to a different input and manually activated it and It seems like it will work.

Code: Select all

YPark = INPUT3

If Not IsActive(INPUT3) Then 'y already parked
  Code("G01 Y60 F75")
  Do While (IsMoving())
    'Sleep, so other threads can run while we’re waiting
    Sleep(5)
    If IsActive(INPUT3) Then 'y parked
      DoButton(3) 'stop
      Sleep(500)
      Exit Do
    End If
  Loop
End If
Code("G01 Y" & GetDRO(1) - 0.5 & " F20")
While (IsMoving())
  'Sleep, so other threads can run while we’re waiting
  Sleep(100)
Wend
Initially I ran into a problem in the first loop where it would catch the input, but the axis would still keep moving. If I stepped through the code and clicked the stop button when it contacted the switch then I could get it to go to the next line and move off the switch. So I added the line to trigger the stop button. It also seems like without adding a bunch of Sleeps, Mach tends to skip over things.
I'm wondering if this is the most elegant solution to get an axis to move an unknown distance toward a switch and then stop when it contacts the switch and back off. Basically a homing move but the opposite direction.
In case you think I'm lazy...I have the same code for all 3 axes under a button so I can just click one button and no matter where the table is at it will move the z up and move the torch to the corner. Just trying to simplify repetitive tasks. And I am a little lazy sometimes. :lol:
2014 Bulltear (StarLab) 4x8
C&CNC EtherCut
Mach3, SheetCam, Draftsight
Hypertherm PM65
Oxy/Acetylene Flame Torch
Pneumatic Plate Marker, Ohmic, 10 inch Rotary Chuck (in progress)
User avatar
FabLab
2 Star Member
2 Star Member
Posts: 65
Joined: Thu Mar 22, 2018 7:46 pm

Re: Best way to home opposite direction to second switch

Post by FabLab »

What I did to accomplish this was to setup G59 in Mach3 to the max + position of my machine (in my case X, Y, & Z) I then setup a button in Mach3 to run the following script:

Code ("G59 G0 X0 Y0 Z0")
While IsMoving()
Wend
Code ("G54")
User avatar
djreiswig
4.5 Star Elite Contributing Member
4.5 Star Elite Contributing Member
Posts: 1937
Joined: Thu Nov 19, 2015 10:02 pm
Location: SE Nebraska

Re: Best way to home opposite direction to second switch

Post by djreiswig »

Thanks. I haven't really messed with offsets. The macro I have has been working great.
2014 Bulltear (StarLab) 4x8
C&CNC EtherCut
Mach3, SheetCam, Draftsight
Hypertherm PM65
Oxy/Acetylene Flame Torch
Pneumatic Plate Marker, Ohmic, 10 inch Rotary Chuck (in progress)
User avatar
FabLab
2 Star Member
2 Star Member
Posts: 65
Joined: Thu Mar 22, 2018 7:46 pm

Re: Best way to home opposite direction to second switch

Post by FabLab »

Okay, Cool!! Thats the fun part, all the different ways you can do the same thing :-)
User avatar
djreiswig
4.5 Star Elite Contributing Member
4.5 Star Elite Contributing Member
Posts: 1937
Joined: Thu Nov 19, 2015 10:02 pm
Location: SE Nebraska

Re: Best way to home opposite direction to second switch

Post by djreiswig »

I agree.
2014 Bulltear (StarLab) 4x8
C&CNC EtherCut
Mach3, SheetCam, Draftsight
Hypertherm PM65
Oxy/Acetylene Flame Torch
Pneumatic Plate Marker, Ohmic, 10 inch Rotary Chuck (in progress)
Post Reply

Return to “Mach3 & Mach4 CNC”