Hello Guest it is March 28, 2024, 12:54:53 PM

Author Topic: Repeat paths & integration  (Read 7126 times)

0 Members and 1 Guest are viewing this topic.

Repeat paths & integration
« on: January 03, 2010, 09:10:49 PM »
I apologize if this is very trivial, but I've read through the Mach3 setup pdf and have a question on the best way to implement what I need.  I'm running an X3 mill, and would like to drive the X and Y axis with a Gecko G540 and some NEMA 23 steppers.  I want to be able to read an input from another panel to the G540 & Mach3 that triggers a simple code, then pulse an output back to my control panel to let it know that the cycle is complete.  The next time the input is triggered, I need a reverse version of the code to execute and again pulse an output.  I'll outline it below...

Wait for input, when true...
G01 X0.6 F2.0
G01 X1.2 F10.0
Pulse output
Wait for input, when true...
G01 X0.6 F2.0
G01 X0.0 F10.0
Pulse output
Wait for input, when true...
G01 X0.6 F2.0
G01 X1.2 F10.0
Pulse output
<Continue cycle>

Thanks for your help!

Steve

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Repeat paths & integration
« Reply #1 on: January 04, 2010, 04:34:57 PM »
You could do this by custom m codes, you write the macro to pause and wait for the input then once seen it will start the code again. All you would then do is have the m code in your code above where you have
"Pulse output
Wait for input, when true..."

What exactly you have in the macro will depend on exactly what you are wanting to do with the pulse and what the signal you are waiting on is.
Hood
Re: Repeat paths & integration
« Reply #2 on: January 05, 2010, 09:10:55 PM »
Thanks, I'll have to do some more learning on M code.  Could you help with some rough code to get me started?  I could probably simplify by just running the same mill path each cycle & just turning on the output while the path is being executed instead of pulsing.  So:

Wait for input...
When input is true, turn on output & execute path
When path is done, turn off output
Repeat

Thanks again!

Steve

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Repeat paths & integration
« Reply #3 on: January 06, 2010, 04:21:44 PM »
I am not that great at VB so would have to think about how to do it. Ray (Himmykabibble)  is probably the best to advise on that.
Hood
Re: Repeat paths & integration
« Reply #4 on: January 06, 2010, 04:42:46 PM »
If the program you're running is really that simple, you could do the whole thing in a macro:

TRIGGER_IN = OEMTRIG1              ' Mach3 signal to trigger code execution
ACKNOWLEDGE_OUT = OUTPUT1  ' Mach3 signal to send acknowledge at end of execution

While 1

    ' Wait for input, when true...
    WaitForTrigger()
    Code "G01 X0.6 F2.0"
    Code "G01 X1.2 F10.0"

    ' Pulse output
    SendAcknowledge()

    ' Wait for input, when true...
    WaitForTrigger()
    G01 X0.6 F2.0
    G01 X0.0 F10.0

    ' Pulse output
    SendAcknowledge()

    ' Wait for input, when true...
    WaitForTrigger()
    G01 X0.6 F2.0
    G01 X1.2 F10.0
    ' Pulse output
    SendAcknowledge()

Wend

Sub WaitForTrigger()
    While IsActive(TRIGGER_IN) = 0
        Sleep 100
    Wend
End Sub


Sub SendAcknowledge()
    ActivateSignal(ACKNOWLEDGE_OUT)
    Sleep 100
    DeactivateSignal(ACKNOWLEDGE_OUT)
End Sub


You can put the above code into a file named M999.m1s ("999" can be any number over 100) in the Mach3\macros\<YourProfileName> directory.  Then, typing M999 on the MDI line, or in a G-code program, will run the macro.  Since it's an endless loop, you'll have to use E-Stop or ESC to terminate it.  Alternatively, you can put the WaitForTrigger subroutine into M998.m1s, and the SendAcknowledge subroutine into M999.m1s, then use M998 in your G-code when you want to wait for the external trigger to be asserted, and M999 when you want the acknowledge to be sent.

Regards,
Ray L.
Regards,
Ray L.
Re: Repeat paths & integration
« Reply #5 on: January 09, 2010, 09:34:10 AM »
Wow, thanks a ton!

I'll give this a try and do some learning with it.

Steve
Re: Repeat paths & integration
« Reply #6 on: July 22, 2013, 04:07:28 PM »
when ı use this code =   WaitForTrigger() 

error massage is : Scripter Compile Error in:M900.m1s

Why is this error

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Repeat paths & integration
« Reply #7 on: July 24, 2013, 04:01:48 AM »
A few errors in there...

Remove the () from the SendAcknowledge and the WaitForTrigger CALLS (or use the explicit CALL syntax). Also there are Code "" statements missing from some of the GCODE calls. Next you'll want to get rid of the 3rd set of calls as they're duplicates of the first set. Finally you'll want to put a while isMoving construct before each of the two remaining calls to SendAcknowledge otherwise the acknowlegements will execute prematurely.

Ian