CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > G-Code Programing


G-Code Programing Discuss G-code programing and problems here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 07-26-2006, 12:40 PM
 
Join Date: Jul 2006
Location: N.Y.
Posts: 22
iMisspell is on a distinguished road
IF variable = bla THEN do this ELSE do that ?

Can someone give me an example of the syntax for an "IF" statment ?

Heres what we would like to do. As of now they use two different programs for the same part, program one is for pallet 1 and program two is for pallet 2.

Would be nice to use one program and set a variable at the beginning to control what workshifts to use (yes, consistent fixtures would be nice ) .

Example.
P01 = pallet one
P21 = pallet two

N001 PL = 1
N002 IF PL = 1 THEN G54.1 P01 ELSE G54.1 P21

Then we would just edit line N001 when needed.

Is this possable, never did anything like this with a CNC program before, but seen some stuff which is close in a few threads around here.

Using a FANUC 16i control.


_
__________________
~ What was once an Opinion, became a Fact, to be later proven Wrong ~
Reply With Quote

  #2   Ban this user!
Old 07-26-2006, 03:49 PM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

060726-1501 EST USA

iMisspell:

I do not know Fanuc details, and I am not where the HAAS manual is.

On HAAS I would use G5x (in your case G54) as the base zero reference. This might be a location near one corner of the pallets. Then I would use G52 to offset from the G54 to the work zero for your part. This hopefully will be clear in the following example.

If there is a machine variable that contains the the pallet number, assume for the following example it is #3028 (pallet number in receiver from HAAS manual on line -- I do not know what this is because we do not have a pallet changer machine), and that a 1 in this variable is pallet 1 and a 2 is pallet 2, then we can make your part zero relative to machine zero automatically set based on which pallet is in the machine. This is automatic as follows:


You can either manually load G54 before you run the program or G54 can be loaded at the start of the program. But this G54 value will remain unchanged from part to part and pallet to pallet. So will the two different G52 values remain constant, but the ones loaded into the G52 location are determined by which pallet is in the machine.

Within your program you will have

