What's new
What's new

Macro suddenly stopped working

meandean77

Aluminum
Joined
Jun 23, 2014
Location
United States
** i need help** KIRA KNH-40HB (300MM HMC) Fanuc 21i** I was dnc'ing the other day and the computer power supply had an issue and decided to shut down, obviously the machine stoped cuz it was waiting for code. No problem, I modify the program to start at the tool that was in the spindle, after fixing the computer power issue, easy stuff. But now I have a major problem that I can not figure out, neither can machine service department. Machine is 300mm HMC with Fanuc 21i controller. Ever since the pc/DNC issue my dynamic work offset macro is not calculating correctly, I have confirmed that all variable values are correct that are used in the dynamic work offset macro, the problem occurs wen these values are calculated in the couple trig equations at the end of the macro. The part program is proven over a thousand parts, the dynamic work offset macro is proven, been using it for several years, problem only started after the computer shut down, mid DNC ** I'm stumped. ANY IDEAS???
 
Has shutting down the machine and restarting not been able to clear up the problem or are you afraid to do this in a mid program restart?

Does the calculation pull values from variables somewhere? Are those variables properly cleared/overwritten when the macro reruns?
 
Has shutting down the machine and restarting not been able to clear up the problem or are you afraid to do this in a mid program restart?

Does the calculation pull values from variables somewhere? Are those variables properly cleared/overwritten when the macro reruns?

Yes, I have completely shut down and restarted machine. Yes, the calculation pulls values from variables and I have confirmed that those variables values are correct. Problem occurs in the calculation. This macro has worked perfectly for a couple years, problem started after computer shut down mid DNC.
 
Yes. Things should be alright after a power cycle.
If not, post the macro for a closer look.
 
%
o9010(g100--dynamic wrk offset)
(** renishaw compatible**)
(use g54.1 p#)
(pmtr 6050 to set g100 as g code)
(x y z variance needs to be set-)
(-in the calling program-)
(-use variable #703 #704 #705)
(b axis must be in cut pstn g54 g57)
(all xyz position no matter)
(g59 needs to be called after g100)
(calling program is to run g59)
(crnt fxtr ofst nmbr p1-p99)
#690=[13980+[#4130*20]]
(set variables- curent offsets)
(number for current offset x)
#691=[#690+1]
(number for current offset y)
#692=[#690+2]
(number for current offset z)
#693=[#690+3]
(number for current offset b)
#694=[#690+4]
(----)
(x shift amount-)
(how far off part is from pgm zero)
(#703 must be spcfd in main pgm)
#710=#703
(y shift amount-)
(how far off part is from pgm zero)
(#704 must be spcfd in main pgm)
#711=#704
(z shift amount-)
(how far off part is from pgm zero)
(#705 must be spcfd in main pgm)
#712=#705
(b axis position with current ofst )
(#5044 is current work offset b axis position)
#713=#5044
(----)
(x pallet c/l machine cords)
#714=#[#691]
(z pallet c/l machine cords)
#715=#[#693]
(----)
(calculate x offset value for g10)
#720=#714+[#710*[cos[#713]]]-[#712*[sin[#713]]]
(round off x value)
#720=[fup[#720*10000]/10000]
(calculate z offset value for g10)
#721=#715+[#710*[sin[#713]]]+[#712*[cos[#713]]]
(round off z value)
#721=[fup[#721*10000]/10000]
(----)
(update xyzb g59)
g90g10l2p6x#720y[#711+#[#692]]z#721b#[#694]
(back to calling program)
m99
%
 
720 and 721 are not calculating correctly, after computer shut down mid DNC. Macro has worked perfectly for several years.

Can you quantify the error somehow so we can understand it? Is it a constant error, or widely variable in value, transposed values, or what?
 
Huflungdung, yes I can. Instead of the macro changing Apx x10 z20 it now reads like XZ 600 hundredish which is also the variables I use, so I'm sure that is a clue, to the problem, what is strange is that this has all worked for several years, till computer shut off mid DNC.
 
g90g10l2p6x#720y[#711+#[#692]]z#721b#[#694]

I don't have experience with programming macros for a cnc, although I have done some logic in other avenues.

So I don't know about this #[#692] thing, in the middle of an expression. You are accomplishing what by writing that?
 
g90g10l2p6x#720y[#711+#[#692]]z#721b#[#694]

I don't have experience with programming macros for a cnc, although I have done some logic in other avenues.

So I don't know about this #[#692] thing, in the middle of an expression. You are accomplishing what by writing that?
Hello HuFlungDung,
Syntax such as #[#692] will specify a variable, the identifying number of which, in this example, is held in variable #692. For example, if variable #692 had the value of 100, then the expression [#711+#[#692]] would translate to [#711+#100].

Regards,

Bill
 
Hello HuFlungDung,
Syntax such as #[#692] will specify a variable, the identifying number of which, in this example, is held in variable #692. For example, if variable #692 had the value of 100, then the expression [#711+#[#692]] would translate to [#711+#100].

Regards,

Bill

Ok, I can understand that but it doesn't really make sense in this situation, does it? #692 never gets any other value than what was assigned earlier.
 
Huflungdung
Yes #692 is needed to collect the Y axis current work offset value. This dynamic work offset macro is proven and has worked perfectly for several years, but suddenly stopped working after my computer shut down mid DNC. After some testing, it seems the problem occurs at #714 & #715 because if i replace #[#691] and #[#693] with the value of the current work offset, it calculates correctly. It seems to me that somehow a machine setting changed, just not sure what it is ?
 
I've experienced some weird things, for example, you think a controller is ignoring what is inside of parenthesis, but it's not really, it still parses it until is gets to the second bracket.

In your comments:

(x pallet c/l machine cords)
#714=#[#691]
(z pallet c/l machine cords)
#715=#[#693]

you have a / mark. That may or may not mean something to the controller and I would try removing it. Maybe temporarily remove all comments from your macro and run the naked code.
 
Greg
To be honest I'm not quite sure, but I was at one time. I believe it has something to do with converting g54.1 Pxx. Looking into doing that part differently. Again this macro has worked perfectly for a couple years and suddenly stopped working after my computer shut down mid DNC.
 








 
Back
Top