What's wrong? SMath or my fundamentals?

What's wrong? SMath or my fundamentals? - Сообщения

#1 Опубликовано: 27.05.2026 12:29:22
Andreas Beldowski

Andreas Beldowski

0 сообщений из 10 понравились пользователям.

Группа: User

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 МиБ) скачан 65 раз(а). Versuch mit R und C Sinus 01.sm (814,63 КиБ) скачан 47 раз(а).
Versuch mit R und C Rechteck 01.pdf (1,86 МиБ) скачан 69 раз(а). Versuch mit R und C Rechteck 01.sm (555,42 КиБ) скачан 45 раз(а).
Отредактировано 27.05.2026 12:32:09
#2 Опубликовано: 28.05.2026 05:43:35
Alvaro

Alvaro

1 106 сообщений из 1 782 понравились пользователям.

Группа: User

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 КиБ) скачан 67 раз(а).
Versuch mit R und C MNA.sm (703,09 КиБ) скачан 55 раз(а).

Best regards.
Alvaro.
#3 Опубликовано: 28.05.2026 06:02:25
Andreas Beldowski

Andreas Beldowski

0 сообщений из 10 понравились пользователям.

Группа: User

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
#4 Опубликовано: 29.05.2026 21:57:27
Alvaro

Alvaro

1 106 сообщений из 1 782 понравились пользователям.

Группа: User

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?

image.png

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.
#5 Опубликовано: 30.05.2026 16:56:59
Andreas Beldowski

Andreas Beldowski

0 сообщений из 10 понравились пользователям.

Группа: User

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.png Versuch mit R und C Sinus 03.net (564 Б) скачан 38 раз(а).
Отредактировано 30.05.2026 16:57:27
#6 Опубликовано: 02.06.2026 09:02:44
Alvaro

Alvaro

1 106 сообщений из 1 782 понравились пользователям.

Группа: User

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 КиБ) скачан 11 раз(а).
Versuch mit R und C MNA.pdf (1016,18 КиБ) скачан 27 раз(а).

Best regards.
Alvaro.
#7 Опубликовано: 03.06.2026 06:22:44
Andreas Beldowski

Andreas Beldowski

0 сообщений из 10 понравились пользователям.

Группа: User

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

Formel.png
#8 Опубликовано: 05.06.2026 00:50:19
Alvaro

Alvaro

1 106 сообщений из 1 782 понравились пользователям.

Группа: User

Hi Andreas. The solution for a square wave, using superposition method and admittance matrix.

Versuch mit R und C sqare.sm (30,43 КиБ) скачан 4 раз(а).
Versuch mit R und C sqare.pdf (544,96 КиБ) скачан 6 раз(а).

Best regards.
Alvaro
  • Новые сообщения
  • Нет новых сообщений