1 Pages (13 items)
What's wrong? SMath or my fundamentals? - Messages
Hello,
My calculations involve a measurement setup designed to measure capacitors with small inductances. Multimeters typically cannot measure in the pF range. This requires a resistor with a known resistance value (as close as possible), a signal generator (possibly using software and a sound card), and a 2-channel oscilloscope. Not only must two amplitudes be measured, but also the phase difference between the two signals.
The calculation works quite well with a sine wave. However, the results for the calculated inductances vary more than I had hoped.
Problem in this program: Why doesn’t Draw2D produce a graph when there is an arg() statement in the last key? If it is replaced, for example, by a -Re()- statement, then Draw3D generates a graph?!
Now I had hoped to be able to perform calculations using the determined complex transfer function even when the input is a square wave instead of a sine wave. Unfortunately, that doesn’t work. Why?
Regards, Andreas
Versuch mit R und C Sinus 01.pdf (2.19 MiB) downloaded 90 time(s). Versuch mit R und C Sinus 01.sm (814.63 KiB) downloaded 85 time(s).
Versuch mit R und C Rechteck 01.pdf (1.86 MiB) downloaded 107 time(s). Versuch mit R und C Rechteck 01.sm (555.42 KiB) downloaded 86 time(s).
My calculations involve a measurement setup designed to measure capacitors with small inductances. Multimeters typically cannot measure in the pF range. This requires a resistor with a known resistance value (as close as possible), a signal generator (possibly using software and a sound card), and a 2-channel oscilloscope. Not only must two amplitudes be measured, but also the phase difference between the two signals.
The calculation works quite well with a sine wave. However, the results for the calculated inductances vary more than I had hoped.
Problem in this program: Why doesn’t Draw2D produce a graph when there is an arg() statement in the last key? If it is replaced, for example, by a -Re()- statement, then Draw3D generates a graph?!
Now I had hoped to be able to perform calculations using the determined complex transfer function even when the input is a square wave instead of a sine wave. Unfortunately, that doesn’t work. Why?
Regards, Andreas
Versuch mit R und C Sinus 01.pdf (2.19 MiB) downloaded 90 time(s). Versuch mit R und C Sinus 01.sm (814.63 KiB) downloaded 85 time(s).
Versuch mit R und C Rechteck 01.pdf (1.86 MiB) downloaded 107 time(s). Versuch mit R und C Rechteck 01.sm (555.42 KiB) downloaded 86 time(s).
Edited 2026/5/27 12:32:09
Hi. I hope these results can help you with your analysis. The circuit is solved numerically using the spice# plugin and symbolically using the MNA method. For more information, see https://smath.com/en-US/forum/topic/HhT3PC/SpiceSharp
Versuch mit R und C MNA.pdf (483.77 KiB) downloaded 101 time(s).
Versuch mit R und C MNA.sm (703.09 KiB) downloaded 96 time(s).
Best regards.
Alvaro.
Versuch mit R und C MNA.pdf (483.77 KiB) downloaded 101 time(s).
Versuch mit R und C MNA.sm (703.09 KiB) downloaded 96 time(s).
Best regards.
Alvaro.
Hi Alvaro,
Thanks for your help. For one thing, I didn't even know there was a Spice plug-in. For another, I need to familiarize myself with how you use SMath first. That will probably take a few days. For problems I couldn't solve using SMath the way I do, I've always switched to Octave so far.
Best regards
Thanks for your help. For one thing, I didn't even know there was a Spice plug-in. For another, I need to familiarize myself with how you use SMath first. That will probably take a few days. For problems I couldn't solve using SMath the way I do, I've always switched to Octave so far.
Best regards
This is the simulation in LTSpice using only the netlist, and it apparently gives the same results in SMath's spice# plugin. Is this netlist correct?

Best regards.
Alvaro.

