Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 31755) +++ trunk/scconfig/Rev.h (revision 31756) @@ -1 +1 @@ -static const int myrev = 31708; +static const int myrev = 31756; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 31755) +++ trunk/scconfig/Rev.tab (revision 31756) @@ -1,3 +1,4 @@ +31756 configure new plugin: formula, for impedance calculations 31708 configure query plugin: move the advanced search dialog from dialogs plugin to query to better access of internals 31623 configure query plugin: net length calculations 31519 configure io_tedax drc block upgrade for drc_query Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 31755) +++ trunk/scconfig/plugins.h (revision 31756) @@ -6,6 +6,7 @@ plugin_header("\nLibrary plugins:\n") plugin_def("lib_compat_help", "#compatibility helper functions", sbuildin, 1, 0) +plugin_def("lib_formula", "mathematical forumlas", sbuildin, 1, 0) plugin_def("lib_gensexpr", "#s-expression library", sdisable, 0, 0) plugin_def("lib_gtk_common", "all-hid_gtk common code", sdisable, 0, 0) plugin_def("lib_hid_common", "all-gui-hid common code", sdisable, 0, 1) Index: trunk/src_plugins/lib_formula/Makefile =================================================================== --- trunk/src_plugins/lib_formula/Makefile (nonexistent) +++ trunk/src_plugins/lib_formula/Makefile (revision 31756) @@ -0,0 +1,6 @@ +all: + cd ../../src && $(MAKE) mod_lib_formula + +clean: + rm *.o *.so 2>/dev/null ; true + Index: trunk/src_plugins/lib_formula/Plug.tmpasm =================================================================== --- trunk/src_plugins/lib_formula/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/lib_formula/Plug.tmpasm (revision 31756) @@ -0,0 +1,10 @@ +put /local/pcb/mod {lib_formula} +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/lib_formula/lib_formula.o +@] + +switch /local/pcb/lib_formula/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/lib_formula/impedance.c =================================================================== --- trunk/src_plugins/lib_formula/impedance.c (nonexistent) +++ trunk/src_plugins/lib_formula/impedance.c (revision 31756) @@ -0,0 +1,44 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2020 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" +#include + +#define TOM(x) (RND_COORD_TO_MM(x) * 1000.0) +#define SQR(x) ((x)*(x)) +#define N0 377 + +double pcb_impedance_microstrip(rnd_coord_t trace_thick, rnd_coord_t trace_height, rnd_coord_t subst_height, double dielect) +{ + double w = TOM(trace_thick), t = TOM(trace_height), h = TOM(subst_height), Er = dielect; + double weff, x1, x2; + + weff = w + (t/M_PI) * log(4*M_E / sqrt(SQR(t/h)+SQR(t/(w*M_PI+1.1*t*M_PI)))) * (Er+1)/(2*Er); + x1 = 4 * ((14*Er+8)/(11*Er)) * (h/weff); + x2 = qsrt(16 * SQR(h/weff) * SQR((14*Er+8)/(11*Er)) + ((Er+1)/(2*Er))*M_PI; + return N0 / (2*M_PI * sqrt(2) * sqrt(Er+1)) * log(1+4*(h/weff)*(x1+x2)); +} + Index: trunk/src_plugins/lib_formula/impedance.h =================================================================== --- trunk/src_plugins/lib_formula/impedance.h (nonexistent) +++ trunk/src_plugins/lib_formula/impedance.h (revision 31756) @@ -0,0 +1,2 @@ +double pcb_impedance_microstrip(rnd_coord_t trace_thick, rnd_coord_t trace_height, rnd_coord_t subst_height, double dielect); + Index: trunk/src_plugins/lib_formula/lib_formula.c =================================================================== --- trunk/src_plugins/lib_formula/lib_formula.c (nonexistent) +++ trunk/src_plugins/lib_formula/lib_formula.c (revision 31756) @@ -0,0 +1,44 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2020 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include +#include + +#include "impedance.h" + +int pplg_check_ver_lib_formula(int ver_needed) { return 0; } + +void pplg_uninit_lib_formula(void) +{ +} + +int pplg_init_lib_formula(void) +{ + RND_API_CHK_VER; + return 0; +} Index: trunk/src_plugins/lib_formula/lib_formula.pup =================================================================== --- trunk/src_plugins/lib_formula/lib_formula.pup (nonexistent) +++ trunk/src_plugins/lib_formula/lib_formula.pup (revision 31756) @@ -0,0 +1,6 @@ +$class lib +$short mathematical forumlas +$long simple formulas, for efficient rule-of-thumb calculations +$state works +$package core +default buildin Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 31755) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 31756) @@ -83,6 +83,7 @@ include {../src_plugins/irc/Plug.tmpasm} include {../src_plugins/jostle/Plug.tmpasm} include {../src_plugins/lib_compat_help/Plug.tmpasm} +include {../src_plugins/lib_formula/Plug.tmpasm} include {../src_plugins/lib_gensexpr/Plug.tmpasm} include {../src_plugins/lib_gtk_common/Plug.tmpasm} include {../src_plugins/lib_hid_common/Plug.tmpasm}