Fanuc macro B thread....

vinny wrote:


Re-reading this, I notice that I've made a few forehead-slapping mistakes. I moved the G28 block to the main program to avoid an extra program call, and probably put it in the wrong place - should go after the "END 1" block (?). Also mistakenly pasted the M20 at the same time. #3100 should be #3000 (you caught that one).

That still won't work. You're trying to do it all in a single loop - if there's more than 8 tools, #101 will decrement to 0, and on to negative values. You'll be calling G54.0, G53.9, ....

Glad to help, but don't count your chickens before the fat lady sings :)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
with your real name. I dont use that email, so you'd have to let me know i got mail there. They have 20 fanucs, all different brands, and they are putting it on all of em. Its the third largest mold shop in Florida...who knows, you might come work down here some day. They got lots of lathes. Two of em are 4 axis. Lathe guys get the most overtime!
Thanks again man!
Now I need a new project! That was cool.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
vinny wrote:

It will loop, just not with the intended effect.

Indeed!

Yeah, I like macro programming. It isn't always the best solution, but you can use it to do some useful stuff.

Looks good to me.

No that's OK, but thanks.

I'm not in the US, so it's unlikely, but I guess anything's possible...

No problem.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Sunday, 27 July 2014 18:38:06 UTC+1, vinny wrote:

Tweak your post to turn this
G90G10L20P1X0.Y0.Z0.(G54.1P1)
G54.1P1
G90M06T1 T2 G43H1Z10. .... G28G91Z0.
G90M06T2 T3 G43H1Z10. .... G28G91Z0.
G90M06T3 T1 G43H1Z10. .... G28G91Z0.
M30
into this
G90G10L20P1X0.Y0.Z0.(G54.1P1) G90G10L20P2X0.Y1.Z0.(G54.1P2) G90G10L20P3X0.Y2.Z0.(G54.1P3) G90G10L20P4X0.Y3.Z0.(G54.1P4) G90G10L20P5X0.Y4.Z0.(G54.1P5)
#2=5.2
G90M06T1 T2 G43H1Z10. #1=1 WHILE[#1LE#2]DO1 G54.1P#1 .... #1=#1+1 END1 G28G91Z0.
G90M06T2 T3 G43H1Z10. #1=1 WHILE[#1LE#2]DO1 G54.1P#1 .... #1=#1+1 END1 G28G91Z0.
G90M06T3 T1 G43H1Z10. #1=1 WHILE[#1LE#2]DO1 G54.1P#1 .... #1=#1+1 END1 G28G91Z0.
M30
And if you want to run only one part just make #2=1.5
Some posts would have the starting position for the next tool just at the end of the tool so watch it.
DanP
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

very nice. This is what i suited it to for our needs, Simply hardcoded into the tool change section of the post. This is by far the simplist way to do this. All that is needed in the main is % O0001 #100 = 10 (Enter program number) #101 = 8 (Enter number of positions) M198P#100 %
% 00010 (posted from ug) T1M6 #105=1 WHILE[#105LE#101]DO1 G54.1P#105 (gcode here) #105=#105+1 END1 G28G91Z0. M30 %
Awesome, I passed it on. Thanks. Kickass man!!! Dang, could it get any simpler?
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
DanP wrote:

[ snip ]

Just out of curiosity, why the fractional part in the values assigned to #2? I'm guessing it's to allow for floating-point inaccuracy, although I didn't think that was an issue on CNC machines.
Nice bit of code BTW. I never thought of doing it that way.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Unless Im wrong, hes using the .2 to keep the loop going. could of been anything. 5.5. 5.9.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Tuesday, 12 August 2014 23:50:59 UTC+1, wrecker wrote:

I had a glitch once in a serial number routine I wrote, the control panel got it wrong every 20 numbers, it was a Matsuura. I have fixed it by not using an integer. Other people I have worked with do it as well, I have never asked why.
As a result I am doing it just in case. It freaks me out when things don't go the way they are supposed to.
DanP
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
DanP wrote:

Thanks for the tip. I had a hunch it was something learned from bitter experience.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Wednesday, August 13, 2014 5:15:12 AM UTC-7, DanP wrote:

Any chance you have a copy of that macro? I would like to see it, curious to see what the root cause is.
Thanks,
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Tuesday, 9 September 2014 18:59:07 UTC+1, brewertr wrote:

No copy but I can tell you the 500 something variable holding the serial number and being incremented was being split in individual digits with the FIX function and every multiple of 20 was giving the previous number.
So, start with 1 in #500, do the maths with FIX and extract 4 digits into #1, #2, #3 and #4, block skip the engraving sub call and watch the numbers on the screen as you push cycle start.
For 19 in #500 I would get #1=0, #2=0, #3=1, #4=9 and for #500 they would stay the same. Carry on to 40 and there is #1=0, #2=0, #3=3, #4=9.
The control was an old Matsuura. I run the macro in Vericut and it was fine.
Start with #500=1.2 and all is fine. I am glad I spotted it on a dry run.
DanP
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Tuesday, September 9, 2014 1:07:34 PM UTC-7, DanP wrote:

