Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Parsing a value in Fanuc B


Guest
 Share

Recommended Posts

Is there a way to parse a value.....

 

Say I set

 

#101=123456789

 

Is there a way to take it and break it down.....something like

 

#500=1

#501=2

#502=3

#504=4

#505=5

#506=6

#507=7

#508=8

#509=9

 

 

 

Link to comment
Share on other sites

attached is a serial number macro that parses out each number from the value in a macro variable register. Basically it divides the value by 10, rounds it down then subtracts itself from the original number and multiplies it by 10 to parse out the number into a separate register. There is a fudge factor in there that deals with binary round off errors caused by the CNC control. Look at N15 of the macro and you see how it extrapolates the number into #104 then jumps to N#104 to engrave the number at which point instead of engraving a number, you could have it fill the registers as you have it shown here.

 

hope this helps!

 

Cheers!

Len Dye

Serial Number Macro.zip

Link to comment
Share on other sites

This will get you started.

Note: I had to use negative numbers to get it to work. This was a station on/off switch for eight part clustertowers. -0.12045608 would mean stations 1,2,4,5,6,8 would machine parts and stations 3, 7 would not. If you using the Fanuc 16 series then you will only be able to parse 8 values. The 30 series will get you 9 or more (I only checked 9).

 

%
O9019(G202 -- PART ON/OFF SWITCH FOR FASTEMS)
(PARAMETER 6059)
#181=0

WHILE[#150EQ1]DO1
IF[#1GE.1]THEN#181=1
GOTO1
END1

WHILE[#150EQ2]DO1
IF[#1GE.1]THEN#1=#1-.1
IF[#1GE.02]THEN#181=1
GOTO1
END1

WHILE[#150EQ3]DO1
IF[#1GE.1]THEN#1=#1-.1
IF[#1GE.02]THEN#1=#1-.02
IF[#1GE.003]THEN#181=1
GOTO1
END1

WHILE[#150EQ4]DO1
IF[#1GE.1]THEN#1=#1-.1
IF[#1GE.02]THEN#1=#1-.02
IF[#1GE.003]THEN#1=#1-.003
IF[#1GE.0004]THEN#181=1
GOTO1
END1

WHILE[#150EQ5]DO1
IF[#1GE.1]THEN#1=#1-.1
IF[#1GE.02]THEN#1=#1-.02
IF[#1GE.003]THEN#1=#1-.003
IF[#1GE.0004]THEN#1=#1-.0004
IF[#1GE.00005]THEN#181=1
GOTO1
END1

WHILE[#150EQ6]DO1
IF[#1GE.1]THEN#1=#1-.1
IF[#1GE.02]THEN#1=#1-.02
IF[#1GE.003]THEN#1=#1-.003
IF[#1GE.0004]THEN#1=#1-.0004
IF[#1GE.00005]THEN#1=#1-.00005
IF[#1GE.000006]THEN#181=1
GOTO1
END1

WHILE[#150EQ7]DO1
IF[#1GE.1]THEN#1=#1-.1
IF[#1GE.02]THEN#1=#1-.02
IF[#1GE.003]THEN#1=#1-.003
IF[#1GE.0004]THEN#1=#1-.0004
IF[#1GE.00005]THEN#1=#1-.00005
IF[#1GE.000006]THEN#1=#1-.000006
IF[#1GE.0000007]THEN#181=1
GOTO1
END1

WHILE[#150EQ8]DO1
IF[#1GE.1]THEN#1=#1-.1
IF[#1GE.02]THEN#1=#1-.02
IF[#1GE.003]THEN#1=#1-.003
IF[#1GE.0004]THEN#1=#1-.0004
IF[#1GE.00005]THEN#1=#1-.00005
IF[#1GE.000006]THEN#1=#1-.000006
IF[#1GE.0000007]THEN#1=#1-.0000007
IF[#1GE.00000008]THEN#181=1
GOTO1
END1

N1M99
%

 

HTH

Link to comment
Share on other sites

Thanks guys, I think I can pull out of these what I am looking to do..

 

:cheers:

here you go, It was easy for me to take the time to write it and test it for you. Load the following program into the memory. If you use it a lot you may want register it as a G-Code macro otherwise the command would be G65 P9020 D= number of digits. Start with your number in #100 and it puts the 1st digit into #501, 2nd goes into #502 etc.

 

Be careful thou, its writing to #500's where your probe calibration data may be and you will be recalibrating you probe like I am :(

I tested 9 digits only but I imagine it would fill as many registers that you have.

 

 

O9020(PARSE OUT NUMBERS)

(COMMAND= G65 P9020 D#)

(D= NUMBER OF DIGITS TO PARSE)

#101=1

#102=0

#106=.001

N1

#100=[#100/10]

#102=FIX[#100+#106]

#105=[[[#100-#102]*10]+#106]

#102=FIX[#105+#106]

#100=FIX[#100+#106]

#104=[#102+500]

#[#104]=[#104-500]

N2

#101=[#101+1]

IF[#101 GT #7]GOTO99

GOTO1

N99

M99

%

 

cheers!

Len Dye

Link to comment
Share on other sites
Here is the way we do it, this works for 4 digits but can be adapted for 8 easily

 

#501=FIX[#101/10000] 

#502=FIX[#101/1000]

#503=FIX[#101/100] 

#504=FIX[#101/10]

#505=FIX[#101/1]


G4P1 

#505=[#505-[#504*10]]

#504=[#504-[#503*10]]

#503=[#503-[#502*10]]

#502=[#502-[#501*10]]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...