Skip to content

Instantly share code, notes, and snippets.

@wojpawlik
Last active September 2, 2026 18:13
Show Gist options
  • Select an option

  • Save wojpawlik/0c35307626730cf5427b0dd7e12e169c to your computer and use it in GitHub Desktop.

Select an option

Save wojpawlik/0c35307626730cf5427b0dd7e12e169c to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#import "@preview/zap:0.6.0"
#set document(author: "Wojciech Pawlik")
#set page(width: auto, height: auto, margin: 1mm)
#page(zap.circuit({ // RR
zap.vsource("s", (-3, -3), (-3, 0), u: (content: $u_1(t)$, label-distance: 5mm))
zap.resistor("R_1", (-3, 0), (0, 0), label: $"R"_1$)
zap.resistor("R_2", (0, -3), (0, 0), label: $"R"_2$, n: "*-*")
zap.voltmeter("v", (3, -3), (3, 0), u: (content: $u_2(t)$, label-distance: 5mm))
zap.wire((0, 0), "v.out")
zap.wire("s.in", "v.in")
}))
// https://github.com/rlalik/UJ_SPE_Lab2_demos
#page(zap.circuit({ // CR
zap.vsource("s", (-3, -3), (-3, 0), u: (content: $u_1(t)$, label-distance: 5mm))
zap.capacitor("C", (-3, 0), (0, 0), label: $"C"$)
zap.resistor("R", (0, -3), (0, 0), label: $"R"$, n: "*-*")
zap.voltmeter("v", (3, -3), (3, 0), u: (content: $u_2(t)$, label-distance: 5mm))
zap.wire((0, 0), "v.out")
zap.wire("s.in", "v.in")
}))
#page(zap.circuit({ // RC
zap.vsource("s", (-3, -3), (-3, 0), u: (content: $u_1(t)$, label-distance: 5mm))
zap.resistor("R", (-3, 0), (0, 0), label: $"R"$)
zap.capacitor("C", (0, -3), (0, 0), label: $"C"$, n: "*-*")
zap.voltmeter("v", (3, -3), (3, 0), u: (content: $u_2(t)$, label-distance: 5mm))
zap.wire((0, 0), "v.out")
zap.wire("s.in", "v.in")
}))
#page(zap.circuit({ // CLR
zap.resistor("R", (0, -3), (0, 0), label: $"R"$, n: "*-*")
zap.inductor("L", (-3, 0), (0, 0), label: $"L"$)
zap.capacitor("C", (-6, 0), (-3, 0), label: $"C"$)
zap.vsource("s", (-6, -3), (-6, 0), u: (content: $u_1(t)$, label-distance: 5mm))
zap.voltmeter("v", (3, -3), (3, 0), u: (content: $u_2(t)$, label-distance: 5mm))
zap.wire((0, 0), "v.out")
zap.wire("s.in", "v.in")
}))
#page(zap.circuit({ // wzmacniacz
import zap: *
opamp("amp", (), variant: "ieee")
nstub(n: "-o", label: $+E$, "amp.v")
sstub(n: "-o", label: $-E$, "amp.g")
wstub(n: "-o", label: $U_"-"$, "amp.minus")
wstub(n: "-o", label: $U_"+"$, "amp.plus")
estub(n: "-o", label: $U_"WY"$, "amp.out")
}))
#page(zap.circuit({ // odwracający
import zap: *
node("U", (-4.5, 0), label: $U_"WE"$, fill: false)
resistor("R", "U", (rel: (3, 0)), label: $"R"_1$, n: "-*")
resistor("R_f", (-1.5, 1.5), (rel: (3, 0)), label: $"R"_"f"$)
opamp("amp", (0, -.45), variant: "ieee")
estub((rel: (1.5, 0)), label: $U_"WY"$, n: "*-o")
rground("rg", (-1.5, -1.5))
swire("amp.plus", "rg")
swire("amp.minus", "R_f.in")
swire("amp.out", "R_f.out")
}))
#page(zap.circuit({ // sumujący
import zap: *
for (k, v) in ("1": 0, "2": 1.5, "3": 3) {
node("U", (-4.5, v), label: $U_#k$, fill: false)
resistor("R", "U", (rel: (3, 0)), label: $"R"_#k$, n: if v < 2 {"-*"})
}
resistor("R_f", (-1.5, 1.5), (rel: (3, 0)), label: $"R"_"f"$)
opamp("amp", (0, -.45), variant: "ieee")
estub((rel: (1.5, 0)), label: $U_"WY"$, n: "*-o")
rground("rg", (-1.5, -1.5))
swire("amp.plus", "rg")
swire("amp.minus", "R.out")
swire("amp.out", "R_f.out")
}))
#page(zap.circuit({ // Schmitt
import zap: *
opamp("amp", (1.5, 0), variant: "ieee")
estub((3, 0), label: $U_"WY"$, n: "*-o")
wstub("amp.minus", label: $U_"WE"$, n: "-o")
rground("rg", (-3, -2))
resistor("R_2", (), (rel: (3, 0)), label: $"R"_2$)
node("2", ())
resistor("R_1", (), (rel: (3, 0)), label: $"R"_1$)
swire("amp.out", "R_1.out")
swire("amp.plus", "R_1.in")
}))
#page(zap.circuit({ // multiwibrator
import zap: *
opamp("amp", (1.5, 0), variant: "ieee")
estub((3, 0), label: $U_"WY"$, n: "*-o")
wire((), "amp.out")
rground("cg", (-3, 2))
capacitor("C", (), (rel: (3, 0)), label: $"C"$)
node("1", (), label: $1$)
resistor("R_f", "1", (rel: (3, 0)), label: $"R"_"f"$)
rground("rg", (-3, -2))
resistor("R_2", (), (rel: (3, 0)), label: $"R"_2$)
node("2", ())
resistor("R_1", (), (rel: (3, 0)), label: $"R"_1$)
wire((), (rel: (0, 4)))
swire("amp.minus", "1")
swire("amp.plus", "R_1.in")
}))
#page(zap.circuit({ // NAND generator
import zap: *
node("node", (3, 0))
estub("node", label: $U_"WY"$, length: .5)
for i in (2, 0, -2) {
lnand("NAND", (i, 0), variant: "ieee")
wire("NAND.out", "node")
node("node", (i - 1, 0))
swire("NAND.in1", "node")
swire("NAND.in2", "node")
}
swire((-3, 0), (-3.5, 1), (3, 0))
}))
#page(zap.circuit({ // RS
import zap: *
lnand("NAND_c", (0, 1), variant: "ieee")
lnand("NAND_d", (0, -1), variant: "ieee")
wstub("NAND_c.in1", label: overline("S"))
wstub("NAND_d.in2", label: overline("R"))
estub("NAND_c.out", label: "Q")
estub("NAND_d.out", label: overline("Q"))
swire("NAND_c.in2", (-1, .5))
wire((-1, .5), (1, -.5), (1, -1), n: "-*")
swire("NAND_d.in1", (-1, -.5))
wire((-1, -.5), (1, .5), (1, 1), n: "-*")
}))
#page(zap.circuit({ // RS latch
import zap: *
cetz.draw.set-style(zap: (variant: "ieee"))
lnand("NAND_a", (-3, 1))
lnand("NAND_b", (-3, -1))
lnand("NAND_c", ( 0, 1))
lnand("NAND_d", ( 0, -1))
wire("NAND_a.out", "NAND_c.west")
wire("NAND_b.out", "NAND_d.west")
wstub("NAND_a.in1", label: "a", length: 1)
wstub("NAND_b.in2", label: "b", length: 1)
wstub("NAND_c.in1", label: "c", length: 1)
wstub("NAND_d.in2", label: "d", length: 1)
wstub("NAND_b.in1", label: "E", length: 1)
estub("NAND_c.out", label: "Q")
estub("NAND_d.out", label: overline("Q"))
swire("NAND_a.in2", (rel: (-.5, 0), to: "NAND_b.in1"), n: "-*")
wire((1, 1), (1, .5), (-1, -.5), n: "*-")
swire("NAND_d.in1", (-1, -.5))
wire((1, -1), (1, -.5), (-1, .5), n: "*-")
swire("NAND_c.in2", (-1, .5))
}))
#page(zap.circuit({ // mod 16
import zap: *
let pins = (
pin1: (content: "T"),
pin3: (clock: true),
pin4: (content: "Q"),
pin6: (content: overline("Q")),
)
for (k, v) in ("A": 0, "B": 3, "C": 6, "D": 9) {
flipflop("T", (v, 0), pins: pins, fill: white)
swire("T.pin1", (v - 1.5, 1.5), n: if v != 0 {"-*"})
node(k, (v - 1.5, -.5), label: if v <= 3 {k}, fill: v != 0)
sstub( (v + 1.5, -.5), label: [Q#sub(k)])
}
wire((), "A")
estub((rel: (-3, 2)), label: [1])
wire((), (-1.5, 1.5))
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment