586,129 active members*
3,072 visitors online*
Register for free
Login
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2015
    Posts
    23

    Macro for Manual Y move

    I am building a machine that consists of a fixed gantry with a head that moves in the X direction. The material underneath needs to be moved forward in one direction (and can only go one direction) manually. The goal is to have Mach3 print one line on the material when the material moves forward and stops at a location that will be picked up by a microswitch connected to one of the inputs.
    Actually the Microswitch triggers ever mm of movement and the forward movement is quite slow so I dont really see the need to add an encoder to this.

    I have altered the Post to output an M code and pass a P variable to Mach3 with the distance required to move. For instance the first movement would be a say 2mm giving Mach3 2 clicks on the input, at that stage it should print one line.

    G0 X0 M666 P2
    G1 Z1 F600
    G1 X20 F1800
    G0 Z0
    G0 M666 P4
    G1 Z1 F600
    G1 X0 F1800
    G0 Z0

    Would tell the gantry to Start at X0 wait for the microswitch to click 2 times then Print one line 20mm long
    Wait for 2 more clicks (making essentially a 4 mm movement from 0) then print the next line from 20 to 0 in the X

    My Macro consists of this, however as I am testing this on a machine that has a powered Y i have added some code to allow for this however at present the thing is triggering on every click rather than waiting for the stipulated clicks.

    Any assistance or suggestions would be greatly appreciated.

    Code:
    TvlDistance = 0
    
    'Location to do the next line passed by the P
    FwdDistance = roun(Param1())
    
    
    'The current position of the Y axis
    CurrentYPos = roun(GetParam("YMachine"))
    
    
    'How many Clicks from input required per mm of travel
    Steps = 1
    
    
    
    
    'If the current position is 0 or a negative number as will be the
    'case on the first and secont pass do not work out the distance to move.
    If (FwdDistance-CurrentYPos) <= 0 Then
        ToMove = FwdDistance
    Else
        ToMove = FwdDistance-CurrentYPos
    
    
    End If
    
    
    'Do not wait for input while the file is loading
    If IsLoading() Then
        'File is loading so dont do anything
    Else
    
    
        'File has loaded now we can start work
        'Message "spool:" & ToMove & " mm " & "From:" & CurrentYPos
    
    
    1:
    'when the machine is moving wait for it to stop
        While IsMoving()
            sleep(100)
        Wend
    
    
    'wait until there is input
        While Not isActive(INPUT2)
            Message "Move Material:" & ToMove & "mm"
            activateSignal(ENABLE1)
            sleep 50        
        Wend
    
    
    If TvlDistance < ToMove Then
        'wait for the next click    
        TvlDistance = TvlDistance + Steps
        GoTo 1
    
    
    End If
    
    
    'Test Code for CNC with Stepper on Y
    'If TvlDistance = ToMove Then
        Message "Moving to Position for X pass:" & FwdDistance
        'y is in position (test code only for powered cnc)
        Code "G1 Y" & FwdDistance
        sleep 100
    'End If
    
    
        deactivateSignal(ENABLE1)
    
    
    End If

  2. #2
    Join Date
    Sep 2010
    Posts
    717

    Re: Macro for Manual Y move

    'wait until there is input
    While Not isActive(INPUT2)
    Message "Move Material:" & ToMove & "mm"
    activateSignal(ENABLE1)
    sleep 50
    Wend

    That's wrong..? The activate signal shouldn't be set every 50 us?

    Try this (for 2 triggers):

    While Not isActive(INPUT2)
    Message "Move Material:" & ToMove & "mm"
    sleep 50
    Wend

    While Not isActive(INPUT2)
    Message "Move Material:" & ToMove & "mm"
    sleep 50
    Wend

    activateSignal(ENABLE1)
    Current build: http://www.cnczone.com/forums/diy-cnc-router-table-machines/264838-new-machine-desing-quot-cnm13-quot.html

  3. #3
    Join Date
    Apr 2015
    Posts
    23

    Re: Macro for Manual Y move

    I set it to 50us just in case the feed was faster and so not to miss a trigger. Changing this seems to only alter the delay that it is waiting for a signal to be passed to the controller. Adding a second instance did nothing.

  4. #4
    Join Date
    Sep 2010
    Posts
    717

    Re: Macro for Manual Y move

    Quote Originally Posted by vangalvin View Post
    I set it to 50us just in case the feed was faster and so not to miss a trigger. Changing this seems to only alter the delay that it is waiting for a signal to be passed to the controller. Adding a second instance did nothing.
    The 50us was a typo, sorry I meant 50ms. like you had it, It won't change much. It's just there to reduce CPU processing.

    Did you remove the activateSignal(ENABLE1) from the While loop, and set it after the last "Wend"?

    Hub
    Current build: http://www.cnczone.com/forums/diy-cnc-router-table-machines/264838-new-machine-desing-quot-cnm13-quot.html

  5. #5
    Join Date
    Apr 2015
    Posts
    23

    Re: Macro for Manual Y move

    Quote Originally Posted by hub View Post
    The 50us was a typo, sorry I meant 50ms. like you had it, It won't change much. It's just there to reduce CPU processing.

    Did you remove the activateSignal(ENABLE1) from the While loop, and set it after the last "Wend"?

    Hub
    I increased the Sleep to 100 and removed the enable but did not make any difference, Its as if it is not counting the clicks from the input or calculating how many are required for the material to be in position for the next pass.

  6. #6
    Join Date
    Apr 2015
    Posts
    23

    Re: Macro for Manual Y move

    I may have found the problem, The Microswitch I am using is bouncing causing multiple triggers on the input. Maybe! just about to recode it, reverse the way it opperates and try it again.

  7. #7
    Join Date
    Apr 2015
    Posts
    23

    Re: Macro for Manual Y move

    And sorted that issue out as well
    The secret is to use the Cypress VB format function Format(VAR, "####0" this will round anyting from the right of the decimal point to a whole number and as my passes are only 1mm I really dont need to worry about anyting that is on the right of the decimal point

    I should have looked at the manual first.
    http://www.cypressinc.com/enduser.pdf

Similar Threads

  1. move to saved location or move a fixed distance
    By BikeCourse in forum Mach Mill
    Replies: 0
    Last Post: 03-21-2015, 03:06 AM
  2. Replies: 9
    Last Post: 09-16-2013, 08:27 PM
  3. Replies: 6
    Last Post: 06-22-2011, 08:30 PM
  4. Fanuc Macro-a Programming Manual
    By CHANDRU in forum Fanuc
    Replies: 4
    Last Post: 03-20-2011, 05:00 PM
  5. Series 2 interact 4 with manual move trouble
    By ronmarkum in forum Bridgeport / Hardinge Mills
    Replies: 0
    Last Post: 06-27-2009, 10:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •