Page 1 of 2 12 LastLast
Results 1 to 12 of 15

Thread: Double End in a While Loop

  1. #1
    Registered
    Join Date
    Jan 2009
    Location
    USA
    Posts
    39
    Downloads
    0
    Uploads
    0

    Double End in a While Loop

    Gentlemen,
    Will this example work:
    WHILE[#103LE#100DO1
    #102=#102-#101
    #108=ABS[#102]
    #104=[#18*#18]
    #105=[#108*#108]
    #106=#104-#105
    #107=SQRT[#106]
    #109=#108/#107
    #110=ATAN[#110]
    IF[#110GT45.]GOTO20
    G1
    G3
    G3
    G3
    #103=#103+1.
    END1
    N20
    G1
    G3
    G3
    G3
    #103=#103+1.
    END1

    I would use GOTO Statements but the cutter pauses after every pass.
    Thanks


  2. #2
    Registered
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    986
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by ggborgen View Post
    Gentlemen,
    Will this example work:
    WHILE[#103LE#100DO1
    #102=#102-#101
    #108=ABS[#102]
    #104=[#18*#18]
    #105=[#108*#108]
    #106=#104-#105
    #107=SQRT[#106]
    #109=#108/#107
    #110=ATAN[#110]
    IF[#110GT45.]GOTO20
    G1
    G3
    G3
    G3
    #103=#103+1.
    END1
    N20
    G1
    G3
    G3
    G3
    #103=#103+1.
    END1

    I would use GOTO Statements but the cutter pauses after every pass.
    Thanks
    No. DO n and End n must correspond to each in one program.

    Something like the following may help you
    #1=0 (Control Flag - initialize before starting DO Loop)
    WHILE[#103LE#100]DO1
    #102=#102-#101
    #108=ABS[#102]
    #104=[#18*#18]
    #105=[#108*#108]
    #106=#104-#105
    #107=SQRT[#106]
    #109=#108/#107
    #110=ATAN[#110]
    WHILE [[#110 LE 45.] AND [#1=0]] DO2
    #1=1 (Set Control Flag so DO2 executes only once)
    G1
    G3
    G3
    G3
    #103=#103+1.
    END2
    #1=0 (Reset Control Flag so that DO2 will execute again if #110 LE 45.)
    N20
    G1
    G3
    G3
    G3
    #103=#103+1.
    END1


    Regards,

    Bill
    Last edited by angelw; 10-27-2011 at 07:44 AM.


  3. #3
    Registered
    Join Date
    Feb 2006
    Location
    india
    Posts
    1,273
    Downloads
    0
    Uploads
    0
    Read the attachment for correct syntax of ATAN function.
    Attached Thumbnails Attached Thumbnails Double End in a While Loop-atan_syntax.pdf  


  4. #4
    Registered
    Join Date
    Jan 2009
    Location
    USA
    Posts
    39
    Downloads
    0
    Uploads
    0

    ATAN syntax

    Sinha nsit,
    Are you telling me there is something wrong with my syntax? Thanks


  • #5
    Registered
    Join Date
    Feb 2006
    Location
    india
    Posts
    1,273
    Downloads
    0
    Uploads
    0
    This is not correct:
    #110=ATAN[#110]


  • #6
    Registered
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    986
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by ggborgen View Post
    Sinha nsit,
    Are you telling me there is something wrong with my syntax? Thanks
    I think what Sinha is saying is that the result when using the ATAN function correctly is an angle. The function provides the Arctangent of the Opposite side to an angle of a triangle divided by its adjacent side to the same angle. The syntax being as follows:

    Arctangent
    #i=ATAN[#j]/[#k];
    Where:
    #1 = the resulting angle
    #j = the opposite side
    #k = the adjacent side

    Now, I've never tried to use the ATAN function in any other way other way than in the above syntax example. Its my understanding that the function requires two arguments, and not just the TAN of an angle. I'll check that out.

    In your example program, its not shown where #110 is allocated a value; obviously somewhere prior to the WHILE statement.

    Lets say #110 was allocated the TAN of an angle elsewhere, and that #110 = ATAN[#110] did not result in a syntax error. In your example program, the first time through the loop, #110 would take on the value of the angle extrapolated from getting the Arctangent of the TAN of an angle ; the second time through, the angle #110 would be plugged back in as the TAN of an angle. For example:

    #110 = TAN [45] (#110 = 1)
    ATAN[#110] (#110 = 45)
    ATAN[#110] (#110 = 88.7269)

    Regards,

    Bill


  • #7
    Registered
    Join Date
    Jan 2009
    Location
    USA
    Posts
    39
    Downloads
    0
    Uploads
    0

    Correction #110=ATAN[#109]

    Gentlemen,
    My example should be as follows:
    #110=ATAN[#109]
    Sorry about the mistake, so would this work? Thanks


  • #8
    Registered
    Join Date
    Feb 2006
    Location
    india
    Posts
    1,273
    Downloads
    0
    Uploads
    0
    No.
    Read the syntax given in Angelw's previous post or my attachment in post #3.


  • #9
    Registered
    Join Date
    Jan 2009
    Location
    USA
    Posts
    39
    Downloads
    0
    Uploads
    0

    Example from Fanuc manual for a 31i control

    Gentlemen,
    Here's an example from a Fanuc control manual:

    #i=ATAN[#j] Arc tangent (one argument)
    #i=ATAN[#j]/[#k] Arc tangent (two arguments)
    #i=ATAN[#j,#k] Arc tangent (two arguments)

    So how does the first example differ from my syntax? Thanks


  • #10
    Registered
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    986
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by ggborgen View Post
    Gentlemen,
    Here's an example from a Fanuc control manual:

    #i=ATAN[#j] Arc tangent (one argument)
    #i=ATAN[#j]/[#k] Arc tangent (two arguments)
    #i=ATAN[#j,#k] Arc tangent (two arguments)

    So how does the first example differ from my syntax? Thanks
    As I stated in my Post #6, I've not used the ATAN function using only the one argument (TAN of angle), simple because, and purely by chance, I've always been calculating the TAN of the angle in the same operation. I've not seen it expressed in a one argument format, but clearly, it would be a big advantage to be able to just plug in the TAN value if it were already known. If the Fanuc manual indicates that the single argument is valid, then
    #109=#108/#107
    #110=ATAN[#109]
    would be fine if #108 and #107 are the opposite and adjacent sides respectively.

    As you're probably aware, the above could also be written as follows:

    #110=ATAN[#108] / [#107]

    Regards,

    Bill
    Last edited by angelw; 11-02-2011 at 10:31 AM.


  • #11
    Registered
    Join Date
    Feb 2006
    Location
    india
    Posts
    1,273
    Downloads
    0
    Uploads
    0
    Quote Originally Posted by ggborgen View Post
    Gentlemen,
    Here's an example from a Fanuc control manual:

    #i=ATAN[#j] Arc tangent (one argument)
    #i=ATAN[#j]/[#k] Arc tangent (two arguments)
    #i=ATAN[#j,#k] Arc tangent (two arguments)

    So how does the first example differ from my syntax? Thanks
    Refer to the original Fanuc manuals. Do not believe on what I say or what others say.
    The best way would be to test it on your machine. And please do report back.

    There is a good reason why Fanuc defined ARCTAN this way.
    tan 45 and tan 225 are both 1. What should be the out put of arctan 1?
    Similarly, tan (-45) and tan 135 are both -1. arctan (-1) would be ambiguous.

    1/1 and -1/-1 are both equal to 1, but refer to angles in I and III quadrants, respectively.
    -1/1 and 1/-1 are both equal to -1, but refer to angles in IV and II quadrants, respectively.

    Thus Fanuc's ATAN always gives correct value of angle.
    Incidently, this feature is not available in even high-level languages such as Pascal.


  • #12
    Registered
    Join Date
    Jan 2009
    Location
    USA
    Posts
    39
    Downloads
    0
    Uploads
    0

    Will this work?

    Gentlemen,
    Will this work?

    WHILE[#***LE#***]DO1
    ***
    ***
    G65P****
    ***
    ***
    END1
    Basically make another macro call in side a While loop. Thanks


  • Page 1 of 2 12 LastLast

    Similar Threads

    1. Open Loop to Closed Loop Stepper Conversion
      By beamhome in forum Stepper Motors and Drives
      Replies: 10
      Last Post: 08-14-2012, 03:58 AM
    2. New 6-axis Double-Closed-Loop Controller?
      By brccrb in forum Product and Manufacturer Announcements
      Replies: 28
      Last Post: 03-04-2009, 10:46 PM
    3. Replies: 628
      Last Post: 02-02-2009, 08:47 AM
    4. CNC Brain is ready! 6-axis Double Closed Loop Controller
      By brccrb in forum Product and Manufacturer Announcements
      Replies: 374
      Last Post: 09-17-2008, 08:42 PM
    5. question on closed loop vs open loop (servo systems)
      By boonie in forum Servo Motors and Drives
      Replies: 20
      Last Post: 11-09-2007, 01:30 PM

    Posting Permissions


     


    About CNCzone.com

      We are the largest and most active discussion forum from DIY CNC Machines to the Cad/Cam software to run them. The site is 100% free to join and use, so join today!

    Follow us on

    Facebook Dribbble RSS Feed


    Search Engine Friendly URLs by vBSEO ©2011, Crawlability, Inc.