What's new
What's new

Macro Value... Store in Part file from Machine Value - Fanuc 31i

dstryr

Diamond
Joined
Jan 22, 2010
Location
Nampa Idaho
Is there a way to pull variables out of the machine and store them in the part program?
I'd like to record 5 numbers so that in a year from now if they get reset they will default back in?
 
You could add them to the program as a constant.

at the top include
#100=12345.
#101=11214.
#500=12414.

and so on.
 
I'm doing operations to these values and they are changing so I'd like the last known value stored in the program hard code.
 
Every number used or stored on a Fanuc, be it a position, spindle speed, offsets, machine status of any kind, is a System Variable. Almost everything. Look through your manuals and find out what those variables are. Then, those system variables can be pulled and stored and used just as any macro variable can.

If you can be more specific, that might help one of us point you in the right direction.

Paul
 
Macro is a serial number macro.
I'd like to take the last number written in the program and save it so in a year from now if I've ever changed it or something happens I'll have the next value ready to go.
 
Can you DPRNT and output to a text file on a server somewhere? Next time you load program, you can glance at the text file stored right next to it for current serial?

Seems like a lot of trouble though...Haven't had a chance myself to make that work seamlessly yet.

Maybe best to keep record of it on the shop traveler or in your MRP system? Next time job is ran you can reference the previous job?
 
That's very trick, unless angelw or some other wiz knows a way... So far as I know it, I don't think you can _write_ anything into the program - in otherwords, the program doesn't have a memory, the machine control does...

The only thing I can think of, is to use the DPRINT command, and output the data, in this case, a macro-variable, into a text file. Then, at least you could look at the last stored value in the text file, and know what the last value was...
 
Is there a way to pull variables out of the machine and store them in the part program?
I'd like to record 5 numbers so that in a year from now if they get reset they will default back in?
Hello dstryr,
The value of a Variable can't be copied to the actual program and thereafter saved with the program. You can, however, use BPRNT (BP), or DPRNT (DP) to write the values of the Variables to an external device as a Text file.

Thinking about it briefly, my approach would be to output either a program number, or a file name (a copy of which would be contained in brackets, say at the start or end of your running program, in your running program), as the first data output after POPEN, followed by the date and time (both of which are accessible via System variables), then the Variable (Variables) you want to save.

You would either have to have the BP/DP code included in you program, disabled using Block Skip (Block Delete) until required, or as a dedicated program that is run when you want to save the Variable data.

Regards,

Bill
 
I will look into the saving a file technique.
Thanks everyone for the advice

Since I already have a thread here I might as well take my next question...
(Please have forgiveness as I've been working for 16 hours and counting and I might have brain lock as I'm assuming this is mathematically a very simple thing to do....)

I took a serial engraving macro online and modified it to my needs. This has been my first experience with macros and it was pretty cool. The original writer of this macro uses 1 macro variable to control each digit.

So
701=0
702=2
703=2
704=3
705=2

Engraves serial # 02232

#700=[[#701*10000]+[#702*1000]+[#703*100]+[#704*10]+[#705*1]]

I was able to come up with the following equation to generate this 02232 number and store it in 1 variable but I can not seem to understand how to back the equation out to find variables 701-705 from Variable 700
 
hrm....... interesting..... If G-Code had string functions available it would be rather simple.... but this is interesting as I've never tried to do what you need to do. I'll have to think on this a bit.
 
I will look into the saving a file technique.
Thanks everyone for the advice

Since I already have a thread here I might as well take my next question...
(Please have forgiveness as I've been working for 16 hours and counting and I might have brain lock as I'm assuming this is mathematically a very simple thing to do....)

I took a serial engraving macro online and modified it to my needs. This has been my first experience with macros and it was pretty cool. The original writer of this macro uses 1 macro variable to control each digit.

So
701=0
702=2
703=2
704=3
705=2

Engraves serial # 02232

#700=[[#701*10000]+[#702*1000]+[#703*100]+[#704*10]+[#705*1]]

I was able to come up with the following equation to generate this 02232 number and store it in 1 variable but I can not seem to understand how to back the equation out to find variables 701-705 from Variable 700

Hello dstryr,
Following is the basic logic to extract each digit in a number from Most to Least significant (Left to Right). If the number of digits in your number string were to remain constant at 5 then 10000 as the max divisor can be used. If the number string length is to vary, then you would have to add code to make that determination (not difficult). However, once that was determined, the following logic could be put into a DO Loop in a Macro where your number can be passed as an argument for decoding.

#700 = 02232

#701 = FIX[#700 / 10000] (= 0)
#702 = FIX[#700 / 1000] - [#701 * 10] (= 2)
#703 = FIX[#700 / 100] - [[#701 * 100] + [#702 * 10]] (= 2)
#704 = FIX[#700 / 10] - [[#701 * 1000] + [#702 * 100] + [#703 * 10]] (= 3)
#705 = FIX[#700 / 1] - [[#701 * 10000] + [#702 * 1000] + [#703 * 100] + [#704 * 10]] (= 2)

Regards,

Bill
 
Hello dstryr,
Following is the basic logic to extract each digit in a number from Most to Least significant (Left to Right). If the number of digits in your number string were to remain constant at 5 then 10000 as the max divisor can be used. If the number string length is to vary, then you would have to add code to make that determination (not difficult). However, once that was determined, the following logic could be put into a DO Loop in a Macro where your number can be passed as an argument for decoding.

#700 = 02232

#701 = FIX[#700 / 10000] (= 0)
#702 = FIX[#700 / 1000] - [#701 * 10] (= 2)
#703 = FIX[#700 / 100] - [[#701 * 100] + [#702 * 10]] (= 2)
#704 = FIX[#700 / 10] - [[#701 * 1000] + [#702 * 100] + [#703 * 10]] (= 3)
#705 = FIX[#700 / 1] - [[#701 * 10000] + [#702 * 1000] + [#703 * 100] + [#704 * 10]] (= 2)

Regards,

Bill

this is perfect.
Thanks Bill

-Dennis
 
Don't know if this'll help or if it even works on your 31i but on our 18i and 21i you can punch macro variables to a file called "MACROVAR.DAT". It'll punch whatever variables you're looking at. It works like this:

Bring up the macro variable display page. If you want to punch your 500s have that one on the screen.

Press the (OPRT) softkey, 2nd from the right.

Press the '+' key and you should see a key that says 'punch". Press it and the machine will punch #500-#5xx to a file called MACROVAR.DAT.

Unfortunately if you pull the file up in a word processor or program editor you'll get a display that looks like this:

#500=0
#501=30592*65536/8338608
#502= etc.

If you do the math you'll get an answer like 239.0, which is what I happen to have stored in #501 right now.

Also unfortunately, I've yet to find a way to read them back in. But if you want a permanent record of what is currently stored in your variables you could do the above steps and rename your .dat file to <your_prog_name_vars.dat> or something you'll recognize.

I'd leave myself some heavy notes in the file so I could figure out in a year or so what the heck I was thinking when I did this.

I know, I know. Very convoluted. But I find a lot of Fanuc stuff is.
 








 
Back
Top