V1 1 0 SINE(0 0.7071 {freq} 0)
* V1 1 0 PULSE(-0.8 0.8 0 1u 1u {1/freq/2-1u} {1/freq})
R1 1 2 327.1k
C1 2 0 200p
RT1 1 3 9M
CT1 1 3 12.78p
LK1 3 4 250n
RK1 4 5 1.5
CK1 5 0 100p
RO1 5 0 1M
CO1 5 0 15p
RT2 2 6 9M
CT2 2 6 12.78p
LK2 6 7 250n
RK2 7 8 1.5
CK2 8 0 100p
RO2 8 0 1M
CO2 8 0 15p
.PARAM freq = 10000
.TRAN 0 1000u 700u 1u
* .TRAN 0 60u 30u 0.1u
* .TRAN 0 {10/freq} {8/freq} 1u
.SAVE V(1) V(2)
.END
Best regards.
Alvaro.
Hi Alvaro,
I haven't had a chance to try out the SMath SPICE plugin yet.
In my LTspice schematic, CH1 has no function. The only important part is what you can see in the attached schematic. I've also included the exported netlist.
In Smath, I mainly wanted to work with complex transfer functions. It worked quite well with a sine wave as input. I thought that the transfer function generated this way would also produce meaningful results with a square wave as input. Unfortunately, that’s not the case. I’d now like to know why not.
Best regards
Andreas
Versuch mit R und C Sinus 03.net (564 B) downloaded 81 time(s).
I haven't had a chance to try out the SMath SPICE plugin yet.
In my LTspice schematic, CH1 has no function. The only important part is what you can see in the attached schematic. I've also included the exported netlist.
In Smath, I mainly wanted to work with complex transfer functions. It worked quite well with a sine wave as input. I thought that the transfer function generated this way would also produce meaningful results with a square wave as input. Unfortunately, that’s not the case. I’d now like to know why not.
Best regards
Andreas
Versuch mit R und C Sinus 03.net (564 B) downloaded 81 time(s).Edited 2026/5/30 16:57:27
Hi. I can't find any errors in your method; however, because it's so slow, it's difficult for me to study it in detail. One observation is that the phasor method only returns the steady-state solution, and the transient response might be what's causing the discrepancy. You can observe the same situation in the sinusoidal waveform solution.
Versuch mit R und C V4.sm (442.88 KiB) downloaded 48 time(s).
Versuch mit R und C MNA.pdf (1016.18 KiB) downloaded 62 time(s).
Best regards.
Alvaro.
Versuch mit R und C V4.sm (442.88 KiB) downloaded 48 time(s).
Versuch mit R und C MNA.pdf (1016.18 KiB) downloaded 62 time(s).
Best regards.
Alvaro.
Hi Alvaro,
Since I'm not interested in the transient phase, I omit the first few oscillations from the simulation. “.tran 0 1000u 700u 1u” shows me only the 8th, 9th, and 10th oscillations.
With the integration used to calculate the coefficients “c(n;f)” for the square-wave oscillation, the calculation takes a very long time. There’s a faster way:
V1(t,f)
{4*V1pp}/π*sum({-1}/{2*n+1}*sin(i*(2*n+1)/2*ω0(f)*t)*e^{1*(2*n+1)/2*ω0(f)*t},n,-nmax-1,-1))+({4*V1pp}/π*sum(1/{2*n-1}*sin((2*n-1)/2*ω0(f)*t)*e^{i*(2*n-1)/2*ω0(f)*t},n,1,nmax+1))
I see you’ve really delved into the Laplace transform. As an engineer, I don’t want to get into the theory behind it—I just want to apply it to my problem. Unfortunately, that doesn’t always work, so I end up having to grapple with the fundamentals after all.
I’m still having trouble with your solution to my problem. But I’m working on it.
Best regards
Andreas

Since I'm not interested in the transient phase, I omit the first few oscillations from the simulation. “.tran 0 1000u 700u 1u” shows me only the 8th, 9th, and 10th oscillations.
With the integration used to calculate the coefficients “c(n;f)” for the square-wave oscillation, the calculation takes a very long time. There’s a faster way:
V1(t,f)
I see you’ve really delved into the Laplace transform. As an engineer, I don’t want to get into the theory behind it—I just want to apply it to my problem. Unfortunately, that doesn’t always work, so I end up having to grapple with the fundamentals after all.
I’m still having trouble with your solution to my problem. But I’m working on it.
Best regards
Andreas