us to see what the root cause is.

number and being incremented was being split in individual digits with the FIX function and every multiple of 20 was giving the previous number.

#1, #2, #3 and #4, block skip the engraving sub call and watch the numbers on the screen as you push cycle start.

20 they would stay the same. Carry on to 40 and there is #1=0, #2=0, # 3=3, #4=9.

ne.

n.

I find the issue you describe very interesting because I haven't seen it be fore. Wish you had a copy of the macro to share.
Serial number Macros I wrote in the past were: Year, Month, Day then count starting at 1 for that day. It made traceability extremely easy.
Anyway, I threw a quick and dirty macro together (pasted below) to see if I could recreate your issue. It did not duplicate your issue. I created the S/N counter and method of extracting digits as you described and the macro runs without duplicating the error you described.
I stepped through the program to watch as the variables changed. Then I cre ated a loop, went through a bunch of cycles and still no errors noticed.
I do initialize the 100 series variables I'm using by giving them 0.0 I do this for all macros I create as a safety, because a variable set to null c an sometimes have very bad effects when least desired.
I don't normally use local variables unless I am going to use them in a cus tom G code. So here I used common variables for my calculations and 1 perma nent common variable to store the accumulated Serial Number. I used the var iables numbers in the order I created the macro.
% O1115 (FOUR DIGIT SERIAL NUMBER) (EXTRACTING DIGITS LEFT TO RIGHT)
IF[#500LE0.]THEN#500=1 IF[#500GT9999]#3000=1 (TOO MANY DIGITS)
WHILE[#500LT9999]DO1 (CREATED LOOP TO TEST MACRO) (DELETE OR COMMENT OUT THE LOOP WHEN MACRO IS DONE)
#100=0.0 #101=0.0 #102=0.0 #103=0.0 #104=0.0 #105=0.0
(#100= FIRST DIGIT) (#102= SECOND DIGIT) (#104= THIRD DIGIT) (#105= LAST DIGIT)
#100=FIX[#500/1000] (EXTRACT 1ST DIGIT BY DIVIDING AND ROUND DOWN)
#101=#500-[#100*1000] (REMOVE 1ST DIGIT) #102=FIX[#101/100] (EXTRACT 2ND DIGIT BY DIVIDING AND ROUND DOWN)
#103=#500-[#100*1000]-[#102*100] (REMOVE 1ST AND 2ND DIGITS) #104=FIX[#103/10] (EXTRACT 3RD DIGIT BY DIVIDING AND ROUND DOWN)
#105=#500-[#100*1000]-[#102*100]-[#104*10] (EXTRACT LAST DIGIT BY REMOVIN G ALL OTHERS)
(#501 THRU #505 FOR VIEWING MACRO VALUES ONLY) (EASIER TO COMPARE THEM TO #500 IF ALL ARE TOGETHER) (WHILE TESTING THE MACRO) (COMMENT OUT OR DELETE WHEN MACRO IS COMPLETED)
#502=#100*1000 #503=#102*100 #504=#104*10 #505=#105+0.0 #501=0.0+#502+#503+#504+#505
#500=#500+1 (ADD 1 TO PERMANENT SN COUNTER)
END1
M30 %
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On Friday, September 12, 2014 9:29:34 PM UTC-7, brewertr wrote:

Dan,
You were talking about an older controller so I edited the macro (mostly IF/THEN) to run on older or new. I also revised some other things I noticed. Anyway here is the less quick and dirty macro version.
% O1115
(FOUR DIGIT SERIAL NUMBER) (DIGITS LEFT TO RIGHT) (TO BEGIN S/N FROM SCRATCH) (#500 SHOULD BE 0. OR 1.)
IF[#500GT10000.]GOTO1000 IF[#500LE0.]GOTO1002
N1 WHILE[#500LT10000]DO1 (CREATED LOOP TO TEST MACRO)
#100=0.0 #102=0.0 #103=0.0 #104=0.0 #105=0.0
(#100= FIRST DIGIT) (#102= SECOND DIGIT) (#104= THIRD DIGIT) (#105= LAST DIGIT) #100=FIX[#500/1000] #101=#500-[#100*1000] #102=FIX[#101/100] #103=#500-[#100*1000]-[#102*100] #104=FIX[#103/10] #105=#500-[#100*1000]-[#102*100]-[#104*10]
#502=#100*1000 G04X.5 #503=#102*100 G04X.5 #504=#104*10 G04X.5 #505=#105+0.0 G04X.5 #501=0.0+#502+#503+#504+#505
#500=#500+1
END1
IF[#500GT9999]GOTO1001
M30
N1000 #30001 (#500 VALUE TOO LARGE) N1001 #30002 (MACRO HAS OUTLIVED USEFULLNESS) N1002 #500=1 GOTO1
%
(#501 THRU #505 FOR VIEWING MACRO VALUES ONLY) (EASIER TO COMPARE THEM TO #500 IF ALL ARE TOGETHER) (WHILE TESTING THE MACRO)
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.