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:

Okuma horizontal offset rotation macro


Recommended Posts

There was some discussion about horizontal programming and rotation macros in this thread. http://www.emasterca...ndpost&p=737320

I shared my Fanuc offset rotation macro and said I would share Okuma when I finished it. So here it is.

 

OROT

(PW = WORK OFFSET TO BE USED FOR CALC)
(PH = NEW WORK OFFSET NUMBER)
(PB = INDEX AMOUNT)


XMPS=0 (MACHINE POS X ROTATION)
ZMPS=-9.9444 (MACHINE POS Z ROTATION)
SOFF=PW (W)
FOFF=PH
INDX=PB
VZOFB[FOFF]=VZOFB[sOFF]
VZOFY[FOFF]=VZOFY[sOFF]

CXOF=VZOFX[sOFF] (STORE CURRENT X OFFSET FOR CALC)
CZOF=VZOFZ[sOFF] (STORE CURRENT Z OFFSET FOR CALC)

XDTA=[CXOF-XMPS](DELTA X)
ZDTA=[CZOF-ZMPS] (DELTA Z)

CHXP=SQRT[[XDTA*XDTA]+[ZDTA*ZDTA]] (HXP FOR CALC)

SDEG=[ASIN[XDTA/CHXP]] (START DEG FOR CALC)

CDEG=[sDEG+-INDX] (CACL DEG)

XDTN=[sIN[CDEG]*CHXP] (NEW DELTA X)
ZDTN=[COS[CDEG]*CHXP] (NEW DELTA Z)

XOFN=[XDTN+XMPS] (NEW X OFFSET)
ZOFN=[ZDTN+ZMPS] (NEW Z OFFSET)

VZOFX[FOFF]=XOFN
VZOFZ[FOFF]=ZOFN
RTS  

  • Like 7
Link to comment
Share on other sites
  • 4 years later...

There was some discussion about horizontal programming and rotation macros in this thread. http://www.emasterca...ndpost&p=737320

I shared my Fanuc offset rotation macro and said I would share Okuma when I finished it. So here it is.

 

OROT

(PW = WORK OFFSET TO BE USED FOR CALC)
(PH = NEW WORK OFFSET NUMBER)
(PB = INDEX AMOUNT)


XMPS=0 (MACHINE POS X ROTATION)
ZMPS=-9.9444 (MACHINE POS Z ROTATION)
SOFF=PW (W)
FOFF=PH
INDX=PB
VZOFB[FOFF]=VZOFB[SOFF]
VZOFY[FOFF]=VZOFY[SOFF]

CXOF=VZOFX[SOFF] (STORE CURRENT X OFFSET FOR CALC)
CZOF=VZOFZ[SOFF] (STORE CURRENT Z OFFSET FOR CALC)

XDTA=[CXOF-XMPS](DELTA X)
ZDTA=[CZOF-ZMPS] (DELTA Z)

CHXP=SQRT[[XDTA*XDTA]+[ZDTA*ZDTA]] (HXP FOR CALC)

SDEG=[ASIN[XDTA/CHXP]] (START DEG FOR CALC)

CDEG=[SDEG+-INDX] (CACL DEG)

XDTN=[SIN[CDEG]*CHXP] (NEW DELTA X)
ZDTN=[COS[CDEG]*CHXP] (NEW DELTA Z)

XOFN=[XDTN+XMPS] (NEW X OFFSET)
ZOFN=[ZDTN+ZMPS] (NEW Z OFFSET)

VZOFX[FOFF]=XOFN
VZOFZ[FOFF]=ZOFN
RTS

can you show me how to use it, thanks

Link to comment
Share on other sites

1. Create an .SSB file called OROT.SSB

2. Copy the code from above into the SSB file, save in MD1

3. In the code there are two variables that need to be set with actual machine positions from your machine. This is a one time setting. These are XMPS and ZMPS. These should be calculated as the center of the rotation of the table.

4. When you want to calculate the position of a work coordinate after you rotate the B axis, you call this from your main program;

        CALL OROT PW=*** PH=*** PB=***

        PW should be the work offset number you want to use as the base number for calculations. 

        PH is the new work offset number it updates with the new calculated coordinates.

        PB is the amount (+/-180 degrees) that you want to calculate for b axis rotation.

  • Like 3
