08-29-2014، 08:43 PM
برنامه به زبان بیسیک :
pw_display.JPG (اندازه 1.17 KB / تعداد دانلود: 26)
کد پیاچپی:
$regfile = "m16def.dat"
$crystal = 8000000
$hwstack = 32
$swstack = 20
$framesize = 32
Config Lcdpin = Pin , Rs = Portb.2 , E = Portb.3 , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7
Config Lcd = 16 * 2
Cursor Off Noblink
Cls
Dim Adcv As Word , Volt As Single
Dim Adca As Word , Amp As Single
Dim P As Single ';Power (P)
Dim R As Single ';Resistance (R)
Const Dif = 5 / 1024
Const Volt_div = 0.152519
Const Amp_div = 0.21978 ';0.0048828125 - Adc Div 5 / 1024
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Do
Adcv = Getadc(0) ';read portA.0 for volt
Adca = Getadc(1) ';read portA.1 for Ampre
Waitms 50
';Calculate
Volt = Adcv * Dif
Amp = Adca * Dif
Volt = Volt / Volt_div
Amp = Amp / Amp_div
P = Volt * Amp
R = Volt / Amp
';show
Locate 1 , 1
If Volt < 10 Then Lcd " "
Lcd Fusing(volt , "##.##") ; " V"
Locate 1 , 12
If P < 100 Then Lcd " "
If P < 10 Then Lcd " "
Lcd Fusing(p , "###.##") ; " W"
Locate 2 , 1
If Amp < 10 Then Lcd " "
Lcd Fusing(amp , "##.##") ; " A"
Locate 2 , 12
If R < 100 Then Lcd " "
If R < 10 Then Lcd " "
Lcd Fusing(r , "###.##") ; " R"
Waitms 150
Loop
End
------
pw_display.JPG (اندازه 1.17 KB / تعداد دانلود: 26)