Adapt any VC underhand to any value you need.

You can talk about anything related to LB Booster here, not covered in another category
sarmednafi
Posts: 36
Joined: Fri Apr 06, 2018 6:27 am

Adapt any VC underhand to any value you need.

Post by sarmednafi »

Radio Constructors can adapt any VC they have underhand to any value they need.

Once the Soviet Union (1970) released the domestic radio set VEF204, the question was arise!
How those Soviet engineers could adapt the (9-360PF) variable capacitor (VC) used in that set to any Minimum-Maximum value they need to cover its eight bands?
Actually, they did that by connecting two fixed capacitors to the VC, but how they calculate the two capacitors values easily?
If we try to use calculator we will discover we going to lose our mind!
Sure those Soviet engineers developed equations to calculate the two values easily.

But for me, I can develop a program to do that visually easily. Using the simple two ways to solve the total value of two capacitors connected either in parallel or series. That what I am going to present here.
How to use the program:
1- Choose any of the two connection we think it is suitable for us.
2- Enter the minimum maximum values of our VC in pf.
3- Enter the minimum maximum values we want to obtain.
4- Enter values for C1 C2 randomly as we like and watch the draw of the lower line which represents the two values we get. Since we see the lower line look to subtend the two blue and red arrows which they represent the two values we want then we start comparing the figures of the two values we want with the two values we get on the GUI of the program. Till they became each one equal to the other.

Code: Select all

NOMAINWIN 
WindowWidth = 931 : WindowHeight = 504 
UpperLeftX = INT((DisplayWidth-WindowWidth)/2) 
UpperLeftY = INT((DisplayHeight-WindowHeight)/2) 
tx1i=0: tx1o=0 
tx2i=0: tx2o=0 
tx3i=0: tx3o=0 
tx4i=0: tx4o=0 
tx5i=0: tx5o=0 
tx6i=0: tx6o=0 
tx7i=0: tx7o=0 
tx8i=0: tx8o=0 

statictext #w.statictext1, "VC min max Values We Have", 5, 128, 200, 25 
statictext #w.statictext2, "VC min max Values We Want", 5, 163, 200, 25 
statictext #w.statictext3, "VC min max Values We Get", 5, 198, 200, 25 
statictext #w.statictext4, "C1 C2 Values We Add", 5, 363, 200, 25 
statictext #w.statictext6, "C1 PF", 310, 365, 60, 25 
statictext #w.statictext7, "C2 PF", 500, 365, 60, 25 
statictext #w.ST1, "Min. Value PF", 230, 108, 120, 15 
statictext #w.ST2, "Max. Value PF", 425, 108, 120, 15 
statictext #w.ChoseOne, "First we chose the net method we going to use:",210, 40, 340, 25 
button #w.Bcnet1, "Parallel C then Serial", [Cnet_1], UL, 210, 70, 160, 20 
button #w.Bcnet2, "Serial C then Parallel", [Cnet_2], UL, 395, 70, 160, 20 
stylebits #w.textbox1, _ES_CENTER, 0, 0, 0 
textbox #w.textbox1, 215, 125, 150, 25 
stylebits #w.textbox2, _ES_CENTER, 0, 0, 0 
textbox #w.textbox2, 405, 125, 150, 25 
TextboxColor$= "176 176 255" 
stylebits #w.textbox3, _ES_CENTER, 0, 0, 0 
textbox #w.textbox3, 215, 160, 150, 25 
TextboxColor$= "255 147 147" 
stylebits #w.textbox4, _ES_CENTER, 0, 0, 0 
textbox #w.textbox4, 405, 160, 150, 25 
TextboxColor$= "255 255 255" 
stylebits #w.textbox5,_ES_READONLY OR _ES_CENTER, _WS_BORDER, 0, 0 
textbox #w.textbox5, 215, 195, 150, 25 
stylebits #w.textbox6,_ES_READONLY OR _ES_CENTER, _WS_BORDER, 0, 0 
textbox #w.textbox6, 405, 195, 150, 25 
stylebits #w.textbox7, _ES_CENTER, 0, 0, 0 
textbox #w.textbox7, 215, 360, 85, 25 
stylebits #w.textbox8, _ES_CENTER, 0, 0, 0 
textbox #w.textbox8, 405, 360, 85, 25 

button #w.b1p1, "+1", [b1p1], UL, 215, 388, 42, 16' 
button #w.b1m1, "-1", [b1m1], UL, 260, 388, 42, 16' 
button #w.b1p5, "+5", [b1p5], UL, 215, 405, 42, 16' 
button #w.b1m5, "-5", [b1m5], UL, 260, 405, 42, 16' 
button #w.b1p10, "+10", [b1p10], UL, 215, 422, 42, 16' 
button #w.b1m10, "-10", [b1m10], UL, 260, 422, 42, 16 
button #w.b2p1, "+1", [b2p1], UL, 405, 388, 42, 16 
button #w.b2m1, "-1", [b2m1], UL, 450, 388, 42, 16 
button #w.b2p5, "+5", [b2p5], UL, 405, 405, 42, 16 
button #w.b2m5, "-5", [b2m5], UL, 450, 405, 42, 16 
button #w.b2p10, "+10", [b2p10], UL, 405, 422, 42, 16 
button #w.b2m10, "-10", [b2m10], UL, 450, 422, 42, 16 
graphicbox #w.GBox, 650, 55, 190, 162 
StyleBits #w.GLBox, 0, _WS_BORDER, 0, 0 
graphicbox #w.GLBox, 50, 240, 803, 110 
CHECKBOX #w.Cnet1, "", [a1], [a2], 197, 70, 13, 20 
CHECKBOX #w.Cnet2, "", [b1], [b2], 555, 70, 13, 20 

'radiobutton #w.Cnet2, "", [click2], [b], 545, 70, 13, 20 
Menu #w, "&File" , "E&xit", [quit] 

Open "Variable Capacitor Value Adapter " for Window as #w 
#w "font Arial 10 bold" 
#w "trapclose [quit]" 
#w.Cnet1 "set" 
#w.textbox1 "9" 
#w.textbox2 "330" 
#w.textbox3 "10" 
#w.textbox4 "100" 
#w.textbox7 "1" 
#w.textbox8 "1" 
'----Drawing the scale 
A= 0 
B= 33 
C= 800 
D= 33 
print #w.GLBox, "size 1" 
print #w.GLBox, "up": #w.GLBox, "home" 
print #w.GLBox, "goto 0 23" 
'------------- 
print #w.GLBox, "fill Buttonface"; 
#w.GLBox, "down" 
print #w.GLBox, "line ";A;" "; B;" ";C;" ";D 
print #w.GLBox, "up": #w.GLBox, "home" 
'------------- 
For xDis =0 to 800 step 200 
#w.GLBox, "down" 
print #w.GLBox, "line ";xDis;" "; 33;" ";xDis;" ";38 
print #w.GLBox, "up": #w.GLBox, "home" 
next 
For xDis =0 to 800 step 20 
#w.GLBox, "down" 
print #w.GLBox, "line ";xDis;" "; 33;" ";xDis;" ";38 
print #w.GLBox, "up": #w.GLBox, "home" 
next 
For xDis =0 to 800 step 100 
#w.GLBox, "down" 
print #w.GLBox, "line ";xDis;" "; 33;" ";xDis;" ";48 
print #w.GLBox, "up": #w.GLBox, "home" 
next 
print #w.GLBox, "goto ";0;" ";62 
#w.GLBox, "down" 
#w.GLBox "backcolor buttonface ;size 10;color 0 0 0"' pen color 0 0 0 
print #w.GLBox, "\0" 
#w.GLBox, "up" 
print #w.GLBox, "goto ";185;" ";62 
#w.GLBox, "down" 
print #w.GLBox, "\100pf" 
#w.GLBox, "up" 
print #w.GLBox, "goto ";385;" ";62 
#w.GLBox, "down" 
print #w.GLBox, "\200pf" 
#w.GLBox, "up" 
print #w.GLBox, "goto ";585;" ";62 
#w.GLBox, "down" 
print #w.GLBox, "\300pf" 
#w.GLBox, "up" 
print #w.GLBox, "goto ";765;" ";62 
#w.GLBox, "down" 
print #w.GLBox, "\400pf" 
#w.GLBox, "up" 
'--------End Drawing the scale End 
'-------- Drawing the circuit diagram 
loadbmp "PSimage", DefaultDir$;"\PS.bmp" 
print #w.GBox, "drawbmp PSimage 0 0" 
unloadbmp "PSimage" 
PS= 1: SP=0 
'-------- End Drawing the circuit diagram 
'----Drawing the Red Blue Triangle 
loadbmp "clearB", DefaultDir$;"\clearB.bmp" 
loadbmp "clearR", DefaultDir$;"\clearR.bmp" 
loadbmp "copyimageb", DefaultDir$;"\b.bmp" 
loadbmp "copyimager", DefaultDir$;"\r.bmp" 
xb = (2*10)-6 
print #w.GLBox, "drawbmp copyimageb ";xb;" ";18 '452 
xr = (2*100)-8 
print #w.GLBox, "drawbmp copyimager ";xr;" ";0 '452 
'----End Drawing the Red Blue Triangle End 
'---- Drawing the lower Line 
print #w.GLBox, "size 4" 
print #w.GLBox, "up": #w.GLBox, "home" 
#w.GLBox, "down" 
print #w.GLBox, "color 0 128 0"'Line color 
print #w.GLBox, "line ";A;" "; 70;" ";1;" ";70 
print #w.GLBox, "up": #w.GLBox, "home" 
'---- End Drawing the lower Line End 



#w.textbox1, "!contents? Txx1$"; 
#w.textbox2, "!contents? Txx2$"; 
#w.textbox3, "!contents? Txx3"; 
#w.textbox4, "!contents? Txx4"; 
#w.textbox5, "!contents? Txx5$"; 
#w.textbox6, "!contents? Txx6$"; 
#w.textbox7, "!contents? Txx7$"; 
#w.textbox8, "!contents? Txx8$"; 

htxt1= hWnd(#w.textbox1) 
htxt2= hWnd(#w.textbox2) 
htxt3= hWnd(#w.textbox3) 
htxt4= hWnd(#w.textbox4) 
htxt5= hWnd(#w.textbox5) 
htxt6= hWnd(#w.textbox6) 
htxt7= hWnd(#w.textbox7) 
htxt8= hWnd(#w.textbox8) 


[Loop] 
Timer 150, [events] 
wait 

[UpdateLine] 
L1=L1*2 
L2=L2*2 
print #w.GLBox, "size 4" 
print #w.GLBox, "up": #w.GLBox, "home" 
#w.GLBox, "down" 
print #w.GLBox, "color 236 233 216"'to clear the color 
print #w.GLBox, "line ";0;" "; 70;" ";800;" ";70'draw color with the same background 
if L1 > L2 then 
print #w.GLBox, "color 228 0 0"'Line color 
Else 
print #w.GLBox, "color 0 128 0"'Line color 
End If 
print #w.GLBox, "line ";L1;" "; 70;" ";L2;" ";70' draw a new line 
'print #w.GLBox, "up": #w.GLBox, "home" 
Return 


[events] 
CallDLL #user32, "GetFocus", Fh As long 'Gheck the focus 
if Fh<>htxt1 then 
#w.textbox1, "!contents? Tx1$" 
if tx1i=1 then tx1o=1: tx1i=0: Timer 0: Goto [AfterUpdate1] 
End if 
if Fh= htxt1 AND tx1i=0 then tx1i=1: tx1o=0: Timer 0: Goto [BeforUpdate1] 
'-------------------------------------------- 
if Fh<>htxt2 then 
#w.textbox2, "!contents? Tx2$" 
if tx2i=1 then tx2o=1: tx2i=0: Timer 0: Goto [AfterUpdate2] 
End if 
if Fh= htxt2 AND tx2i=0 then tx2i=1: tx2o=0: Timer 0: Goto [BeforUpdate2] 
'-------------------------------------------- 
if Fh<>htxt3 then ' #w.textbox3 Blue 
#w.textbox3, "!contents? Tx3" 
if tx3i=1 then tx3o=1: tx3i=0: Timer 0: Goto [AfterUpdate3] 
End if 
if Fh= htxt3 AND tx3i=0 then tx3i=1: tx3o=0: Timer 0: Goto [BeforUpdate3] 
'-------------------------------------------- 
if Fh<>htxt4 then '#w.textbox4 Red 
#w.textbox4, "!contents? Tx4" 
if tx4i=1 then tx4o=1: tx4i=0: Timer 0: Goto [AfterUpdate4] 
End if 
if Fh= htxt4 AND tx4i=0 then tx4i=1: tx4o=0: Timer 0: Goto [BeforUpdate4] 
'-------------------------------------------- 
if Fh<>htxt5 then 
#w.textbox5, "!contents? Tx5$" 
if tx5i=1 then tx5o=1: tx5i=0: Timer 0: Goto [AfterUpdate5] 
End if 
if Fh= htxt5 AND tx5i=0 then tx5i=1: tx5o=0: Timer 0: Goto [BeforUpdate5] 
'-------------------------------------------- 
if Fh<>htxt6 then 
#w.textbox6, "!contents? Tx6$" 
if tx6i=1 then tx6o=1: tx6i=0: Timer 0: Goto [AfterUpdate6] 
End if 
if Fh= htxt6 AND tx6i=0 then tx6i=1: tx6o=0: Timer 0: Goto [BeforUpdate6] 
'-------------------------------------------- 
if Fh<>htxt7 then 
#w.textbox7, "!contents? Tx7$" 
if tx7i=1 then tx7o=1: tx7i=0: Timer 0: Goto [AfterUpdate7] 
End if 
if Fh= htxt7 AND tx7i=0 then tx7i=1: tx7o=0: Timer 0: Goto [BeforUpdate7] 
'-------------------------------------------- 
if Fh<>htxt8 then 
#w.textbox8, "!contents? Tx8$" 
if tx8i=1 then tx8o=1: tx8i=0: Timer 0: Goto [AfterUpdate8] 
End if 
if Fh= htxt8 AND tx8i=0 then tx8i=1: tx8o=0: Timer 0: Goto [BeforUpdate8] 
Goto [Loop] 


[Cnet_1] 
Timer 0 
PS= 1 
SP=0 
loadbmp "PSimage", DefaultDir$;"\PS.bmp" 
print #w.GBox, "drawbmp PSimage 0 0" 
unloadbmp "PSimage" 
#w.Cnet1 "set" 
#w.Cnet2 "reset" 
Goto [Loop] 


[Cnet_2] 
Timer 0 
SP= 1 
PS=0 
loadbmp "SPimage", DefaultDir$;"\SP.bmp" 
print #w.GBox, "drawbmp SPimage 0 0" 
unloadbmp "SPimage" 
#w.Cnet2 "set" 
#w.Cnet1 "reset" 
Goto [Loop] 


[AfterUpdate1] 
IF Tx1$<>Txx1$ then 'Update 
Gosub [CalculateValueWeGet] 
end if 
Goto [Loop] 


[AfterUpdate2] 
IF Tx2$<>Txx2$ then 'Update 
Gosub [CalculateValueWeGet] 
end if 
Goto [Loop] 


[AfterUpdate3] 
IF Tx3<>Txx3 then 'Update 
'notice "AfterUpdate 3" 
print #w.GLBox, "drawbmp clearB ";xb;" ";18 ' 
#w.textbox3, "!contents? xb"; 
xb= (xb*2)-6 
print #w.GLBox, "drawbmp copyimageb ";xb;" ";18 ' 
'print ABS(Tx3-Txx4) 
if ABS(Txx4-Tx3)<18 then 'If one of the Triangles over the other 
print #w.GLBox, "drawbmp copyimager ";xr;" ";0 ' 
print #w.GLBox, "drawbmp copyimageb ";xb;" ";18 ' 
end if 
end if 
Goto [Loop] 


[AfterUpdate4] 
IF Tx4<>Txx4 then 'Update 
'notice "AfterUpdate 4" 
print #w.GLBox, "drawbmp clearR ";xr;" ";0 ' 
#w.textbox4, "!contents? xr"; 
xr= (xr*2)-8 
print #w.GLBox, "drawbmp copyimager ";xr;" ";0 ' 
if Txx4=Txx3 then 'If one of the Triangles over the other 
print #w.GLBox, "drawbmp copyimageb ";xb;" ";5 ' 
end if 
end if 
Goto [Loop] 

[AfterUpdate5] 
IF Tx5$<>Txx5$ then 'Update 
'notice "AfterUpdate 5" 
end if 
Goto [Loop] 


[AfterUpdate6] 
IF Tx6$<>Txx6$ then 'Update 
'notice "AfterUpdate 6" 
end if 
Goto [Loop] 


[AfterUpdate7] 
IF Tx7$<>Txx7$ then 'Update 
#w.textbox7, "!contents? C1add"; 
GoSub [CalculateValueWeGet] 
'notice "AfterUpdate 7" 
end if 
Goto [Loop] 


[AfterUpdate8] 
IF Tx8$<>Txx8$ then 'Update 
'notice "AfterUpdate 8" 
#w.textbox8, "!contents? C2add"; 
GoSub [CalculateValueWeGet] 




end if 
Goto [Loop] 


[CalculateValueWeGet] 


if PS= 1 AND SP=0 then 
print #w.textbox1, "!contents? MinVC"; 'Min VC 
print #w.textbox2, "!contents? MaxVC"; 'Max VC 
print #w.textbox7, "!contents? C1ad"; 'C1 Add 
print #w.textbox8, "!contents? C2ad"; 'C2 Add 
CPMax = C1ad + MaxVC: CPMin = C1ad + MinVC 
L1= INT((CPMin * C2ad) / (CPMin + C2ad))'Minimum End 
L2= INT((CPMax * C2ad) / (CPMax + C2ad))'Maximum End 
#w.textbox5, L1 
#w.textbox6, L2 
Else 
If PS= 0 AND SP=1 then 
print #w.textbox1, "!contents? MinVC"; 'Min VC 
print #w.textbox2, "!contents? MaxVC"; 'Max VC 
print #w.textbox7, "!contents? C1ad"; 'C1 Add 
print #w.textbox8, "!contents? C2ad"; 'C2 Add 
CSmn= INT((MinVC * C1ad) / (MinVC + C1ad)) 
CSmx= INT((MaxVC * C1ad) / (MaxVC + C1ad)) 
L1= CSmn + C1ad 'Minimum End 
L2= CSmx + C2ad 'Maximum End 
#w.textbox5, L1 
#w.textbox6, L2 
End if 
End if 
Gosub [UpdateLine] 
'#w.textbox5, L1 
'#w.textbox6, L2 


Return 


[b1p1] 
#w.textbox7, "!contents? C1add"; 
C1add = C1add + 1 
#w.textbox7 C1add 
GoSub [CalculateValueWeGet] 
'L1=10: L2=30 
'Gosub [UpdateLine] 
Goto [Loop] 


[b1m1] 
#w.textbox7, "!contents? C1add"; 
if C1add-1 <=0 then Beep: Goto [Loop] 
C1add = C1add - 1 
#w.textbox7 C1add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b1p5] 
#w.textbox7, "!contents? C1add"; 
C1add = C1add + 5 
#w.textbox7 C1add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b1m5] 
#w.textbox7, "!contents? C1add"; 
if C1add-5 <=0 then Beep: Goto [Loop] 
C1add = C1add - 5 
#w.textbox7 C1add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b1p10] 
#w.textbox7, "!contents? C1add"; 
C1add = C1add + 10 
#w.textbox7 C1add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b1m10] 
#w.textbox7, "!contents? C1add"; 
if C1add-10 <=0 then Beep: Goto [Loop] 
C1add = C1add - 10 
#w.textbox7 C1add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b2p1] 
#w.textbox8, "!contents? C2add"; 
C2add = C2add + 1 
#w.textbox8 C2add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b2m1] 
#w.textbox8, "!contents? C2add"; 
if C2add-1 <=0 then Beep: Goto [Loop] 
C2add = C2add - 1 
#w.textbox8 C2add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b2p5] 
#w.textbox8, "!contents? C2add"; 
C2add = C2add + 5 
#w.textbox8 C2add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b2m5] 
#w.textbox8, "!contents? C2add"; 
if C2add-5 <=0 then Beep: Goto [Loop] 
C2add = C2add - 5 
#w.textbox8 C2add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b2p10] 
#w.textbox8, "!contents? C2add"; 
C2add = C2add + 10 
#w.textbox8 C2add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[b2m10] 
#w.textbox8, "!contents? C2add"; 
if C2add-10 <=0 then Beep: Goto [Loop] 
C2add = C2add - 10 
#w.textbox8 C2add 
GoSub [CalculateValueWeGet] 
Goto [Loop] 


[BeforUpdate1] 
#w.textbox1, "!contents? Txx1$"; 
'notice "BeforUpdate 1" 
Goto [Loop] 


[BeforUpdate2] 
#w.textbox2, "!contents? Txx2$"; 
'notice "BeforUpdate 2" 
Goto [Loop] 


[BeforUpdate3] 
#w.textbox3, "!contents? Txx3"; 
'notice "BeforUpdate 3" 
Goto [Loop] 


[BeforUpdate4] 
#w.textbox4, "!contents? Txx4"; 
'notice "BeforUpdate 4" 
Goto [Loop] 


[BeforUpdate5] 
#w.textbox5, "!contents? Txx5$"; 
'notice "BeforUpdate 5" 
Goto [Loop] 


[BeforUpdate6] 
#w.textbox6, "!contents? Txx6$"; 
'notice "BeforUpdate 6" 
Goto [Loop] 


[BeforUpdate7] 
#w.textbox7, "!contents? Txx7$"; 
'notice "BeforUpdate 7" 
Goto [Loop] 


[BeforUpdate8] 
#w.textbox8, "!contents? Txx8$"; 
'notice "BeforUpdate 8" 
Goto [Loop] 
'-------------------------- 
[a1] 
#w.Cnet1 "value? setVal1$" 
if setVal1$="set" then #w.Cnet1 "reset" Else if setVal1$="reset" then #w.Cnet1 "set" 
Goto [Loop] 
[a2] 
#w.Cnet1 "value? setVal1$" 
if setVal1$="set" then #w.Cnet1 "reset" Else if setVal1$="reset" then #w.Cnet1 "set" 
Goto [Loop] 


[b1] 
#w.Cnet2 "value? setVal2$" 
if setVal2$="set" then #w.Cnet2 "reset" Else if setVal2$="reset" then #w.Cnet2 "set" 
Goto [Loop] 
[b2] 
#w.Cnet2 "value? setVal2$" 
if setVal2$="set" then #w.Cnet2 "reset" Else if setVal2$="reset" then #w.Cnet2 "set" 
Goto [Loop] 


[quit] 
close #w : END 
'code Ends 
Regards,
Sarmed Nafi

A zip file (folder) contains the code and the necessary pictures for the program.
You can access this file at the URL:
https://groups.yahoo.com/neo/groups/lbb ... dapter.zip

You need to sign up to this LBB group to get access to file location.