Link to comment
Share on other sites
  • 3 weeks later...
  • 4 weeks later...
  • 1 year later...

Hey team, just a heads up, I found this macro to have a few issues in its function. My initial setup or application of it maybe at fault but I assume I am not the only one. I re wrote the sub based on this macro for an Okuma MB-5000. I also created a function in the post for the macro to be used at all times. The format of the code is 

G115 PH=1 PX=0. PY=0. PB=0.

Where G115 calls sub OROT, PH=# will reference your work offset (G15 H#), PY=# & PX=# is the start position of the tool and PB=# is your rotation to.

When you first setup a part, set your X, Y, and Z in your work offset relative to your center of rotation. Once the sub is called it will shift your new X,Y,Z, and B to theatrical zero relative to center. I do not currently have a function for shifting the zero if your center of rotation is not X0, Z0 but I could help put one together if need be. Once the sub is ran the machine will be reading from G15 H200. Here is the sub 

OROT(115)
(PH = WORK OFFSET TO BE USED FOR CALC)
(PX = MOVE TO X)
(PY = MOVE TO Y)
(PB = MOVE TO B)


INDX=PB (SAVE B POSITION)

XDTA=VZOFX[PH] (PULL X POS)
ZDTA=VZOFZ[PH] (PULL Z POS)

CHXP=SQRT[[XDTA*XDTA]+[ZDTA*ZDTA]] (HXP FOR CALC)

XDEG=[ASIN[XDTA/CHXP]] (START DEG FOR CALC X)
ZDEG=[ASIN[ZDTA/CHXP]] (START DEG FOR CALC Z)

XCDG=[XDEG-INDX] (CACL DEG X)
ZCDG=[ZDEG-INDX] (CACL DEG Z)

XDTN=[SIN[XCDG]*CHXP] (NEW DELTA X)
ZDTN=[SIN[ZCDG]*CHXP] (NEW DELTA Z)

VZOFX[200]=XDTN
VZOFY[200]=VZOFY[PH]
VZOFZ[200]=ZDTN
VZOFB[200]=VZOFB[PH] 

M403
G0 G90 G15 H200 X=PX Y=PY B=INDX
RTS 

Lastly, for the Mastercam side of things.

Switch allows to turn on and off as needed in the post

g115         : 1  #G115 swtitch

Under the ptlchg_com post block I have

        pcan1, pbld, n$, *sgcode, *sgplane, *sgabsinc, *sgfeed, "G40", "G80", e$
          if g115, "G115", [if not(index), pfwcs], pfxout, pfyout, pfcout, e$
          else, [if not(index), pwcs], pfxout, pfyout, pfcout, e$
          pfspindleout, [if gcode$ = 1, *feed], strcantext, e$
        if lock_codes = one & not(index) & rot_on_x & cuttype = 0, pbld, n$, *slock, slockcomm, e$

Under the ptlchg0$ post block

            if g115, "G115", [if not(index), pfwcs], pfxout, pfyout, pfcout, pspindleout, e$
               else, [if not(index), pwcs], *sgcode, pfxout, pfyout, pfcout, pspindleout, e$

Under pfwcs Post block

            if g115,
            [
              g_wcs = workofs$
              gh_wcs = g_wcs, !g_wcs *gh_wcs
            ]
            else,
            [
            g_wcs = workofs$
            *g_wcs
            ]

Then for forced output I added this to give the G115 its location

pfxout          #Force X axis output
      if g115 & ((wcstype > one & workofs$ <> prv_workofs$) | (tlplnno$ <> last_tlplnno) | retractflg), [xpx=xabs, *xpx, !xabs, !xinc ]
         else,
         if absinc$ = zero, *xabs, !xinc
         else, *xinc, !xabs

pfyout          #Force Y axis output
      if g115 & ((wcstype > one & workofs$ <> prv_workofs$) | (tlplnno$ <> last_tlplnno) | retractflg), [ypy=yabs, *ypy, !yabs, !yinc ]
         else,
         [
         if absinc$ = zero, *yabs, !yinc
         else, *yinc, !yabs
         ]

