Commit ad615b454a7d47d931a918a21309bf0da56671a5

Authored by Chris Smartt
1 parent c78a9409

Add incident field pins to LTspice and Ngspice schematic symbols

SOFTWARE_NOTES/work_log.txt
@@ -12,3 +12,5 @@ @@ -12,3 +12,5 @@
12 25th June CJS Add the nex flex cable test cases EDGE_COUPLED_STRIPLINE and 12 25th June CJS Add the nex flex cable test cases EDGE_COUPLED_STRIPLINE and
13 SYMMETRIC_STRIPLINE to test the new flex cable model 13 SYMMETRIC_STRIPLINE to test the new flex cable model
14 14
  15 +
  16 +13th July CJS fix error in creaating circuit symbols: incident field nodes were missing...
SRC/CREATE_SPICE_CIRCUIT_MODEL/create_spice_subcircuit_symbol.F90
@@ -29,7 +29,6 @@ @@ -29,7 +29,6 @@
29 ! File Contents: 29 ! File Contents:
30 ! SUBROUTINE create_spice_subcircuit_symbol_NGspice 30 ! SUBROUTINE create_spice_subcircuit_symbol_NGspice
31 ! SUBROUTINE create_spice_subcircuit_symbol_LTspice 31 ! SUBROUTINE create_spice_subcircuit_symbol_LTspice
32 -! SUBROUTINE create_spice_subcircuit_symbol_Pspice  
33 ! 32 !
34 ! NAME 33 ! NAME
35 ! create_spice_subcircuit_symbol_NGspice 34 ! create_spice_subcircuit_symbol_NGspice
@@ -118,6 +117,11 @@ character(len=line_length) :: pinlabel_string @@ -118,6 +117,11 @@ character(len=line_length) :: pinlabel_string
118 117
119 ymax_symbol=ymin_offset+(n_conductors-1)*y_conductor_spacing+ymax_offset 118 ymax_symbol=ymin_offset+(n_conductors-1)*y_conductor_spacing+ymax_offset
120 119
  120 +! add a space for the incident field nodes
  121 + if (spice_bundle_model%include_incident_field) then
  122 + ymax_symbol=ymax_symbol+y_conductor_spacing
  123 + end if
  124 +
