Che Guevara
31.08.2008, 01:48
hallo leute,
ich habe mal wider ein problem.
ich habe folgenden code, welcher auch einwandfrei funzt, bis auf eine sache:
wenn ich auf taste 1 zum beispiele drücke, zeigt mir das prog die batteriespannung an.
allerdings wird dieser wert (also die anzeige) nicht aktualisiert, wenn ich am labornetzgerät die spannung verstelle!
hier nun der code:
$regfile = "m32def.dat"
$crystal = 16000000
$baud = 9600
$hwstack = 32
$swstack = 32
$framesize = 64
Declare Function Tastenabfrage() As Byte
Declare Sub Batteriespannung()
Config Lcd = 20 * 4
Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.4 , Rs = Portc.5
Config Lcdbus = 4
Config Adc = Single , Prescaler = Auto
Config Pina.7 = Input
Porta.7 = 1
Config Timer1 = Timer , Prescale = 1024
Enable Timer1
Enable Interrupts
Timer1 = 49910
On Timer1 Isr_von_timer1
Config Timer0 = Counter , Edge = Falling
Enable Timer0
Timer0 = 255
On Timer0 Isr_von_timer0
Dim A As Integer
Dim Taste As Byte
Dim Volt As Single
Dim Secu As Single
Dim Minu As Single
Dim Hour As Single
Dim X As Single
Dim Tasten_flag As Byte
Dim F As Single
Dim T As Single
Dim Freq As Single
Dim N As Long
Dim W As Word
Dim J As Word
Dim Y As Word
Const Ref = 5 / 1023
A = 1
X = 1
Secu = 00
Minu = 00
Hour = 00
T = 0
Tasten_flag = 0
F = 0
Cls
Locate 1 , 4
Lcd "Daten-Terminal "
Locate 2 , 1
Lcd "Hier koennen Sie"
Locate 3 , 1
Lcd "ermittelte Daten"
Locate 4 , 1
Lcd "Speichern!!! "
Do
Taste = Tastenabfrage()
If Taste <> 0 Then
Select Case Taste
Case 1
Cls
N = 0
Y = 1
Tasten_flag = 0
For N = 1 To 100000000
Initlcd
Start Adc
W = Getadc(6)
Volt = W * Ref
Volt = Volt * 5.2941
Cls
Locate 1 , 1
Lcd "Die aktuelle "
Locate 2 , 1
Lcd "Spannung betraegt: "
Locate 3 , 1
Lcd Volt ; " Volt "
W = Getadc(7)
If W < 500 Then
Select Case W
Case 400 To 450
J = 1
Case 330 To 380
J = 2
Case 260 To 305
J = 3
Case 180 To 220
J = 4
Case 90 To 130
J = 5
End Select
End If
If J <> Y Then
Tasten_flag = 1
Exit For
End If
If Tasten_flag = 1 Then
Exit For
End If
Next N
Case 2
Cls
N = 0
Y = 2
Tasten_flag = 0
Writeeeprom Secu , 1
Writeeeprom Minu , 10
Writeeeprom Volt , 20
Cls
Locate 1 , 1
Lcd "Speichern von: "
Locate 2 , 1
Lcd "Frequenz, Laufzeit "
Locate 3 , 1
Lcd "und Batteriespannung"
Locate 4 , 1
Lcd "Daten jetzt abrufbar"
Case 3
Cls
N = 0
Y = 3
Tasten_flag = 0
For N = 1 To 100000000
Initlcd
Freq = F / T
Locate 1 , 1
Lcd "Sekunden = " ; T
Locate 2 , 1
Lcd "Signale = " ; F
Locate 3 , 1
Lcd "==> Frequenz:"
Locate 4 , 1
Lcd Freq ; "Hz"
Start Adc
W = Getadc(7)
If W < 500 Then
Select Case W
Case 400 To 450
J = 1
Case 330 To 380
J = 2
Case 260 To 305
J = 3
Case 180 To 220
J = 4
Case 90 To 130
J = 5
End Select
End If
If J <> Y Then
Tasten_flag = 1
Exit For
End If
If Tasten_flag = 1 Then
Exit For
End If
Next N
Case 4
N = 0
Y = 4
Tasten_flag = 0
For N = 1 To 100000000
Cls
Initlcd
If Secu = 60 Then
Secu = 00
Minu = Minu + 1
Elseif Minu = 60 Then
Minu = 00
Hour = Hour + 1
End If
Locate 2 , 1
Lcd "Zeit = "
Locate 2 , 8
Lcd Hour ; Minu ; Secu ;
Start Adc
W = Getadc(7)
If W < 500 Then
Select Case W
Case 400 To 450
J = 1
Case 330 To 380
J = 2
Case 260 To 305
J = 3
Case 180 To 220
J = 4
Case 90 To 130
J = 5
End Select
End If
If J <> Y Then
Tasten_flag = 1
Exit For
End If
If Tasten_flag = 1 Then
Exit For
End If
Next N
Case 5
Cls
N = 0
Y = 5
Tasten_flag = 0
For N = 1 To 100000000
Initlcd
Readeeprom Secu , 1
Readeeprom Volt , 20
Locate 1 , 1
Lcd Freq ; " Hz "
Locate 2 , 1
Lcd Secu ; " Sekunde(n) "
Locate 3 , 1
Lcd Minu ; " Minute(n) "
Locate 4 , 1
Lcd Volt ; " Volt "
Start Adc
W = Getadc(7)
If W < 500 Then
Select Case W
Case 400 To 450
J = 1
Case 330 To 380
J = 2
Case 260 To 305
J = 3
Case 180 To 220
J = 4
Case 90 To 130
J = 5
End Select
End If
If J <> Y Then
Tasten_flag = 1
Exit For
End If
If Tasten_flag = 1 Then
Exit For
End If
Next N
End Select
End If
Loop
Isr_von_timer1:
Timer1 = 49910
Incr Secu
Incr T
Return
Isr_von_timer0:
Timer0 = 255
Incr F
Return
Function Tastenabfrage() As Byte
Local Ws As Word
Tastenabfrage = 0
Start Adc
Ws = Getadc(7)
If Ws < 500 Then
Select Case Ws
Case 400 To 450
Tastenabfrage = 1
Case 330 To 380
Tastenabfrage = 2
Case 260 To 305
Tastenabfrage = 3
Case 180 To 220
Tastenabfrage = 4
Case 90 To 130
Tastenabfrage = 5
End Select
End If
End Function
Sub Batteriespannung()
End Sub
habt ihr eine idee, wie ich das display aktualisieren kann, ohne
wiat 1
cls
????
danke für eure bemühungen.
gruß
chris
ich habe mal wider ein problem.
ich habe folgenden code, welcher auch einwandfrei funzt, bis auf eine sache:
wenn ich auf taste 1 zum beispiele drücke, zeigt mir das prog die batteriespannung an.
allerdings wird dieser wert (also die anzeige) nicht aktualisiert, wenn ich am labornetzgerät die spannung verstelle!
hier nun der code:
$regfile = "m32def.dat"
$crystal = 16000000
$baud = 9600
$hwstack = 32
$swstack = 32
$framesize = 64
Declare Function Tastenabfrage() As Byte
Declare Sub Batteriespannung()
Config Lcd = 20 * 4
Config Lcdpin = Pin , Db4 = Portc.0 , Db5 = Portc.1 , Db6 = Portc.2 , Db7 = Portc.3 , E = Portc.4 , Rs = Portc.5
Config Lcdbus = 4
Config Adc = Single , Prescaler = Auto
Config Pina.7 = Input
Porta.7 = 1
Config Timer1 = Timer , Prescale = 1024
Enable Timer1
Enable Interrupts
Timer1 = 49910
On Timer1 Isr_von_timer1
Config Timer0 = Counter , Edge = Falling
Enable Timer0
Timer0 = 255
On Timer0 Isr_von_timer0
Dim A As Integer
Dim Taste As Byte
Dim Volt As Single
Dim Secu As Single
Dim Minu As Single
Dim Hour As Single
Dim X As Single
Dim Tasten_flag As Byte
Dim F As Single
Dim T As Single
Dim Freq As Single
Dim N As Long
Dim W As Word
Dim J As Word
Dim Y As Word
Const Ref = 5 / 1023
A = 1
X = 1
Secu = 00
Minu = 00
Hour = 00
T = 0
Tasten_flag = 0
F = 0
Cls
Locate 1 , 4
Lcd "Daten-Terminal "
Locate 2 , 1
Lcd "Hier koennen Sie"
Locate 3 , 1
Lcd "ermittelte Daten"
Locate 4 , 1
Lcd "Speichern!!! "
Do
Taste = Tastenabfrage()
If Taste <> 0 Then
Select Case Taste
Case 1
Cls
N = 0
Y = 1
Tasten_flag = 0
For N = 1 To 100000000
Initlcd
Start Adc
W = Getadc(6)
Volt = W * Ref
Volt = Volt * 5.2941
Cls
Locate 1 , 1
Lcd "Die aktuelle "
Locate 2 , 1
Lcd "Spannung betraegt: "
Locate 3 , 1
Lcd Volt ; " Volt "
W = Getadc(7)
If W < 500 Then
Select Case W
Case 400 To 450
J = 1
Case 330 To 380
J = 2
Case 260 To 305
J = 3
Case 180 To 220
J = 4
Case 90 To 130
J = 5
End Select
End If
If J <> Y Then
Tasten_flag = 1
Exit For
End If
If Tasten_flag = 1 Then
Exit For
End If
Next N
Case 2
Cls
N = 0
Y = 2
Tasten_flag = 0
Writeeeprom Secu , 1
Writeeeprom Minu , 10
Writeeeprom Volt , 20
Cls
Locate 1 , 1
Lcd "Speichern von: "
Locate 2 , 1
Lcd "Frequenz, Laufzeit "
Locate 3 , 1
Lcd "und Batteriespannung"
Locate 4 , 1
Lcd "Daten jetzt abrufbar"
Case 3
Cls
N = 0
Y = 3
Tasten_flag = 0
For N = 1 To 100000000
Initlcd
Freq = F / T
Locate 1 , 1
Lcd "Sekunden = " ; T
Locate 2 , 1
Lcd "Signale = " ; F
Locate 3 , 1
Lcd "==> Frequenz:"
Locate 4 , 1
Lcd Freq ; "Hz"
Start Adc
W = Getadc(7)
If W < 500 Then
Select Case W
Case 400 To 450
J = 1
Case 330 To 380
J = 2
Case 260 To 305
J = 3
Case 180 To 220
J = 4
Case 90 To 130
J = 5
End Select
End If
If J <> Y Then
Tasten_flag = 1
Exit For
End If
If Tasten_flag = 1 Then
Exit For
End If
Next N
Case 4
N = 0
Y = 4
Tasten_flag = 0
For N = 1 To 100000000
Cls
Initlcd
If Secu = 60 Then
Secu = 00
Minu = Minu + 1
Elseif Minu = 60 Then
Minu = 00
Hour = Hour + 1
End If
Locate 2 , 1
Lcd "Zeit = "
Locate 2 , 8
Lcd Hour ; Minu ; Secu ;
Start Adc
W = Getadc(7)
If W < 500 Then
Select Case W
Case 400 To 450
J = 1
Case 330 To 380
J = 2
Case 260 To 305
J = 3
Case 180 To 220
J = 4
Case 90 To 130
J = 5
End Select
End If
If J <> Y Then
Tasten_flag = 1
Exit For
End If
If Tasten_flag = 1 Then
Exit For
End If
Next N
Case 5
Cls
N = 0
Y = 5
Tasten_flag = 0
For N = 1 To 100000000
Initlcd
Readeeprom Secu , 1
Readeeprom Volt , 20
Locate 1 , 1
Lcd Freq ; " Hz "
Locate 2 , 1
Lcd Secu ; " Sekunde(n) "
Locate 3 , 1
Lcd Minu ; " Minute(n) "
Locate 4 , 1
Lcd Volt ; " Volt "
Start Adc
W = Getadc(7)
If W < 500 Then
Select Case W
Case 400 To 450
J = 1
Case 330 To 380
J = 2
Case 260 To 305
J = 3
Case 180 To 220
J = 4
Case 90 To 130
J = 5
End Select
End If
If J <> Y Then
Tasten_flag = 1
Exit For
End If
If Tasten_flag = 1 Then
Exit For
End If
Next N
End Select
End If
Loop
Isr_von_timer1:
Timer1 = 49910
Incr Secu
Incr T
Return
Isr_von_timer0:
Timer0 = 255
Incr F
Return
Function Tastenabfrage() As Byte
Local Ws As Word
Tastenabfrage = 0
Start Adc
Ws = Getadc(7)
If Ws < 500 Then
Select Case Ws
Case 400 To 450
Tastenabfrage = 1
Case 330 To 380
Tastenabfrage = 2
Case 260 To 305
Tastenabfrage = 3
Case 180 To 220
Tastenabfrage = 4
Case 90 To 130
Tastenabfrage = 5
End Select
End If
End Function
Sub Batteriespannung()
End Sub
habt ihr eine idee, wie ich das display aktualisieren kann, ohne
wiat 1
cls
????
danke für eure bemühungen.
gruß
chris