'accuscheider def 1.5 25 mei 2013
'programma scheidingsrelais voor twee accu''s nu 229 van 256 05-02-2013
'gebruik 20M
'configuratie:
'inputs: pin 9=input1=adc1=accu1=vtg
' pin 8=input2=adc2=accu2=acc
' pin 7=input3=adc3=Uuit
' pin 5=input5=druktoets
' pin 18=output0= LedH = b.0 = gr
''outputs pin 17=output1= R1 = b.1
' pin 16=putput2= LedM = b.2 = gr
' pin 15=output3= R2 = b.3
' pin 14=output4= LedL = b.4 = ge
' pin 13=output5= Red = b.5 = ro
' pin 12=output6= LedR2= b.6 = gr
' pin 11=output7= LedR1= b.7 = ge
'
'Variabelen toewijzing:
'b0=teller
'b1=ingelezen outputs
'b2=Avtg
'b3=Aacc
'b4=Uuit
'b5, b6, b7 tijdelijke variabelen bij 'lees'
'b8= Leds3 = 13.8V
'b9= Leds2 = 12,2V
'b10= Leds1= 11,6V
'b11=hoog =13,4
'b12=mid =12,8
'b13=laag =11,4
'Overzicht van spanningsniveau's en acties
'tehoog = 16V = 140 ==> Aacc wordt afgeschakeld (open R1)
'leds3 = 13,8V = 124 ==> bij 13,8V gaat de derde (groene) led aan
'hoog = 13,4V = 120 ==> bij Avtg=hoog gaat R1 aan (koppelen twee accu's)
'mid = 12,8V = 114 ==> bij Avtg<mid gaat R1 uit (loskoppelen twee accu's)
'bij > leds2 gaat R2 aan
'leds2 = 12,2V = 110 ==> bij leds2 gaat de derde groene led uit, blijven 1 groene en 1 gele over
'leds1 = 11,6V = 104 ==> bij leds1 brand alleen de gele led nog, < leds1 nog alleen de rode
'laag = 11,4V = 102 ==> bij laag schakelt R2 de verbruikers af
'telaag = 10V = 92 ==> bij te laag (accu defect of geen 2e accu)
'************************************************************************************************************
Init:
symbol toets=pinc.5
symbol ledR1=b.7
symbol ledR2=b.6
symbol R1=b.1
symbol R2=b.3
symbol red=b.5
symbol tel=b0
symbol Avtg=b2 'c.1
symbol Aacc=b3 'c.2
symbol Uuit=b4 'c.3
symbol leds3=b8
symbol leds2=b9
symbol leds1=b10
symbol hoog=b11
symbol mid=b12
symbol laag=b13
hoog=120
mid=114
laag=102
leds3=124
leds2=110
leds1=104
'tehoog=140
'telaag=92
let pins = %11110101 'high ledr1,ledr2, red + 3 spanningsleds
pause 1500
let pins=0
goto main
Main:
gosub lees
gosub disp
gosub schakel
goto main
Lees: 'lees en deel door twee, twee keer, geeft waarde in ca 4 sec
let Avtg=0
let Aacc=0
let Uuit=0
let tel=1
for tel= 1 to 2
readadc c.1,b5 'Avtg 'b2
b5=b5/2
Avtg=Avtg+b5
readadc c.2,b6 'Aacc 'b3
b6=b6/2
Aacc=Aacc+b6
readadc c.3,b7 'Uacc 'b4
b7=b7/2
Uuit=Uuit+b7
pause 1000
next tel
'check op aanwezigheid 2e accu / te lege accu
If Aacc < 92 then let pins=%00110000 let Avtg=0 endif 'rood, geel
'check op te hoge accuspanning
If Avtg >= 140 then let pins=%00110001 let Avtg=0 Aacc=0 endif 'rood, geel groen2
return
Schakel:
if Aacc <= laag then low R2 low ledr2 endif 'Accu2 < 11,4V: uit
if Aacc > leds2 then high R2 high ledr2 endif 'Accu2 > 12,2V: aan
If Avtg >= hoog then high R1 high ledr1 gosub slope endif 'accu1 > 13,4V: aan
if Avtg < mid then low R1 low ledr1 endif 'accu1 < 12,8V: uit
return
slope:
pause 2000 'pause 2 sec
readadc c.1,b5 'lees in b5 = startwaarde
let tel=0 'max gedurende 5 min in deze subroutine
do while b5<= mid and tel<150 and b5> laag 'blijf laden zolang b6> start (b5)
pause 1000
let aacc=b5
'debug
gosub disp
pause 1000
tel=tel+1
readadc c.1,b5 'lees in b5
loop
return
Disp:
readoutputs b1
b1=b1&%11001010 'zet U-leds uit, laat rest
if Aacc >= leds3 then '>13,8V groen2
pins=%00000101 or b1
endif
if Aacc>=leds2 and Aacc < leds3 then '>=12,2V en < 13,8V groen1
pins=%00000100 or b1
endif
if Aacc>=leds1 and Aacc < leds2 then '>=11,6V en < 12,2V geel
pins=%00010000 or b1
endif
if Aacc>=92 and Aacc < leds1 then '>=telaag (10v)V en < 11,6V red '
pins=%00100000 or b1
endif
'debug
'pause 1000
return
#rem:
aanpassingen aan def1.0 =def 1,1
kleine textuele verduidelijkingen
toegevoegd: extra pause om pendelen te voorkomen. Nadat hoofdrelais is
ingeschakeld 10 min laten laden en dan pas weer meten.
If Avtg > hoog then high R1 high ledr1 pause 60000 endif =pause 60000 toegevoegd
iden bij uitschakelen. Tevens de volgorde omgedraaid.
#endrem
#rem
verdere aanpassingen:subroutine slope toegevoegd
standaard vertraging van 10 minuten omgezet in check op spanningstijging
gedurende max 5 min. De waarde van pause en/of tel hierop nog aanpassen
(nu 120*2sec+1min)