-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzener-diode-voltage-regulator-design.bas
145 lines (145 loc) · 3.29 KB
/
zener-diode-voltage-regulator-design.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
10 REM THIS IS PROGRAM NO. 27 PROG27
12 REM THIS PROGRAM ALLOWS YOU TO
13 REM DESIGN SIMPLE ZENER DIODE
14 REM VOLTAGE REGULATOR CIRCUITS
20 VZ = 0
30 MIN = 0
40 MAX = 0
50 I = 0
55 V = 0
60 PD = 0
65 R = 0
70 PRMIN = 0
75 IMAX = 0
80 H = 0
130 GOSUB 770
140 PRINT "THIS PROGRAM IS A DESIGN AID"
145 PRINT "FOR ZENER DIODE VOLTAGE"
150 PRINT "REGULATOR CIRCUITS."
160 PRINT
170 PRINT "THERE ARE THREE CONDITIONS:"
180 PRINT
190 PRINT
200 PRINT TAB(5);"1. VARIABLE V, CONSTANT I"
210 PRINT
220 PRINT TAB(5);"2. CONSTANT V, VARIABLE I"
230 PRINT
240 PRINT TAB(5);"3. VARIABLE V, VARIABLE I"
250 PRINT
260 PRINT "SELECT ONE FROM ABOVE AND PRESS CR...."
270 INPUT N
271 IF N > 3 THEN GOTO 160
272 IF N < 1 THEN GOTO 160
280 GOSUB 770
290 PRINT "ENTER REGULATED OUTPUT VOLTAGE: ???"
300 INPUT VZ
310 GOSUB 770
320 ON N GOTO 350,490,600
350 PRINT "ENTER MINIMUM VALUE OF INPUT VOLTAGE: ???"
360 INPUT MIN
361 IF MIN = VZ THEN GOSUB 3000
362 IF MIN = VZ THEN GOTO 280
365 IF MIN < VZ THEN GOSUB 2000
366 IF MIN < VZ THEN GOTO 280
370 PRINT
380 PRINT "ENTER MAXIMUM VALUE OF INPUT VOLTAGE: ???"
390 INPUT MAX
395 IF MAX < VZ THEN GOSUB 2000
396 IF MAX < VZ THEN GOTO 370
397 IF MAX = VZ THEN GOSUB 3000
398 IF MAX = VZ THEN GOTO 370
400 PRINT
410 PRINT "ENTER LOAD CURRENT"
420 INPUT I
430 R = (MIN - VZ)/(1.1*I)
440 PD = ((MAX - VZ)^2)/R
450 PRMIN = PD
460 PD = PD - (I*VZ)
470 GOSUB 840
480 GOTO 950
490 PRINT "ENTER VALUE OF CONSTANT INPUT VOLTAGE: ???"
500 INPUT V
510 PRINT
520 PRINT "ENTER MAXIMUM VALUE OF LOAD CURRENT: ???"
530 INPUT I
540 R = (V - VZ)/(1.1*I)
550 PD = ((V - VZ)^2)/R
560 PRMIN = PD : REM TODO: CODE HAS NO EFFECT
570 PRMIN = PD + (I*VZ)
580 GOSUB 840
590 GOTO 950
600 PRINT "ENTER MINIMUM VALUE OF INPUT VOLTAGE: ???"
610 INPUT MIN
614 IF MIN = VZ THEN GOSUB 2000
615 IF MIN = VZ THEN GOTO 600
616 IF MIN < VZ THEN GOSUB 3000
617 IF MIN < VZ THEN GOTO 600
620 PRINT
630 PRINT "ENTER MAXIMUM VALUE OF INPUT VOLTAGE: ???"
640 INPUT MAX
644 IF MAX < VZ THEN GOSUB 3000
645 IF MAX < VZ THEN GOTO 620
646 IF MAX = VZ THEN GOSUB 2000
647 IF MAX = VZ THEN GOTO 620
650 PRINT
660 PRINT "ENTER MAXIMUM VALUE OF LOAD CURRENT: ???"
670 INPUT IMAX
680 PRINT
690 PRINT
700 R = (MIN - VZ)/(1.1*IMAX)
710 PD = ((MAX - VZ)^2)/R
720 PRMIN = PD
730 PD = PD - (IMAX*VZ)
740 GOSUB 840
750 GOTO 950
760 GOTO 1050 : REM TODO: UNREACHABLE?
770 FOR I = 1 TO 30
780 PRINT
800 RETURN
810 PRINT "PRESS CR TO CONTINUE..."
820 INPUT KK
830 RETURN
840 PRINT
850 R = R*100
860 R = INT(R)
870 R = R/100
880 PRINT
890 PRINT "RESISTOR R1: ";R;" OHMS"
900 PRINT
910 PRINT "RESISTOR R1 POWER DISSAPATION IS:"
915 PRINT PRMIN;" WATTS"
920 PRINT
930 PRINT "ZENER DIODE DISSAPATION: ";PD;" WATTS"
940 RETURN
950 PRINT "FINISHED?"
960 PRINT TAB(5);"1. YES"
970 PRINT TAB(5);"2. NO"
980 PRINT
990 INPUT H
1000 IF H > 2 THEN GOTO 950
1005 IF H < 1 THEN GOTO 950
1010 IF H = 2 THEN GOTO 10
1020 PRINT
1040 PRINT "PROGRAM ENDED"
1050 END
2000 REM INPUT LESS THAN OUTPUT???
2020 PRINT
2030 PRINT
2040 PRINT
2050 PRINT "OUTPUT VOLTAGE CANNOT BE"
2060 PRINT "LESS THAN INPUT VOLTAGE!"
2070 PRINT "TRY AGAIN"
2080 PRINT "PRESS CR TO CONTINUE..."
2090 INPUT ZZ
2100 RETURN
3000 REM TRIVIAL CASE MESSAGE
3010 PRINT
3020 PRINT
3030 PRINT "WHEN INPUT = OUTPUT NO"
3040 PRINT "REGULATOR IS POSSIBLE!"
3050 PRINT
3060 PRINT "TRY AGAIN"
3070 PRINT
3080 PRINT "PRESS CR TO CONTINUE..."
3090 INPUT ZZ
3100 RETURN