refactored files add some new ones

This commit is contained in:
2026-02-23 20:46:02 +13:00
parent ade276e1ec
commit 3a634cdb18
5 changed files with 293 additions and 0 deletions

View File

@@ -0,0 +1,150 @@
include <idt.scad>
include <bond_pad.scad>
// creates the input and output idts
// [TODO] clean this
module bi_directional_idt(
c,
f,
n_fingers,
distance = 100,
finger_length = 50,
gap = 0,
thickness = 0,
impedance = 50,
// bond pad prams
has_bond_pads = false,
bond_pad_leg_length = 0.00005,
bond_pad_leg_width = 0.00001875,
bond_pad_size = 0.000075,
bond_pad_angle = 45,
bond_pad_bond_pad_shape = "square",
// id number prams
id_number = 0,
has_id = false,
id_flip_dir = [1, 1, 1],
// extra
post_scale = 1,
echo_stats = false,
center = false
) {
lambda = c/f * post_scale;
// dont worry about these magic fractions
length_of_input = n_fingers*lambda+1.74*lambda;
should_be_centered = center ? 1 : 0;
center_offset_y = length_of_input + distance * lambda/2;
center_offset_x = finger_length*lambda/2 + gap/2 + thickness;
translate([-center_offset_x * should_be_centered, -center_offset_y * should_be_centered, 0]) {
if (has_id) {
color([255/255, 0/255, 255/255])
translate([finger_length*lambda/2, has_bond_pads ? -(bond_pad_leg_length * post_scale * cos(bond_pad_angle)) : -lambda*finger_length/2, 0])
scale(id_flip_dir)
text(str(id_number), size=id_text_size, halign="center");
}
// echo(str("lambda_scale = ", post_scale));
delay_line(lambda, n_fingers, finger_length, gap, thickness);
color([0/255, 255/255, 128/255]) {
translate([0, distance*lambda+length_of_input, 0]) {
delay_line(lambda, n_fingers, finger_length, gap, thickness);
}
}
// near ori
rotate([0, 0, -90]) {
if (has_bond_pads) {
color([255/255, 255/255, 255/255]) {
bond_pad(
leg_length_tweak = lambda/4,
leg_width=c/f/4,
leg_length=length(
[0,0,0],
[bond_pad_leg_length, bond_pad_leg_length, 0]
),
leg_angle = -bond_pad_angle,
size = bond_pad_size,
post_scale=scale_unit
);
}
}
}
// near side
translate([lambda*finger_length+gap+thickness*2+lambda, 0, 0]) {
rotate([0, 0, -90]) {
if (has_bond_pads) {
bond_pad(
leg_length_tweak = lambda/5,
leg_width=c/f/4,
leg_length=length(
[0,0,0],
[bond_pad_leg_length, bond_pad_leg_length, 0]
),
leg_angle = bond_pad_angle,
size = bond_pad_size,
post_scale=scale_unit
);
}
}
}
// far side
translate([0, length_of_input+distance*lambda+length_of_input, 0]) {
rotate([0, 0, 90]) {
if (has_bond_pads) {
bond_pad(
leg_length_tweak = lambda/5,
leg_width=c/f/4,
leg_length=length(
[0,0,0],
[bond_pad_leg_length, bond_pad_leg_length, 0]
),
leg_angle = bond_pad_angle,
size = bond_pad_size,
post_scale=scale_unit
);
}
}
// furthest side
translate([lambda*finger_length+gap+thickness*2+lambda, 0, 0]) {
rotate([0, 0, 90]) {
if (has_bond_pads) {
bond_pad(
leg_length_tweak = lambda/4,
leg_width=c/f/4,
leg_length=length(
[0,0,0],
[bond_pad_leg_length, bond_pad_leg_length, 0]
),
leg_angle = -bond_pad_angle,
size = bond_pad_size,
post_scale=scale_unit
);
}
}
}
}
}
if (echo_stats) {
echo("===== DELAY LINE IDT INFO ===== ");
echo(str("lambda = ", lambda));
echo(str("min feature size lambda/4 = ", lambda/4));
echo(str("impedance = ", impedance));
echo(str("total capacitance = ", 1/(2*PI*f*impedance)));
echo("===== DELAY LINE IDT INFO ===== ");
}
}