Hi Andreas. The solution for a square wave, using superposition method and admittance matrix.
Versuch mit R und C sqare.sm (30.43 KiB) downloaded 39 time(s).
Versuch mit R und C sqare.pdf (544.96 KiB) downloaded 80 time(s).
Best regards.
Alvaro
Versuch mit R und C sqare.sm (30.43 KiB) downloaded 39 time(s).
Versuch mit R und C sqare.pdf (544.96 KiB) downloaded 80 time(s).
Best regards.
Alvaro
Hi Alvaro,
this morning I took a few more measurements. I’m still using capacitors whose capacitance I know. My goal is to determine capacitances between 10 pF and 0.1 pF.
That reminded me again why I wanted to calculate with complex transfer functions in Smath.
I’ve gotten pretty good at using LTspice by now. But in LTspice, I have to specify the component values myself. I’ve also imported measured pulses into LTspice and then tried varying the specified values until the simulation output resembled the measured output. That’s tedious work.
For a sine wave, I managed to use SMath to reverse the formulas and calculate the component values (especially those of C1) from the measured values. That’s exactly what I wanted to achieve for a square wave as well.
Gegards Andreas
this morning I took a few more measurements. I’m still using capacitors whose capacitance I know. My goal is to determine capacitances between 10 pF and 0.1 pF.
That reminded me again why I wanted to calculate with complex transfer functions in Smath.
I’ve gotten pretty good at using LTspice by now. But in LTspice, I have to specify the component values myself. I’ve also imported measured pulses into LTspice and then tried varying the specified values until the simulation output resembled the measured output. That’s tedious work.
For a sine wave, I managed to use SMath to reverse the formulas and calculate the component values (especially those of C1) from the measured values. That’s exactly what I wanted to achieve for a square wave as well.
Gegards Andreas
Hi Andreas. What the previous worksheets show is how to use the superposition principle once you have the frequency-domain expression for the circuit. The MNA function finds it, or you can find it by hand.
In the case of this circuit, the symbolic expression for v2 is
-{RT*(s*LK*(((RT*(1+s^2*CT*LK)+s*LK)*(RT+R1*(1+s*RT*(CT+C1)))-(1+s*CT *RT)^2*R1*s*LK)*RO+R1*(1+s*CT*RT)^2*(-(RO+RK*(1+s*RO*(CO+CK)))*(RK+s*L K)+RO*s*LK))-(RO+RK*(1+s*RO*(CO+CK)))*(-(RT+R1*(1+s*RT*(CT+C1)))*RK*RT +(RK+s*LK)*((RT*(1+s^2*CT*LK)+s*LK)*(RT+R1*(1+s*RT*(CT+C1)))-(1+s*CT*R T)^2*R1*s*LK)))*V1*e^{s*t}}/{(RT+R1*(1+s*RT*(CT+C1)))*(-((RT*(1+s^2*CT) *LK)+s*LK)*(RT+R1*(1+s*RT*(CT+C1)))-(1+s*CT*RT)^2*R1*s*LK)*RO*s*LK+(RO +RK*(1+s*RO*(CO+CK)))*(-(RT+R1*(1+s*RT*(CT+C1)))*RK*RT+(RK+s*LK)*((RT* (1+s^2*CT*LK)+s*LK)*(RT+R1*(1+s*RT*(CT+C1)))-(1+s*CT*RT)^2*R1*s*LK)))}
where V1 is the Laplace transform of the input voltage, which for a square wave is -i*{4*Vo}/{(2*k-1)*π}

The expression may seem very complicated, but only because it derives from inverting the circuit's admittance matrix, which is simpler to understand. What calculations have you planned by varying C1?
Best regards.
Alvaro.
In the case of this circuit, the symbolic expression for v2 is
-{RT*(s*LK*(((RT*(1+s^2*CT*LK)+s*LK)*(RT+R1*(1+s*RT*(CT+C1)))-(1+s*CT *RT)^2*R1*s*LK)*RO+R1*(1+s*CT*RT)^2*(-(RO+RK*(1+s*RO*(CO+CK)))*(RK+s*L K)+RO*s*LK))-(RO+RK*(1+s*RO*(CO+CK)))*(-(RT+R1*(1+s*RT*(CT+C1)))*RK*RT +(RK+s*LK)*((RT*(1+s^2*CT*LK)+s*LK)*(RT+R1*(1+s*RT*(CT+C1)))-(1+s*CT*R T)^2*R1*s*LK)))*V1*e^{s*t}}/{(RT+R1*(1+s*RT*(CT+C1)))*(-((RT*(1+s^2*CT) *LK)+s*LK)*(RT+R1*(1+s*RT*(CT+C1)))-(1+s*CT*RT)^2*R1*s*LK)*RO*s*LK+(RO +RK*(1+s*RO*(CO+CK)))*(-(RT+R1*(1+s*RT*(CT+C1)))*RK*RT+(RK+s*LK)*((RT* (1+s^2*CT*LK)+s*LK)*(RT+R1*(1+s*RT*(CT+C1)))-(1+s*CT*RT)^2*R1*s*LK)))}
where V1 is the Laplace transform of the input voltage, which for a square wave is -i*{4*Vo}/{(2*k-1)*π}