pfcout          #Force C axis output 
      if index = zero & rot_on_x,
        [
        if use_rotmcode & (fmtrnd(cabs) <> fmtrnd(prv_cabs) | sof), *sindx_mc
        if g115 & ((wcstype > one & workofs$ <> prv_workofs$) | (tlplnno$ <> last_tlplnno) | retractflg), [cpc=cabs, *cpc, !cabs, !cinc ]
            else,
            [
            if absinc$ = zero, *cabs, !cinc, !cout_i
            else, *cout_i, !cinc, !cabs
            ]
        ]

I hope this is of use to others. I love the ability to slap a part on the rotary, probe it once and be ready to run with out a worry.

Oh, something else to mention. If you leave your work offset as zero or -1 in Mastercam you will get an alarm at the machine. I have been meaning to add something for that. Also, never set your work offset as 200 when using this sub... bad things will happen...

 

  • Like 1
Link to comment
Share on other sites
On 9/29/2017 at 4:28 PM, ahaslam said:

 I found this macro to have a few issues in its function.

 I do not currently have a function for shifting the zero if your center of rotation is not X0, Z0 but I could help put one together if need be. 

What issues did you find? We have installed this in many machines and have people that use it regularly without issue. . 

The macro was designed to work regardless of where your machines encoder 0 points are. This way you can program to your part regardless of which machine or which tombstone the part is going in. All the macro does is calculate/populate the machine values for a new offset based on a B axis index amount and an existing work offset. It does require though that you update the macro with the exact position in machine coordinates of the b rotation for each machine you install it in. The variables are listed below. 

XMPS=0 (MACHINE POS X ROTATION)
ZMPS=-9.9444 (MACHINE POS Z ROTATION)
  • Like 1
Link to comment
Share on other sites
16 hours ago, ahaslam said:

I think I am confused on the CDEG=[SDEG+-INDX] (CACL DEG). It seems to flip flop I go from a ZMPS positive to a ZMPS negative. Have I done something wrong there?

I am not sure what you mean. I translated this to Okuma macro 6 years ago. I wrote the original Fanuc version I use many years before that. I honestly can't remember why I have that calc using +-, but I can say it has worked in every machine (Fanuc or Okuma) that I have tried it in regardless of where the machines axis 0's are located. At one job we used it in Hitachi Horizontals where the machine X0 and Z0 were at the full X- and Z+ travel limit. It also works on Okumas with the pallet face as Z0 and pallet center as X0. 

Also, for those that like to program to center of rotation as 0, you can easily reset the machine Z0 on an Okuma horizontal to the center of B axis rotation. 

Link to comment
Share on other sites
  • 9 months later...

Doug,

 So 

XMPS=0 (MACHINE POS X ROTATION)<-------This is where I input the new X?
ZMPS=-9.9444 (MACHINE POS Z ROTATION)<------This is where I input the distance from lets say table face to center of table?

Don't mean to beat a dead horse, but I have just taken over a new job shop that has almost all Okuma Horizontals and

I want to start programming from center of rotation.  Your Macro is exactly what I am looking for.

 

So for example, I set G15 H1 as the center of rotation, input those numbers in the PW=

Then input G15 H10 as the new Work offset in the PH=

Then the rotation as lets say B0 or B180 as PB=?

Thanks,

 Todd

 

Link to comment
Share on other sites
1 hour ago, tsaladyga said:

Doug,

 So 


XMPS=0 (MACHINE POS X ROTATION)<-------This is where I input the new X?
ZMPS=-9.9444 (MACHINE POS Z ROTATION)<------This is where I input the distance from lets say table face to center of table?

Don't mean to beat a dead horse, but I have just taken over a new job shop that has almost all Okuma Horizontals and

I want to start programming from center of rotation.  Your Macro is exactly what I am looking for.

 

So for example, I set G15 H1 as the center of rotation, input those numbers in the PW=

Then input G15 H10 as the new Work offset in the PH=

Then the rotation as lets say B0 or B180 as PB=?

Thanks,

 Todd

 

Todd, you are correct in your comments. The XMPS will be a number very close to 0 and the ZMPS will be about half the table size in inches.