121 ! end 1 pin parameters # this could maybe go with parameters in the module... 125 ! end 1 pin parameters # this could maybe go with parameters in the module...
122 xpin1(1)=xmin_symbol-x_pin_length 126 xpin1(1)=xmin_symbol-x_pin_length
123 xpin2(1)=xmin_symbol 127 xpin2(1)=xmin_symbol
@@ -175,6 +179,59 @@ character(len=line_length) :: pinlabel_string @@ -175,6 +179,59 @@ character(len=line_length) :: pinlabel_string
175 end do ! next conductor 179 end do ! next conductor
176 180
177 end do ! other cable end 181 end do ! other cable end
  182 +
  183 +! add a space for the incident field nodes
  184 + if (spice_bundle_model%include_incident_field) then
  185 +
  186 +! put the first Einc pin on the LHS of the symbol
  187 + end=1
  188 + pin=pin+1
  189 + ypin=ymax_symbol-ymax_offset-(n_conductors)*y_conductor_spacing
  190 +
  191 + string1='pinnumber='
  192 + CALL add_integer_to_string(string1,pin,pinnumber_string)
  193 +
  194 + string1='pinseq='
  195 + CALL add_integer_to_string(string1,pin,pinseq_string)
  196 +
  197 + pinlabel_string='Einc1'
  198 + write(symbol_file_unit,'(A,4I6,A)')'P ',xpin1(end),ypin,xpin2(end),ypin,' 1 0 0'
  199 + write(symbol_file_unit,'(A)')'{'
  200 + write(symbol_file_unit,'(A)')'T 150 250 5 8 0 0 0 6 1'
  201 + write(symbol_file_unit,'(A)')trim(pinnumber_string)
  202 + write(symbol_file_unit,'(A)')'T 150 150 5 8 0 0 0 8 1'
  203 + write(symbol_file_unit,'(A)')trim(pinseq_string)
  204 + write(symbol_file_unit,'(A,2I6,A,I3,A)')'T ',xpin_label(end),ypin,' 9 6 1 1 0 ',align_label(end),' 1'
  205 + write(symbol_file_unit,'(A)')trim(pinlabel_string)
  206 + write(symbol_file_unit,'(A)')'T 200 200 5 8 0 0 0 2 1'
  207 + write(symbol_file_unit,'(A)')'pintype=pas'
  208 + write(symbol_file_unit,'(A)')'}'
  209 +
  210 +! put the first Einc pin on the LHS of the symbol
  211 + end=2
  212 + pin=pin+1
  213 + ypin=ymax_symbol-ymax_offset-(n_conductors)*y_conductor_spacing
  214 +
  215 + string1='pinnumber='
  216 + CALL add_integer_to_string(string1,pin,pinnumber_string)
  217 +
  218 + string1='pinseq='
  219 + CALL add_integer_to_string(string1,pin,pinseq_string)
  220 +
  221 + pinlabel_string='Einc2'
  222 + write(symbol_file_unit,'(A,4I6,A)')'P ',xpin1(end),ypin,xpin2(end),ypin,' 1 0 0'
  223 + write(symbol_file_unit,'(A)')'{'
  224 + write(symbol_file_unit,'(A)')'T 150 250 5 8 0 0 0 6 1'
  225 + write(symbol_file_unit,'(A)')trim(pinnumber_string)
  226 + write(symbol_file_unit,'(A)')'T 150 150 5 8 0 0 0 8 1'
  227 + write(symbol_file_unit,'(A)')trim(pinseq_string)
  228 + write(symbol_file_unit,'(A,2I6,A,I3,A)')'T ',xpin_label(end),ypin,' 9 6 1 1 0 ',align_label(end),' 1'
  229 + write(symbol_file_unit,'(A)')trim(pinlabel_string)
  230 + write(symbol_file_unit,'(A)')'T 200 200 5 8 0 0 0 2 1'
  231 + write(symbol_file_unit,'(A)')'pintype=pas'
  232 + write(symbol_file_unit,'(A)')'}'
  233 +
  234 + end if
