585,971 active members*
4,250 visitors online*
Register for free
Login
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2013
    Posts
    16

    Question Loop Exiting Improperly

    Hey all,

    I need this loop to execute as many times as necessary until my user input = 65. for both variables #500 and #501. It seems to exit if either of them equal 65. Can anyone shed any light on my mistake(s)? Thanks in advance for any help.

    Code:
    #500= 0. 
    #501= 0. 
    
    WHILE [ [ #500 NE 65. ] AND [ #501 NE 65. ] ] DO1 
    
    G103 P1 
    
    
    N0 #500= 0. (RESETS MESSAGE VARIABLE) 
    N1 M109 P500 (TOTAL EXTRA REMOVAL FROM SIDES) 
    IF [ #500 EQ 0. ] GOTO1 (WAIT FOR BUTTON PRESS) 
    IF [ #500 EQ 65. ] #104= 0. 
    IF [ #500 EQ 66. ] #104= 0.001 
    IF [ #500 EQ 67. ] #104= 0.002 
    IF [ #500 EQ 68. ] #104= 0.003 
    IF [ #500 EQ 69. ] #104= 0.004 
    IF [ #500 EQ 70. ] #104= 0.005 
    IF [ #500 EQ 71. ] #104= 0.006 
    IF [ #500 EQ 72. ] #104= 0.007 
    IF [ #500 EQ 73. ] #104= 0.008 
    IF [ #500 EQ 74. ] #104= 0.009 
    IF [ #500 EQ 75. ] #104= 0.010 
    IF [ #500 EQ 76. ] #104= 0.011 
    IF [ #500 EQ 77. ] #104= 0.012 
    IF [ #500 EQ 78. ] #104= 0.013 
    IF [ #500 EQ 79. ] #104= 0.014 
    IF [ #500 EQ 80. ] #104= 0.015 
    IF [ #500 EQ 81. ] #104= 0.016 
    IF [ #500 EQ 82. ] #104= 0.017 
    IF [ #500 EQ 83. ] #104= 0.018 
    IF [ #500 EQ 84. ] #104= 0.019 
    IF [ #500 EQ 85. ] #104= 0.020 
    IF [ #500 EQ 86. ] #104= 0.021 
    IF [ #500 EQ 87. ] #104= 0.022 
    IF [ #500 EQ 88. ] #104= 0.023 
    IF [ #500 EQ 89. ] #104= 0.024 
    IF [ #500 EQ 90. ] #104= 0.025 
    IF [ #500 GT 90. ] GOTO0 (INVALID SELECTION) 
    
    N2 #501= 0. (RESETS MESSAGE VARIABLE) 
    N3 M109 P501 (TOTAL EXTRA REMOVAL FROM TOP) 
    IF [ #501 EQ 0. ] GOTO3 (WAIT FOR BUTTON PRESS) 
    IF [ #501 EQ 65. ] #105= 0. 
    IF [ #501 EQ 66. ] #105= 0.001 
    IF [ #501 EQ 67. ] #105= 0.002 
    IF [ #501 EQ 68. ] #105= 0.003 
    IF [ #501 EQ 69. ] #105= 0.004 
    IF [ #501 EQ 70. ] #105= 0.005 
    IF [ #501 EQ 71. ] #105= 0.006 
    IF [ #501 EQ 72. ] #105= 0.007 
    IF [ #501 EQ 73. ] #105= 0.008 
    IF [ #501 EQ 74. ] #105= 0.009 
    IF [ #501 EQ 75. ] #105= 0.010 
    IF [ #501 EQ 76. ] #105= 0.011 
    IF [ #501 EQ 77. ] #105= 0.012 
    IF [ #501 EQ 78. ] #105= 0.013 
    IF [ #501 EQ 79. ] #105= 0.014 
    IF [ #501 EQ 80. ] #105= 0.015 
    IF [ #501 EQ 81. ] #105= 0.016 
    IF [ #501 EQ 82. ] #105= 0.017 
    IF [ #501 EQ 83. ] #105= 0.018 
    IF [ #501 EQ 84. ] #105= 0.019 
    IF [ #501 EQ 85. ] #105= 0.020 
    IF [ #501 GT 85. ] GOTO2 (INVALID SELECTION) 
    
    G00 G17 G20 G40 G80 G90 
    M97 P10 (READ PARAMETERS) 
    G57 
    F5. 
    
    IF [ #104 EQ 0. ] GOTO4 
    G103 P1 
    
    
    #106= #150 - #5281 + [ #104 / 2 ] (NEW X VALUE) 
    #150= #106 + #5281 (RESET FINAL X POS) 
    M08 
    M03 S3200 
    Z1. 
    G00 G90 X#106 Y5.75 A#101 
    G91 
    M97 P21 
    Y10.5 A-180. 
    M97 P21 
    
    N4 IF [ #105 EQ 0. ] GOTO5 
    G103 P1 
    
    
    #107= #151 - #5281 + #105 (NEW X VALUE) 
    #151= #107 + #5281 (RESET FINAL X POS) 
    #108= #101 - 90. 
    M08 
    M03 S3200 
    Z1. 
    G00 G90 X#107 Y5.75 A#108 
    G91 
    M97 P21 
    
    N5 G56 
    G90 Z0. 
    M05 
    M09 
    X0. Y0. A-30.008 
    M60 
    
    END1

  2. #2
    Join Date
    Jun 2015
    Posts
    4154

    Re: Loop Exiting Improperly

    hy the problem in that aproach is that condition definition is not direct, but indirect

    for example, "if true" and "if not false" are similar, but may be tricky to implement

    i will write the code for an okuma machine, then try to adapt it

    NHERE
    // code, do something
    V3=0

    IF [ V1 NE 65 ] NJUMP1
    V3=V3+1 ( increment v3 only if v1=65 )
    NJUMP1

    IF [ V2 NE 65 ] NJUMP2
    V3=V3+1 ( increment v3 only if v2=65 )
    NJUMP2

    IF [ V3 NE 2 ] NHERE

    it is a bit long, but uses simply if syntaxes, so should be easy to adapt;
    next aproach will be a bit dense, since it will join those conditions, thus less code lines
    can't provide code for "while", is not available on the controlers around here

    NHERE
    // code, do something
    IF [ [ [ V1 EQ 65 ] AND [ V2 EQ 65 ] ] EQ 0 ] NHERE

    kindly
    Ladyhawke - My Delirium, https://www.youtube.com/watch?v=X_bFO1SNRZg

Similar Threads

  1. Generate an alarm signal, during an improperly placed workpiece..!
    By CGovindaraj in forum CNC Machine Related Electronics
    Replies: 5
    Last Post: 08-16-2022, 08:31 PM
  2. Improperly formatted rack entry
    By sse4 in forum PCB milling
    Replies: 0
    Last Post: 07-15-2019, 07:28 PM
  3. Pink Plasma but Nothing Exiting Tube
    By t6t8 in forum Laser Engraving / Cutting Machine General Topics
    Replies: 4
    Last Post: 09-10-2014, 01:17 PM
  4. Exiting a function
    By WingNutz in forum Mastercam
    Replies: 3
    Last Post: 02-05-2009, 01:21 AM
  5. Coolant Exiting Hoses keep Getting Clogged
    By JWB_Machining in forum MetalWork Discussion
    Replies: 5
    Last Post: 01-14-2009, 06:02 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
  •