## Re: [Ktechlab-devel] no more errors SVN - revision 491

 Re: [Ktechlab-devel] no more errors SVN - revision 491 From: David Saxton - 2005-09-28 13:26:53 ```On Wednesday 28 September 2005 00:07, Eric Ensmann wrote: > I'm thinking about building an inductor component but currently I don't > know where to start. Perhaps I get an idea of it tomorrow.. Excellent :) You'll need to start by adding code for simulating inductance (the rest after that is easy). As an example, I'll explain how capacitance is simulated. Have a look at src/electronics/simulation/capacitance.cpp Here, the capacitance formula "I = C (dV/dt)" is simulated using numerical integration. At the moment, it uses the backwards euler method (it should really be using trapezoidal method, but I haven't written that yet....). By using a small time step (m_delta = h), the above formula is approximated by I_(n+1) = C * ( V_(n+1) - V_n ) / h (where the "V_n" is the current voltage, "V_(n+1)" is the voltage at (current time)+(time step), and "I_(n+1)" is the current flowing into the capacitor at (current time)+(time step). Google for "numerical integration" if the above formula doesn't make sense. Capacitance can be simulated as a current source in parallel with resistance - and so the above formula is written as (turn on fixed width fonts...): I_(n+1) = (C / h) * V_(n+1) - (C * V_n / h) I_(n+1) = g_eq * V_(n+1) - I_eq where g_eq is the conductance of the resistor, and I_eq is the current of the current source. This boils down to a few lines of code in Capacitance::time_step(): double v = p_cnode[0]->v-p_cnode[1]->v; g_eq_new = m_cap/m_delta; i_eq_new = -v*g_eq_new; The rest of the code in that function is just plugging the values into the simulation matrix for simulating as a resistance and a current source in parallel. The simulator uses modified nodal analysis to simulate the circuit (google for more information). For the inductor, you'll need to do similar for the inductance formula "V = L (dI/dt)" formula. Then, you'll need to make the inductance property available for use by adding the right functions to the Component class (src/electronics/component.[h/cpp]), and then writing an inductor component that draws itself and uses the inductance property. Any questions - I'm more than happy to help :) Regards, David Saxton ```

 [Ktechlab-devel] 2 Errors compiling SVN - revision 489 From: Eric Ensmann - 2005-09-27 14:58:31 ```Hi, i was able to fix the first Error by adding an #include to the projectdlgs.cpp file but i don't know how to fix the second one: Making all in components make[4]: Entering directory `/home/quinn/downloads/svn.ktechlab.org/src/electronics/components' source='multiplexer.cpp' object='multiplexer.lo' libtool=yes \ depfile='.deps/multiplexer.Plo' tmpdepfile='.deps/multiplexer.TPlo' \ depmode=gcc3 /bin/sh ../../../admin/depcomp \ /bin/sh ../../../libtool --silent --mode=compile --tag=CXX g++ -DHAVE_CONFIG_H -I. -I. -I../../.. -I../../../src -I../../../src/electronics -I../../../src/electronics/components -I../../../src/electronics/simulation -I../../../src/gui -I../../../src/languages -I../../../src/micro -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/kde/3.4/include -I/usr/qt/3/include -I. -DQT_THREAD_SUPPORT -D_REENTRANT -Wnon-virtual-dtor -Wno-long-long -Wundef -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common -c -o multiplexer.lo `test -f 'multiplexer.cpp' || echo './'`multiplexer.cpp multiplexer.cpp: In member function `virtual void Multiplexer::dataChanged()': multiplexer.cpp:68: error: call of overloaded `log(int)' is ambiguous :68: error: candidates are: double std::log(double) /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3/cmath:411: error: float std::log(float) /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3/cmath:419: error: long double std::log(long double) multiplexer.cpp:68: error: call of overloaded `log(int)' is ambiguous :68: error: candidates are: double std::log(double) /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3/cmath:411: error: float std::log(float) /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3/cmath:419: error: long double std::log(long double) make[4]: *** [multiplexer.lo] Error 1 Thanks for your help.. ```
 Re: [Ktechlab-devel] 2 Errors compiling SVN - revision 489 From: David Saxton - 2005-09-27 18:25:04 ```Ah, "this" bug again. =46or some reason, my g++ and associated tool chain doesn't pick up on when= I've=20 neglected to include assert.h, or have ambigious calls to std math function= s,=20 or several other similar problems. I've commited fixes - but can't be sure that something hasn't been missed a= s I=20 don't get these compilation errors - please say if anything still isn't=20 compiling. Regards, David Saxton On Tuesday 27 September 2005 15:58, Eric Ensmann wrote: > Hi, > > i was able to fix the first Error by adding an > > =A0=A0=A0=A0=A0=A0=A0=A0#include > > to the projectdlgs.cpp file but i don't know how to fix the second one: ```
 Re: [Ktechlab-devel] errors compiling SVN - revision 490 From: Eric Ensmann - 2005-09-27 20:18:26 ```Hi again :) okay there are a few other problems: 1. multiplexer.cpp: In member function `virtual void Multiplexer::dataChanged()': multiplexer.cpp:68: error: call of overloaded `log(int)' is ambiguous :68: error: candidates are: double std::log(double) /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3/cmath:411: error: float std::log(float) /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3/cmath:419: error: long double std::log(long double) can be fixed (don't know if this makes any sense) in line 68 of multiplexer.cpp by casting dataInt to double: int addressSize = int( std::ceil( std::log( (double)dataInt("numInput") ) std::log(2.0) ) ); instead of: int addressSize = int( std::ceil( std::log( dataInt("numInput") ) std::log(2.0) ) ); 2. demultiplexer.cpp: In member function `virtual void Demultiplexer::dataChanged()': demultiplexer.cpp:68: error: call of overloaded `log(int)' is ambiguous :68: error: candidates are: double std::log(double) /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3/cmath:411: error: float std::log(float) /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3/cmath:419: error: long double std::log(long double) same "solution" as above. 3. Finally i get this one: gpsimprocessor.cpp: In member function `unsigned int GpsimProcessor::programMemorySize() const': gpsimprocessor.cpp:162: error: `program_memory_size' undeclared (first use this function) gpsimprocessor.cpp:162: error: (Each undeclared identifier is reported only once for each function it appears in.) gpsimprocessor.cpp: In member function `void GpsimDebugger::stackStep(int)': gpsimprocessor.cpp:616: warning: unused parameter `int dl' gpsimprocessor.cpp: In member function ` RegisterSet::RegisterSet(RegisterMemoryAccess*)': gpsimprocessor.cpp:654: warning: unused parameter `RegisterMemoryAccess*rma' gpsimprocessor.cpp: In member function `RegisterInfo::RegisterInfo(Register*)': gpsimprocessor.cpp:701: warning: unused parameter `Register*reg' Have fun ;-) > Ah, "this" bug again. > > For some reason, my g++ and associated tool chain doesn't pick up on when > I've neglected to include assert.h, or have ambigious calls to std math > functions, or several other similar problems. > > I've commited fixes - but can't be sure that something hasn't been missed > as I don't get these compilation errors - please say if anything still > isn't compiling. > > Regards, > David Saxton ```
 Re: [Ktechlab-devel] errors compiling SVN - revision 490 From: David Saxton - 2005-09-27 22:17:36 ```Thanks for the feedback :) I've committed revision 491 which should have fixed all the mentioned problems, and hopefully ktechlab will compile nicely now :) On Tuesday 27 September 2005 21:18, Eric Ensmann wrote: > Hi again :) > > okay there are a few other problems: ```
 Re: [Ktechlab-devel] no more errors SVN - revision 491 From: Eric Ensmann - 2005-09-27 23:07:51 ```Thanks alot for fixing it so fast ! It's now compiling without any problems. I really like this software and was curious about the new transistor :) I'm thinking about building an inductor component but currently I don't know where to start. Perhaps I get an idea of it tomorrow.. well, that's it for today, good night :) > Thanks for the feedback :) > > I've committed revision 491 which should have fixed all the mentioned > problems, and hopefully ktechlab will compile nicely now :) ```
 Re: [Ktechlab-devel] no more errors SVN - revision 491 From: David Saxton - 2005-09-28 13:26:53 ```On Wednesday 28 September 2005 00:07, Eric Ensmann wrote: > I'm thinking about building an inductor component but currently I don't > know where to start. Perhaps I get an idea of it tomorrow.. Excellent :) You'll need to start by adding code for simulating inductance (the rest after that is easy). As an example, I'll explain how capacitance is simulated. Have a look at src/electronics/simulation/capacitance.cpp Here, the capacitance formula "I = C (dV/dt)" is simulated using numerical integration. At the moment, it uses the backwards euler method (it should really be using trapezoidal method, but I haven't written that yet....). By using a small time step (m_delta = h), the above formula is approximated by I_(n+1) = C * ( V_(n+1) - V_n ) / h (where the "V_n" is the current voltage, "V_(n+1)" is the voltage at (current time)+(time step), and "I_(n+1)" is the current flowing into the capacitor at (current time)+(time step). Google for "numerical integration" if the above formula doesn't make sense. Capacitance can be simulated as a current source in parallel with resistance - and so the above formula is written as (turn on fixed width fonts...): I_(n+1) = (C / h) * V_(n+1) - (C * V_n / h) I_(n+1) = g_eq * V_(n+1) - I_eq where g_eq is the conductance of the resistor, and I_eq is the current of the current source. This boils down to a few lines of code in Capacitance::time_step(): double v = p_cnode[0]->v-p_cnode[1]->v; g_eq_new = m_cap/m_delta; i_eq_new = -v*g_eq_new; The rest of the code in that function is just plugging the values into the simulation matrix for simulating as a resistance and a current source in parallel. The simulator uses modified nodal analysis to simulate the circuit (google for more information). For the inductor, you'll need to do similar for the inductance formula "V = L (dI/dt)" formula. Then, you'll need to make the inductance property available for use by adding the right functions to the Component class (src/electronics/component.[h/cpp]), and then writing an inductor component that draws itself and uses the inductance property. Any questions - I'm more than happy to help :) Regards, David Saxton ```