178 235
179 ! spice_subcircuit_filename=trim(MOD_spice_bundle_lib_dir)//trim(spice_bundle_model%spice_model_name)//spice_model_file_extn 236 ! spice_subcircuit_filename=trim(MOD_spice_bundle_lib_dir)//trim(spice_bundle_model%spice_model_name)//spice_model_file_extn
180 spice_subcircuit_filename='PATH_TO_TRANSMISSION_LINE_SUB_CIRCUITS/'// & 237 spice_subcircuit_filename='PATH_TO_TRANSMISSION_LINE_SUB_CIRCUITS/'// &
@@ -264,6 +321,7 @@ integer :: LT_ymax_symbol ! maximum y extent of the symbol (depends on the nu @@ -264,6 +321,7 @@ integer :: LT_ymax_symbol ! maximum y extent of the symbol (depends on the nu
264 321
265 integer :: LT_xpin1(2),LT_xpin2(2) ! pin x coordinates for ends 1 and 2 of the transmission line symbol 322 integer :: LT_xpin1(2),LT_xpin2(2) ! pin x coordinates for ends 1 and 2 of the transmission line symbol
266 integer :: LT_ypin ! pin y coordinate 323 integer :: LT_ypin ! pin y coordinate
  324 +integer :: Einc_y_offset
267 325
268 integer :: xpin_label(2) ! x coordinate for conductor labels at ends 1 and 2 of the transmission line symbol 326 integer :: xpin_label(2) ! x coordinate for conductor labels at ends 1 and 2 of the transmission line symbol
269 327
@@ -299,6 +357,13 @@ character(len=line_length) :: pinlabel_string @@ -299,6 +357,13 @@ character(len=line_length) :: pinlabel_string
299 n_conductors=spice_bundle_model%bundle%tot_n_conductors 357 n_conductors=spice_bundle_model%bundle%tot_n_conductors
300 358
301 LT_ymax_symbol=LT_ymin_offset+(n_conductors-1)*LT_y_conductor_spacing+LT_ymax_offset 359 LT_ymax_symbol=LT_ymin_offset+(n_conductors-1)*LT_y_conductor_spacing+LT_ymax_offset
  360 +
  361 +! add a space for the incident field nodes
  362 + Einc_y_offset=0
  363 + if (spice_bundle_model%include_incident_field) then
  364 + Einc_y_offset=LT_y_conductor_spacing
  365 + LT_ymax_symbol=LT_ymax_symbol+Einc_y_offset
  366 + end if
302 367
303 ! end 1 pin parameters # this could maybe go with parameters in the module... 368 ! end 1 pin parameters # this could maybe go with parameters in the module...
304 LT_xpin1(1)=LT_xmin_symbol-LT_x_pin_length 369 LT_xpin1(1)=LT_xmin_symbol-LT_x_pin_length
@@ -326,7 +391,7 @@ character(len=line_length) :: pinlabel_string @@ -326,7 +391,7 @@ character(len=line_length) :: pinlabel_string
326 391
327 pin=pin+1 392 pin=pin+1
328 393
329 - LT_ypin=LT_ymax_symbol-LT_ymax_offset-(n_conductors-conductor)*LT_y_conductor_spacing 394 + LT_ypin=LT_ymax_symbol-LT_ymax_offset-(n_conductors-conductor)*LT_y_conductor_spacing-Einc_y_offset
330 395
331 write(symbol_file_unit,'(A,4I6)')'LINE Normal ',LT_xpin1(end),LT_ypin,LT_xpin2(end),LT_ypin 396 write(symbol_file_unit,'(A,4I6)')'LINE Normal ',LT_xpin1(end),LT_ypin,LT_xpin2(end),LT_ypin
332 397
@@ -334,6 +399,25 @@ character(len=line_length) :: pinlabel_string @@ -334,6 +399,25 @@ character(len=line_length) :: pinlabel_string
334 399
335 end do ! other cable end 400 end do ! other cable end
336 401
  402 +! add pins for the incident field nodes
  403 + if (spice_bundle_model%include_incident_field) then
  404 +
  405 + end=1
  406 + pin=pin+1
  407 +
  408 + LT_ypin=LT_ymax_symbol-LT_ymax_offset
  409 +
  410 + write(symbol_file_unit,'(A,4I6)')'LINE Normal ',LT_xpin1(end),LT_ypin,LT_xpin2(end),LT_ypin
  411 +
  412 + end=2
  413 + pin=pin+1
  414 +
  415 + LT_ypin=LT_ymax_symbol-LT_ymax_offset
  416 +
  417 + write(symbol_file_unit,'(A,4I6)')'LINE Normal ',LT_xpin1(end),LT_ypin,LT_xpin2(end),LT_ypin
  418 +
  419 + end if
  420 +
337 ! write general information 421 ! write general information
338 422
339 write(symbol_file_unit,'(A,2I6,A)')'WINDOW 3 ',(LT_xmin_symbol+LT_xmax_symbol)/2,-LT_ymax_text_offset,' centre 0' 423 write(symbol_file_unit,'(A,2I6,A)')'WINDOW 3 ',(LT_xmin_symbol+LT_xmax_symbol)/2,-LT_ymax_text_offset,' centre 0'
@@ -357,7 +441,7 @@ character(len=line_length) :: pinlabel_string @@ -357,7 +441,7 @@ character(len=line_length) :: pinlabel_string
357 do conductor=1,n_conductors 441 do conductor=1,n_conductors
358 442
359 pin=pin+1 443 pin=pin+1
360 - LT_ypin=LT_ymax_symbol-LT_ymax_offset-(n_conductors-conductor)*LT_y_conductor_spacing 444 + LT_ypin=LT_ymax_symbol-LT_ymax_offset-(n_conductors-conductor)*LT_y_conductor_spacing-Einc_y_offset
361 445
362 if (end.eq.1) then 446 if (end.eq.1) then
363 write(symbol_file_unit,'(A,2I6,A,I6)')'PIN ',LT_xpin1(end),LT_ypin,' LEFT ',LT_x_pin_length 447 write(symbol_file_unit,'(A,2I6,A,I6)')'PIN ',LT_xpin1(end),LT_ypin,' LEFT ',LT_x_pin_length
@@ -379,6 +463,30 @@ character(len=line_length) :: pinlabel_string @@ -379,6 +463,30 @@ character(len=line_length) :: pinlabel_string
379 463
380 end do ! other cable end 464 end do ! other cable end
381 465
  466 + if (spice_bundle_model%include_incident_field) then
  467 +
  468 + end=1
  469 + pin=pin+1
  470 + LT_ypin=LT_ymax_symbol-LT_ymax_offset
  471 + write(symbol_file_unit,'(A,2I6,A,I6)')'PIN ',LT_xpin1(end),LT_ypin,' LEFT ',LT_x_pin_length
  472 + pinlabel_string='PinName Einc1'
  473 + write(symbol_file_unit,'(A,A)')'PINATTR ',trim(pinlabel_string)
  474 + string1=''
  475 + CALL add_integer_to_string(string1,pin,pinnumber_string)
  476 + write(symbol_file_unit,'(A,A)')'PINATTR SpiceOrder ',trim(pinnumber_string)
  477 +
  478 + end=2
  479 + pin=pin+1
  480 + write(symbol_file_unit,'(A,2I6,A,I6)')'PIN ',LT_xpin1(end),LT_ypin,' RIGHT ',LT_x_pin_length
  481 + pinlabel_string='PinName Einc2'
  482 + write(symbol_file_unit,'(A,A)')'PINATTR ',trim(pinlabel_string)
  483 + string1=''
  484 + CALL add_integer_to_string(string1,pin,pinnumber_string)
  485 + write(symbol_file_unit,'(A,A)')'PINATTR SpiceOrder ',trim(pinnumber_string)
  486 +
  487 +
  488 + end if
  489 +
382 xpin_label(1)=LT_xmin_symbol 490 xpin_label(1)=LT_xmin_symbol
383 xpin_label(2)=LT_xmax_symbol 491 xpin_label(2)=LT_xmax_symbol
384 492
@@ -391,184 +499,3 @@ character(len=line_length) :: pinlabel_string @@ -391,184 +499,3 @@ character(len=line_length) :: pinlabel_string
391 RETURN 499 RETURN
392 500
393 END SUBROUTINE create_spice_subcircuit_symbol_LTspice 501 END SUBROUTINE create_spice_subcircuit_symbol_LTspice
394 -!  
395 -! NAME  
396 -! create_spice_subcircuit_symbol_Pspice  
397 -!  
398 -! AUTHORS  
399 -! Chris Smartt  
400 -!  
401 -! DESCRIPTION  
402 -! This subroutine creates a symbol for the Spice subcircuit model for the cable bundle  
403 -! to be used in schematic capture software  
404 -!  
405 -! The file formats for Gschem can be found here: http://wiki.geda-project.org/geda:file_format_spec  
406 -!  
407 -! COMMENTS  
408 -!  
409 -!  
410 -! HISTORY  
411 -!  
412 -! started 15/12/2015 CJS: STAGE_1 developments  
413 -!  
414 -!  
415 -SUBROUTINE create_spice_subcircuit_symbol_Pspice(spice_bundle_model)  
416 -  
417 -USE type_specifications  
418 -USE general_module  
419 -USE constants  
420 -USE cable_module  
421 -USE cable_bundle_module  
422 -USE spice_cable_bundle_module  
423 -USE circuit_symbol_module  
424 -  
425 -IMPLICIT NONE  
426 -  
427 -! variables passed to the subroutine  
428 -  
429 -TYPE(spice_model_specification_type),intent(IN) :: spice_bundle_model  
430 -  
431 -! local variables  
432 -  
433 -character(len=filename_length) :: filename ! filename for the symbol file  
434 -character(len=filename_length) :: spice_subcircuit_filename ! filename for the associated spice sub-circuit model  
435 -  
436 -integer :: n_conductors  
437 -  
438 -integer :: ymax_symbol ! maximum y extent of the symbol (depends on the number of conductors)  
439 -  
440 -integer :: xpin1(2),xpin2(2) ! pin x coordinates for ends 1 and 2 of the transmission line symbol  
441 -integer :: ypin ! pin y coordinate  
442 -  
443 -integer :: xpin_label(2) ! x coordinate for conductor labels at ends 1 and 2 of the transmission line symbol  
444 -integer :: align_label(2) ! alignment type for symbols  
445 -  
446 -! loop variables  
447 -integer :: pin ! pin number  
448 -integer :: end ! end number  
449 -integer :: conductor ! conductor number  
450 -  
451 -! temporary strings  
452 -character(len=line_length) :: string1  
453 -character(len=line_length) :: string2  
454 -  
455 -! pin label strings  
456 -character(len=line_length) :: pinnumber_string  
457 -character(len=line_length) :: pinseq_string  
458 -character(len=line_length) :: pinlabel_string  
459 -  
460 -! START  
461 -  
462 -! filename for the symbol. The directory for the symbol is read from the  
463 -! .spice_model_spec file (i.e. specified by the GUI)  
464 -  
465 - filename=trim(spice_symbol_dir)//trim(spice_bundle_model%spice_model_name)//symbol_file_extn  
466 -  
467 -! open the symbol file  
468 -  
469 - OPEN(unit=symbol_file_unit,file=filename)  
470 -  
471 - if (verbose) write(*,*)'Opened file:',trim(filename)  
472 -  
473 -! calculate the size of the symbol from the number of conductors and set all symbol dimensions  
474 -  
475 - n_conductors=spice_bundle_model%bundle%tot_n_conductors  
476 -  
477 - ymax_symbol=ymin_offset+(n_conductors-1)*y_conductor_spacing+ymax_offset  
478 -  
479 -! end 1 pin parameters # this could maybe go with parameters in the module...  
480 - xpin1(1)=xmin_symbol-x_pin_length  
481 - xpin2(1)=xmin_symbol  
482 -  
483 -! end 2 pin parameters  
484 - xpin1(2)=xmax_symbol+x_pin_length  
485 - xpin2(2)=xmax_symbol  
486 -  
487 - ! write the header  
488 - write(symbol_file_unit,'(A)')symbol_version  
489 -  
490 -! write the rectangular box  
491 - write(symbol_file_unit,'(A,4I6,A)')'L ',xmin_symbol,ymin_symbol,xmin_symbol,ymax_symbol,' 3 0 0 0 -1 -1'  
492 - write(symbol_file_unit,'(A,4I6,A)')'L ',xmin_symbol,ymax_symbol,xmax_symbol,ymax_symbol,' 3 0 0 0 -1 -1'  
493 - write(symbol_file_unit,'(A,4I6,A)')'L ',xmax_symbol,ymax_symbol,xmax_symbol,ymin_symbol,' 3 0 0 0 -1 -1'  
494 - write(symbol_file_unit,'(A,4I6,A)')'L ',xmax_symbol,ymin_symbol,xmin_symbol,ymin_symbol,' 3 0 0 0 -1 -1'  
495 -  
496 -! write the connection pins  
497 - xpin_label(1)=xmin_symbol  
498 - xpin_label(2)=xmax_symbol  
499 - align_label(1)=1 ! left  
500 - align_label(2)=7 ! right  
501 -  
502 - pin=0  
503 - do end=1,2  
504 -  
505 - do conductor=1,n_conductors  
506 -  
507 - pin=pin+1  
508 - ypin=ymax_symbol-ymax_offset-(conductor-1)*y_conductor_spacing  
509 -  
510 - string1='pinnumber='  
511 - CALL add_integer_to_string(string1,pin,pinnumber_string)  
512 -  
513 - string1='pinseq='  
514 - CALL add_integer_to_string(string1,pin,pinseq_string)  
515 -  
516 - string1='pinlabel=c_'  
517 - CALL add_integer_to_string(string1,conductor,string2)  
518 - string1=trim(string2)//'_e_'  
519 - CALL add_integer_to_string(string1,end,pinlabel_string)  
520 -  
521 - write(symbol_file_unit,'(A,4I6,A)')'P ',xpin1(end),ypin,xpin2(end),ypin,' 1 0 0'  
522 - write(symbol_file_unit,'(A)')'{'  
523 - write(symbol_file_unit,'(A)')'T 150 250 5 8 0 0 0 6 1'  
524 - write(symbol_file_unit,'(A)')trim(pinnumber_string)  
525 - write(symbol_file_unit,'(A)')'T 150 150 5 8 0 0 0 8 1'  
526 - write(symbol_file_unit,'(A)')trim(pinseq_string)  
527 - write(symbol_file_unit,'(A,2I6,A,I3,A)')'T ',xpin_label(end),ypin,' 9 6 1 1 0 ',align_label(end),' 1'  
528 - write(symbol_file_unit,'(A)')trim(pinlabel_string)  
529 - write(symbol_file_unit,'(A)')'T 200 200 5 8 0 0 0 2 1'  
530 - write(symbol_file_unit,'(A)')'pintype=pas'  
531 - write(symbol_file_unit,'(A)')'}'  
532 -  
533 - end do ! next conductor  
534 -  
535 - end do ! other cable end  
536 -  
537 -! spice_subcircuit_filename=trim(MOD_spice_bundle_lib_dir)//trim(spice_bundle_model%spice_model_name)//spice_model_file_extn  
538 - spice_subcircuit_filename='PATH_TO_TRANSMISSION_LINE_SUB_CIRCUITS/'// &  
539 - trim(spice_bundle_model%spice_model_name)//spice_model_file_extn  
540 -  
541 -! write the general circuit symbol information  
542 - write(symbol_file_unit,'(A,2I6,A)')'T ',(xmin_symbol+xmax_symbol)/2,ymax_symbol+2*ymax_text_offset,' 8 10 1 1 0 4 1'  
543 - string1='device='//trim(spice_bundle_model%spice_model_name)  
544 - write(symbol_file_unit,'(A)')trim(string1)  
545 -  
546 - write(symbol_file_unit,'(A,2I6,A)')'T ',(xmin_symbol+xmax_symbol)/2,ymax_symbol+ymax_text_offset,' 5 10 1 0 0 4 1'  
547 - write(symbol_file_unit,'(A)')'refdes=X?'  
548 -  
549 - write(symbol_file_unit,'(A,2I6,A)')'T ',xmin_symbol,ymin_symbol,' 8 10 0 0 0 4 1'  
550 - string1='description='//trim(spice_bundle_model%spice_model_name)  
551 - write(symbol_file_unit,'(A)')trim(string1)  
552 -  
553 - write(symbol_file_unit,'(A,2I6,A)')'T ',xmin_symbol,ymin_symbol,' 8 10 0 0 0 0 1'  
554 - string1='value='//trim(spice_bundle_model%spice_model_name)  
555 - write(symbol_file_unit,'(A)')trim(string1)  
556 -  
557 - write(symbol_file_unit,'(A,2I6,A)')'T ',xmin_symbol,ymin_symbol,' 8 10 0 0 0 0 1'  
558 - write(symbol_file_unit,'(A,A)')'file=',trim(spice_subcircuit_filename)  
559 -  
560 - write(symbol_file_unit,'(A,2I6,A)')'T ',xmin_symbol,ymin_symbol,' 8 10 0 0 0 0 1'  
561 - write(symbol_file_unit,'(A)')'numslots=0'  
562 -  
563 - write(symbol_file_unit,'(A,2I6,A)')'T ',xmin_symbol,ymin_symbol,' 8 10 0 0 0 0 1'  
564 - write(symbol_file_unit,'(A)')'symversion=0.1'  
565 -  
566 -! close the symbol file  
567 -  
568 - CLOSE(unit=symbol_file_unit)  
569 -  
570 - if (verbose) write(*,*)'Closed file:',trim(filename)  
571 -  
572 - RETURN  
573 -  
574 -END SUBROUTINE create_spice_subcircuit_symbol_Pspice