1 % my adjustable tone control simulation 2 3 % 0.022 uF capacitor 4 Ctone = 0.22e-6; 5 6 % 500 Kohms Original Tone Pot 7 Rtone = 50e3; 8 % steps on the tone resistor 9 toneres = logspace(0, log10(Rtone)); 10 %toneres = linspace(0, Rtone, 50); 11 %toneres = logspace(1,log10(30e3)); 12 %toneres = linspace(0,30e3,50); 13 14 % Added series tone pot to take the place of Rpickup 15 Rtone2ser = 100; 16 Rtone2 = 20e3; 17 % steps on the series tone resistor 18 toneres2 = logspace(0,log10(Rtone2)) + Rtone2ser; 19 20 % steps in frequency 21 freq = logspace(log10(20), log10(20e3), 100); 22 23 ZCtone = repmat( (-j./(2*pi*Ctone.*freq))' , [1 size(toneres,2) size(toneres2,2)]); 24 25 Ztone = repmat(toneres,[size(ZCtone,1) 1 size(ZCtone,3)]) + ZCtone; 26 27 Ztone2 = ones(1,1,size(Ztone,3)); 28 Ztone2(1,1,:) = toneres2; 29 Ztone2 = repmat(Ztone2, [size(Ztone,1) size(Ztone,2), 1]); 30 31 gain = abs(Ztone ./ (Ztone + Ztone2) ); 32 33 % fc = 1/ (2pi * Ctone * sqrt( Rtone2^2 + Rtone2*Rtone - Rtone^2) 34 % we set up the matrices so that 35 % x(down) = constant Rtone2 / changing Rtone 36 % y(across) = constant Rtone / changing Rtone2 37 Rtone_fc = repmat(toneres', [1 size(toneres,2)]); 38 Rtone2_fc = repmat(toneres2, [size(toneres2,2) 1]); 39 fc = 1./(2*pi*Ctone*sqrt(Rtone2_fc.^2 + Rtone2_fc.*Rtone_fc - Rtone_fc.^2)); 40 41 % create Gain Gif 42 figure(1) 43 filename = 'Gain.gif'; 44 for n = 1:size(gain,3) 45 semilogx(freq,20*log10(gain(:,:,n))); 46 title(sprintf('Rtone2(KOhms) = %.3f ; Rtone(KOhms) = 0 - %.3f', Ztone2(1,1,n)/1000, Rtone/1000)); 47 ylim([-12 0]); 48 xlabel('Frequency (Hz)'); 49 ylabel('Gain (dB)'); 50 drawnow 51 frame = getframe(1); 52 im = frame2im(frame); 53 [imind,cm] = rgb2ind(im,256); 54 if n == 1; 55 imwrite(imind,cm,filename,'gif', 'Loopcount',inf); 56 else 57 imwrite(imind,cm,filename,'gif','WriteMode','append'); 58 end 59 end 60 61 62 % plot fc of circuit 63 figure(4); 64 semilogx(toneres2,real(fc(1,:))); 65 xlabel('Rtone2 (Ohms)'); 66 ylabel('Cutoff Frequency (Hz)'); 67 title ('Cutoff Frequency with Rtone = 0');