585,712 active members*
3,997 visitors online*
Register for free
Login
Results 1 to 13 of 13
  1. #1
    Join Date
    Oct 2011
    Posts
    0

    Deciphering Help

    We have an exsiting program that has some interesting features which I could some help in decipering what each line is doing. Any help would be greatly appricated.

    Beginning of program:

    IF[#503 GE #502] GOTO777 - What is GE?
    IF[#502 GT ***] GOTO778 - What is GT ***?
    IF[#500 LT *] GOTO779 - What is LT *?

    #19=#503 - What is this?
    #5=*
    #2=*
    #14=0
    G90 G10 L2 P3 X#5221 Y#5222 Z#5223 (G54 XYZ TO G56) - And all this?
    WHILE [#14 LT #502] DO1 - This?
    #10=0 - And this?
    G90 G10 L2 P3 X#5221 (G54 X TO G56) - And this?
    WHILE [#10 LT **] DO2 - And this?

    Regular code here....
    Before Tool change ...

    G91 G10 L2 P3 X#5 - Not sure what this does.
    G90
    #10=#10+1 - Or this
    #19=#19+1 - Or this
    #14=#14+1 - Or this
    IF[#19 GE #502] GOTO 102 - Or this
    END2

    G91 G10 L2 P3 Y#2 - Or this
    G90

    Then there is a tool change call out and the following...

    #19=#503
    #5=*
    #2=*
    #14=0
    G90 G10 L2 P3 X#5221 Y#5222 Z#5223 (G54 XYZ TO G56)
    WHILE [#14 LT #502] DO1
    #10=0
    G90 G10 L2 P3 X#5221 (G54 X TO G56)
    WHILE [#10 LT **] DO2

    Any help on the above would be great!

    Regular code and then pretty much all the above repeats again. Who's the guru here that can decipher this code?

  2. #2
    Join Date
    Jun 2008
    Posts
    1511
    Oh boy....that is a lot of explanations. Sinha.....I think he needs your book!!!

    First off welcome to the forum.

    Second I have to say I do not know what the *** are for in your code and how this would even logicly function.

    GE means “Greater than or Equal To”
    GT means “Greater Than”
    LT means “Less Than”
    GOTO means “Go To”

    What you are seeing in your program with #19 or any other #() are variables. These variables hold values that that the program specifies. As an example if you were to program #19=5 and then go look at your variable settings thru the settings screen you will find that #19 is equal to 5. Now if you were to program a G0X#19 it would be like programming G0X5 because #19 is set to 5

    This is really just skimming the surface of macroB programming.

    Now the GE, GT, LT, GOTO, WHILE…DO statements are all conditions of the program and are read really as explained above. What you posted is not a complete program as the conditions at the beginning have no address to go to if they prove true. Lets use the following code as an example of what this means.

    (main program)
    #19=5
    #20=2
    IF[#19EQ5]GOTO100
    G0X#2
    N100M30

    In the first 2 lines macro variable #19 is being set =5 and #20 is being set =2. The IF statement is saying If #19 is equal to 5 got to address N100. In this program #19 is set equal to 5 so the IF statement is true and the program will skip everything else and go directly to address N100 and read M30 and end the program. If you were to change #19 to be say 4 then the IF statement will be false and will not go to N100 and instead read the next line of G0X#2 which is G0X2 and continue on to the N100M30 and end your program.

    You basically have to substitute your #() numbers for what the value of them are. When the program runs and #20=5 and your line of code is G0X#20 once it reads this line it will take the #20 and make it 5 reading G0X5

    WHILE statements are more tricky and if you do not grasp what is posted above you will have a tuff time understanding what this means until you do.

    #19=0
    WHILE[#19LT5]DO1
    G0G91X1.
    #19=#19+1
    END1
    M30

    What the WHILE statement does is run between the WHILE and DO until the WHILE statement is true. So the above code sets #19=0 then jumps into the loop. #19=0 so it will move the X 1” at the G0G91X1. Line and then read #19=#19+1 which we know it was =0 and now it adds 1 to the value making #19=1 but the WHILE statement is not satisfied because it is still less than (LT) 5. So it will go back to the G0G91X1. Line moving the machine again and then reading #19=#19+1. #19 in the last run thru was =1 so now it is equal to itself +1 which makes it =2 and once again not satisfying the WHILE statement because #19 is still less than 5. This will keep adding until #19 is no longer less than 5 and once that happens it will leave the loop and go to the block directly after the END1 line which is M30 ending your program.

    The G91G10L2P3 is setting a workcoordinate. G10 is the code to do theis, L2 is the registry of the workcoordinate and the P3 is the coordinate number which is G56 so if you program G91G10L2P3X2. It will add 2 to the X value in G56 now it is using #5 so if #5 is =2 it will do the same thing. To explain G10…if you were to useP2 instead it would set G55 and P1 would be G54. L2 means to change the coordinate but you can use a different L() to change tool offsets or parameters.

    Hope this helps.
    Stevo

  3. #3
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by stevo1 View Post

    Second I have to say I do not know what the *** are for in your code and how this would even logicly function.

    Stevo
    You're right Stevo, code like IF[#502 GT ***] GOTO778 will result in a syntax error. At a guess, I'd say that its a visual prompt to replace with varying data. But why you would not use a variable and some commented notes to set the variable, who knows.

    Regards,

    Bill

  4. #4
    Join Date
    Feb 2006
    Posts
    1792
    Systematic study is needed. See the attachments for basic information on macro programming. These are not my notes.
    Attached Thumbnails Attached Thumbnails macro.jpg  
    Attached Files Attached Files

  5. #5
    Join Date
    May 2007
    Posts
    1003
    You definitely need to buy sinha's book. As a cheaper alternative you could buy Peter Smid's book. However, it is my understanding that sinha's book gives more detailed examples. Haven't purchased it yet myself, but will eventually invest in one. I had Peter Smid's book before sinha wrote his. The Fanuc Operator's Manual gives examples, but in my opinion is harder to understand. Once you do have a handle on how to use Macros, then it becomes easier to understand Fanuc's explanations.

    I think you will find using macros to be not only fun, but a great programming tool. I'm always looking for a new way to incorporate macros into my programming.

  6. #6
    Join Date
    Oct 2011
    Posts
    0
    Thanks so much for the help guys!! Really appreciate it!

    What is this sinha book people are referring to? Looks like I need to get a copy.

  7. #7
    Join Date
    Feb 2008
    Posts
    267
    Quote Originally Posted by millmasterflex View Post
    Thanks so much for the help guys!! Really appreciate it!

    What is this sinha book people are referring to? Looks like I need to get a copy.
    [ame="http://www.amazon.com/Programming-using-Fanuc-Custom-Macro/dp/0071713328/?tag=5336612511-20"]From Amazon[/ame]
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  8. #8
    Join Date
    Feb 2006
    Posts
    1792
    I could not really understand the US book market.

    There is one seller (---SuperBookDeals) which sells this book for as low as $17.11.
    There is another (alibris) which sells it for $60.00

    [ame="http://www.amazon.com/gp/product/0071713328/ref=sc_pgp__m_A3FHD0R6JB0VL8_7?ie=UTF8&m=A3FHD0R6J B0VL8&n=&s=&v=glance"]Amazon.com: CNC Programming using Fanuc Custom Macro B (9780071713320): S.K Sinha: Books[/ame]

    Why is there so much difference in price? Moreover, if one can get it for 17.11 why would anybody purchase it for 60.00? Both the prices are for new book.

  9. #9
    Join Date
    Feb 2008
    Posts
    267
    Quote Originally Posted by sinha_nsit View Post
    I could not really understand the US book market.

    There is one seller (---SuperBookDeals) which sells this book for as low as $17.11.
    There is another (alibris) which sells it for $60.00

    Amazon.com: CNC Programming using Fanuc Custom Macro B (9780071713320): S.K Sinha: Books

    Why is there so much difference in price? Moreover, if one can get it for 17.11 why would anybody purchase it for 60.00? Both the prices are for new book.
    Those are the strange anomalies of a free market society.
    It's up to the purchaser to decide whom to buy from and how much they are willing to pay.
    If a seller is not selling a particular product it's up to them to change the price to a level that buyers are willing to pay.
    Control the process, not the product!
    Machining is more science than art, master the science and the artistry will be evident.

  10. #10
    Join Date
    Jun 2008
    Posts
    1511
    Quote Originally Posted by angelw View Post
    You're right Stevo, code like IF[#502 GT ***] GOTO778 will result in a syntax error. At a guess, I'd say that its a visual prompt to replace with varying data. But why you would not use a variable and some commented notes to set the variable, who knows.
    I was assuming the same thing. I was more thinking that this was not an actual program in the control but something to reference and fill in the blanks if you will.
    Quote Originally Posted by sinha_nsit View Post
    I could not really understand the US book market.
    Why is there so much difference in price? Moreover, if one can get it for 17.11 why would anybody purchase it for 60.00? Both the prices are for new book.
    Hey Sinha.....you still have your book out there correct? I see you have it listed and the MTH forum. I was thinking about picking up another copy as I have lent mine out a few times to some fellow friends that are getting into the trade (well macros anyway). I also have my brother and his family coming into town from Europe and it is nice to have something lying around that has me published so I can at least keep up with my brothers well doing. Nothing like saying "good for you but are you published".....

    Quote Originally Posted by millmasterflex View Post
    Thanks so much for the help guys!! Really appreciate it!
    You are welcome. Ask all you want....everyone here is more then willing to help. I would suggest picking up Sinha's book as it is a very good book for starting with basics of macroB programming and will cover in detail every question you asked in your first post.

    Stevo

  11. #11
    Join Date
    May 2007
    Posts
    1003
    Quote Originally Posted by sinha_nsit View Post
    I could not really understand the US book market.

    There is one seller (---SuperBookDeals) which sells this book for as low as $17.11.
    There is another (alibris) which sells it for $60.00

    Amazon.com: CNC Programming using Fanuc Custom Macro B (9780071713320): S.K Sinha: Books

    Why is there so much difference in price? Moreover, if one can get it for 17.11 why would anybody purchase it for 60.00? Both the prices are for new book.
    I finally ordered a copy for myself. A quick search found copies marked as high as $76 and $96. I opted for a copy costing much less. Looking forward to reading it.

  12. #12
    Join Date
    Feb 2006
    Posts
    1792
    Take the print of the additional appendices attached here which are not there in the book. These are helpful references.
    Attached Files Attached Files

  13. #13
    Join Date
    May 2007
    Posts
    1003
    Thanks, Sinha. Appreciate that.

Similar Threads

  1. Need help in DECIPHERING ENCODER WIRES from a rotary table
    By ichudov in forum Community Club House
    Replies: 3
    Last Post: 08-03-2010, 02:53 AM
  2. Help deciphering this encoder - Aerotech DC1000
    By yantra3d in forum Servo Motors / Drives
    Replies: 5
    Last Post: 02-11-2010, 10:36 PM

Posting Permissions

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