%!PS % GONZO TABLEMAKER DEV FOURIER EQUATION GENERATOR V2.5 % ====================================================== % THIS VERSION SPECIFIC TO MSCAL76Q % Copyright c 2001 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 2.5 % This utility auto-generates JavaScript Magic Sinewave calculators as % JavaScript .asp files. To use, view in wp or editor, modify as needed, % and send to distiller. Upload generated .asp file to ISP for testing. % Detailed assistance is available per http://www.tinaja.com/info01.asp % The first portion of the calculator up to the table is easier handled with % word or GoLive, so it is prepended as a read disk file. The final portion is % handled by an existing include file. % The generated program is intended for ISP distribution as a .asp file for use % with Internet Exploder only. Setting Netscapeok and recompiling defeats the auto % carrier detector and display, but prevents some Netscape version Javascript errors. % Certain portions of the delta code still has to be hand coded. Search on "ZZZZZ" % to reach these three code areas. % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is needed for this program. % After obvious location mods, uncomment ONE of the following two lines: (C:\\windows\\desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990,1996,2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. %%%%%%%%%%%%%%% FILE CONTROL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /print {targ1 exch writestring} def % divert print from log file to new disk file /netscapeok false def % leave off IE color cells? Not recommended. /prefix (C:\\WINDOWS\\desktop\\Magsn 5\\forflush\\Q series\\) store % filename prefix /sname1(genheader.asp) store % short name of first BMP input file /sn1 prefix sname1 mergestr store sn1 (r) file /source1 exch store % create read file netscapeok {/tname1(mscal76N.asp) store} % short name of ms output {/tname1(mscal76Q.asp) store} ifelse /tn1 prefix tname1 mergestr store tn1 (w+) file /targ1 exch store % create read file /strx 64000 string store source1 strx readstring pop % transfer header targ1 exch writestring %%%%%%%%%%%%%%%% CONTROL VARIABLES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /pulsesperquadrant 19 store /harmsneeded pulsesperquadrant dup 6 lt {pop 6} if 1 sub 4 mul store % (\ \n) print % (\ \n) print % (\ \n\n) print % (\ \n) print % form colors /lime ("#33FF33") def % needs BGCOLOR= /magenta ("#FF99FF") def /skyblue ("#CCFFFF") def /orange ("#FF9900") def /teal ("#66FFCC") def /starttablerow {(\ \n) print } def /endtablerow {(\ \n) print } def /colrow { } def /morestuff {} def /datacell { /notblank exch store /bgcolor exch store /callout exch store /inname exch store /value exch store /size exch store (\\ ) mergestr callout mergestr ( \\) mergestr } if morestuff (\ \n) mergestr print } def /blankhcell {(\n \\\n) print } def % start the main selection table (\\ \n) print % start table /autotable {pulsesperquadrant 1 sub 2 mul dup 10 lt {pop 10 } if /totalrows exch store %% green headers starttablerow % 12 (0.000 ) (fp1s) ( p1s:) orange true datacell ( \n\n) print blankhcell ( \n) print blankhcell blankhcell endtablerow %% mixed orange-magenta ( \n) print % pad vertically starttablerow 12 (0.000 ) (fp1s) ( p1s:) orange true datacell blankhcell % magenta amplitude /colrow {( COLSPAN="2" )mergestr} def 12 (0.5300 ) (fa01) ( Fundamental Amplitude:) magenta true datacell /colrow { } def blankhcell blankhcell endtablerow /rowcol {} def /morestuff {} def starttablerow 12 (0.000) (fp1e) ( p1e:) orange true datacell blankhcell % magenta tdh /morestuff { (  is  \\  percent. ) mergestr } def /colrow {( COLSPAN="2" )mergestr} def 4 (2-??) (fzthd) ( THD ) magenta true datacell /colrow { } def blankhcell blankhcell /morestuff {} def endtablerow %% main size programmable portion of table 0 1 totalrows 1 sub { /currow exch store starttablerow 12 (0.000) (fp) currow 2 idiv 2 add 4 string cvs mergestr currow 2 mod 0 eq {(s)}{(e)} ifelse mergestr (p) currow 2 idiv 2 add 10 lt {( ) exch mergestr} if % prespace if less than 10 currow 2 idiv 2 add 4 string cvs mergestr currow 2 mod 0 eq {(s:)}{(e:)} ifelse mergestr currow 2 idiv 2 add 10 lt {( ) mergestr} if orange currow 2 idiv 2 mul pulsesperquadrant 1 sub 2 mul ge {false}{true} ifelse datacell blankhcell 12 (999.9) (fh) currow 2 mul 3 add 10 lt {(0) mergestr} if currow 2 mul 3 add 3 string cvs mergestr (h) currow 2 mul 3 add 10 lt {(0) mergestr} if currow 2 mul 3 add 3 string cvs mergestr (:) mergestr skyblue true datacell % high harms 12 (999.9) (fh) currow 2 mul 3 add totalrows 2 mul add 3 string cvs mergestr (h) currow 2 mul 3 add totalrows 2 mul add 3 string cvs mergestr (:) mergestr skyblue true datacell endtablerow } for } def autotable % end the main selection table (\n\ \n) print % end table %%%%%%%%%% %%%%%%%%%% SPLICE %%%%%%%%% (\n\ \n\n) print % end form (\ //script at end so form is defined \n\n) print % more script stuff %%%%%%%%%%%%%%%% CONTROL VARIABLES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% (var pulsesperquadrant = ) pulsesperquadrant 4 string cvs mergestr ( ; \n\n) mergestr print /harmsneeded pulsesperquadrant dup 6 lt {pop 6} if 1 sub 4 mul store % pulsenamearray generates p1s p1e , etc as matrix /pulsenamearray mark 1 1 pulsesperquadrant {10 string cvs /ppp exch store (p) ppp mergestr (s) mergestr (p) ppp mergestr (e) mergestr } for ] def % pulsenamearray == % generate variable defs (\n\n// ------> start Gonzo autogenerated code from build4a.psl\n) print (// ------> for ) pulsesperquadrant 10 string cvs mergestr ( pulses per quadrant.\n\n) mergestr print (var pi = Math.PI // good old pi for radian conversion and Fourier amp ; \n\n) print (//these attempt Fourier speedup by eliminating repeat calculations\n\n) print (var x1 = pi/180\n) print 1 1 harmsneeded {/harmloc exch store (var x) 1 harmloc 2 mul add 10 string cvs /xxx exch store xxx mergestr ( = ) mergestr xxx mergestr (*x1\n) mergestr print } for (\n) print flush % more variables (var thd = 1.0 // predefine variables to be passed\n) print (var xthd = 999.9 // old thd for one pass\n) print (var xxthd = 999.0 // old thd for full min\n\n) print (var p01 = 1.0\n)print (var a01 = 1.0\n)print 1 1 harmsneeded {/harmloc exch store (var h) 1 harmloc 2 mul add 10 string cvs /xxx exch store xxx cvi 10 lt {(0) mergestr} if xxx mergestr ( = 1.0\n) mergestr print } for (\n) print flush % sc variables 1 1 pulsesperquadrant {10 string cvs /xxx exch store (var p) xxx mergestr (sc = 1.0\n) mergestr print (var p) xxx mergestr (ec = 1.0\n) mergestr print } for (\n) print flush % main pulse variables 1 1 pulsesperquadrant { 10 string cvs /xxx exch store (var p) xxx mergestr (s = 1.0\n) mergestr print (var p) xxx mergestr (d = 1.0\n) mergestr print (var p) xxx mergestr (e = 1.0\n) mergestr print } for (\n) print flush % loose stuff (var zthd = "2-xx" ; \n\n) print (var ampdelta = 0.0\n) print (var incD5 = 0.00001 ;\n) print (var maxIncs = 70 ;\n) print (var roundAt = 100000000 ;\n\n) print (// low level routines \n\n) print % findharms (function findHarms (form) {\n\n) print 0 1 harmsneeded 2 div 1 add cvi {1 exch 2 mul add 10 string cvs /harpoint exch store (h) harpoint cvi 1 eq {pop (a)} if harpoint cvi 10 lt {(0) mergestr} if harpoint mergestr ( = \( \n) mergestr print 1 1 pulsesperquadrant {10 string cvs /pulsepoint exch store ( Math.cos \(p) pulsepoint mergestr (s*x) mergestr harpoint mergestr (\) -\n) mergestr print ( Math.cos \(p) pulsepoint mergestr (e*x) mergestr harpoint mergestr (\) +\n) mergestr print } for % each burst ( 0 \)) harpoint cvi 1 ne {( / \(a01 * ) harpoint mergestr (\)) mergestr mergestr} if ( ;\n\n) mergestr print } for % total bursts ( calcThd (form) ;\n\n }\n\n) print flush %% high harms (function hiHarms (form) {\n\n) print %%% experiment area for background color netscapeok not { 3 2 pulsesperquadrant 4 mul 4 add {/ccharm exch store (cfh) ccharm 10 lt {(0) mergestr} if ccharm 4 string cvs mergestr (.bgColor="#CCFFFF" ; \n) mergestr print } for (\n\n) print (eval ("cfh" + eval (highestZeroharm + 2).toString() + ".bgColor='#66FFCC'") ; \n) print (eval ("cfh" + eval (highestZeroharm + 4).toString() + ".bgColor='#66FFCC'") ; \n) print % ( cfh37.bgColor='#FF6699' ; \n) print } if % IE only %%%%% (zthd = "2-" + (highestZeroharm + 1).toString() ; \n ) print % moved from thdcalcs harmsneeded 2 div cvi 2 add 1 harmsneeded {1 exch 2 mul add 10 string cvs /harpoint exch store (h) harpoint cvi 1 eq {pop (a)} if harpoint cvi 10 lt {(0) mergestr} if harpoint mergestr ( = \( \n) mergestr print 1 1 pulsesperquadrant {10 string cvs /pulsepoint exch store ( Math.cos \(p) pulsepoint mergestr (s*x) mergestr harpoint mergestr (\) -\n) mergestr print ( Math.cos \(p) pulsepoint mergestr (e*x) mergestr harpoint mergestr (\) +\n) mergestr print } for % each burst ( 0 \)) harpoint cvi 1 ne {( / \(a01 * ) harpoint mergestr (\)) mergestr mergestr} if ( ;\n\n) mergestr print } for % total bursts ( ;\n\n }\n\n) print flush % fixpow and company (// fixPow and fixAmp update power on amplitude and vice versa\n\n) print (function fixPow (form) {form.fp00.value = (Math.round (1000000 * (Math.pow(form.fa00.value,2)))) / 1000000}\n\n) print (function fixAmp (form) {form.fa00.value = (Math.round (1000000 * (Math.sqrt(form.fp00.value)))) / 1000000}\n\n) print % report to form (function reportToForm (form) {\n\n) print ( hiHarms (form) ;\n) print ( form.fthd.value = thd ;\n) print ( form.fzthd.value = zthd ;\n\n) print ( form.fa01.value = a01 * (4 / pi) ; // only scalings used \n) print 1 1 harmsneeded { 1 exch 2 mul add 10 string cvs /harpoint1 exch store ( form.fh) harpoint1 cvi 10 lt {(0) mergestr} if harpoint1 mergestr (.value = h) mergestr harpoint1 cvi 10 lt {(0) mergestr} if harpoint1 mergestr ( ;\n) mergestr print } for (\n\n) print flush 1 1 pulsesperquadrant { 10 string cvs /pulsepoint1 exch store ( form.fp) pulsepoint1 mergestr (s.value = p) mergestr pulsepoint1 mergestr (s ;\n) mergestr print ( form.fp) pulsepoint1 mergestr (e.value = p) mergestr pulsepoint1 mergestr (e ;\n) mergestr print } for (}\n\n) print flush % predict best efficiency... (function preDictBesteff (form) { \n\n) print ( reportFromForm \n\n) print (a00 = (eval (document.mainform.fa00.value)) * (pi/4) // unnormalize\n\n) print (// best eff interval is 2x + 1 pulses per 180 with full zero offset \n\n) print (var ppqx = 180/ ((pulsesperquadrant *2) + 1)\n\n) print (// interval is 180/) pulsesperquadrant 2 mul 1 add 10 string cvs mergestr ( = ) mergestr /ppqx 180 pulsesperquadrant 2 mul 1 add div def 1 1 pulsesperquadrant { ppqx mul 10000 mul round 10000 div 15 string cvs mergestr ( ) mergestr } for (.\n\n) mergestr print 1 1 pulsesperquadrant {10 string cvs /ii exch store (var t) ii mergestr ( = ) mergestr ii mergestr (*ppqx ;\n) mergestr print } for (var sinsum = ) print 1 1 pulsesperquadrant {10 string cvs /jj exch store (Math.sin\(t) jj mergestr (*pi/180\) + ) mergestr print } for ( 0 ; \n\n) print 1 1 pulsesperquadrant {10 string cvs /kk exch store (var share) kk mergestr ( = Math.sin \(t) mergestr kk mergestr ( *pi/180\) / sinsum ; \n) mergestr print } for (\n) print flush (var a00x = 20 ; \n) print (a00x = a00 * 4/pi ; \n\n) print 1 1 pulsesperquadrant {10 string cvs /ll exch store (p) ll mergestr (s = \(180/pi\) * \(Math.acos \(Math.cos\(t) mergestr ll mergestr (*pi/180\)\) - \(a00x * share) mergestr ll mergestr (/2\)\) ; \n) mergestr print (p) ll mergestr (e = \(180/pi\) * \(Math.acos \(Math.cos\(t) mergestr ll mergestr (*pi/180\)\) + \(a00x * share) mergestr ll mergestr (/2\)\) ; \n) mergestr print } for (\n\n) print flush 1 1 pulsesperquadrant {10 string cvs /mm exch store (form.fp) mm mergestr (s.value = p) mergestr mm mergestr (s\n) mergestr print (form.fp) mm mergestr (e.value = p) mergestr mm mergestr (e\n) mergestr print } for (\n\n) print flush ( doStuffx (form) ;\n) print ( doStuffx (form) ;\n\n) print ( }\n\n) print %%%%%%%%%%%%%%%%%%%%%% % predict normal (function preDictNormal (form) { \n\n) print ( reportFromForm \n\n) print (a00 = (eval (document.mainform.fa00.value)) * (pi/4) // unnormalize\n\n) print (// best eff interval is 2x pulses per 180 with half zero offset \n\n) print (var ppqx = 180/ (pulsesperquadrant * 2)\n\n) print (// interval is 180/) pulsesperquadrant 2 mul 10 string cvs mergestr ( = ) mergestr /ppqx 180 pulsesperquadrant 2 mul div def 0 1 pulsesperquadrant 1 sub { ppqx mul ppqx 2 div add 10000 mul round 10000 div 15 string cvs mergestr ( ) mergestr } for (.\n\n) mergestr print 1 1 pulsesperquadrant {10 string cvs /ii exch store (var t) ii mergestr ( = ) mergestr ii mergestr (*ppqx ;\n) mergestr print } for (var sinsum = ) print 1 1 pulsesperquadrant {10 string cvs /jj exch store (Math.sin\(t) jj mergestr (*pi/180\) + ) mergestr print } for ( 0 ; \n\n) print 1 1 pulsesperquadrant {10 string cvs /kk exch store (var share) kk mergestr ( = Math.sin \(t) mergestr kk mergestr ( *pi/180\) / sinsum ; \n) mergestr print } for (\n) print flush (var a00x = 20 ; \n) print (a00x = a00 * 4/pi ; \n\n) print 1 1 pulsesperquadrant {10 string cvs /ll exch store (p) ll mergestr (s = \(180/pi\) * \(Math.acos \(Math.cos\(t) mergestr ll mergestr (*pi/180\)\) - \(a00x * share) mergestr ll mergestr (/2\)\) ; \n) mergestr print (p) ll mergestr (e = \(180/pi\) * \(Math.acos \(Math.cos\(t) mergestr ll mergestr (*pi/180\)\) + \(a00x * share) mergestr ll mergestr (/2\)\) ; \n) mergestr print } for (\n\n) print flush 1 1 pulsesperquadrant {10 string cvs /mm exch store (form.fp) mm mergestr (s.value = p) mergestr mm mergestr (s\n) mergestr print (form.fp) mm mergestr (e.value = p) mergestr mm mergestr (e\n) mergestr print } for (\n\n) print flush ( doStuffx (form) ;\n) print ( doStuffx (form) ;\n\n) print ( }\n\n) print %%%%%%%%% predict delta %%%%%%%% WARNING: MUST HAND PRECODE search: ZZZZZZZ %%%%%%%%% (// preDictDelta 744 has 4 high triad pulses, 4 mid triad pulses, and 7 low \n) print (// triad pulses. The high three have cos30 = .500 energy, proportionally split. \n) print (// The low tseven have cos0 - cos30 = .133 energy proportionally split.\n\n) print (// There is no triad conflict, so this should be a good but excessive choice. \n\n) print (// locking diagram -- \n\n) print (// !15s 15e!16s 16e!17s 17e!18s 18e!19s 19e! 60-90 \n) print (// !14e 14s ! 13e 13s ! 12e 12s ! 11e 11s ! 10e 10s !60-30 \n) print (// ! 1s 1e! 2s 2e 3s 3e!4s 4e 5s 5e! 6s 6e 7s p7e! 8s 8e 9s 9e! 0-30 \n\n) print (// tracking is \n) print (// p1s = 60 - p14s \n) print (// p1e = p15e - 60 \n) print (// p2s = p16s - 60 \n) print (// p2e = 60 - p13e \n) print (// p3s = 60 - p13s \n) print (// p3e = p16e - 60 \n) print (// p4s = p17s - 60 \n) print (// p4e = 60 - p12e \n) print (// p5s = 60 - p12s \n) print (// p5e = p17e - 60 \n) print (// p6s = p18s - 60 \n) print (// p6e = 60 - p11e \n) print (// p7s = 60 - p11s \n) print (// p7e = p18e - 60 \n) print (// p8s = p19s - 60 \n) print (// p8e = 60 - p10e \n) print (// p9s = 60 - p10s \n) print (// p9e = p19e - 60 \n) print (// p14e = 120 - p15s \n\n) print (// variables: p10s through p19e except for p14e locked \n) print (// high centers are 63 69 75 81 87. degrees. \n) print (// mid centers are assumed 33 39 45 51 57 degrees. \n\n) print (function preDictDelta (form) { // delta 533\n\n) print (reportFromForm \n\n)print (a00 = (eval (document.mainform.fa00.value)) * (pi/4) // unnormalize \n) print (a00x = a00 * 4/pi ; // unnormalize \n) print (hinrgTot = Math.sin (63*pi/180) + Math.sin (69*pi/180) + Math.sin (75*pi/180) + Math.sin (81*pi/180) + Math.sin (87*pi/180); \n\n) print (p19nrg = a00x * 0.5 * Math.sin (87*pi/180) / hinrgTot ; \n) print (p18nrg = a00x * 0.5 * Math.sin (81*pi/180) / hinrgTot ; \n) print (p17nrg = a00x * 0.5 * Math.sin (75*pi/180) / hinrgTot ; \n) print (p16nrg = a00x * 0.5 * Math.sin (69*pi/180) / hinrgTot ; \n) print (p15nrg = a00x * 0.5 * Math.sin (63*pi/180) / hinrgTot ; \n\n) print (p19e = (180/pi) * (Math.acos (Math.cos(87*pi/180)) + ( p19nrg/2 )) ; \n) print (p19s = (180/pi) * (Math.acos (Math.cos(87*pi/180)) - ( p19nrg/2 )) ; \n\n) print (p18e = (180/pi) * (Math.acos (Math.cos(81*pi/180)) + ( p18nrg/2 )) ; \n) print (p18s = (180/pi) * (Math.acos (Math.cos(81*pi/180)) - ( p18nrg/2 )) ; \n\n) print (p17e = (180/pi) * (Math.acos (Math.cos(75*pi/180)) + ( p17nrg/2 )) ; \n) print (p17s = (180/pi) * (Math.acos (Math.cos(75*pi/180)) - ( p17nrg/2 )) ; \n\n) print (p16e = (180/pi) * (Math.acos (Math.cos(69*pi/180)) + ( p16nrg/2 )) ; \n) print (p16s = (180/pi) * (Math.acos (Math.cos(69*pi/180)) - ( p16nrg/2 )) ; \n\n) print (p15e = (180/pi) * (Math.acos (Math.cos(63*pi/180)) + ( p15nrg/2 )) ; \n) print (p15s = (180/pi) * (Math.acos (Math.cos(63*pi/180)) - ( p15nrg/2 )) ; \n\n) print (midnrgfract = Math.cos (30*pi/180) - Math.cos (60*pi/180) // approx .366 \n) print (midnrgTot = Math.sin (33*pi/180) + Math.sin (39*pi/180) + Math.sin (45*pi/180) + Math.sin (51*pi/180) + Math.sin (57*pi/180) ; \n\n) print (p14nrg = a00x * midnrgfract * Math.sin (57*pi/180) / midnrgTot ; \n) print (p13nrg = a00x * midnrgfract * Math.sin (51*pi/180) / midnrgTot ; \n) print (p12nrg = a00x * midnrgfract * Math.sin (45*pi/180) / midnrgTot ; \n) print (p11nrg = a00x * midnrgfract * Math.sin (39*pi/180) / midnrgTot ; \n) print (p10nrg = a00x * midnrgfract * Math.sin (33*pi/180) / midnrgTot ; \n) print (p14e = 120 - p15s \n\n) print (p14s = (180/pi) * (Math.acos (Math.cos(p14e*pi/180)) - ( p14nrg )) ; \n) print (p13s = (180/pi) * (Math.acos (Math.cos(51*pi/180)) - ( p13nrg/2 )) ; \n) print (p13e = (180/pi) * (Math.acos (Math.cos(51*pi/180)) + ( p13nrg/2 )) ; \n\n) print (p12s = (180/pi) * (Math.acos (Math.cos(45*pi/180)) - ( p12nrg/2 )) ; \n) print (p12e = (180/pi) * (Math.acos (Math.cos(45*pi/180)) + ( p12nrg/2 )) ; \n\n) print (p11s = (180/pi) * (Math.acos (Math.cos(39*pi/180)) - ( p11nrg/2 )) ; \n) print (p11e = (180/pi) * (Math.acos (Math.cos(39*pi/180)) + ( p11nrg/2 )) ; \n\n) print (p10s = (180/pi) * (Math.acos (Math.cos(33*pi/180)) - ( p10nrg/2 )) ; \n) print (p10e = (180/pi) * (Math.acos (Math.cos(33*pi/180)) + ( p10nrg/2 )) ; \n\n) print ( p1s = 60 - p14s \n) print ( p1e = p15e - 60 \n) print ( p2s = p16s - 60 \n) print ( p2e = 60 - p13e \n) print ( p3s = 60 - p13s \n) print ( p3e = p16e - 60 \n) print ( p4s = p17s - 60 \n) print ( p4e = 60 - p12e \n) print ( p5s = 60 - p12s \n) print ( p5e = p17e - 60 \n) print ( p6s = p18s - 60 \n) print ( p6e = 60 - p11e \n) print ( p7s = 60 - p11s \n) print ( p7e = p18e - 60 \n) print ( p8s = p19s - 60 \n) print ( p8e = 60 - p10e \n) print ( p9s = 60 - p10s \n) print ( p9e = p19e - 60 \n) print (\n\n\n\n// end delta hand recoding \n\n) print 1 1 pulsesperquadrant {10 string cvs /mm exch store (form.fp) mm mergestr (s.value = p) mergestr mm mergestr (s\n) mergestr print (form.fp) mm mergestr (e.value = p) mergestr mm mergestr (e\n) mergestr print } for (\n\n) print flush ( doStuffx (form) ;\n) print ( doStuffx (form) ;\n\n) print ( }\n\n) print % report from form (function reportFromForm (form) { \n\n ) print ( a00 = (eval (document.mainform.fa00.value)) * (pi/4) // unnormalize \n\n) print 1 1 pulsesperquadrant {10 string cvs /nn exch store (p)nn mergestr (e = eval \(document.mainform.fp) mergestr nn mergestr (e.value\)\n) mergestr print (p)nn mergestr (s = eval \(document.mainform.fp) mergestr nn mergestr (s.value\)\n) mergestr print } for ( }\n\n) print %% start high level procs % dostuff (// high level routines \n\n) print (function doStuffx (form) \n) print ( {reportFromForm (form); \n) print ( doStuff (form); \n) print ( reportToForm (form) ; \n) print ( } \n\n) print (function doStuff (form) \n) print ( {findHarms \(form\)} ; \n\n) print % harmonic calcs (function calcThd (form) { \n) print ( if (form.whichMS[0].checked){calcThdbeff (form) } ; // best efficiency \n) print ( if (form.whichMS[1].checked){calcThdnorm (form) } ; // normal sequence \n) print ( if (form.whichMS[2].checked){calcThddelta (form) } ; // delta friendly \n) print ( }\n\n) print % /calcthdgen accepts a name and a max harmonic value /calcthdgen {/highestharm exch store /functionname exch store (function ) functionname mergestr ((form) { \n\n) mergestr print (highestZeroharm = ) highestharm 4 string cvs mergestr ( ; \n\n) mergestr print % (zthd = "2-) highestharm 1 add 4 string cvs mergestr (" ; \n\n) mergestr print % (zthd = "2-" + highestZeroharm.toString() ; \n ) print (thd = Math.sqrt \( \n) print 3 2 highestharm {10 string cvs /curharmx exch store (\(h) curharmx cvi 10 lt {(0) mergestr} if curharmx mergestr (*h) mergestr curharmx cvi 10 lt {(0) mergestr} if curharmx mergestr (\) + \n) mergestr print } for ( 0 \) * 100 ; \n) print ( }\n\n) print } def (calcThdbeff) pulsesperquadrant 4 mul 1 sub cvi calcthdgen % best efficiency code (calcThdnorm) pulsesperquadrant 4 mul 3 sub cvi calcthdgen % normal code %%%%%%%% WARNING: MUST HAND PRECODE ENTER MAX DELTA HARMONIC search: ZZZZZZZ (calcThddelta) 57 calcthdgen % delta code % redirect prediction (// redirects prediction per radio button \n\n) print (function preDict (form) { // this may be slow \n) print ( if (form.whichMS[0].checked){preDictBesteff (form) } ; // best efficiency \n) print ( if (form.whichMS[1].checked){preDictNormal (form) } ; // normal sequence \n)print ( if (form.whichMS[2].checked){preDictDelta (form) } ; // delta friendly \n) print ( } \n\n) print % automin code (var maxFirsttrips = 12 \n) print (var maxMintrips = 120 \n\n) print (function autoMin (form) {doStuff (form)\nxxthd = thd \n)print (self.status = "Optimizing first decimal place -- please wait" \n) print (reportToForm (form) \n\n) print ( for (j = 0 ; j < maxFirsttrips; j++) \n) print ( { addFirst (form) ; \n) print ( if (thd >= xxthd) break ; \n) print ( xxthd = thd ; \n ) print ( } \n\n) print ( if \((form.hominydp[1].checked) || \n) print ( (form.hominydp[2].checked) || \n) print ( (form.hominydp[3].checked) || \n) print ( (form.hominydp[4].checked) || \n) print ( (form.hominydp[5].checked) || \n) print ( (form.hominydp[6].checked) || \n) print ( (form.hominydp[7].checked) \n) print ( \) { \n\n) print (self.status = "Optimizing second decimal place -- please wait" \n) print (reportToForm (form) \n\n) print ( for (j = 0 ; j < maxMintrips; j++) \n) print ( {addSecond (form) ; \n) print ( if (thd >= xxthd) break ; \n) print ( xxthd = thd ; \n) print ( } \n\n) print ( if \((form.hominydp[2].checked) || \n) print ( (form.hominydp[3].checked) || \n) print ( (form.hominydp[4].checked) || \n) print ( (form.hominydp[5].checked) || \n) print ( (form.hominydp[6].checked) || \n) print ( (form.hominydp[7].checked) \n) print ( \) { \n\n) print (self.status = "Optimizing third decimal place -- please wait" \n) print (reportToForm (form) \n\n) print ( for (j = 0 ; j < maxMintrips; j++) \n) print ( { addThird (form) ; \n) print ( if (thd >= xxthd) break ; \n) print ( xxthd = thd ; \n) print ( } \n\n) print ( if \((form.hominydp[3].checked) || \n) print ( (form.hominydp[4].checked) || \n) print ( (form.hominydp[5].checked) || \n) print ( (form.hominydp[6].checked) || \n) print ( (form.hominydp[7].checked) \n) print ( \) { \n\n) print (self.status = "Optimizing fourth decimal place -- please wait" \n) print (reportToForm (form) \n\n) print ( for (j = 0 ; j < maxMintrips; j++) \n) print ( { addFourth (form) ; \n) print ( if (thd >= xxthd) break ; \n) print ( xxthd = thd ; \n) print ( } \n\n) print ( if \((form.hominydp[4].checked) || \n) print ( (form.hominydp[5].checked) || \n) print ( (form.hominydp[6].checked) || \n) print ( (form.hominydp[7].checked) \n) print ( \) { \n\n) print (self.status = "Optimizing fifth decimal place -- please wait" \n) print (reportToForm (form) \n\n) print ( for (j = 0 ; j < maxMintrips; j++) \n) print ( { addFifth (form) ; \n) print ( if (thd >= xxthd) break ; \n) print ( xxthd = thd ; \n) print ( } \n\n) print ( if \((form.hominydp[5].checked) || \n) print ( (form.hominydp[6].checked) || \n) print ( (form.hominydp[7].checked) \n) print ( \) { \n\n) print (self.status = "Optimizing sixth decimal place -- please wait" \n) print (reportToForm (form) \n\n) print ( for (j = 0 ; j < maxMintrips; j++) \n) print ( { addSixth (form) ; \n) print ( if (thd >= xxthd) break ; \n) print ( xxthd = thd ; \n) print ( } \n\n) print ( if \((form.hominydp[6].checked) || \n) print ( (form.hominydp[7].checked) \n) print ( \) { \n\n) print (self.status = "Optimizing seventh decimal place -- please wait" \n) print (reportToForm (form) \n\n) print ( for (j = 0 ; j < maxMintrips; j++) \n) print ( { addSeventh (form) ; \n) print ( if (thd >= xxthd) break ; \n) print ( xxthd = thd ; \n) print ( } \n\n) print ( if \((form.hominydp[7].checked) \n) print ( \) { \n) print (self.status = "Optimizing eighth decimal place -- please wait" \n) print (reportToForm (form) \n\n) print ( for (j = 0 ; j < maxMintrips; j++) \n) print ( { addEighth (form) ; \n) print ( if (thd >= xxthd) break ; \n) print ( xxthd = thd ; \n) print ( } \n\n) print ( } // if 8 \n) print ( } // if 7 or more \n) print ( } // if 6 or more \n) print ( } // if 5 or more \n) print ( } // if 4 or more \n) print ( } // if 3 or more \n) print ( } // if 2 or more \n\n) print ( reportToForm (form) \n) print ( self.status = "Done" \n) print ( } \n\n) print % adder codes (function addFirst (form) \n) print ({ \n) print ( incD5 = 0.1 ; \n) print ( maxIncs = 100 ; \n) print ( addAny (form); \n) print (} \n\n) print (function addSecond (form) \n) print ({ \n) print ( incD5 = 0.01 ; \n) print ( maxIncs = 100 ; \n) print ( addAny (form); \n) print (} \n\n) print (function addThird (form) \n) print ({ \n) print ( incD5 = 0.001 ; \n) print ( maxIncs = 100 ; \n) print ( addAny (form); \n) print (} \n\n) print (function addFourth (form) \n) print ({ \n) print ( incD5 = 0.0001 ; \n) print ( maxIncs = 100 ; \n) print ( addAny (form); \n) print (} \n\n) print (function addFifth (form) \n) print ({ \n) print ( incD5 = 0.00001 ; \n) print ( maxIncs = 100 ; \n) print ( addAny (form); \n) print (} \n\n) print (function addSixth (form) \n) print ({ \n) print ( incD5 = 0.000001 ; \n) print ( maxIncs = 100 ; \n) print ( addAny (form); \n) print (} \n\n) print (function addSeventh (form) \n) print ({ \n) print ( incD5 = 0.0000001 ; \n) print ( maxIncs = 100 ; \n) print ( addAny (form); \n) print (} \n\n) print (function addEighth (form) \n) print ({ \n) print ( incD5 = 0.00000001 ; \n) print ( maxIncs = 100 ; \n) print ( addAny (form); \n) print (} \n\n) print % addAny intercept from radio buttons ( function addAny (form) { \n) print ( if (form.whichMS[0].checked){addAnyreg (form) } ; // best efficiency \n) print ( if (form.whichMS[1].checked){addAnyreg (form) } ; // normal sequence \n) print ( if (form.whichMS[2].checked){addAnydelta(form) } ; // delta friendly \n) print ( } \n\n) print (// improved optimizer routines \n\n) print (function minimizethd (form, pzz, lockRule) { \n) print ( xthd = thd ; \n) print (for (i = 0 ; i < maxIncs ; i++) // pulse edge up \n\n) print ( {if (thd > xthd){ break} ; // quit after minimum \n) print ( xthd = thd ; \n) print ( eval( pzz + " += incD5 " ) ;\n) print ( eval(lockRule) ;\n) print ( doStuff (form) ;\n) print ( }\n\n) print (xthd = thd ; \n\n) print ( for (i = 0 ; i < maxIncs ; i++) // pulse edge down\n\n) print ( {if (thd > xthd){ break} ; // quit after minimum\n) print ( xthd = thd ;\n) print ( eval( pzz + " -= incD5 " ) ;\n) print ( eval(lockRule) ; \n) print ( doStuff (form) ;\n) print ( }\n\n) print ( eval( pzz + " += incD5 " ) // correct undershoot \n) print ( eval(lockRule) ;\n) print ( doStuff (form) ;\n) print ( }\n\n) print (//format: minimizethd (form, "p3e", "p1e = p3e - 60") or (form, "")\n\n) print % add any regular (function addAnyreg (form) \n\n) print ({ doStuff (form) \n\n) print 1 1 pulsesperquadrant {10 string cvs /oo exch store (minimizethd \(form, "p) oo mergestr (s",""\)) mergestr (\n) mergestr print (minimizethd \(form, "p) oo mergestr (e",""\)) mergestr (\n) mergestr print } for (\n) print (reportToForm (form) // leave one at end \n)print (}\n\n) print %%%% addany delta %%%%%% WARNING: MUST HAND ENTER LOCK RULES search: ZZZZZZZ %%%%%%%%% (function addAnydelta \(form\){ \n\n) print (// tracking is \n) print (// p1s = 60 - p14s \n) print (// p1e = p15e - 60 \n) print (// p2s = p16s - 60 \n) print (// p2e = 60 - p13e \n) print (// p3s = 60 - p13s \n) print (// p3e = p16e - 60 \n) print (// p4s = p17s - 60 \n) print (// p4e = 60 - p12e \n) print (// p5s = 60 - p12s \n) print (// p5e = p17e - 60 \n) print (// p6s = p18s - 60 \n) print (// p6e = 60 - p11e \n) print (// p7s = 60 - p11s \n) print (// p7e = p18e - 60 \n) print (// p8s = p19s - 60 \n) print (// p8e = 60 - p10e \n) print (// p9s = 60 - p10s \n) print (// p9e = p19e - 60 \n) print (// p14e = 120 - p15s \n\n) print (// variables: p10s through p19e except for p14e locked \n) print ( //format is (form, "p3e", "p1e = p3e - 60") \n\n) print ( doStuff (form) \n\n) print (minimizethd (form, "p10s", "p9s = 60 - p10s" ) \n\n) print (minimizethd (form, "p10e", "p8e = 60 - p10e" ) \n\n) print (minimizethd (form, "p11s", "p7s = 60 - p11s " ) \n\n) print (minimizethd (form, "p11e", "p6e = 60 - p11e" ) \n\n) print (minimizethd (form, "p12s", "p5s = 60 - p12s " ) \n\n) print (minimizethd (form, "p12e", "p4e = 60 - p12e" ) \n\n) print (minimizethd (form, "p13s", "p3s = 60 - p13s" ) \n\n) print (minimizethd (form, "p13e", "p2e = 60 - p13e" ) \n) print (minimizethd (form, "p14s", "p1s = 60 - p14s" ) \n\n) print (minimizethd (form, "p15s", "p14e = 120 - p15s" ) \n) print (minimizethd (form, "p15e", "p1e = p15e - 60" ) \n\n) print (minimizethd (form, "p16s", "p2s = p16s - 60" ) \n\n) print (minimizethd (form, "p16e", "p3e = p16e - 60" ) \n\n) print (minimizethd (form, "p17s", "p4s = p17s - 60" ) \n\n) print (minimizethd (form, "p17e", "p5e = p17e - 60" ) \n\n) print (minimizethd (form, "p18s", "p6s = p18s - 60" ) \n\n) print (minimizethd (form, "p18e", "p7e = p18e - 60" ) \n\n) print (minimizethd (form, "p19s", "p8s = p19s - 60" ) \n\n) print (minimizethd (form, "p19e", "p9e = p19e - 60" ) \n\n) print (reportToForm (form) // leave one at end \n)print (}\n\n) print % guess new amp (// guessNewamp is the same for best eff, normal, and delta magic sinewaves. \n) print (// nothing special used for delta; automin forces locking. \n\n) print (function guessNewamp (form) { \n\n) print 1 1 pulsesperquadrant {10 string cvs /pp exch store (p)pp mergestr (s = p) mergestr pp mergestr (s - \(\(\(p) mergestr pp mergestr (d * ampdelta\) - p) mergestr pp mergestr (d\)/2\) ; \n) mergestr print (p)pp mergestr (e = p) mergestr pp mergestr (e + \(\(\(p) mergestr pp mergestr (d * ampdelta\) - p) mergestr pp mergestr (d\)/2\) ; \n) mergestr print } for ( } \n\n) print % adjust amplitude routines... (function adjAmpl (form) { \n\n) print ( reportFromForm (form) ; \n) print ( doStuff (form)\n) print 1 1 pulsesperquadrant {10 string cvs /qq exch store (p) qq mergestr (d = p) mergestr qq mergestr (e - p) mergestr qq mergestr (s ; \n) mergestr print } for ( \n\n) print ( a00 = (eval (document.mainform.fa00.value)) * (pi/4) // unnormalize \n) print ( ampdelta = a00 / a01 \n) print ( guessNewamp (form) \n\n ) print ( form.fa01.value = a01* (4 / pi) ; // only scaling used \n\n) print 1 1 pulsesperquadrant {10 string cvs /rr exch store (form.fp) rr mergestr (s.value = p) mergestr rr mergestr (s \n) mergestr print (form.fp) rr mergestr (e.value = p) mergestr rr mergestr (e \n) mergestr print } for ( \n) print (doStuffx (form) \n) print (reportToForm (form) \n) print (autoMin (form) ; \n) print ( } \n\n) print % quantization routines (// quantization routines find distortions for given number of amplitude data bits. \n\n) print (maxdegrees = 20 ; // number of degrees corresponding to "full scale" delay.\n\n) print (function adjQuant8 (form) {qincr = maxdegrees / 256 ; \nquantany (form)} ; \n) print (function adjQuant10 (form) {qincr = maxdegrees / 1024 ; \nquantany (form)} ; \n) print (function adjQuant12 (form) {qincr = maxdegrees / 4096 ; \nquantany (form)} ; \n) print (function adjQuant16 (form) {qincr = maxdegrees / (256 * 256); \n quantany (form) }; \n) print (function adjQuant24 (form) {qincr = maxdegrees / (256 * 256 * 256); \nquantany (form)} ; \n\n ) print (function quantany (form) { \n\n) print 1 1 pulsesperquadrant {10 string cvs /ss exch store (p) ss mergestr (s = qincr * \( Math.round \(p) mergestr ss mergestr (s /qincr \)\) \n) mergestr print (p) ss mergestr (e = qincr * \( Math.round \(p) mergestr ss mergestr (e /qincr \)\) \n) mergestr print } for ( \n) print 1 1 pulsesperquadrant {10 string cvs /tt exch store (form.fp) tt mergestr (s.value = p) mergestr tt mergestr (s ; \n) mergestr print (form.fp) tt mergestr (e.value = p) mergestr tt mergestr (e ; \n) mergestr print } for ( \n) print ( doStuffx (form) ; // update recalculation \n\n) print ( } \n\n) print (// end Gonzo autogenerated code \n\n) print flush % html trailer (\ \n\n) print (\ \n\n) print (\\
Pulse Positions
\n) print (in Degrees
                   Target Amplitude: 
                          Target Power: