/* single knob L-tuner exploration */ #define gcc 1 #if gcc #include #include #else #include "..\..\include\math.h" #include "..\..\include\stdio.h" #endif #define p 20 #define f1 (3e6) #define f2 f1 #define fr (1.02) #define plot 1 #define sgn(x) ((x == 0)? 1 :((x > 0)?1 :-1))) #define twopi (2*3.1415926535) float l(turns) float turns; { #define L0 (1.0e-7) #define L1 (2.653e-8) #define L2 (1.313e-7) #define T0 (5.75) return (L0 + (L1*turns*turns) + (L2*turns)); } float c(turns) float turns; { #define C0 (15.e-12) #define C1 ((3500.e-12)-C0) return (C0 + (C1*(1.0+(((2*(turns-floor(turns)))-1)*(sgn(sin(twopi*(turns-floor(turns)))))))); } float z1r(r,xs,xp) float r,xs,xp; { return (float)((xp*xp*r)/((r*r)+((xs+xp)*(xs+xp)))); } float z1i(r,xs,xp) float r,xs,xp; { return (float)((xp*((r*r)+(xs*(xs+xp))))/((r*r)+((xs+xp)*(xs+xp)))); } float z2r(r,xp,xs) float r,xs,xp; { return (float)(xp*xp*r/((r*r)+(xp*xp))); } float z2i(r,xp,xs) float r,xs,xp; { return (float)(xs+(xp*r*r/((r*r)+(xp*xp)))); } float xl(f,t) float f,t; { float tmp; tmp = l(t); return (float)(twopi*f*tmp); } float xc(f,t) float f,t; { float tmp; tmp = c(t); return ((float)((-1.0)/(float)((float)twopi*f*(float)tmp))); /*return (1.0/(float)c(t));*/ } rcircle(r) float r; { float t; for(t = 0;t < 2*r; t = t+0.02) printf("%8.3e %9.3e plt\n",t,sqrt(t*((2.0*r)-t))); for(t = 2*r-0.02;t >= 0; t = t-0.02) printf("%8.3e %9.3e plt\n",t,-sqrt(t*((2.0*r)-t))); } xcircle(x) float x; { float t,tmax; tmax = 2.0/(x*x+1.0); for(t = 0;t < tmax; t = t+0.02) printf("%8.3e %9.3e plt\n",t,(1-sqrt(1.0-(x*x*t*t)))/x); for(t = tmax-0.02;t >= 0; t = t-0.02) printf("%8.3e %9.3e plt\n",t,(1-sqrt(1.0-(x*x*t*t)))/x); for(t = 0;t < tmax; t = t+0.02) printf("%8.3e %9.3e plt\n",t,-(1-sqrt(1.0-(x*x*t*t)))/x); for(t = tmax-0.02;t >= 0; t = t-0.02) printf("%8.3e %9.3e plt\n",t,-(1-sqrt(1.0-(x*x*t*t)))/x); } smithchart() { rcircle(1.0); rcircle(0.5); xcircle(1.0); } #define r0 (50.0) #define f0 (1.0e6) main() { int i,j; float t,f,r,x,xt,yt,d; if( plot != 1) { printf(" turns C pf L uh\n"); for(i = 0; i <= 17*p; i++){t = i/(float)p; printf("%5.2f %5.3e %5.3e\n",t,c(t),l(t));}; }; for (f = f1; f <= f2; f = f*fr) { printf("\n\n\nfrequency = %5.3e\n",f); if( plot == 1) smithchart(); else { printf("capacitor shunts antenna port\n"); printf("turns R ohms X ohms R/r0 X/r0 f/f0 conn.\n"); }; for(i = 0; i <= 17*p; i++) { t = i/(float)p; r = z1r(r0,xl(f,t),xc(f,t))/r0; x = z1i(r0,xl(f,t),xc(f,t))/r0; d = ((x*x)+1.0+(2*r)+(r*r)); xt = 2*(1+r)/d; yt = 2*x/d; if( plot != 1) printf("%5.2f %8.3e %9.3e %8.3e %9.3e %5.2f %8.3e %9.3e CsA\n",t,r*r0,x*r0,r,x,f/f0,xt,yt); else printf("%8.3e %9.3e CsA\n",xt,yt); }; if( plot != 1) { printf("\ninductor shunts antenna port\n"); printf("turns R ohms X ohms R/r0 X/r0 f/f0 conn.\n"); }; for(i = 0; i <= 17*p; i++) { t = i/(float)p; r = z1r(r0,xc(f,t),xl(f,t))/r0; x = z1i(r0,xc(f,t),xl(f,t))/r0; d = ((x*x)+1.0+(2*r)+(r*r)); xt = 2*(1+r)/d; yt = 2*x/d; if( plot != 1) printf("%5.2f %8.3e %9.3e %8.3e %9.3e %5.2f %8.3e %9.3e LsA\n",t,r*r0,x*r0,r,x,f/f0,xt,yt); else printf("%8.3e %9.3e LsA\n",xt,yt); }; if( plot != 1) { printf("\ninductor shunts transciever port\n"); printf("turns R ohms X ohms R/r0 X/r0 f/f0 conn.\n"); }; for(i = 0; i <= 17*p; i++) { t = i/(float)p; r = z2r(r0,xl(f,t),xc(f,t))/r0; x = z2i(r0,xl(f,t),xc(f,t))/r0; d = ((x*x)+1.0+(2*r)+(r*r)); xt = 2*(1+r)/d; yt = 2*x/d; if( plot != 1) printf("%5.2f %8.3e %9.3e %8.3e %9.3e %5.2f %8.3e %9.3e LsT\n",t,r*r0,x*r0,r,x,f/f0,xt,yt); else printf("%8.3e %9.3e LsT\n",xt,yt); }; if( plot != 1) { printf("\ncapacitor shunts transciever port\n"); printf("turns R ohms X ohms R/r0 X/r0 f/f0 conn.\n"); }; for(i = 0; i <= 17*p; i++) { t = i/(float)p; r = z2r(r0,xc(f,t),xl(f,t))/r0; x = z2i(r0,xc(f,t),xl(f,t))/r0; d = ((x*x)+1.0+(2*r)+(r*r)); xt = 2*(1+r)/d; yt = 2*x/d; if( plot != 1) printf("%5.2f %8.3e %9.3e %8.3e %9.3e %5.2f %8.3e %9.3e CsT\n",t,r*r0,x*r0,r,x,f/f0,xt,yt); else printf("%8.3e %9.3e CsT\n",xt,yt); }; }; }