Also if you do prefer to program to the center of the table there is a document that explains setting the Z0 to the center of the table. It simplifies work offsets as they should be close to 0 for X and Z after making the changes.  Your Okuma dist should be able to get you a copy of the document if interested. 

Link to comment
Share on other sites

Thanks Doug!

 I like your idea because there are legacy programs that run off the front of the table and use formulas to adjust for shift, so until I update those

programs your Macro gives me the flexibility to run "old" style programs vs. "new".

 

Link to comment
Share on other sites
  • 2 weeks later...

Okay, now I follow. I did it a bit different, I changed my probe routine so that my tools would be shifted to center of table from the touch off. I also came up with a slightly different way to calculate it but in general it is the same concept. Please note, on the Okuma MB-5000 I found that if the machine over travels inside of the macro it will not alarm out. My macro told it to move to Y-.5 and the machine made it to Y-.43 and started the G81. Kinda scary if you don't watch it. When I get the chance I'll post the in position check that I added. 

Link to comment
Share on other sites
31 minutes ago, ahaslam said:

Okay, now I follow. I did it a bit different, I changed my probe routine so that my tools would be shifted to center of table from the touch off. I also came up with a slightly different way to calculate it but in general it is the same concept. Please note, on the Okuma MB-5000 I found that if the machine over travels inside of the macro it will not alarm out. My macro told it to move to Y-.5 and the machine made it to Y-.43 and started the G81. Kinda scary if you don't watch it. When I get the chance I'll post the in position check that I added. 

Set your post or programs to force the X and Y position of the first drilling location in the G81 (or other) canned cycle call line. That way if the machine ran out of travel in the G0 positioning move it will alarm on the G81 call versus drilling in the wrong location. 

Link to comment
Share on other sites
  • 3 weeks later...
On 5/25/2016 at 7:23 PM, YoDoug® said:

1. Create an .SSB file called OROT.SSB

2. Copy the code from above into the SSB file, save in MD1

3. In the code there are two variables that need to be set with actual machine positions from your machine. This is a one time setting. These are XMPS and ZMPS. These should be calculated as the center of the rotation of the table.

4. When you want to calculate the position of a work coordinate after you rotate the B axis, you call this from your main program;

        CALL OROT PW=*** PH=*** PB=***

        PW should be the work offset number you want to use as the base number for calculations. 

        PH is the new work offset number it updates with the new calculated coordinates.

        PB is the amount (+/-180 degrees) that you want to calculate for b axis rotation.

Thanks for sharing this program.  Would this work in conjunction with probing if we had to shift the X or Y  for locating parts?  Here is a program of how i'm picturing this working.