IF [ #3028 NE 1 ] GOTO 110

N100
G52 X5.1260 Y4.8796 (for pallet 1 work zero from G54)
GOTO 130

N110
IF [ #3028 NE 2 ] GOTO 120
G52 X5.1753 Y4.9903 (for pallet 2 work zero from G54)
GOTO 130

N120
(Pallet number error)
M00


N130
(Your common program is here)


.
Reply With Quote

  #3   Ban this user!
Old 07-27-2006, 01:44 AM
 
Join Date: Jul 2006
Location: N.Y.
Posts: 22
iMisspell is on a distinguished road

Thanks for your example and explanation, gar.

Ive seen the GOTO and understand its use but think it would be a bit of a pain to implement for us.

In short, heres the my situation. I was just moved on a machine in a prodution shop which has been running programs and parts for a while now (2-3 years). Ive been re-doing some of the programs but do not want to make two programs for each part (a program for each pallets Work-Shift with the only change being a P0# to P2#).

Cutting a four sided casting they use a G54.1 and P# to set the origin for each side, pallet one would be P01=SideA, P02=SideB, P03=SideC, P04=SideD and P05 to control the bores (the old programer tryed to set up the programs so a compleat simpleton can run the machine and theres no real set-up to do, just plug in a few numbers and their done, i have to keep it like that, which is not my choice) for pallet two would be P21, P22, P23, P24, P25. I like the G52, but that would cause alot of confusion for the other guy running the machine, i cant make alot of "radical" changes.

Anyway...
Tool 1 is called up, does some work on Side-A which is P01, then the pallet indexs to Side-B and P02 is called up, all in the same operation. If we were using pallet 2 it would be SideA=P21 and SideB=P22.


Heres a clip of one op (i edited out all the cutting lines)...

(T2, 4" FACE MILL, FINISH 4 SIDES)
N008 G54.1 P01 (work-shift SIDE-A)
.... edited-out ...
N016 G53 Z0.
N017 M01
N018 G0 B90.
N019 G54.1 P02 (work-shift SIDE-B)
.... edited-out ...
N049 G53 Z0.
N050 M01
N051 G0 B180.
N052 G54.1 P03 (work-shift SIDE-C)
.... edited-out ...
N060 G53 Z0.
N061 M01
N062 G0 B270.
N063 G54.1 P04 (work-shift SIDE-D)
.... edited-out ...
N095 G53 Z0.
N094 M01
N095 M06
N096 M01


So for what your saying i would have to do somthing like this ???

Default the code for P01 (pallet one) and use the IF's to skip over them if we're gonna use pallet 2...

(T2, 4" FACE MILL, FINISH 4 SIDES)
IF [ #3028 NE 2 ] GOTO 100
N008 G54.1 P01 (work-shift SIDE-A)
GOTO 101
N100 G54.1 P21
N101 X0 Y0 Z0
.... edited-out ...
N016 G53 Z0.
N017 M01
N018 G0 B90.
IF [ #3028 NE 2 ] GOTO 200
N019 G54.1 P02 (work-shift SIDE-B)
GOTO 201
N200 G54.1 P22
N201 X0 Y0 Z0
.... edited-out ...
N049 G53 Z0.
N050 M01

ect...


I dabble with VB (Visual Basics) and some other simple PC programing langs and was hopping that there was an 'ELSE' command that whent with the IF statment's.

For the ease of editing i was hoping there was somthing along the lines of...

(T2, 4" FACE MILL, FINISH 4 SIDES)
IF [ #3028 NE 1 ] G54.1 P01 ELSE G54.1 P21
.... edited-out ...
N016 G53 Z0.
N017 M01
N018 G0 B90.
IF [ #3028 NE 1 ] G54.1 P02 ELSE G54.1 P22
.... edited-out ...
N049 G53 Z0.
N050 M01

ect...


Less to edit and i would not have to pay attention to line numbers, one less mistake which can be made .


------



Anyway...
When using the IF statment, NE is the equivalent for = (equals) ?


Thanks again for the example, ger.
- joe


__
__________________
~ What was once an Opinion, became a Fact, to be later proven Wrong ~
Reply With Quote

  #4  
Old 07-27-2006, 06:34 AM
HuFlungDung's Avatar
Moderator
 
Join Date: Mar 2003
Location: Canada
Posts: 4,825
HuFlungDung is on a distinguished road

Since you only have two conditions, why not just write two IF statements, on two lines?
In computereez, when an IF condition is false, no further processing takes place on that line.
An Else function may be too high order in command language for your cnc to interpret.
__________________
First you get good, then you get fast. Then grouchiness sets in.

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #5   Ban this user!
Old 07-27-2006, 07:47 AM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

060727-0728 EST USA

iMisspell:

If I understand your original question --- you have two pallets and the parts machined on these pallets are identical, but each pallet clamps in the machine in a slightly different position than the other one. Therefore, you effectively need different values in G54 for pallet 1 than for pallet 2.when clamped in the machine.

Your second post introduces an unexpected factor, rotation. If you simply changed from one set of values in G54 for pallet 1 to a different set of G54 values for pallet 2, then would this cover all four rotational positions. My guess is not. That would mean that you actually required 4 different G54 sets for each part or a total of 8. This can be handled fairly easily, but I need to know if this is what is required, and do you have G52 that provides a modification to G54 without changing G54.

If you do not have G52, it is not a major problem, just a different route.

Do you have G65 which allows passing paramters to a subroutine?

.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 07-27-2006, 09:15 AM
 
Join Date: Mar 2005
Location: Silicon Valley, CA
Posts: 982
psychomill is on a distinguished road

Actually, you could just use IF statements to read G10s and use the same offset call for both pallets.....

IF [ #3028 EQ 1 ] GOTO 100(PALLET 1 OFFSETS)
IF [ #3028 EQ 2 ] GOTO 200(PALLET 2 OFFSETS)

N100
G10L2P1X??Y??Z??B??(G54 FOR PALLET 1)
GOTO300
N200
G10L2P1X??Y??Z??B??(G54 FOR PALLET 2)
GOTO300

N300(START PROGRAM)



Simple and easy and one program. G52 will work as well, but a lot of people today don't understand G52 and its relation since its not that common anymore in many places.
__________________
It's just a part..... cutter still goes round and round....
Reply With Quote

  #7   Ban this user!
Old 07-27-2006, 10:59 AM
 
Join Date: May 2006
Location: USA
Posts: 10
thogib is on a distinguished road

Can not use the else statement, so I just do it first then run my if:

N001 PL = 1
N002 IF PL = 1 THEN G54.1 P01 ELSE G54.1 P21

N001 PL = 1
G54.1 P21
N002 IF PL = 1 THEN G54.1 P01

My pallets are set at parameter #1000 and #1001 but I think that might vary by the machine manufacturer.

O7999
N010
#1=0.(SAFTEY CHECK)
IF[#1001EQ1]#1=1.(PALLET #1 ID)
IF[#1000EQ1]#1=21.(PALLET #2 ID)
IF[#1LE0.]THEN#3000=54(WHAT THE HELL W.O. ALARM)
N020
G54.1 P#1
N100
M99

In my main program I run;
M60(PALLET CHANGE)
G65P7999(SET WORK OFFSET)

Tom G
Reply With Quote

  #8   Ban this user!
Old 07-27-2006, 12:02 PM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

060727-1159 EST USA

iMisspell:

EQ is the logical function symbol for equals (a comparison function)
others are NE for not equal, LT less than, etc.

= is a symbol for inserting a value into a variable
#100 = 1.23 causes the number 1.23 to be put into variable #100 obviously destroying what was previously in #100.
#100 = #101 causes the content of variable #101 to be put into #100.
A more descriptive symbol might be
#100 <= 1.23 where <= means copy the evaluated value from the right side to the variable on the left side.


psychomill's suggestion is a simpler way. In HAAS it does not always work, and is dependent upon the function following the implied THEN.

What the G10 L2 P1 command does is to overwrite the contents of the variables that store the G54 offsets. Only the axes listed as parameters in the G10 command are overwritten.
In HAAS some of the addresses are
#5201-#5205 G52 X, Y ....
#5221-#5225 G54
#5241-#5245 G55
etc.

Assume that G54 is the current work offset, then in a HAAS mill in either HAAS or Fanuc mode the G52 values are added (added may mean subtracted) to the currently selected work offset (G54) to produce the actual work offset, but the value in the current work offset (G54) is not modified. For example:
#5201 is added to #5221 to generate the actual X work coordinate.

When the G52 values are all zeros the current work offset is the actual work offset.

Suppose you make G54 the work offset for the part zero for pallet 1 side 1. Then the values you would load into G52 would be the offsets from that one reference position to the corrected position for the other faces and pallets. In other words the contents of G52 would be the error in part positon relative to the position for pallet 1 side 1.

G52 is a very powerfull and useful tool in HAAS. In HAAS mode the values in G52 are retained even thru power down or program changes. In a HAAS machine in Fanuc mode G52 is zeroed on power on, program start, and some other conditions.

.

Last edited by gar; 07-27-2006 at 12:52 PM.
Reply With Quote

  #9   Ban this user!
Old 07-27-2006, 01:12 PM
 
Join Date: Jul 2006
Location: N.Y.
Posts: 22
iMisspell is on a distinguished road

Originally Posted by HuFlungDung
Since you only have two conditions, why not just write two IF statements, on two lines?
For the ease of editing and being that my hands are tied on the extent of editing i can do, im gonna try what thogib posted.

PL = 1

G54.1 P21
IF [PL = 1] G54.1 P01


Originally Posted by gar
Your second post introduces an unexpected factor, rotation.

...Do you have G65 which allows passing paramters to a subroutine?
Sorry, i should have mentioned the table rotation.

These programs are straight-up simple CAM programs, no subroutines of any sort (at least not that ive seen yet.) (i can post one if your bored and want to peek at it).


Originally Posted by psychomill
Actually, you could just use IF statements to read G10s and use the same offset call for both pallets.....

Simple and easy and one program. G52 will work as well, but a lot of people today don't understand G52 and its relation since its not that common anymore in many places.
Im gonna try this some tiem when i get time, but i do not think my partner is gonna be too keen on this, his not real big on change Plus im not wrting the programs from scratch just editing them to fine tune them alittle, i just counted how many P0#'s (pallet rotations) in one program and it was 22, setting them all with G10's is alot-like-work for someone thats a bit lazy But for learning im gonna give it a shot on an op or two.


thogib
Im new to Milling (and subroutines (but understand the concept from PC programing)), from the reading ive done, thats somthing which i would like to do, but i know the other guy running the machine would flip, then he would have to keep track of what program numbers not to delete from the control and having two O### printed out or in the same file... just wont work with him.



Originally Posted by gar
EQ is the logical function symbol for equals (a comparison function)
others are NE for not equal, LT less than, etc.

= is a symbol for inserting a value into a variable
#100 = 1.23 causes the number 1.23 to be put into variable #100 obviously destroying what was previously in #100.
#100 = #101 causes the content of variable #101 to be put into #100.
A more descriptive symbol might be
#100 <= 1.23 where <= means copy the evaluated value from the right side to the variable on the left side.
Copy/Paste and print thanks.
Its nice to see they keep the syntax close to other programming langs, those attributes can be used with PC SQL-DataBase work.

gar, thanks alot for your explanations, im sure it will help others reading this thread as well for the help you've been to me.


Another question.
At the beging of the program im gonna define PL = 1
Will the PL varable hole the value of 1 after we hit the Rest button on the control ?
I would think it would loose its value once the machine is powered down but what about just hitting the re-set button ?

Thanks again to every one, been a big help, nice to see different paths that can be takin.


_
__________________
~ What was once an Opinion, became a Fact, to be later proven Wrong ~
Reply With Quote

  #10   Ban this user!
Old 07-27-2006, 02:37 PM
 
Join Date: Mar 2005
Location: Silicon Valley, CA
Posts: 982
psychomill is on a distinguished road

i just counted how many P0#'s (pallet rotations) in one program and it was 22, setting them all with G10's is alot-like-work for someone thats a bit lazy
Yes, but you only need to set the G10 once at the top of the program, not 22 times through out the program. If you're using say 6 ofsets, then you could write it like this:

IF[#3028EQ1]GOTO100(PALLET 1 OFFSETS)
IF[#3028EQ2]GOTO 200(PALLET 2 OFFSETS)

N100
G10L20P1X??Y??Z??B??(G54.1 P1 FOR PALLET 1)
G10L20P2X??Y??Z??B??(G54.1 P2 FOR PALLET 1)
G10L20P3X??Y??Z??B??(G54.1 P3 FOR PALLET 1)
G10L20P4X??Y??Z??B??(G54.1 P4 FOR PALLET 1)
G10L20P5X??Y??Z??B??(G54.1 P5 FOR PALLET 1)
G10L20P6X??Y??Z??B??(G54.1 P6 FOR PALLET 1)
GOTO300
N200
G10L20P1X??Y??Z??B??(G54.1 P1 FOR PALLET 2)
G10L20P2X??Y??Z??B??(G54.1 P2 FOR PALLET 2)
G10L20P3X??Y??Z??B??(G54.1 P3 FOR PALLET 2)
G10L20P4X??Y??Z??B??(G54.1 P4 FOR PALLET 2)
G10L20P5X??Y??Z??B??(G54.1 P5 FOR PALLET 2)
G10L20P6X??Y??Z??B??(G54.1 P6 FOR PALLET 2)
GOTO300

N300(START PROGRAM)
.
.
.


Then you use the same program, same offset calls to run both pallets. You won't need to do this:
Tool 1 is called up, does some work on Side-A which is P01, then the pallet indexs to Side-B and P02 is called up, all in the same operation. If we were using pallet 2 it would be SideA=P21 and SideB=P22.
Just use the one program and one set of offsets.

__________________
It's just a part..... cutter still goes round and round....
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 07-28-2006, 12:25 AM
 
Join Date: Jul 2006
Location: N.Y.
Posts: 22
iMisspell is on a distinguished road

Bad new for me
Tried the IF statments and it kicked up an error, bad macro (or somthing, wrote it down but forgot the paper at work, i know the word 'macro' was in the error.) recived this same error when trying to set a varable, PL = 1. When keying in the ...
PL = 1
it would input...
P L =1
(space between P and L and removed space between = and 1), so i tried A=1 and kept getting the same error, didnt have time to play around.

psychomill
After re-reading what gar post, i now compleatly understand what you are saying and actuly think the day guy will like that, alot. Since we cant get the IF's working right now, maybe ill just write in both (pallet A and B) and then when we start the run we can just delete or skip/block what ever set we dont want to use.


_
__________________
~ What was once an Opinion, became a Fact, to be later proven Wrong ~
Reply With Quote

  #12   Ban this user!
Old 07-28-2006, 07:01 AM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

060728-0632 EST USA

iMisspell:

More questions.

On your pallet is there one part, or is it a tombstone with many parts?

Assuming it is one part, then is it a raw blank, or has it had previous operations performed?

These questions relate to whether you need different work zeros for each rotary position of the pallet, or just for the different pallets.

Try the following to test for macro capability:

IF [ 4 GT 1 ] GOTO 100
M00

N 100
M00

If there is an error it probably means you do not have macros functional.
Note: the square brackets around 4 GT 1, these are not parens () because parens are used for comments. And they are not {}, at least on HAAS.


In your machine is it possible to address a variable with an ahphanumeric label? You used the assignment PL = 1 where I might expect that you would have use the #number for a variable address. Thus, instead of
PL = 1
I have to use for example
#100 = 1
on a HAAS machine.

In a previous post of mine I referenced the variable #3028. I believe this is a HAAS variable that they automatically load with the number of the pallet in the station. If this is the case, then you would not need to manually load the pallet number. Rather you would simply use a test on #3028 to determine your action.

At this point we really need to know whether you have macro capability.

If you do not have macros you may not be able to load values into variables except as allowed thru G-code parameters where everthing in terms of internal storage is hidden from you.

.
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -5. The time now is 08:12 PM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361