Hier nun erste Erfolge mit folgenden Listing :
Code:
$regfile = "m8def.dat"
$crystal = 1000000
$hwstack = 40
$swstack = 30
$framesize = 60
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , _
Db7 = Portd.7 , E = Portd.3 , Rs = Portd.2
Config Lcd = 16 * 2
Cursor Off
Cls
Dim Messvolt As Word
Dim Messstrom As Word
Dim Volt As Single
Dim Volt_a As String * 10
Dim Strom As Single
Dim Strom_a As String * 10
Dim Watt As Single
Dim Watt_a As String * 10
Const Spannungsfaktor = 0.0048828125
Const Stromfaktor = 0.0000048828125
Do
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Messvolt = Getadc(0)
Messstrom = Getadc(1)
Volt = Messvolt * Spannungsfaktor
Strom = Messstrom * Stromfaktor
Watt = Volt * Strom
Locate 1 , 1
Lcd "Wattmeter"
Volt_a = Fusing(volt , "#.#.#")
If Len(volt_a) = 3 Then
Volt_a = " " + Volt_a + "V"
Else
Volt_a = Volt_a + "V"
End If
Locate 1 , 12
Lcd Volt_a
Strom_a = Fusing(strom , "#.#.#")
If Len(strom_a) = 3 Then
Strom_a = " " + Strom_a + "A"
Else
Strom_a = Strom_a + "A"
End If
Locate 2 , 12
Lcd Strom_a
Watt_a = Fusing(watt , "#.#.#")
If Len(watt_a) = 3 Then
Watt_a = " " + Watt_a + "W"
Else
Watt_a = Watt_a + "W"
End If
Locate 2 , 3
Lcd Watt_a
Waitms 250
Loop
End
Die Spannung =5 Volt scheint zu stimmen.
Bei der Stromstärke bin ich mir nicht sicher.
gruß Computeropa
Lesezeichen