@@ -230,7 +230,7 @@ function updatespan(sch_num, obj, unitIndex=0) {
230230 var customMarkers = [ ] ;
231231
232232 schematic . push ( { type :'raw' , zo : 50 , freq :2440 , er : 1 , freq_unit :{ unit :'MHz' , multiplier :1e6 } , span :0.0 , span_unit :{ unit :'MHz' , multiplier :1e6 } } ) ;
233- schematic . push ( { type :'bb' , real :1 , imaginary :0 , abs :[ 50 , 0 ] , unit :'null' } ) ;
233+ schematic . push ( { type :'bb' , real :1 , imaginary :0 , abs :[ 50 , 0 ] , unit :'null' , tol : 0 } ) ;
234234
235235function one_over_complex ( real , imaginary ) {
236236 var realn = real / ( real * real + imaginary * imaginary ) ;
@@ -240,29 +240,29 @@ function one_over_complex(real, imaginary) {
240240
241241function clicked_cell ( type ) {
242242 if ( type == "pr" ) {
243- schematic . push ( { type :'pr' , real :0 , imaginary :0 , abs :[ 50 ] , unit :[ 'Ω' ] } ) ;
243+ schematic . push ( { type :'pr' , real :0 , imaginary :0 , abs :[ 50 ] , unit :[ 'Ω' ] , tol : 0 } ) ;
244244 } else if ( type == "sr" ) {
245- schematic . push ( { type :'sr' , real :0 , imaginary :0 , abs :[ 50 ] , unit :[ 'Ω' ] } ) ;
245+ schematic . push ( { type :'sr' , real :0 , imaginary :0 , abs :[ 50 ] , unit :[ 'Ω' ] , tol : 0 } ) ;
246246 } else if ( type == "si" ) {
247- schematic . push ( { type :'si' , real :0 , imaginary :0 , abs :[ 1 ] , unit :[ 'nH' ] } ) ;
247+ schematic . push ( { type :'si' , real :0 , imaginary :0 , abs :[ 1 ] , unit :[ 'nH' ] , tol : 0 } ) ;
248248 } else if ( type == "pi" ) {
249- schematic . push ( { type :'pi' , real :0 , imaginary :0 , abs :[ 1 ] , unit :[ 'nH' ] } ) ;
249+ schematic . push ( { type :'pi' , real :0 , imaginary :0 , abs :[ 1 ] , unit :[ 'nH' ] , tol : 0 } ) ;
250250 } else if ( type == "sc" ) {
251- schematic . push ( { type :'sc' , real :0 , imaginary :0 , abs :[ 1 ] , unit :[ 'pF' ] } ) ;
251+ schematic . push ( { type :'sc' , real :0 , imaginary :0 , abs :[ 1 ] , unit :[ 'pF' ] , tol : 0 } ) ;
252252 } else if ( type == "pc" ) {
253- schematic . push ( { type :'pc' , real :0 , imaginary :0 , abs :[ 1 ] , unit :[ 'pF' ] } ) ;
253+ schematic . push ( { type :'pc' , real :0 , imaginary :0 , abs :[ 1 ] , unit :[ 'pF' ] , tol : 0 } ) ;
254254 } else if ( type == "tl" ) {
255- schematic . push ( { type :'tl' , line_length :1e-3 , abs :[ 1 ] , line_zo :50 , unit :[ 'mm' ] , real :0 , imaginary :0 } ) ;
255+ schematic . push ( { type :'tl' , line_length :1e-3 , abs :[ 1 ] , line_zo :50 , unit :[ 'mm' ] , real :0 , imaginary :0 , tol : 0 } ) ;
256256 } else if ( type == "ss" ) {
257- schematic . push ( { type :'ss' , line_length :1e-3 , abs :[ 1 ] , line_zo :50 , unit :[ 'mm' ] , real :0 , imaginary :0 } ) ;
257+ schematic . push ( { type :'ss' , line_length :1e-3 , abs :[ 1 ] , line_zo :50 , unit :[ 'mm' ] , real :0 , imaginary :0 , tol : 0 } ) ;
258258 } else if ( type == "so" ) {
259- schematic . push ( { type :'so' , line_length :1e-3 , abs :[ 1 ] , line_zo :50 , unit :[ 'mm' ] , real :0 , imaginary :0 } ) ;
259+ schematic . push ( { type :'so' , line_length :1e-3 , abs :[ 1 ] , line_zo :50 , unit :[ 'mm' ] , real :0 , imaginary :0 , tol : 0 } ) ;
260260 } else if ( type == "rc" ) {
261- schematic . push ( { type :'rc' , real :0 , imaginary :0 , abs :[ 50 , 1 ] , unit :[ 'Ω' , 'pF' ] } ) ;
261+ schematic . push ( { type :'rc' , real :0 , imaginary :0 , abs :[ 50 , 1 ] , unit :[ 'Ω' , 'pF' ] , tol : 0 } ) ;
262262 } else if ( type == "rl" ) {
263- schematic . push ( { type :'rl' , real :0 , imaginary :0 , abs :[ 50 , 1 ] , unit :[ 'Ω' , 'nH' ] } ) ;
263+ schematic . push ( { type :'rl' , real :0 , imaginary :0 , abs :[ 50 , 1 ] , unit :[ 'Ω' , 'nH' ] , tol : 0 } ) ;
264264 } else if ( type == "rlc" ) {
265- schematic . push ( { type :'rlc' , real :0 , imaginary :0 , abs :[ 50 , 1 , 1 ] , unit :[ 'Ω' , 'nH' , 'pF' ] } ) ;
265+ schematic . push ( { type :'rlc' , real :0 , imaginary :0 , abs :[ 50 , 1 , 1 ] , unit :[ 'Ω' , 'nH' , 'pF' ] , tol : 0 } ) ;
266266 }
267267 update_smith_chart ( ) ;
268268}
@@ -308,7 +308,7 @@ function unitTextToNum (unit, freq_here) {
308308 else if ( unit [ 0 ] == 'n' ) return 1e-9 ;
309309 else if ( unit [ 0 ] == 'u' ) return 1e-6 ;
310310 else if ( unit == 'm' ) return 1 ; //tl can have unit of meters
311- else if ( unit [ 0 ] == 'm' ) return 1e-3 ;
311+ else if ( unit [ 0 ] == 'm' ) return 1e-3 ; //milli...
312312 else if ( unit [ 0 ] == 'K' ) return 1e3 ;
313313 else if ( unit [ 0 ] == 'M' ) return 1e6 ;
314314 else if ( unit [ 0 ] == 'λ' ) return ( 3e8 / ( freq_here * Math . sqrt ( schematic [ 0 ] . er ) ) ) ;
@@ -950,24 +950,8 @@ var layout_polar = {
950950
951951 //update the HTML tables
952952 drawMakerTable ( ) ;
953-
954-
955953}
956954
957- // function createAbsBox(i,content) {
958- // return "<div class=\"abs_box\"><input type=\"text\" value="+schematic[i].abs+" onchange=\"update_schem_abs("+i+",this,'abs')\"></input>" + content + "</div>";
959- // }
960-
961- // function createDropdown (i,unit, unitIndex=0) {
962- // //Add units selector
963- // var content = "<div id=\"sch_"+i+"_"+unitIndex+"\" class=\"wrapper-dropdown-5 \" tabindex=\"1\"><div>"+schematic[i].unit[unitIndex]+"</div><ul class=\"dropdown\">";
964- // for (j=0;j<unit.length;j++) {
965- // content += "<li onclick=\"updatespan(parentElement.parentElement.id,'"+unit[j]+"',"+unitIndex+")\"><a href=\"#\">"+unit[j]+"</a></li>";
966- // }
967- // content +="</ul></div>";
968- // return createAbsBox(i,content);
969- // }
970-
971955function draw_schematic ( i ) {
972956
973957 //Add the element to the schematic view
@@ -989,10 +973,10 @@ function draw_schematic(i) {
989973 sch_abs = true ;
990974 sch_icon = "black_box" ;
991975 sch_svg = 0 ;
992- rows_to_create = [ [ 'abs' , 'abs' ] , [ 'Impedance ' ] ] ;
976+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'abs' ] , [ 'tol ' ] ] ;
993977 break ;
994978 case ( "pr" ) :
995- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'Impedance ' ] ] ;
979+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'tol ' ] ] ;
996980 sch_label = "Parallel Resistor" ;
997981 sch_imag = false ;
998982 sch_real = true ;
@@ -1002,7 +986,7 @@ function draw_schematic(i) {
1002986 sch_svg = 2500 ;
1003987 break ;
1004988 case ( "sr" ) :
1005- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'Impedance ' ] ] ;
989+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'tol ' ] ] ;
1006990 sch_label = "Series Resistor" ;
1007991 sch_imag = false ;
1008992 sch_real = true ;
@@ -1012,7 +996,7 @@ function draw_schematic(i) {
1012996 sch_svg = 3000 ;
1013997 break ;
1014998 case ( "pc" ) :
1015- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'Impedance ' ] ] ;
999+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'tol ' ] ] ;
10161000 sch_label = "Parallel Capacitor" ;
10171001 sch_imag = true ;
10181002 sch_real = false ;
@@ -1022,7 +1006,7 @@ function draw_schematic(i) {
10221006 sch_svg = 500 ;
10231007 break ;
10241008 case ( "sc" ) :
1025- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'Impedance ' ] ] ;
1009+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'tol ' ] ] ;
10261010 sch_label = "Series Capacitor" ;
10271011 sch_imag = true ;
10281012 sch_real = false ;
@@ -1032,7 +1016,7 @@ function draw_schematic(i) {
10321016 sch_svg = 1000 ;
10331017 break ;
10341018 case ( "pi" ) :
1035- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'Impedance ' ] ] ;
1019+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'tol ' ] ] ;
10361020 sch_label = "Parallel Inductor" ;
10371021 sch_imag = true ;
10381022 sch_real = false ;
@@ -1042,7 +1026,7 @@ function draw_schematic(i) {
10421026 sch_svg = 1500 ;
10431027 break ;
10441028 case ( "si" ) :
1045- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'Impedance ' ] ] ;
1029+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'tol ' ] ] ;
10461030 sch_label = "Series Inductor" ;
10471031 sch_imag = true ;
10481032 sch_real = false ;
@@ -1052,7 +1036,7 @@ function draw_schematic(i) {
10521036 sch_svg = 2000 ;
10531037 break ;
10541038 case ( "tl" ) :
1055- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'line_zo' ] ] ;
1039+ rows_to_create = [ [ 'blank-impedance' ] , [ ' abs', 'unit_0' ] , [ 'line_zo' ] ] ;
10561040 sch_label = "Transmission Line" ;
10571041 sch_imag = false ;
10581042 sch_real = false ;
@@ -1062,7 +1046,7 @@ function draw_schematic(i) {
10621046 sch_svg = 3500 ;
10631047 break ;
10641048 case ( "ss" ) :
1065- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'line_zo' ] ] ;
1049+ rows_to_create = [ [ 'blank-impedance' ] , [ ' abs', 'unit_0' ] , [ 'line_zo' ] ] ;
10661050 sch_label = "Short Stub" ;
10671051 sch_imag = false ;
10681052 sch_real = false ;
@@ -1072,7 +1056,7 @@ function draw_schematic(i) {
10721056 sch_svg = 4500 ;
10731057 break ;
10741058 case ( "so" ) :
1075- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'line_zo' ] ] ;
1059+ rows_to_create = [ [ 'blank-impedance' ] , [ ' abs', 'unit_0' ] , [ 'line_zo' ] ] ;
10761060 sch_label = "Open Stub" ;
10771061 sch_imag = false ;
10781062 sch_real = false ;
@@ -1082,7 +1066,7 @@ function draw_schematic(i) {
10821066 sch_svg = 4000 ;
10831067 break
10841068 case ( "rc" ) :
1085- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'abs' , 'unit_1' ] , [ 'Impedance ' ] ] ;
1069+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'abs' , 'unit_1' ] , [ 'tol ' ] ] ;
10861070 sch_label = "Capacitor w/ ESR" ;
10871071 sch_imag = true ;
10881072 sch_real = true ;
@@ -1092,7 +1076,7 @@ function draw_schematic(i) {
10921076 sch_svg = 5000 ;
10931077 break ;
10941078 case ( "rl" ) :
1095- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'abs' , 'unit_1' ] , [ 'Impedance ' ] ] ;
1079+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'abs' , 'unit_1' ] , [ 'tol ' ] ] ;
10961080 sch_label = "Inductor w/ ESR" ;
10971081 sch_imag = true ;
10981082 sch_real = true ;
@@ -1102,7 +1086,7 @@ function draw_schematic(i) {
11021086 sch_svg = 5500 ;
11031087 break ;
11041088 case ( "rlc" ) :
1105- rows_to_create = [ [ 'abs' , 'unit_0' ] , [ 'abs' , 'unit_1' ] , [ 'abs' , 'unit_2' ] , [ 'Impedance ' ] ] ;
1089+ rows_to_create = [ [ 'Impedance' ] , [ ' abs', 'unit_0' ] , [ 'abs' , 'unit_1' ] , [ 'abs' , 'unit_2' ] , [ 'tol ' ] ] ;
11061090 sch_label = "Inductor w/ ESR" ;
11071091 sch_imag = true ;
11081092 sch_real = true ;
@@ -1112,8 +1096,6 @@ function draw_schematic(i) {
11121096 sch_svg = 6000 ;
11131097 break ;
11141098 }
1115- //div.innerHTML = "<p>"+sch_label+"</p>";
1116- // div.innerHTML += "<img src=\"icons/"+sch_icon+".png\" alt="+sch_label+">";
11171099 innerText += '<div class="row"><div class="col"><svg viewBox="' + sch_svg + ' 0 500 500"><use xlink:href="svg/elements.svg#rainbow3" alt="' + sch_label + '" /></svg></div></div>' ;
11181100
11191101 var cntR , cntC , ittUnit , boxType , varSelect , unitIndex ;
@@ -1122,8 +1104,15 @@ function draw_schematic(i) {
11221104 innerText += '<div class="row ms-3 me-3"><div class="input-group mb-1 p-0">'
11231105 for ( cntC = 0 ; cntC < rows_to_create [ cntR ] . length ; cntC ++ ) {
11241106 boxType = rows_to_create [ cntR ] [ cntC ] ;
1125- if ( boxType == 'Impedance' ) {
1126- innerText += '<div class="row ms-3">Impedance = '
1107+ if ( boxType == 'tolxxx' ) {
1108+ innerText += '<span class="input-group-text">tol ± </span>'
1109+ innerText += '<input type="text" class="form-control" value="0" name="tol" onchange="update_schem_tol(' + i + ',this)">'
1110+ innerText += '<span class="input-group-text">%</span>'
1111+ } else
1112+ if ( boxType == 'blank-impedance' ) {
1113+ innerText += '<div class="fst-italic m-auto"> </div>' ;
1114+ } else if ( boxType == 'Impedance' ) {
1115+ innerText += '<div class="fst-italic m-auto">Z = '
11271116 if ( sch_real ) innerText += Number ( ( ( schematic [ i ] . real * zo ) ) . toPrecision ( precision ) )
11281117 if ( sch_real && sch_imag ) {
11291118 if ( schematic [ i ] . imaginary * zo >= 0 ) innerText += ' + '
@@ -1147,7 +1136,7 @@ function draw_schematic(i) {
11471136 } else {
11481137 if ( cntC > 0 ) innerText += '<span class="input-group-text">+</span>'
11491138 innerText += '<input type="text" class="form-control inputMW" value=' + schematic [ i ] [ boxType ] [ absCounter ] + ' name="' + boxType + '" onchange="update_schem_abs(' + i + ',this,' + absCounter + ')">'
1150- if ( cntC > 0 ) innerText += '<span class="input-group-text">j</span>'
1139+ if ( cntC > 0 ) innerText += '<span class="input-group-text ps-2 pe-2 ">j</span>'
11511140 if ( boxType == 'abs' ) absCounter = absCounter + 1 ;
11521141 }
11531142 }
0 commit comments