On 23.03.12 10:59, gene heskett wrote: > On Friday, March 23, 2012 10:23:48 AM Erik Christiansen did opine: > > > > Sub drill_em_there (123.456, 789.012) { > > Rel Drill X#1 Y#2 Z1.5 Retract 2.8 Repeat 3 // Drills 3 > > holes. } > > I just got lost, 3 holes but only one XY specified? I came into this > scene after it was outlined obviously. :)
It's just dressing up this: http://www.linuxcnc.org/docs/html/gcode_main.html#sub:G81:-Drilling-Cycle with some words to avoid the need to remember the difference between G91 and G81, and whether it's L for retract and R for repeat, or was that Q? So the gcode output, shown below, still only has one XY specified. Perhaps I should have constructed a more realistic subroutine, with start point and increments, and some decent comments. But it was just cobbled together on the spur of the moment, to show how we could use knowledge of machine state to let us drop a relative command into the middle of a section of absolute program, without harm. It's to protect against things going BANG, due to forgetting to put the distance mode back manually, that I've succumbed to the temptation to make distance mode non-modal when it's specified as a prefix to a single command (as above), and only modal when it's specified with our "modal" operator "=>", as in: Motion => Abs We only have gcode with which to make the distance mode non-modal, so we just make it self-restoring, so the subroutine can safely be invoked anywhere: > > That currently translates to gcode which tests for the previous distance > > mode, and conditionally restores it before returning: > > > > O105 sub [123.456] [789.012] > > G91 G81 X#1 Y#2 Z1.5 R2.8 L3 ; Drills 3 holes. > > O106 if [#<abs_modality> EQ 1] > > G90 > > O106 endif > > O105 endsub It's all simpler than it looks, when you come in cold. ... > It is estimated that if every well were plugged today, it will be > 50,000 years before that water is back to the level it was in 1920. > But without it, our ability to feed 2/3rds of the planet goes away, > and bread will be $20 a loaf at Kroger. > > That is the 18,000 lb elephant no one wants to talk about here folks. You have a way with words, Gene. I enjoy pointing at the big smash up ahead, but it's hair-raising to meet more eloquent evidence coming the other way. The doubling of wheat prices, a couple of years back, due to fires in Russia, together with China and Qatar buying up slabs of Australian farmland now, with the declared intent of feeding their own populations, all seems to point to us approaching the edge, and nations recognising the threat. Maybe I should fix the chicken coop out on the farm, and cultivate the little garden paddock, as in the old days. > > P.S. Question: Are those squiggly brackets on the Sub better eye candy > > than an Endsub instead? > > I have no official opinion as I have carved some C, many years ago now. I > suspect we would use it if it was available, but we are used to the > endwhile/endsub syntax too, so it's a shrug. Whatever works. But I would > add that if too much "C" creeps in there will be a net loss of the "feel" > of gcode, and a tendency to write in C instead, then sit and stare at it > for hours because it didn't do what you wrote. Languages have > personalities that keep them separated, usually for a reason. ;-) You've hit that nail fair and square, Gene. It's pretty much what I was flippantly asking. > OTOH Erik, I can just as easily be ignored. ;-) Not a chance. If I stray too far with any of this, I'm hoping for just the kind of rational appraisal you've been giving it thus far. In a later post, it did sink in that a gcode subroutine has its own scope, so similarity to a 'C' block with the same properties yields a gain in "feel", I sense. Erik -- ... and to avoid the tedious repetition of these woordes 'is equal to' I will sett, as I doe often in woorke use, a paire of parralelles or twin lines of one length, thus = bicause no 2 things can be moare equal. - Robert Recorde, writing in 1557 (quoted by Tubal Cain, in ME No. 4042) ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users