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 01-17-2008, 11:59 PM
 
Join Date: Jan 2008
Location: USA
Posts: 85
dapoling is on a distinguished road
Macro Programming

It has been sometime since I have written simple macros and was hoping to find a little help here.

I seen this problem presented in another post but this would have strayed off topic.
He was wanting to machine a profile to a depth of Z-2.55 in .05 depths of cuts.
I have taken it one step farther to allow different depths and depth of cuts by using a macro.

I have not had the chance to run this into a controller to see if it works or not but I would like imput on writing macros, I know there are other ways to accomplish but I am looking for information on macros.



%
O1001
G65P1000 A-2.55 B-.05
M30
%

%
O1000
(G65P1000A-2.55B-.05)
#101=0 (ENSURE COUNTER IS CLEAR)
#100=#1(DEPTH)
#101=#2(STEP DEPTH)
G0G20G40G80G90
T21 M06
(1.25 3 FLUTE)
G90 G58 G00 X3.25 Y5.
M88 ( I AM NOT FAMILIAR WITH M88)
S1800 M03
G43 H21 Z1. M08

N100 (BEGIN LOOP ADDING TO - DEPTH
#101+#2(COUNTER)

IF[#101 LT #100] THEN [#101=#100]

G01 Z#101 F15.
G90 G41 G01 X2.375 Y4. D21
G01 Y3.077
G03 X2.7606 Y2.174 R1.25
G02 X2. Y0.2794 R1.1
G02 X1.2394 Y2.174 R1.1
G03 X1.625 Y3.077 R1.25
G01 Y3.7294
G01 X2.5
G40 X3.25 Y5. F25.

IF[#101 EQ #100] GOTO200

GOTO100

N200
G0Z2.M9
G91G28Y0Z0
G90
M30
%
__________________
My Response to "It's Close Enough", "Is Your Tool Box and The Door Close Enough?"
Reply With Quote

  #2   Ban this user!
Old 01-18-2008, 08:04 AM
gar gar is offline
 
Join Date: Mar 2005
Location: USA
Posts: 1,498
gar is on a distinguished road

080118-0825 EST USA

dapoling:

#101 does not appear to be a counter by my normal definition, but rather the cummulative depth as you progress. Defining it as a counter really had me confused as to what you were doing.

When you do #101 = 0 you are initiallizing Z to 0 relative to whatever G5x is active.

#100 is your final depth, it has to be negative, and is based on G5x Z0. You assume no material above Z0.

IF[#101 LT #100] THEN [#101=#100] this is OK now that I understand #101 is not what I expected for a counter. In a broad sense you can call this a counter but it is not what one initially would visualize as a counter.

IF[#101 EQ #100] GOTO200
GOTO100

I might change this to
IF[#101 GT #100] GOTO 100

Why was I confused? When I look at code it is usually a whole mess of useless stuff cluttered around the basic logic. Thus, based on bits of information I jump into to it to see what the basic logic is. Here I started looking at #101 because it was defined as a counter. Then why would I want to set #101 to the value of #100 inside of the loop?

Maybe if
G01 Z#101 F15.
G90 G41 G01 X2.375 Y4. D21
G01 Y3.077
G03 X2.7606 Y2.174 R1.25
G02 X2. Y0.2794 R1.1
G02 X1.2394 Y2.174 R1.1
G03 X1.625 Y3.077 R1.25
G01 Y3.7294
G01 X2.5
G40 X3.25 Y5. F25.

Had been written as
G01 Z#101 F15.
(do cutting work)

and

#101=0 (ENSURE COUNTER IS CLEAR)
#100=#1(DEPTH)

had been
#101=0 (cummulative depth from G5x Z0, initialize to start at Z0)
#100=#1(final depth relative to G5x Z0)

I would have converged on your logic sooner.

.
Reply With Quote

  #3   Ban this user!
Old 01-18-2008, 10:16 AM
 
Join Date: Jan 2008
Location: USA
Posts: 85
dapoling is on a distinguished road

Gar thanks for responding as it seems you have a good grip on macros, but let me see if I can sum this up, it will work but you would prefer better notations and terminology?

Your view on this maybe different then mine as I consider a counter a method to add a number to another coming up with a result.
If you would post what you would feel a counter I can see the difference between the way we both look at it.

When you do #101 = 0 you are initializing Z to 0 relative to whatever G5x is active.
The variable is set to 0, at this point there is no other influence until G5x was called up.

Then why would I want to set #101 to the value of #100 inside of the loop?
if #101 reached a depth deeper then #100 it would revert to #100, thus preventing undercut area.
__________________
My Response to "It's Close Enough", "Is Your Tool Box and The Door Close Enough?"
Reply With Quote

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

080118-1124 EST USA

dapoling:

In computer programming and generic useage count usually means incrementing or decrementing by 1 or an integer multiple thereof. Although I can not disagree in a broad sense with count including any arbitrary incremental value. It is just that was not my expectation when first encountering your code.

When looking at code I do not start at the beginning and walk thru it, but rather I may start in the middle and try to pick out a clue of the essential logic without a lot of detailed clutter. Thus, I did not catch some clues that might have altered my train of thought.

When you set #101 to 0 you are really setting an inital dimension relative to whatever was the last (prior to the #101=0 line) assertion of a G5x. If there was a G5x in the loop somewhere or after the #101=0 line, then this would be the new reference for Z. I do not see any G5x in your code so it is whatever existed before. Now I found your G58. The value for #101 initialization could be 0.5645 and your program would work perfectly to take you to the same final depth of #100 but starting from 0.5645-#101.

Since you are primarily using dimensions as your variable I would describe them as such rather than as a count.

Once I determined what you were doing, then setting #101 to #100 in the if statement inside the loop made sense. But before I understood your code my initial question was why was this being done when I thought by my generic useage of count that #101 was an incrementing (by 1) counter. The function does exactly what you intended and is correct. You could use LE also.

I responded because no one else had. It provides an interesting discussion, and it does not mean what you did was wrong.

.
Reply With Quote

  #5   Ban this user!
Old 01-18-2008, 11:33 AM
 
Join Date: Jan 2008
Location: USA
Posts: 85
dapoling is on a distinguished road

Gar thanks for replying I find different opinions and views often lead to a well rounded knowledge.

As I mentioned before it has been sometime since I have written a basic macro as this. I know this could have become more complex putting more safeguards in but with instructions to the user on how to use it, one would hope they would follow them.
__________________
My Response to "It's Close Enough", "Is Your Tool Box and The Door Close Enough?"
Reply With Quote

Sponsored Links
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fanuc Macro and G-Code Programming kilogulf59 Fanuc 3 11-01-2006 11:02 AM
Do I need macro programming in future koppis General CAM Discussion 3 09-19-2006 01:44 PM
A2100 advanced (macro) programming bender68 G-Code Programing 0 12-29-2005 11:28 AM
Macro/Parametric Programming screensnot Fadal 4 03-28-2005 08:45 PM




All times are GMT -5. The time now is 10:07 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