From: Gene H. <gen...@ve...> - 2007-08-17 02:19:40
|
On Thursday 16 August 2007, Jeff Epler wrote: >I spotted several more errors in your program. > >> #10 = 1.4 ( o.d ) > >... > >> #22 = 90 (final arc angle) > >Parameters up to 30 are used for subroutine arguments. Use parameters >above 30 for global variables: > > #40 = 1.4 ( o.d ) > ... > #52 = 90 (final arc angle) > >> o200 sub (rounds half top of pinion leaf in several steps) >> do >> G0 Z[[sin[#10]/[#20]] X[[cos[#10]/[#20]] >> G1 Y[#14] F4 >> G0 Y[0-[#14]] >> G0 A[#21] >> #10 = [[#10]+[#21]] >> while [#10] LT [#22] >> endsub > >Numbers are required for the beginning and end of a subroutine, loop, or >conditional. So your code should look more like: > O200 sub ... > O201 do > ... > O201 while ... > O200 endsub >It's the missing "O100" for the first "endsub" that makes emc run off >the end of the program without doing anything -- it's looking for O100 >endsub and nothing else will do. > >> while [#10] LT [#22] > >the correct syntax is > O201 while [#10 LT #22] > >> G1 Y[#14] F4 > >Brackets are not necessary here, but not harmful either > >> N0500 [#17] = [#17] + 1 (increment counter) > >The correct bracketing is: > #17=[#17+1] >In addition to the original, these are both incorrect: > [#17]=[#17+1] > #17=[#17]+1 > >> G0 Z[[sin[#10]/[#20]] X[[cos[#10]/[#20]] > >The correct bracketing is: > G0 Z[sin[#10]/#20] >if you want to compute what would be written sin(x)/y in many other >languages, or > G0 Z[sin[#10/#20]] >if you want to compute what would be written sin(x/y) in many other >languages. > >> N2000 o200 call [#10][#14][#20][#21][#22] > >Inside O200 sub, you refer to #10, #14, #21, #21, and #22 which are the >numbers of the variables you intended to be global. You could either >omit these parameters from O200 call and use the global variable numbers >once you renumber them to be above 30. Or, inside O200 sub you could >refer to them as #1 through #5. Thanks for the lengthy explanation Jeff, I'm learning things from this myself. I wasn't aware that the subs treated passed arguments as a completely different numbering system, starting I assume at 1, and going up in the order of their location in the 'oxxx call' lines list. The wiki would be better if some of this reasoning was included, it is a bit 'dry' shall we say? [...] -- Cheers, Gene "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) "It's God. No, not Richard Stallman, or Linus Torvalds, but God." (By Matt Welsh) |