48
modules/bond_pad.scad Normal file
View File

@@ -0,0 +1,48 @@
function length(point_1, point_2) = sqrt(
(point_1-point_2).x^2 +
(point_1-point_2).y^2 +
(point_1-point_2).z^2
);
// todo fix this
// units in m, the size is the min bond pad size
module bond_pad(
leg_length = 0.000075,
leg_width = 0.00001875,
leg_length_tweak = 0,
leg_angle = 45,
size = 0.000075,
bond_pad_shape = "square",
post_scale = false
) {
if (post_scale) {
circle(r=leg_width*post_scale);
rotate([0, 0, leg_angle+180]) {
translate([-leg_length*post_scale-leg_length_tweak, -leg_width*post_scale/2, 0]) {
// color([0, 255/255, 255/255]) {
// arm
square(size=[(leg_length)*post_scale+leg_length_tweak, leg_width*post_scale]);
// }
}
}
// pad
translate([post_scale*leg_length*cos(leg_angle), post_scale*leg_length*sin(leg_angle), 0]) {
square(size=[size*post_scale, size*post_scale], center=true);
}
// echo(str("x = ", post_scale*leg_length*cos(leg_angle+180)));
// echo(str("y = ", post_scale*leg_length*sin(leg_angle+180)));
} else {
rotate([0, 0, leg_angle+180]) {
translate([-leg_length/2, -leg_width, 0]) {
// color([0, 255/255, 255/255]) {
square(size=[leg_length, leg_width]);
// }
}
}
square(size=[size, size], center=true);
}
}

69
modules/idt.scad Normal file
View File

@@ -0,0 +1,69 @@
// creates 1 side of the idt
module delay_line(lambda = 1, n_fingers = 1, finger_length = 50, gap = 0, thickness = 0) {
// code
l45 =lambda*5/4;
l2 = lambda/2;
l4 = lambda/4;
l8 = lambda/8;
b = l4 + thickness;
f = l4 + finger_length*lambda;
points_cap = [
[0, 0],
[0, l2],
[-b-f, l2],
[-b-f, l4],
[-b, l4],
[-b, 0]
];
points = [
[0, 0],
[b, 0],
[b, l2],
[b+f, l2],
[b+f, l2+l4],
[b, l2+l4],
[b, l4*5-l4],
[0, l4*5-l4]
];
// union () {
translate([0, l2, 0]){
for(i = [0:n_fingers]){
translate([0, i*(l45-l4), 0]) {
polygon(points);
}
}
color("red") {
rotate([0, 0, 180])
translate([0, 0, 0]) {
polygon(points_cap);
}
translate([f+l2+gap+thickness, -l2, 0]) {
square(size=[l4+thickness, l4]);
}
}
union() {
for(i = [0:n_fingers]){
translate([2*b+f+gap+l4, i*(l45-l4)+l2+l4 , 0])
rotate([0, 0, 180])
polygon(points);
}
}
color("red") {
translate([2*b+f+gap+l4, n_fingers*lambda+lambda-l4, 0]) {
polygon(points_cap);
}
translate([0, n_fingers*lambda+lambda, 0]) {
square(size=[l4+thickness, l4]);
}
}
}
}

View File

@@ -0,0 +1,15 @@
module parameter_text(
heading,
params,
heading_size = 4,
param_size = 2.5,
font = "Ubuntu Sans Mono:style=Regular",
center = false
) {
text(heading, size=heading_size, font=FONT, halign = center ? "center" : "left");
for (i=[0:len(params)]) {
translate([0, -heading_size*(i+1), 0])
text(params[i], size=param_size, font=FONT, halign = center ? "center" : "left");
}
}

11
modules/wafer.scad Normal file
View File

@@ -0,0 +1,11 @@
// [TODO] try add the flat edge on to the wafer
module wafer(d) {
color([128/255, 128/255, 128/255]) {
translate([0, 0, -1]) {
circle(r=d/2);
}
}
}