مرسی آقا رسول بابت کمکتون،
خروجی این آیسی منفیه که با یه پول آپ 10k به مثبت وصله... اصلن به عبارتی مدار تست شدست ولی نمیدونم چرا تو این برنامه و سیستم کار نمیکنه( البته وقتی به یو اس بی وصلش میکنم عالی کار میکنه) ولی وقتی به منبع تغذیه وصلش میکنم کار نمیکنه؟
تنها تفاوتی که تونستم بین این دوتا منبع پیدا کنم تو این مدار اینه که خروجی دیتا زمانی که دریافت نداریم 0.118 mA و زمان دریافت میشه 0.230 mA ولی تو سوئیچینگ زمان عدم دریافت 0.77 و زمان دریافت 0.130 میشه چرا نمیدونم همین طور که گفتم میشه از منبع تغذیه جریان بیشتر کشید ولی انگار میکرو نمیخواد!!!
http://s6.uplod.ir/i/00439/khq5af7n1x37.jpg
http://s6.uplod.ir/i/00439/3lju7psnupu5.jpg
توضیح اینکه اون مقاومت 330 در اصل وصله فقط موقع عکس اینشکلی بود
راستی با منبع 700 mA هم امتحان کردم ولی جواب نداد!!!
این هم کد برنامه
کد:
$regfile = "m8def.dat"
$crystal = 8000000
Config Timer1 = Timer , Prescale = 256
Config Timer2 = Timer , Prescale = 256
Timer1 = 34286
Timer2 = 0
Config Portc = Output
''''''''''''''''''''''
Ddrd.0 = 1 : Ddrd.1 = 1 : Ddrb.1 = 1 : Ddrd.3 = 1 : Ddrd.4 = 1 : Reset Portd.4
'''''''''switches'''''
Ddrd.5 = 0 : Ddrd.6 = 0 : Ddrd.7 = 0 : Ddrb.0 = 0
Portd.5 = 1 : Portd.6 = 1 : Portd.7 = 1 : Portb.0 = 1
''''''''sensor''''''''
Ddrd.2 = 0
'Config Int0 = Low Level
'On Int0 Irc
'Enable Int0
''''''''''''''''''''''
Declare Sub Heart
Declare Sub Remote
Declare Sub Yes
Declare Sub No
Declare Sub Check
''''''''''''''''''''''
L1 Alias Portc.0
L2 Alias Portc.1
L3 Alias Portc.2
L4 Alias Portc.3
L5 Alias Portc.4
L6 Alias Portc.5
L7 Alias Portd.0
L8 Alias Portd.1
L9 Alias Portb.1
T1 Alias Portd.3
S4 Alias Pinb.0
S3 Alias Pind.7
S2 Alias Pind.6
S1 Alias Pind.5
Lamp Alias Portd.4
''''''''''''''''''''''
Dim Eb(48) As Eram Word , J(48) As Word
Dim H As Integer , A As Byte , C As Byte , L As Byte , B1 As Bit , I1 As Byte , I2 As Byte , Ii1 As Bit , F As Byte
Dim M1 As Eram Byte , M2 As Eram Integer
Dim Aham As Byte , Cham As Byte , Oham(24) As Word , Zham(24) As Word , Zzham(5) As Word , Ooham(5) As Word , Numham(4) As Word , Bham As Byte , Yham As Byte , Checkham As Bit , Checham As Bit
H = 180 : A = 0 : C = 0 : L = 0 : B1 = 0 : F = 100
''''''''''''''''''''''
Enable Interrupts
Enable Timer1
Enable Timer2
On Timer1 Lam
If M1 = 0 Then
Reset Lamp
Set T1
If M2 > 0 Then
H = M2
Else
H = 180
End If
Gosub Lam
Start Timer1
Else
Set Lamp
Reset T1
H = 180
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
B1 = 0
End If
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
'''''''''''''''Main''''''''''''
Do
If B1 = 1 Then Call Heart
Call Check
Loop
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Lam:
Timer1 = 34286
If L < 60 Then
Incr L
Else
L = 0 : B1 = 0
Decr H
M2 = H
If H <= 10 Then
Select Case H
Case 10
Set L1
Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
Case 9
Set L2 : Set L1
Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
Case 8
Set L3 : Set L2 : Set L1
Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
Case 7
Set L4 : Set L3 : Set L2 : Set L1
Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
Case 6
Set L5 : Set L4 : Set L3 : Set L2 : Set L1
Reset L6 : Reset L7 : Reset L8 : Reset L9
Case 5
Set L6 : Set L5 : Set L4 : Set L3 : Set L2 : Set L1
Reset L7 : Reset L8 : Reset L9
Case 4
Set L7 : Set L6 : Set L5 : Set L4 : Set L3 : Set L2 : Set L1
Reset L8 : Reset L9
Case 3
Set L8 : Set L7 : Set L6 : Set L5 : Set L4 : Set L3 : Set L2 : Set L1
Reset L9
Case 2
Set L9 : Set L8 : Set L7 : Set L6 : Set L5 : Set L4 : Set L3 : Set L2 : Set L1
Case 1
B1 = 1
F = 100
Case 0
Stop Timer1
H = 180
Timer1 = 34286
Set Lamp
M1 = 1
Reset T1
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
B1 = 0
End Select
End If
End If
'If Checkham = 1 Then
' If Checham = 1 Then
' Checkham = 0
' Checham = 0
' Goto Yyy
' Else
' Set Checham
' End If
'End If
Return
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Sub Heart
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Set L1 : Set L2 : Set L3 : Set L4 : Set L5 : Set L6 : Set L7 : Set L8 : Set L9
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
Set L1 : Set L2 : Set L3 : Set L4 : Set L5 : Set L6 : Set L7 : Set L8 : Set L9
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Set L1 : Set L2 : Set L3 : Set L4 : Set L5 : Set L6 : Set L7 : Set L8 : Set L9
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
'''''''''''''''''''
Call Check
If B1 = 0 Then Exit Sub
'''''''''''''''''''
Waitms F
If F > 10 Then F = F - 10
End Sub
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Sub Remote
Select Case C
Case 4
If Lamp = 1 Then
Call Yes
Start Timer1
H = 180
Reset Lamp
M1 = 0
Set T1
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
Else
Stop Timer1
Call Yes
H = 180
Timer1 = 34286
Set Lamp
M1 = 1
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
Set T1
Waitms 200
Reset T1
End If
''''''''''''''''''''''''''
Case 8
If Lamp = 1 Then
Call No
Else
If T1 = 0 Then
Call No
Else
If H < 25 Then
Call No
Else
H = H - 15
Call Yes
End If
End If
End If
''''''''''''''''''''''''''
Case 12
If T1 = 1 Then
If B1 = 1 Then
Ii1 = 1
B1 = 0
Else
Ii1 = 0
I1 = H
H = 180
End If
Call Yes
Stop Timer1
Reset T1
Else
If Lamp = 0 Then
If Ii1 = 1 Then
H = I1
B1 = 1
Call Yes
Else
B1 = 0
H = I1
Call Yes
End If
Start Timer1
Set T1
Else
Call No
End If
End If
''''''''''''''''''''''''''
Case 16
If Lamp = 1 Then
Call No
Else
If T1 = 0 Then
Call No
Else
If H > 345 Then
Call No
Else
If H < 11 Then
H = 60
Call Yes
Else
H = H + 15
Call Yes
End If
End If
End If
End If
End Select
C = 0
End Sub
''''''''''''''''''''''''''
''''''''''''''''''''''''''
''''''''''''''''''''''''''
Sub Yes
If B1 = 1 Then
B1 = 0
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
Waitms 100
Set L1 : Waitms 50
Set L2 : Waitms 50
Set L3 : Waitms 50
Set L4 : Waitms 50
Set L5 : Waitms 50
Set L6 : Waitms 50
Set L7 : Waitms 50
Set L8 : Waitms 50
Set L9 : Waitms 50
Reset L9 : Waitms 50
Reset L8 : Waitms 50
Reset L7 : Waitms 50
Reset L6 : Waitms 50
Reset L5 : Waitms 50
Reset L4 : Waitms 50
Reset L3 : Waitms 50
Reset L2 : Waitms 50
Reset L1 : Waitms 50
If H = 1 Then B1 = 1
Else
If L1 = 1 Then
Reset L1
Waitms 50
Set L1
Else
Set L1
Waitms 50
End If
If L2 = 1 Then
Reset L2
Waitms 50
Set L2
Else
Set L2
Waitms 50
End If
If L3 = 1 Then
Reset L3
Waitms 50
Set L3
Else
Set L3
Waitms 50
End If
If L4 = 1 Then
Reset L4
Waitms 50
Set L4
Else
Set L4
Waitms 50
End If
If L5 = 1 Then
Reset L5
Waitms 50
Set L5
Else
Set L5
Waitms 50
End If
If L6 = 1 Then
Reset L6
Waitms 50
Set L6
Else
Set L6
Waitms 50
End If
If L7 = 1 Then
Reset L7
Waitms 50
Set L7
Else
Set L7
Waitms 50
End If
If L8 = 1 Then
Reset L8
Waitms 50
Set L8
Else
Set L8
Waitms 50
End If
If L9 = 1 Then
Reset L9
Waitms 50
Set L9
Else
Set L9
Waitms 50
End If
If H > 2 Then
Reset L9 : Waitms 50
Else
Reset L9 : Waitms 50 : Set L9
End If
If H > 3 Then
Reset L8 : Waitms 50
Else
Reset L8 : Waitms 50 : Set L8
End If
If H > 4 Then
Reset L7 : Waitms 50
Else
Reset L7 : Waitms 50 : Set L7
End If
If H > 5 Then
Reset L6 : Waitms 50
Else
Reset L6 : Waitms 50 : Set L6
End If
If H > 6 Then
Reset L5 : Waitms 50
Else
Reset L5 : Waitms 50 : Set L5
End If
If H > 7 Then
Reset L4 : Waitms 50
Else
Reset L4 : Waitms 50 : Set L4
End If
If H > 8 Then
Reset L3 : Waitms 50
Else
Reset L3 : Waitms 50 : Set L3
End If
If H > 9 Then
Reset L2 : Waitms 50
Else
Reset L2 : Waitms 50 : Set L2
End If
If H > 10 Then
Reset L1 : Waitms 50
Else
Reset L1 : Waitms 50 : Set L1
End If
End If
End Sub
''''''''''''''''''''''''''
''''''''''''''''''''''''''
''''''''''''''''''''''''''
Sub No
If B1 = 1 Then
B1 = 0
Set L1 : Set L2 : Set L3 : Set L4 : Set L5 : Set L6 : Set L7 : Set L8 : Set L9
Waitms 900
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
B1 = 1
Else
I2 = 0
If L1 = 1 Then I2 = 1 : If L2 = 1 Then I2 = 2 : If L3 = 1 Then I2 = 3
If L4 = 1 Then I2 = 4 : If L5 = 1 Then I2 = 5 : If L6 = 1 Then I2 = 6
If L7 = 1 Then I2 = 7 : If L8 = 1 Then I2 = 8 : If L9 = 1 Then I2 = 9
Set L1 : Set L2 : Set L3 : Set L4 : Set L5 : Set L6 : Set L7 : Set L8 : Set L9
Waitms 900
If I2 = 0 Then
Reset L1 : Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
End If
If I2 = 1 Then
Reset L2 : Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
End If
If I2 = 2 Then
Reset L3 : Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
End If
If I2 = 3 Then
Reset L4 : Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
End If
If I2 = 4 Then
Reset L5 : Reset L6 : Reset L7 : Reset L8 : Reset L9
End If
If I2 = 5 Then
Reset L6 : Reset L7 : Reset L8 : Reset L9
End If
If I2 = 6 Then
Reset L7 : Reset L8 : Reset L9
End If
If I2 = 7 Then
Reset L8 : Reset L9
End If
If I2 = 8 Then
Reset L9
End If
End If
End Sub
''''''''''''''''''''''''''
''''''''''''''''''''''''''
''''''''''''''''''''''''''
Sub Check
C = 0
Debounce Pind.2 , 0 , Irc
Debounce S1 , 0 , Sw1
Debounce Pind.2 , 0 , Irc
Debounce S2 , 0 , Sw2
Debounce Pind.2 , 0 , Irc
Debounce S3 , 0 , Sw3
Debounce Pind.2 , 0 , Irc
Debounce S4 , 0 , Sw4
Lo:
End Sub
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Sw1:
C = 4
Call Remote
Goto Lo
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Sw2:
C = 8
Call Remote
Goto Lo
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Sw3:
C = 16
Call Remote
Goto Lo
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Sw4:
C = 12
Call Remote
Goto Lo
'''''''''''''''''''''''''''
'''''''''''''''''''''''''''
Irc:
Set L6
Start Timer2
'Disable Int0
'Checkham = 1
'Checham = 0
'Ddrd.2 = 0
'Bitwait Pind.2 , Reset
'Checkham = 0
'Checham = 0
''Goto Yyy
'Hlh:
'Start Timer1
'Disable Interrupts
'Bham = 1
Set L2 'lll
'C = 0
'Bham = 1
'Timer1 = 0
'Do
' Do
' If Timer1 > 200 Then Goto Ch
' Loop Until Pind.2 = 1
' Oham(bham) = Timer1
' Timer1 = 0
' Do
' If Timer1 > 200 Then Goto Ch
' Loop Until Pind.2 = 0
' Zham(bham) = Timer1
' Timer1 = 0
' Incr Bham
' Ch:
'Loop Until Bham > 24 Or Timer1 > 200
Timer2 = 0
Do
Do
If Timer2 > 200 Then Goto Ch
Loop Until Pind.2 = 1
J(bham) = Timer2
Timer2 = 0
Incr Bham
Do
If Timer2 > 200 Then Goto Ch
Loop Until Pind.2 = 0
J(bham) = Timer2
Timer2 = 0
Incr Bham
Ch:
Loop Until Bham > 48 Or Timer2 > 200
Waitms 200
Reset L2
Set L3
For Bham = 1 To 48
Eb(bham) = J(bham)
J(bham) = 0
Next Bham
Waitms 700
Reset L3 'lll offf
'Numham(1) = 0 : Numham(2) = 0 : Numham(3) = 0 : Numham(4) = 0
'Cham = 20
'For Aham = 1 To 20
' If Oham(aham) > 70 And Oham(aham) < 115 Then
'
' Cham = Aham - 1
' For Bham = 1 To 5
' Yham = Cham + Bham
' Ooham(bham) = Oham(yham)
' Zzham(bham) = Zham(yham)
' Next Bham
'
' Bham = 0
' If Ooham(2) > 44 And Ooham(2) < 62 Then
' Cham = 35
' If Zzham(3) =< Cham Then Bham = 1
' If Zzham(4) =< Cham Then Bham = Bham + 2
' If Zzham(5) =< Cham Then Bham = Bham + 4
' End If
'
' Select Case Bham
' Case 1 : Incr Numham(1)
' Case 2 : Incr Numham(2)
' Case 3 : Incr Numham(3)
' Case 4 : Incr Numham(4)
' Case Else : Bham = 1 'none
' End Select
'
' End If
'Re:
'Next Aham
'For Aham = 1 To 24
' Oham(aham) = 0 : Zham(aham) = 0
'Next Aham
'
'
'Aham = 222
'If Numham(4) >= 2 Then Aham = 4
'If Numham(3) >= 2 Then Aham = 3
'If Numham(2) >= 2 Then Aham = 2
'If Numham(1) >= 2 Then Aham = 1
'Select Case Aham
'Case 1
'C = 4
'Case 2
'C = 16
'Case 3
'C = 12
'Case 4
'C = 8
'End Select
'If Aham > 0 And Aham < 5 Then
' Call Remote
'End If
'Ex:
Yyy:
'Enable Interrupts
'Enable Int0
Stop Timer2
Waitms 1000
Reset L6
Goto Lo
همین طور که میبینید وقفه رو هم امتحان کردم اما جواب نداد
رسیدن به آرزو لذت بخشه، اما تلاش برای رسیدن به آرزو لذت بخش ترین قسمت زندگیه...