The expression may seem very complicated, but only because it derives from inverting the circuit's admittance matrix, which is simpler to understand. What calculations have you planned by varying C1?
Best regards.
Alvaro.
Hi Alvaro,
It’s been a very long time since I’ve worked with matrices of functions, so I’ll need to get back into the swing of things.
For the LTspice simulation of an entire system, I need more precise values for individual components. For example, for the RG58 cables and the photomultiplier (PMT). The PMT manufacturer recommends using a current source (not a voltage source) to simulate the anode signal, along with a resistor greater than 1 teraohm and a capacitance less than 10 pF. However, to get my simulation results closer to the measured pulses, I need to choose a capacitance that is less than 1 pF.
In the meantime, I’ve conducted a series of measurements using different frequencies of the sine wave. I think a frequency should be chosen where the phase is close to 45°.
Regards Andreas
Versuch mit R und C.pdf (214.2 KiB) downloaded 16 time(s).
It’s been a very long time since I’ve worked with matrices of functions, so I’ll need to get back into the swing of things.
For the LTspice simulation of an entire system, I need more precise values for individual components. For example, for the RG58 cables and the photomultiplier (PMT). The PMT manufacturer recommends using a current source (not a voltage source) to simulate the anode signal, along with a resistor greater than 1 teraohm and a capacitance less than 10 pF. However, to get my simulation results closer to the measured pulses, I need to choose a capacitance that is less than 1 pF.
In the meantime, I’ve conducted a series of measurements using different frequencies of the sine wave. I think a frequency should be chosen where the phase is close to 45°.
Regards Andreas
Versuch mit R und C.pdf (214.2 KiB) downloaded 16 time(s).
Hi Alvaro,
I’ve never worked symbolically in SMath before. Using your SMath file, I’ve now had my first experience with it. I’ve also started working with MNT for the first time.
What I haven’t managed to do, and what I can’t figure out from your file either: How do I use symbolic results to continue my mathematical calculations?
And: How do I manipulate the symbolic results so that I can use my measurement results to calculate the capacitance of the capacitor?
Regards Andreas
Versuch mit R und C Sinus nach Alvaro.sm (524.33 KiB) downloaded 7 time(s).
I’ve never worked symbolically in SMath before. Using your SMath file, I’ve now had my first experience with it. I’ve also started working with MNT for the first time.
What I haven’t managed to do, and what I can’t figure out from your file either: How do I use symbolic results to continue my mathematical calculations?
And: How do I manipulate the symbolic results so that I can use my measurement results to calculate the capacitance of the capacitor?
Regards Andreas
Versuch mit R und C Sinus nach Alvaro.sm (524.33 KiB) downloaded 7 time(s).
Hi Andreas. SMath's symbolic functionalities are somewhat limited; however, it does allow for several manipulations. I've attached some examples of how to perform electrical measurements in the case of a square wave.
Versuch mit R und C sqare measures.sm (78.34 KiB) downloaded 9 time(s).
Versuch mit R und C sqare measures.pdf (706.69 KiB) downloaded 7 time(s).
Regarding the file you attached, you can't simply invert a matrix with numerical admittances, as it contains mixed units of electrical potential and current. However, you can use the S function, which, in the absence of a function that simplifies expressions, can be useful in several cases, and this is one of them.

Versuch mit R und C Sinus nach Alvaro.sm (501.94 KiB) downloaded 8 time(s).
However, the V1 that appears in column vector B must be in the frequency domain, that is, it must be the Laplace transform of v1(t) (I follow the convention that lowercase letters are for functions in the time domain and uppercase letters for transforms or constant values). The correct expressions for v1, v2, and i1 would be obtained by inverting the expressions in VI, that is, v1(t) = invlaplace(v[1],s,t). Sometimes Maple can do this; otherwise, you can use the numerical inversion function.
Another way is to use the superposition of solutions in linear systems, which is what I applied in the previous examples. That's where the summations come from.
Another option would be to use FFT to solve the circuit numerically. If you're interested, I can show you how.
Best regards.
Alvaro.
Versuch mit R und C sqare measures.sm (78.34 KiB) downloaded 9 time(s).
Versuch mit R und C sqare measures.pdf (706.69 KiB) downloaded 7 time(s).
Regarding the file you attached, you can't simply invert a matrix with numerical admittances, as it contains mixed units of electrical potential and current. However, you can use the S function, which, in the absence of a function that simplifies expressions, can be useful in several cases, and this is one of them.

Versuch mit R und C Sinus nach Alvaro.sm (501.94 KiB) downloaded 8 time(s).
However, the V1 that appears in column vector B must be in the frequency domain, that is, it must be the Laplace transform of v1(t) (I follow the convention that lowercase letters are for functions in the time domain and uppercase letters for transforms or constant values). The correct expressions for v1, v2, and i1 would be obtained by inverting the expressions in VI, that is, v1(t) = invlaplace(v[1],s,t). Sometimes Maple can do this; otherwise, you can use the numerical inversion function.
Another way is to use the superposition of solutions in linear systems, which is what I applied in the previous examples. That's where the summations come from.
Another option would be to use FFT to solve the circuit numerically. If you're interested, I can show you how.
Best regards.
Alvaro.
1 Pages (13 items)
- New Posts
- No New Posts