204 |
miho |
1 |
unit PP_ALL03; |
|
|
2 |
|
|
|
3 |
{$I-,S-} |
|
|
4 |
|
|
|
5 |
{=========================================================} |
|
|
6 |
{ } |
|
|
7 |
{ Unita pro ovladani programatoru HI-LO model ALL-03 } |
|
|
8 |
{ (c) DECROS pefi } |
|
|
9 |
{---------------------------------------------------------} |
|
|
10 |
{ Verze : 1.0.0 uvodni verze } |
|
|
11 |
{ 1.0.1 preformatovani zdrojaku miho } |
|
|
12 |
{ 1.0.2 prejmenovani na PP_ALL03.PAS } |
|
|
13 |
{=========================================================} |
|
|
14 |
|
|
|
15 |
interface |
|
|
16 |
|
|
|
17 |
procedure ErrorProc; |
|
|
18 |
{== vypise slovne obsah chyby ==} |
|
|
19 |
|
|
|
20 |
procedure PowerOff; |
|
|
21 |
{== vypne programator ==} |
|
|
22 |
|
|
|
23 |
procedure Initialize(Baze :word); |
|
|
24 |
{== ziniciuje programator a nastavi bazovou adresu programatoru ==} |
|
|
25 |
|
|
|
26 |
procedure SetVoltageV1(Napeti : real); |
|
|
27 |
{== nastavi napeti na prevodniku s vahou 0.4, napeti je zadavano ==} |
|
|
28 |
{== ve voltech, max. napeti 9.6V. Zapina se jim programator, ==} |
|
|
29 |
{== musi byt pouzit vzdy ==} |
|
|
30 |
|
|
|
31 |
procedure SetVoltageV2(Napeti : real); |
|
|
32 |
{== nastavi napeti na prevodniku s vahou 0.6, napeti je zadavano ==} |
|
|
33 |
{== ve voltech, max. napeti 14.4V. ==} |
|
|
34 |
|
|
|
35 |
procedure SetVoltageV3(Napeti : real); |
|
|
36 |
{== nastavi napeti na prevodniku s vahou 1, napeti je zadavano ==} |
|
|
37 |
{== ve voltech, max. napeti je 25V ==} |
|
|
38 |
|
|
|
39 |
procedure SetBit(Pin,Stav:byte); |
|
|
40 |
{== nastavi pin podle parametru Stav. Piny jsou v rozsahu 1-40, ==} |
|
|
41 |
{== stav je 0 nebo 1. ==} |
|
|
42 |
|
|
|
43 |
procedure GetBitProc (Pin:byte;var Stav:byte); |
|
|
44 |
{== cte stav pinu,pin v rozsahu 1-40,Stav nabyva hodnot 0 nebo 1 ==} |
|
|
45 |
|
|
|
46 |
function GetBit(Pin:byte):byte; |
|
|
47 |
{== cte stav pinu, pin v rozsahu 1-40,vraci 0 nebo 1 ==} |
|
|
48 |
|
|
|
49 |
procedure ConnectV1(Pin:byte;On:boolean); |
|
|
50 |
{== pripojuje prevodnik V1 s vahou 0.4 k pinum, ==} |
|
|
51 |
{== piny v rozsahu 24-32,34,36,40 ==} |
|
|
52 |
|
|
|
53 |
procedure ConnectV2(Pin:byte;On:boolean); |
|
|
54 |
{== pripojuje prevodnik V2 s vahou 0.6 k pinum. ==} |
|
|
55 |
{== piny v rozsahu 9-32 ==} |
|
|
56 |
|
|
|
57 |
procedure ConnectV3(Pin:byte;On:boolean); |
|
|
58 |
{== pripojuje prevodnik V3 s vahou 1 k pinum. ==} |
|
|
59 |
{== piny v rozsahu 1,5-7,9-32,36 ==} |
|
|
60 |
|
|
|
61 |
procedure Gnd11(On:boolean); |
|
|
62 |
{== prepina zem mezi piny 20 a 11, true=pin 11, false= pin20 ==} |
|
|
63 |
|
|
|
64 |
procedure Led(On:boolean); |
|
|
65 |
{== ovlada led s napisem 'GOOD', true= sviti, false= nesviti ==} |
|
|
66 |
|
|
|
67 |
function ReadButton:boolean; |
|
|
68 |
{== vypne programator a cte tlacitko s napisem 'YES' , ==} |
|
|
69 |
{== true=stiknuto, false=uvolneno ==} |
|
|
70 |
|
|
|
71 |
|
|
|
72 |
{=========================================================} |
|
|
73 |
|
|
|
74 |
implementation |
|
|
75 |
|
|
|
76 |
|
|
|
77 |
uses DELAY; |
|
|
78 |
|
|
|
79 |
|
|
|
80 |
{== Definice konstant ==} |
|
|
81 |
|
|
|
82 |
const InitNum = 22; { pocet registru } |
|
|
83 |
|
|
|
84 |
const InitArray : array[1..InitNum,1..2] of byte = |
|
|
85 |
{== zakladni inicializace tj. vsechny piny jako vstupni,prevodniky ==} |
|
|
86 |
{== odpojeny od vsech pinu a vymulovany ==} |
|
|
87 |
( |
|
|
88 |
(231,0),(230,0),(229,0), |
|
|
89 |
(238,0),(237,0),(241,0), |
|
|
90 |
(242,0),(242,0),(243,0), |
|
|
91 |
(232,0),(233,0),(234,0), |
|
|
92 |
(235,0),(236,0),(224,255), |
|
|
93 |
(225,255),(226,255),(227,255), |
|
|
94 |
(228,255),(247,0),(239,0), |
|
|
95 |
(245,0) |
|
|
96 |
); |
|
|
97 |
|
|
|
98 |
const PinSet : array[1..40,1..2] of byte = |
|
|
99 |
{== tabulka pro ovladani jednotlivych pinu, na prvni pozici ==} |
|
|
100 |
{== prislusny I/O registr na druhe pozici maska pinu v registru ==} |
|
|
101 |
( |
|
|
102 |
($E0,$01),($E0,$02),($E0,$04),($E0,$08), |
|
|
103 |
($E0,$10),($E0,$20),($E0,$40),($E0,$80), |
|
|
104 |
($E1,$01),($E1,$02),($E1,$04),($E1,$08), |
|
|
105 |
($E1,$10),($E1,$20),($E1,$40),($E1,$80), |
|
|
106 |
($E2,$01),($E2,$02),($E2,$04),($E2,$08), |
|
|
107 |
($E2,$10),($E2,$20),($E2,$40),($E2,$80), |
|
|
108 |
($E3,$01),($E3,$02),($E3,$04),($E3,$08), |
|
|
109 |
($E3,$10),($E3,$20),($E3,$40),($E3,$80), |
|
|
110 |
($E4,$01),($E4,$02),($E4,$04),($E4,$08), |
|
|
111 |
($E4,$10),($E4,$20),($E4,$40),($E4,$80) |
|
|
112 |
); |
|
|
113 |
|
|
|
114 |
const PinConnectV1: array[1..40,1..2] of byte = |
|
|
115 |
{== tabulka pro pripojeni prevodniku s vahou 0.4 k pinum, na prvni ==} |
|
|
116 |
{== pozici registr pro pripojeni, na druhe pozici maska ==} |
|
|
117 |
{== pinu v registru ==} |
|
|
118 |
( |
|
|
119 |
($00,$00),($00,$00),($00,$00),($00,$00), |
|
|
120 |
($00,$00),($00,$00),($00,$00),($00,$00), |
|
|
121 |
($00,$00),($00,$00),($00,$00),($00,$00), |
|
|
122 |
($00,$00),($00,$00),($00,$00),($00,$00), |
|
|
123 |
($00,$00),($00,$00),($00,$00),($00,$00), |
|
|
124 |
($00,$00),($00,$00),($00,$00),($EE,$80), |
|
|
125 |
($EE,$04),($EE,$02),($EE,$01),($ED,$80), |
|
|
126 |
($ED,$40),($ED,$20),($ED,$10),($ED,$08), |
|
|
127 |
($00,$00),($ED,$04),($00,$00),($ED,$02), |
|
|
128 |
($00,$00),($00,$00),($00,$00),($ED,$01) |
|
|
129 |
); |
|
|
130 |
|
|
|
131 |
const PinConnectV2: array[1..40,1..2] of byte = |
|
|
132 |
{== tabulka pro pripojeni prevodniku s vahou 0.6 k pinum, na prvni ==} |
|
|
133 |
{== pozici registr pro pripojeni, na druhe pozici maska ==} |
|
|
134 |
{== pinu v registru ==} |
|
|
135 |
( |
|
|
136 |
($00,$00),($00,$00),($00,$00),($00,$00), |
|
|
137 |
($00,$00),($00,$00),($00,$00),($00,$00), |
|
|
138 |
($F1,$01),($F1,$02),($F1,$04),($F1,$08), |
|
|
139 |
($F1,$10),($F1,$20),($F1,$40),($F1,$80), |
|
|
140 |
($F2,$01),($F2,$02),($F2,$04),($F2,$08), |
|
|
141 |
($F2,$10),($F2,$20),($F2,$40),($F2,$80), |
|
|
142 |
($F3,$01),($F3,$02),($F3,$04),($F3,$08), |
|
|
143 |
($F3,$10),($F3,$20),($F3,$40),($F3,$80), |
|
|
144 |
($00,$00),($00,$00),($00,$00),($00,$00), |
|
|
145 |
($00,$00),($00,$00),($00,$00),($00,$00) |
|
|
146 |
); |
|
|
147 |
|
|
|
148 |
const PinConnectV3: array[1..40,1..2] of byte = |
|
|
149 |
{== tabulka pro pripojeni prevodniku s vahou 1 k pinum, na prvni ==} |
|
|
150 |
{== registr pro pripojeni, na druhe pozici maska pinu v registru ==} |
|
|
151 |
( |
|
|
152 |
($E8,$01),($00,$00),($00,$00),($00,$00), |
|
|
153 |
($E8,$10),($E8,$20),($E8,$40),($00,$00), |
|
|
154 |
($E9,$01),($E9,$02),($E9,$04),($E9,$08), |
|
|
155 |
($E9,$10),($E9,$20),($E9,$40),($E9,$80), |
|
|
156 |
($EA,$01),($EA,$02),($EA,$04),($EA,$08), |
|
|
157 |
($EA,$10),($EA,$20),($EA,$40),($EA,$80), |
|
|
158 |
($EB,$01),($EB,$02),($EB,$04),($EB,$08), |
|
|
159 |
($EB,$10),($EB,$20),($EB,$40),($EB,$80), |
|
|
160 |
($00,$00),($00,$00),($00,$00),($EC,$08), |
|
|
161 |
($00,$00),($00,$00),($00,$00),($00,$00) |
|
|
162 |
); |
|
|
163 |
|
|
|
164 |
{== definice globalnich promennych ==} |
|
|
165 |
|
|
|
166 |
var BazovaAdresa : word; |
|
|
167 |
Error : integer; { cislo chyby } |
|
|
168 |
PortStat : array[1..5] of byte; { aktualni stavy pinu } |
|
|
169 |
ConnectV1Stat: array[1..2] of byte; { aktualni pripojeni prevodniku V1 } |
|
|
170 |
ConnectV2Stat: array[1..3] of byte; { aktualni pripojeni prevodniku V2 } |
|
|
171 |
ConnectV3Stat: array[1..5] of byte; { aktualni pripojeni prevodniku V3 } |
|
|
172 |
GndStat : boolean; { =1 GND na 11, =0 GND na 20 } |
|
|
173 |
|
|
|
174 |
|
|
|
175 |
{== vykonne procedury TPU ==} |
|
|
176 |
|
|
|
177 |
|
|
|
178 |
{== Vytiskne hlaseni o chybe a ukonci program ==} |
|
|
179 |
procedure ErrorProc; |
|
|
180 |
begin |
|
|
181 |
writeln; |
|
|
182 |
write('Error: '); |
|
|
183 |
case Error of |
|
|
184 |
0:writeln('Zadna Chyba'); |
|
|
185 |
1:writeln('Napeti pro prevodnik mimo rozsah'); |
|
|
186 |
2:Writeln('Spatny stav pinu, mozne pouze 0 nebo 1'); |
|
|
187 |
3:Writeln('Pin mimo rozsah, mozne 1-40, u pripojeni prevodniku jen nektere'); |
|
|
188 |
end; {case} |
|
|
189 |
writeln; |
|
|
190 |
halt(1); |
|
|
191 |
end; {End Error} |
|
|
192 |
|
|
|
193 |
|
|
|
194 |
{== Zapise bajt do prislusneho registru programatoru ==} |
|
|
195 |
procedure OutPort(Adr, Data : byte); |
|
|
196 |
begin |
|
|
197 |
asm |
|
|
198 |
mov dx,BazovaAdresa |
|
|
199 |
mov al,Adr |
|
|
200 |
out dx,al |
|
|
201 |
add dx,2 |
|
|
202 |
mov al,Data |
|
|
203 |
out dx,al |
|
|
204 |
end; {asm} |
|
|
205 |
end; {OutPort} |
|
|
206 |
|
|
|
207 |
|
|
|
208 |
{== Precte bajt a prislusneho registru programatoru ==} |
|
|
209 |
function InPort(Adr : byte) : byte; |
|
|
210 |
begin |
|
|
211 |
asm |
|
|
212 |
mov dx,BazovaAdresa |
|
|
213 |
mov al,Adr |
|
|
214 |
out dx,al |
|
|
215 |
add dx,2 |
|
|
216 |
in al,dx |
|
|
217 |
mov Adr,al |
|
|
218 |
end; {asm} |
|
|
219 |
InPort := Adr; |
|
|
220 |
end; |
|
|
221 |
|
|
|
222 |
|
|
|
223 |
{== Zinicializuje programator ==} |
|
|
224 |
procedure PowerOff; |
|
|
225 |
var n,i :byte; |
|
|
226 |
begin |
|
|
227 |
for i:= 1 to InitNum do |
|
|
228 |
OutPort(InitArray[i,1],InitArray[i,2]); |
|
|
229 |
|
|
|
230 |
{--- nastav otisk pinu} |
|
|
231 |
for i:= 1 to 5 do |
|
|
232 |
PortStat[i]:=255; |
|
|
233 |
|
|
|
234 |
{--- nastav otisk pripojeni prevodniku V1} |
|
|
235 |
for i:=1 to 2 do |
|
|
236 |
ConnectV1Stat[i]:=0; |
|
|
237 |
|
|
|
238 |
{--- nastav otisk pripojeni prevodniku V2} |
|
|
239 |
for i:=1 to 3 do |
|
|
240 |
ConnectV2Stat[i]:=0; |
|
|
241 |
|
|
|
242 |
{--- nastav otisk pripojeni prevodniku V3} |
|
|
243 |
for i:=1 to 5 do |
|
|
244 |
ConnectV3Stat[i]:=0; |
|
|
245 |
|
|
|
246 |
end; {PowerOff} |
|
|
247 |
|
|
|
248 |
|
|
|
249 |
{== Inicializace programatoru se zadanim Bazove adresy ==} |
|
|
250 |
procedure Initialize(Baze :word); |
|
|
251 |
begin |
|
|
252 |
BazovaAdresa:=Baze; |
|
|
253 |
Error:=0; |
|
|
254 |
GndStat:=false; |
|
|
255 |
PowerOff; |
|
|
256 |
end; {Initialize} |
|
|
257 |
|
|
|
258 |
|
|
|
259 |
{== Zadani napeti pro prevodnik s vahou 0.4 ==} |
|
|
260 |
procedure SetVoltageV1(Napeti : real); |
|
|
261 |
var Voltage:Integer; |
|
|
262 |
begin |
|
|
263 |
if Napeti<=9.6 then begin Voltage:=Round(((255/9.5)*Napeti)); |
|
|
264 |
OutPort(231,Voltage); |
|
|
265 |
end |
|
|
266 |
else begin Error:=1; |
|
|
267 |
end; |
|
|
268 |
end; {SetVoltageV1} |
|
|
269 |
|
|
|
270 |
|
|
|
271 |
{== Zadani napeti pro prevodnik s vahou 0.6 ==} |
|
|
272 |
procedure SetVoltageV2(Napeti : real); |
|
|
273 |
var Voltage:Integer; |
|
|
274 |
begin |
|
|
275 |
if Napeti<=14.4 then begin Voltage:=Round(((255/14.4)*Napeti)); |
|
|
276 |
OutPort(230,Voltage); |
|
|
277 |
end |
|
|
278 |
else begin Error:=1; |
|
|
279 |
end; |
|
|
280 |
end; {SetVoltageV2} |
|
|
281 |
|
|
|
282 |
|
|
|
283 |
{== Zadani napeti pro prevodnik s vahou 1 ==} |
|
|
284 |
procedure SetVoltageV3(Napeti : real); |
|
|
285 |
var Voltage:Integer; |
|
|
286 |
begin |
|
|
287 |
if Napeti<=25 then begin Voltage:=Round(((255/24)*Napeti)); |
|
|
288 |
OutPort(229,Voltage); |
|
|
289 |
end |
|
|
290 |
else begin Error:=1; |
|
|
291 |
end; |
|
|
292 |
end; {SetVoltageV1} |
|
|
293 |
|
|
|
294 |
|
|
|
295 |
{== Nastaveni pinu ==} |
|
|
296 |
procedure SetBit(Pin,Stav:byte); |
|
|
297 |
var PozReg:byte; |
|
|
298 |
begin |
|
|
299 |
if (Pin>=1) and (Pin<=40) |
|
|
300 |
then begin |
|
|
301 |
{--- urceni indexu I/O registru pro pole otisku} |
|
|
302 |
if (Pin>=1) and (Pin<=8) then PozReg:=1; |
|
|
303 |
if (Pin>=9) and (Pin<=16) then PozReg:=2; |
|
|
304 |
if (Pin>=17) and (Pin<=24) then PozReg:=3; |
|
|
305 |
if (Pin>=25) and (Pin<=32) then PozReg:=4; |
|
|
306 |
if (Pin>=33) and (Pin<=40) then PozReg:=5; |
|
|
307 |
|
|
|
308 |
if Stav=1 |
|
|
309 |
then begin |
|
|
310 |
{--- pin do Log.1, zaznam do otisku} |
|
|
311 |
PortStat[PozReg]:=PortStat[PozReg] or PinSet[Pin,2]; |
|
|
312 |
OutPort(PinSet[Pin,1],PortStat[PozReg]); |
|
|
313 |
{ writeln(PortStat[PozReg]); } |
|
|
314 |
end |
|
|
315 |
else Error:=2; |
|
|
316 |
|
|
|
317 |
if Stav=0 |
|
|
318 |
then begin |
|
|
319 |
{--- pin do log.0, zaznam do otisku} |
|
|
320 |
PortStat[PozReg]:=PortStat[PozReg] and not(PinSet[Pin,2]); |
|
|
321 |
OutPort(PinSet[Pin,1],PortStat[PozReg]); |
|
|
322 |
{ writeln(PortStat[PozReg]); } |
|
|
323 |
end |
|
|
324 |
else Error:=2; |
|
|
325 |
|
|
|
326 |
end |
|
|
327 |
else Error:=3; |
|
|
328 |
end; {SetBit} |
|
|
329 |
|
|
|
330 |
|
|
|
331 |
{== Cteni bitu jako procedura ==} |
|
|
332 |
procedure GetBitProc (Pin:byte;var Stav:byte); |
|
|
333 |
var ReadBit:byte; |
|
|
334 |
begin |
|
|
335 |
if (Pin>=1) and (Pin<=40) |
|
|
336 |
then begin |
|
|
337 |
Readbit:=InPort(PinSet[Pin,1]) and PinSet[Pin,2]; |
|
|
338 |
if ReadBit=0 then Stav:=0 |
|
|
339 |
else Stav:=1; |
|
|
340 |
end |
|
|
341 |
else Error:=3; |
|
|
342 |
end; {GetbitProc} |
|
|
343 |
|
|
|
344 |
|
|
|
345 |
{== Cteni bitu jako funkce ==} |
|
|
346 |
function GetBit(Pin:byte):byte; |
|
|
347 |
var ReadBit:byte; |
|
|
348 |
begin |
|
|
349 |
Readbit:=InPort(PinSet[Pin,1]) and PinSet[Pin,2]; |
|
|
350 |
if ReadBit=0 then GetBit:=0 |
|
|
351 |
else GetBit:=1; |
|
|
352 |
end; {Getbit} |
|
|
353 |
|
|
|
354 |
|
|
|
355 |
{== Pripojeni prevodniku V1 s vahou 0.4 ==} |
|
|
356 |
procedure ConnectV1(Pin:byte;On:boolean); |
|
|
357 |
var PozReg:byte; |
|
|
358 |
TestPin:boolean; |
|
|
359 |
begin |
|
|
360 |
{--- lze pripojit k pinum 24,26-32,34,36 a 40} |
|
|
361 |
TestPin:=(Pin>=26) and (Pin<=32)or (Pin=24) or (Pin=34) or (Pin=36) or (Pin=40); |
|
|
362 |
if TestPin |
|
|
363 |
then begin |
|
|
364 |
{ writeln('V1 ',Pin); } |
|
|
365 |
|
|
|
366 |
{--- urceni indexu I/O registru pro pole otisku} |
|
|
367 |
if Pin=24 then PozReg:=3; |
|
|
368 |
if (Pin>=25) and (Pin<=32) then PozReg:=4; |
|
|
369 |
if (Pin>=33) and (Pin<=40) then PozReg:=5; |
|
|
370 |
|
|
|
371 |
{--- na pin se musi zapsat log.1, udelej zaznam do otisku} |
|
|
372 |
PortStat[PozReg]:=PortStat[PozReg] or PinSet[Pin,2]; |
|
|
373 |
{ writeln(PinSet[Pin,1],' ',PortStat[PozReg]); } |
|
|
374 |
|
|
|
375 |
{--- urci registr v poli otisku pripojeni} |
|
|
376 |
if (Pin>=24) and (Pin<=27) then PozReg:=1 |
|
|
377 |
else PozReg:=2; |
|
|
378 |
if On |
|
|
379 |
then {--- udelej zaznam o pripojeni do otisku} |
|
|
380 |
ConnectV1Stat[PozReg] := ConnectV1Stat[PozReg] |
|
|
381 |
or PinConnectV1[Pin,2] |
|
|
382 |
else {--- udelej zaznam o odpojeni do otisku} |
|
|
383 |
ConnectV1Stat[PozReg] := ConnectV1Stat[PozReg] |
|
|
384 |
and not( PinConnectV1[Pin,2]); |
|
|
385 |
|
|
|
386 |
OutPort(PinConnectV1[Pin,1],ConnectV1Stat[PozReg]); |
|
|
387 |
|
|
|
388 |
end |
|
|
389 |
else Error:=3; |
|
|
390 |
end; {ConnectV1} |
|
|
391 |
|
|
|
392 |
|
|
|
393 |
{== Pripojeni prevodniku V2 s vahou 0.6 ==} |
|
|
394 |
procedure ConnectV2(Pin:byte;On:boolean); |
|
|
395 |
var PozReg:byte; |
|
|
396 |
TestPin:boolean; |
|
|
397 |
begin |
|
|
398 |
{--- lze pripojit piny 9-32} |
|
|
399 |
TestPin:=(Pin>=9) and (Pin<=32); |
|
|
400 |
|
|
|
401 |
{--- pokud je pouzit pin 11 nebo 20 jako zem, nejze na nej ---} |
|
|
402 |
{--- pripojit prevodnik ---} |
|
|
403 |
if (Pin=11) and GndStat then TestPin:=false; { pin 11 je uzemen } |
|
|
404 |
if (Pin=20) and Not(GndStat) then TestPin:=false; { pin20 je uzemen } |
|
|
405 |
|
|
|
406 |
if TestPin |
|
|
407 |
then begin |
|
|
408 |
{ writeln('V2 ',Pin); } |
|
|
409 |
|
|
|
410 |
{--- urceni indexu I/O registru pro pole otisku} |
|
|
411 |
if (Pin>=9) and (Pin<=16) then PozReg:=2; |
|
|
412 |
if (Pin>=17) and (Pin<=24) then PozReg:=3; |
|
|
413 |
if (Pin>=25) and (Pin<=32) then PozReg:=4; |
|
|
414 |
|
|
|
415 |
{--- na pin je nutne zapsat log.1, udelej zapis do otisku} |
|
|
416 |
PortStat[PozReg]:=PortStat[PozReg] or PinSet[Pin,2];{nastav na pin log.1} |
|
|
417 |
OutPort(PinSet[Pin,1],PortStat[PozReg]); |
|
|
418 |
{ writeln(PinSet[Pin,1],' ',PortStat[PozReg]); } |
|
|
419 |
|
|
|
420 |
{--- urci registr otisku pripojeni} |
|
|
421 |
if (Pin>=9) and (Pin<=16) then PozReg:=1; |
|
|
422 |
if (Pin>=17) and (Pin<=24) then PozReg:=2; |
|
|
423 |
if (Pin>=25) and (Pin<=32) then PozReg:=3; |
|
|
424 |
|
|
|
425 |
|
|
|
426 |
if On |
|
|
427 |
then {--- udelej zaznam o pripojeni do otisku} |
|
|
428 |
ConnectV2Stat[PozReg] := ConnectV2Stat[PozReg] |
|
|
429 |
or PinConnectV2[Pin,2] |
|
|
430 |
else ConnectV2Stat[PozReg] := ConnectV2Stat[PozReg] |
|
|
431 |
and not(PinConnectV2[Pin,2]); |
|
|
432 |
|
|
|
433 |
OutPort(PinConnectV2[Pin,1],ConnectV2Stat[PozReg]); |
|
|
434 |
|
|
|
435 |
end |
|
|
436 |
else Error:=3; |
|
|
437 |
end; {ConnectV2} |
|
|
438 |
|
|
|
439 |
|
|
|
440 |
{== Pripojeni prevodniku V3 s vahou 1 ==} |
|
|
441 |
procedure ConnectV3(Pin:byte;On:boolean); |
|
|
442 |
var PozReg:byte; |
|
|
443 |
TestPin:boolean; |
|
|
444 |
begin |
|
|
445 |
{--- lze pripojit k pinum 1,5-7,9-32,a36} |
|
|
446 |
TestPin:=(Pin>=9)and(Pin<=32)or(Pin=1)or((Pin>=5)and(Pin<=7))or(Pin=36); |
|
|
447 |
|
|
|
448 |
{--- pokud je pouzit pin 11 nebo 20 pro zem, nelze na nej ---} |
|
|
449 |
{--- pripojit prevodnik ---} |
|
|
450 |
if (Pin=11) and GndStat then TestPin:=false; { pin 11 je uzemen } |
|
|
451 |
if (Pin=20) and Not(GndStat) then TestPin:=false; { pin20 je uzemen } |
|
|
452 |
|
|
|
453 |
if TestPin |
|
|
454 |
then begin |
|
|
455 |
{ writeln('V3 ',Pin); } |
|
|
456 |
|
|
|
457 |
{--- urceni indexu I/O registru pro pole otisku } |
|
|
458 |
if (Pin>=1) and (Pin<=8) then PozReg:=1; |
|
|
459 |
if (Pin>=9) and (Pin<=16) then PozReg:=2; |
|
|
460 |
if (Pin>=17) and (Pin<=24) then PozReg:=3; |
|
|
461 |
if (Pin>=25) and (Pin<=32) then PozReg:=4; |
|
|
462 |
if (Pin>=33) and (Pin<=40) then PozReg:=5; |
|
|
463 |
{ writeln(PozReg); } |
|
|
464 |
|
|
|
465 |
{--- na pin nutno zapsat log.1 , udelej zapis do otisku } |
|
|
466 |
PortStat[PozReg] := PortStat[PozReg] |
|
|
467 |
or PinSet[Pin,2]; { nastav na pin log.1 } |
|
|
468 |
|
|
|
469 |
OutPort(PinSet[Pin,1],PortStat[PozReg]); |
|
|
470 |
|
|
|
471 |
{ writeln(PinSet[Pin,1],' ',PortStat[PozReg]); } |
|
|
472 |
|
|
|
473 |
{--- urci registr otisku pripojeni} |
|
|
474 |
if (Pin>=1) and (Pin<=7) then PozReg:=1; |
|
|
475 |
if (Pin>=9) and (Pin<=16) then PozReg:=2; |
|
|
476 |
if (Pin>=17) and (Pin<=24) then PozReg:=3; |
|
|
477 |
if (Pin>=25) and (Pin<=32) then PozReg:=4; |
|
|
478 |
if (Pin=36) then PozReg:=5; |
|
|
479 |
|
|
|
480 |
if On |
|
|
481 |
then ConnectV3Stat[PozReg] := ConnectV3Stat[PozReg] |
|
|
482 |
or PinConnectV3[Pin,2] |
|
|
483 |
else ConnectV3Stat[PozReg] := ConnectV3Stat[PozReg] |
|
|
484 |
and not(PinConnectV3[Pin,2]); |
|
|
485 |
|
|
|
486 |
OutPort(PinConnectV3[Pin,1],ConnectV3Stat[PozReg]); |
|
|
487 |
|
|
|
488 |
end |
|
|
489 |
else Error:=3; |
|
|
490 |
end; {ConnectV3} |
|
|
491 |
|
|
|
492 |
|
|
|
493 |
{== Prepinani zeme mezi vyvody 11 nebo 20 ==} |
|
|
494 |
{ True = pripojen Pin11 } |
|
|
495 |
{ False = pripojen pin20 } |
|
|
496 |
procedure Gnd11(On:boolean); |
|
|
497 |
begin |
|
|
498 |
if On then begin |
|
|
499 |
OutPort($EF,1); |
|
|
500 |
GndStat:=true; |
|
|
501 |
end |
|
|
502 |
else |
|
|
503 |
begin |
|
|
504 |
OutPort($EF,0); |
|
|
505 |
GndStat:=false; |
|
|
506 |
end; |
|
|
507 |
end; {Gnd11} |
|
|
508 |
|
|
|
509 |
|
|
|
510 |
{== Ovladani LED 'GOOD' ==} |
|
|
511 |
{ True = sviti } |
|
|
512 |
procedure Led(On:boolean); |
|
|
513 |
begin |
|
|
514 |
if On then OutPort($F7,$8) |
|
|
515 |
else OutPort($F7,$0); |
|
|
516 |
end; {Led} |
|
|
517 |
|
|
|
518 |
|
|
|
519 |
{== Cteni tlacitka 'YES' ==} |
|
|
520 |
{ True = stisknut } |
|
|
521 |
function ReadButton:boolean; |
|
|
522 |
begin |
|
|
523 |
PowerOff; |
|
|
524 |
xDelay(50); |
|
|
525 |
writeln(InPort($E4)); |
|
|
526 |
if (InPort($E4)and $80)<>0 then ReadButton:=true |
|
|
527 |
else ReadButton:=false; |
|
|
528 |
end; {ReadButton} |
|
|
529 |
|
|
|
530 |
|
|
|
531 |
begin |
|
|
532 |
end. |