%
O1001
(CG00522-1)
(T22, 1/2" HIGH TECH CARBIDE)
(T200, 6mm PROBE)
VZOFX[200]=0.
VZOFY[200]=0.
VZOFZ[200]=0.
VZOFB[200]=0.
VZOFX[21]=0.
VZOFY[21]=0.
VZOFZ[21]=0.
VZOFB[21]=0.
VZOFX[20]=0.
VZOFY[20]=0.
VZOFZ[20]=-9.840
VZOFB[20]=180
G40 G80 G90 G94 G17
G20
G00 Z400.
M21
G00 B0.
CALL OROT PW=200 PH=21 PB=0.
M20

(Probe4)
G116 T200 (6mm PROBE)
T22
M130
G15 H20
M21
G00 B180.
CALL OROT PW=200 PH=21 PB=180.
M20
G00 X4.2673 Y4.209
G56 Z15.845 H200
CALL O9832
CALL O9810 PZ=10.845 PF=80
CALL O9811 PZ=9.845 PQ=0.5 PS=21.
CALL O9810 PZ=15.845
CALL O9833
G00 X4.2673 Y4.209 Z15.845
G40 G80 G90 G94

(Probe6)
M130
G00 X3.0525 Y3.5
G56 Z15.845 H200
CALL O9832
CALL O9810 PZ=11.845 PF=80
CALL O9812 PX=3. PZ=9.6088 PQ=2. PR=3. PS=21.
CALL O9810 PZ=15.845
CALL O9833
G40 G80 G90 G94
M05
G90 G00 Z400.

(Drill1)
M01
G116 T22 (1/2" HIGH TECH CARBIDE)
T200
S3900 M03
G15 H21
M21
G00 B180.
CALL OROT PW=200 PH=21 PB=180.
M20
M08
M120
G00 X4.5525 Y5.
G56 Z15.845 H22
Z13.845
G71 Z13.845
G90 G81 X4.5525 Y5. Z10.845 R11.245 F30 M53
G00 Z13.845
Z15.845
G40 G80 G90 G94
G00 Z400.
M21
G00 B0.
CALL OROT PW=200 PH=21 PB=0.
M20

(Drill1 2)
S3900 M03
M21
G00 B-90.
CALL OROT PW=200 PH=21 PB=-90.
M20
G00 X-9.845 Y5.
G56 Z10.5525 H22
Z8.5525
G71 Z8.5525
G90 G81 X-9.845 Y5. Z5.5525 R5.9525 F30 M53
G00 Z8.5525
Z10.5525
G40 G80 G90 G94

M05
M09
G00 Z400.
G30 P1
M21
G00 B0.
M02
%

 

What do you think or do you have experience with this?
thanks!

Link to comment
Share on other sites
1 hour ago, narf said:

Thanks for sharing this program.  Would this work in conjunction with probing if we had to shift the X or Y  for locating parts?  Here is a program of how i'm picturing this working.

%
O1001
(CG00522-1)
(T22, 1/2" HIGH TECH CARBIDE)
(T200, 6mm PROBE)
VZOFX[200]=0.
VZOFY[200]=0.
VZOFZ[200]=0.
VZOFB[200]=0.
VZOFX[21]=0.
VZOFY[21]=0.
VZOFZ[21]=0.
VZOFB[21]=0.
VZOFX[20]=0.
VZOFY[20]=0.
VZOFZ[20]=-9.840
VZOFB[20]=180
G40 G80 G90 G94 G17
G20
G00 Z400.
M21
G00 B0.
CALL OROT PW=200 PH=21 PB=0.
M20

(Probe4)
G116 T200 (6mm PROBE)
T22
M130
G15 H20
M21
G00 B180.
CALL OROT PW=200 PH=21 PB=180.
M20
G00 X4.2673 Y4.209
G56 Z15.845 H200
CALL O9832
CALL O9810 PZ=10.845 PF=80
CALL O9811 PZ=9.845 PQ=0.5 PS=21.
CALL O9810 PZ=15.845
CALL O9833
G00 X4.2673 Y4.209 Z15.845
G40 G80 G90 G94

(Probe6)
M130
G00 X3.0525 Y3.5
G56 Z15.845 H200
CALL O9832
CALL O9810 PZ=11.845 PF=80
CALL O9812 PX=3. PZ=9.6088 PQ=2. PR=3. PS=21.
CALL O9810 PZ=15.845
CALL O9833
G40 G80 G90 G94
M05
G90 G00 Z400.

(Drill1)
M01
G116 T22 (1/2" HIGH TECH CARBIDE)
T200
S3900 M03
G15 H21
M21
G00 B180.
CALL OROT PW=200 PH=21 PB=180.
M20
M08
M120
G00 X4.5525 Y5.
G56 Z15.845 H22
Z13.845
G71 Z13.845
G90 G81 X4.5525 Y5. Z10.845 R11.245 F30 M53
G00 Z13.845
Z15.845
G40 G80 G90 G94
G00 Z400.
M21
G00 B0.
CALL OROT PW=200 PH=21 PB=0.
M20

(Drill1 2)
S3900 M03
M21
G00 B-90.
CALL OROT PW=200 PH=21 PB=-90.
M20
G00 X-9.845 Y5.
G56 Z10.5525 H22
Z8.5525
G71 Z8.5525
G90 G81 X-9.845 Y5. Z5.5525 R5.9525 F30 M53
G00 Z8.5525
Z10.5525
G40 G80 G90 G94

M05
M09
G00 Z400.
G30 P1
M21
G00 B0.
M02
%

 

What do you think or do you have experience with this?
thanks!

I did not look over your code, but short answer, yes it can be used with probing. I helped a customer with a casting that required cross features of a cast bore to be controlled to the center line of the cast bore. We probed the bore for XYZ at B0 then used the rotation macro to update the work offset for B90 cross work. 

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...