Mail Archives: geda-user/2024/04/30/10:28:44
Richard Rasker:
> Thank you for your explanation. So there is no easy solution that I
> overlooked. This hierarchical numbering seems rather complicated;
A possible solution to your req. last in this message.
Simple requirements make the designs simple and lot of functions and
requirments make the the design complicated. Hierarchical design is
a tool to simplify the complicated things, soo ofcause it is complicated
since it useful in the complicated cases, where not using it is even
more complicated. Hierarchical design is a good way to divide and a
conquer a problem, it is similar to what we in programming call
top-down or down-up design.
Take a look at:
https://aspodata.se/git/openhw/boards_arm_aspo/stm32f100_styrkort/styrkort.pcb
There you you have 8 pt100 inputs, t0 to t7. Looking at the board it is
easy to see which components belongs to input t1, it is simply thoose
with refdeses beginning with t1. If you have global refdeses, how do
you decide what R143 belongs to ?
In the bottom-up case, say you usually use the same ldo in many designs,
then you can prepare something like:
https://aspodata.se/git/openhw/share/gschem/_sub_page/pwr.ncp700b_3.3.sch
and just name it in a source symbol. The design is really simple, inp./
output cap., the ldo and a possible protection diode, but it saves you
a few clicks and its easy to include a ready made pcb subdesign in your
final board. There, it is really inconvenient to have a global namespace:
. what will the refdes of the input capacitor be in my future designs ?
. dito if you use two of theese ldo designs ?
The easiest way to solve thoose two is to use a prefix in the final
refdes, I belive there two ways to do that:
1, C! in subpage becomes aC1, bC1 etc depending of the source sym. refdes
2, C1 becomes C101, i.e. add 10 or 100 to each new subpage.
I personally prefere variant 1, which is easier to follow through
navigating the page heirarchy, and the refdeses in the subpage clearly
relates to the final refdes, it's just the refdes you see plus a prefix.
In the top-down case, say you want to design a mcu card and it will have
eight relay outputs. So start out with a source sym. with ref. to an
empty subpage, juse a placeholder for "I want a relay here" and copies it
so you have eigth of thoose in your current page. Coping a symbol is
much easier than copiing readymade subdesigns. Now you are free to add
other things, but eventually go down to the relay page and do it. The
same things happens with the refdeses as in the bottom-up case.
> I think I'll follow upĀ on your suggestion and write a simple script that
> maintains a list of all RefDes-attributes in all relevant page files,
> and simply coughs up the next free RefDes for the most common categories
> of components (R, C, L, U, Q).
...
If you don't use subpages, then you already have global refdeses. If
you want subpages, you can temporarily accept the hierarchical refdeses,
and when your design finalizes, you can extract them with:
$ grep '^Element\[' styrkort.pcb | cut -f6 -d\" | sort | tee list | head
12C1
12C2
12C3
12D1
12D2
12D3
12D4
12Ds1
12L1
12Rb1
$
and split out the prefix and the local refdeses like (or similar):
$ head < list | perl -ne 'm/([A-Za-z]+)(\d+)/ && print "$` / $1 / $2\n"'
12 / C / 1
12 / C / 2
12 / C / 3
12 / D / 1
12 / D / 2
12 / D / 3
12 / D / 4
12 / Ds / 1
12 / L / 1
12 / Rb / 1
$
From such a list you can make a conversion table so you can finalize
the refdeses with some sed or similar script:
ch_refdes < hier.pcb > global.pcb
which you can place in a Makefile to automate the conversion.
If you use numeric source symbol refdeses like 100, 200, ... or 10, 20, ..
you could use that as something to add to the local refdeses:
$ grep ^12 list | perl -ne 'm/([A-Z][a-z]*)(\d+)/ && do { chomp; $n = $`+$2; print "/^Element\\[/s/$_/$1$n/\n"; }' | tee sed
/^Element\[/s/12C1/C13/
/^Element\[/s/12C2/C14/
/^Element\[/s/12C3/C15/
/^Element\[/s/12D1/D13/
/^Element\[/s/12D2/D14/
/^Element\[/s/12D3/D15/
/^Element\[/s/12D4/D16/
/^Element\[/s/12Ds1/Ds13/
/^Element\[/s/12L1/L13/
/^Element\[/s/12Rb1/Rb13/
/^Element\[/s/12Rt1/Rt13/
/^Element\[/s/12Rt2/Rt14/
/^Element\[/s/12Rt3/Rt15/
/^Element\[/s/12U1/U13/
$ sed -f sed < styrkort.pcb > tt.pcb
$ diff styrkort.pcb tt.pcb | head -4
2766c2766
< Element["onsolder" "ipc7351b_1608Ar.fp" "12Rt3" "6.8k" 138.5000mm 52.7500mm -1.9500mm -0.8000mm 2 100 "onsolder"]
---
> Element["onsolder" "ipc7351b_1608Ar.fp" "Rt15" "6.8k" 138.5000mm 52.7500mm -1.9500mm -0.8000mm 2 100 "onsolder"]
$
Regards,
/Karl Hammar
- Raw text -