Skip to content

Instantly share code, notes, and snippets.

@robertocommit
Created November 16, 2022 20:59
Show Gist options
  • Save robertocommit/a741679df6e8804b30504a88b80f1476 to your computer and use it in GitHub Desktop.
Save robertocommit/a741679df6e8804b30504a88b80f1476 to your computer and use it in GitHub Desktop.
'Ultima realise counter + spettro adeguate le variabili per non avere count negativi oltre il riporto,
'e stabile lo zero batterie sempre per il medesimo motivo. Poi lettura della HV per un paio di secondi
'Firmware inserito dal ser n° 008 in avanti. I precedenti hanno bisogno di upgrade.
'Aggiunta funzione killer che dopo tot accensioni non procede....per annullarla accendere l'apparecchio
'senza collegare la sonda (variabile a 0) per alcuni minuti finchè rimuove il blocco da solo.
'Scheda contatore con ingresso interrupt0
$prog &HFF , &HE1 , &HD9 , &H00 '
' e lettura batteria + 2 trimmer di setup
$regfile = "m8def.dat"
$crystal = 8000000
'Cha Alias Pind.2
'Chb Alias Pind.3
'Config Chb = Input
Config Int0 = Falling
Dim Wtime As Word
Dim Siv As Single
Dim Coeff As Single
Dim Batt As Integer
Dim Encounter As Word
Dim A As Word
Dim B As Word
Dim C As Word
Dim Tebat As Word
Dim Media As Word
Dim Killer As Integer
Dim Kilcount As Byte
'Set Chb
On Int0 Getencoder
Config Pind.0 = Output 'sound
Config Pind.1 = Input 'giù
Config Pind.4 = Input 'su
Config Pind.5 = Input 'giù
Config Pind.2 = Input 'indietro (int0)
Config Pind.3 = Input 'pulsante lettura HV
Config Pinb.0 = Output 'uscita x dosaggio - led verde
Config Pinb.1 = Output 'uscita allarme - led rosso
Config Pinb.2 = Output
Config Pinb.7 = Output 'cicalino attivo alto
Config Pinc.0 = Input 'trim0'lcd
Config Pinc.1 = Input 'trim1'lcd
Config Pinc.2 = Input 'lcd
Config Pinc.3 = Input 'lcd
Config Pinc.4 = Output 'lcd
Config Pinc.5 = Output 'lcd
Config Pind.6 = Output 'lcd
Config Pind.7 = Output 'lcd
Config Adc = Single , Prescaler = Auto
Start Adc
Dim Trim1 As Word , Trim2 As Word
Dim Hv As Word , Bott As Byte
Dim Pulses As Word , Periods As Word
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portb.4 , Rs = Portb.3
Config Lcd = 20 * 2
Gosub Beeper
Reset Portb.7 'tolgo la contesa tra audio e crepitio causa or digitale
Tebat = 0
Readeeprom Killer , 1
Do 'loop di lettura alta tensione
Tebat = Tebat + 1
Hv = Getadc(1)
Hv = Hv * 2 'prima era 2.07
Hv = Hv + 93 'aumentata per Bonora e successivi
Cls
Lcd "Tens.HV:" ; Hv
Waitms 300
Loop Until Tebat > 6
Tebat = 0
Cls
Wtime = 350
'Wtime = 500
Encounter = 0
Enable Interrupts
Enable Int0
'******* procedura killer **********
Waitms 20
Readeeprom Killer , 1 'recuperoo la variab da memoria
Waitms 50 'ci aggiungo 1 ogni accensione
Killer = Killer + 1
Writeeeprom Killer , 1 'la salvo subito aggiornata
If Killer > 500 Then 'se la var è superiore a 500
Do
Lcd "reload register" ; " "
Waitms 20 'in questo loop se non sono presenti impulsi
A = Encounter 'resto dentro
If A = 0 Then
Kilcount = Kilcount + 1 'incremento il conteggio fino a 250
End If 'circa 1 minuto e poi azzero il killer
Waitms 200
Cls
Encounter = 0
If Kilcount > 250 Then
Killer = 0
Writeeeprom Killer , 1
Goto Riparti
End If
Loop
End If
'****** fine killer *************
Riparti:
Do 'corretto scompenso sotto lo zero
Trim1 = Getadc(2) 'sulla misura di batt
Trim2 = Getadc(3) 'il febbr 2021
Batt = Getadc(0)
Batt = Batt - 730
If Batt > 100 Then Batt = 100
If Batt < 0 Then Batt = 0
Coeff = Trim2 / 100
Waitms Wtime
Cls
Upperline
A = Encounter
Media = A + B
Media = Media + C
Media = Media / 3
C = B
B = A
'************vecchio dsplay***************************************************
'Lcd Encounter ; " " ; "cps" ; " " ; "Alarm: " ; Trim1 ;
'Siv = Media * Coeff
'If Batt < 760 Then Goto Batgiu 'soglia della batt. a 7.4V
'Batsu:
'Lowerline
'Siv = Int(siv)
'Lcd Siv ; " " ; "nSv/h" ; " Batt:OK "
'Goto Fine
'Batgiu:
'Lowerline
'Siv = Int(siv)
'Lcd Siv ; " " ; "nSv/h" ; " " ; Batt
'*****************************************************************************
Siv = Media * Coeff
Siv = Int(siv)
Lcd Encounter ; " " ; "cps" ; " " ; Siv ; " " ; "nSv/h"
Lowerline
Lcd "Alarm:" ; Trim1 ; " " ; "Batt:" ; Batt ; "%" ; " "
Fine:
If Encounter > Trim1 Then Gosub Beeper
'If Siv > Trim1 Then Gosub Beeper
Encounter = 0
Waitms Wtime
Loop
Getencoder:
Incr Encounter
'If Chb = 0 Then Decr Encounter Else Incr Encounter
Waitus 2
'waitus 20
Gifr = 256
Return
Beeper:
'Pulses = 200 : Periods = 800 'set variables
'Speaker Alias Portd.0 'define port pin
'Sound Speaker , Pulses , Periods
Set Portb.7
Waitms 200
Reset Portb.7
Waitms 1
Return
'end program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment