summaryrefslogtreecommitdiffstats
path: root/volume_pot
diff options
context:
space:
mode:
authorJames McKenzie <root@ka-ata-killa.panaceas.james.local>2025-08-30 14:36:24 +0100
committerJames McKenzie <root@ka-ata-killa.panaceas.james.local>2025-08-30 14:36:24 +0100
commit85c2729de30dbfd095ad2c9ce46c25da4e8d3e72 (patch)
tree61dc4a73a871892ae10c077c762d0fedaa5b4143 /volume_pot
parentf14f2b812ca595db90990fc642d9d294dab1c612 (diff)
downloadvictoria-001-85c2729de30dbfd095ad2c9ce46c25da4e8d3e72.tar.gz
victoria-001-85c2729de30dbfd095ad2c9ce46c25da4e8d3e72.tar.bz2
victoria-001-85c2729de30dbfd095ad2c9ce46c25da4e8d3e72.zip
update
Diffstat (limited to 'volume_pot')
-rwxr-xr-xvolume_pot/volume.pl32
1 files changed, 22 insertions, 10 deletions
diff --git a/volume_pot/volume.pl b/volume_pot/volume.pl
index ad1e41c..fff39fb 100755
--- a/volume_pot/volume.pl
+++ b/volume_pot/volume.pl
@@ -3,6 +3,8 @@
use Math::Complex;
use Math::Trig;
+# proportion of total resistance for a log taper pot
+
sub logpot($) {
my $x = shift;
@@ -16,6 +18,7 @@ sub logpot($) {
return $a * ( $b**$x ) - $a;
}
+# proportion of resistance between two points on a log pot
sub logprop($$$) {
my ( $v, $t1, $t2 ) = @_;
@@ -26,20 +29,32 @@ sub logprop($$$) {
return ( $v - $t1 ) / ( $t2 - $t1 );
}
+# compute impedance of two elements in parallel
sub par($$) {
my ( $a, $b ) = @_;
return 1. / ( ( 1. / $a ) + ( 1. / $b ) );
}
+# impedance of capacitor in nF at frequency f
+sub cap($$) {
+ my ( $c, $f ) = @_;
+
+ my $z = $c * 1.e-9 * 2 * pi * $f;
+
+ $z = -i / $z;
+
+ return $z;
+}
+
@fns = ();
@frqs = ();
-# calc gain for taps at te,td frequeny f and knob position k (0-10)
-
+# calc gain at frequeny f and knob position k (0-10)
sub calc_gain($$) {
my ( $f, $k ) = @_;
+ # position of taps on pot.
my $te = 0.4; # terminal e
my $td = 0.6; # terminal d
@@ -49,11 +64,9 @@ sub calc_gain($$) {
#terminal b is output
#terminal a is ground
- my $cnf = -i * ( 1. / ( 0.000000001 * 2 * pi * $f ) );
-
# loads on terminals d and e
- my $ld = 18000. + ( ( 1. / 47. ) * $cnf ); #18k+47nF
- my $le = 4700. + ( ( 1. / 250. ) * $cnf ); #4.7k+250nF
+ my $ld = 18000. + cap( 47., $f ); #18k+47nF
+ my $le = 4700. + cap( 250., $f ); #4.7k+250nF
#compute resistances of track
my $rae = $rac * logpot($te);
@@ -78,10 +91,9 @@ sub calc_gain($$) {
my $etot = $erac;
# input filter
- $etot += 150000.; # 150k
- $etot += ( ( 1. / 15. ) * $cnf ); # 15nF
- #balance control
- $etot += par( 1100., ( 1. / 120. ) * $cnf ); # 1.1k in parallel with 120nF
+ $etot += 150000. + cap( 15., $f ); # 150k +15nF
+ #balance control
+ $etot += par( 1100., cap( 120., $f ) );
print "Effective total impedance $erae + $ered + $erdc = $erac\n";