Skip to content

Question about circuits with feedback loops #143

@hemmer

Description

@hemmer

Preamble

I'm testing out the following simple circuit, which is just two buffered RC filters with a fixed feedback loop. It's from Moritz Klein's mki series: https://www.ericasynths.lv/media/VCF_MANUAL_v2.pdf

Image

I've actually built it in person, but also checked on falstad and get the following expected behaviour
falstad link: https://tinyurl.com/25r2l538

Image

Julia circuit
I've tried to build the circuit with Julia (actually as part of verifying an independent project where i work through the maths of the paper!), and I just find that input/output are exactly the same. I'm sure it's a silly error but I've been staring at it for a while and can't work it out! Is there a limitation of the method to model feedback loops?

using ACME
using Plots

circ = @circuit begin
    V0 = voltagesource()
    R1 = resistor(33000)
    C1 = capacitor(1e-09)
    OAmp = opamp()
    R2 = resistor(33000)
    C2 = capacitor(1e-09)
    OAmp_1 = opamp()
    J = voltageprobe()

    J[-] ⟷ C2[2] ⟷ V0[-] ⟷ gnd
    V0[+] ⟷ R1[1] ⟷ "1"
    OAmp["in+"] ⟷ C1[1] ⟷ R1[2] ⟷ "2"
    R2[1] ⟷ OAmp["out+"] ⟷ OAmp["in-"]  ⟷ "3"
    OAmp_1["in+"] ⟷ C2[1] ⟷ R2[2]  ⟷ "4"
    J[+] ⟷ OAmp_1["out+"] ⟷ OAmp_1["in-"] ⟷ C1[2]   ⟷ "5"

end
        
model = DiscreteModel(circ, 1/44100.0, SimpleSolver)
# square wave
u = [1.5 * (isodd(fld(200 * n, 44100 ÷ 2)) ? 1 : -1) for c in 1:1, n in 0:499]
y = run!(model, u)

for i in 1:size(y,2)
    println(u[1, i], " ", y[1,i])
end

plot(u[1, :], label="Input", xlabel="Sample", ylabel="Amplitude")
plot!(y[1, :], label="Output")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions