پاسخ : محافظ ولتاژ
و اینم آخر کارم

خازن رو که 100 میکرو گذاشتم درست شد /توی پروتئوس کاملا درست کار می کنه.اینم برنامه:
ولی یه چیزی!چه جوری توی عمل تستش کنم؟! :NO:
یعنی چه جوری برق شهر رو زیر 180 و بالای 240 ببرم؟! :eek:
و اینم آخر کارم

خازن رو که 100 میکرو گذاشتم درست شد /توی پروتئوس کاملا درست کار می کنه.اینم برنامه:
$regfile = "M8def.dat"
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.1 , Rs = Portb.0
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Clock = Soft , Gosub = Sectic
Config Portd = Output
Enable Interrupts
Enable Timer2
'-----------------------------------------------
Dim A As Word , B As Word , Volt As Single , Seco As Byte , Lock As Bit
Cursor Off
Cls
Rele Alias Portd.0
Do
'-----------------------------------------------
Start Adc
B = Getadc(0)
Stop Adc
Waitms 100
Volt = B * 0.77
Home
Lcd "Volt = " ; Fusing(volt , "##.#"
; " [v]"
Lowerline
Lcd Seco ; " "
'----------------------------------------------- down
If Volt < 180 Then
Set Portd.1
Reset Portd.2
Reset Portd.3
Set Rele
Lock = 0
End If
'-----------------------------------------------up
If Volt > 240 Then
Reset Portd.1
Reset Portd.2
Set Portd.3
Set Rele
Lock = 0
End If
'-----------------------------------------------normal
If Volt > 180 And Volt < 240 Then
Lock = 1
End If
'-----------------------------------------------
Loop
End 'end program
Sectic:
If Lock = 1 Then
Incr Seco
If Seco = 240 Then
Seco = 0
Reset Portd.1
Set Portd.2
Reset Portd.3
Reset Rele
End If
End If
Return
$crystal = 1000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.1 , Rs = Portb.0
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Clock = Soft , Gosub = Sectic
Config Portd = Output
Enable Interrupts
Enable Timer2
'-----------------------------------------------
Dim A As Word , B As Word , Volt As Single , Seco As Byte , Lock As Bit
Cursor Off
Cls
Rele Alias Portd.0
Do
'-----------------------------------------------
Start Adc
B = Getadc(0)
Stop Adc
Waitms 100
Volt = B * 0.77
Home
Lcd "Volt = " ; Fusing(volt , "##.#"

Lowerline
Lcd Seco ; " "
'----------------------------------------------- down
If Volt < 180 Then
Set Portd.1
Reset Portd.2
Reset Portd.3
Set Rele
Lock = 0
End If
'-----------------------------------------------up
If Volt > 240 Then
Reset Portd.1
Reset Portd.2
Set Portd.3
Set Rele
Lock = 0
End If
'-----------------------------------------------normal
If Volt > 180 And Volt < 240 Then
Lock = 1
End If
'-----------------------------------------------
Loop
End 'end program
Sectic:
If Lock = 1 Then
Incr Seco
If Seco = 240 Then
Seco = 0
Reset Portd.1
Set Portd.2
Reset Portd.3
Reset Rele
End If
End If
Return
ولی یه چیزی!چه جوری توی عمل تستش کنم؟! :NO:
یعنی چه جوری برق شهر رو زیر 180 و بالای 240 ببرم؟! :eek:
دیدگاه