۰۹-مرداد-۱۳۸۹, ۱۹:۰۵:۴۱
۰۹-مرداد-۱۳۸۹, ۲۰:۱۴:۱۹
مهندس اینو ببین :
http://www.iranled.com/forum/showthread....#pid111795
و تایپیک های زیر رو هم ببین :
http://www.iranled.com/forum/showthread.php?tid=16565
http://www.iranled.com/forum/showthread.php?tid=11059
مدار زیر چنین کارهایی می کند :
1- دماسنج با دقت 0.25 درجه
2- ساعت با نمایش ثانیه و به صورت 24 ساعته با تنظیم منو بندی شده و راحت ! ( نکته مهمی بودش )
3- کرنومتر با دقت 1/128 ثانیه
4- شمارنده خودرو پارکینگی با روش مادون قرمز به همراه کنترل دستی
5- فرکانس متر با دقت هرتز و حداکثر یک مگاهرتز
6- شمارنده دستی ( بهش صلوات شمار هم می گن )
7- نمایش حروف روان !!!!
و اینم برنامه مدار فوق :
و دریافت فایل های مورد نیاز مثل نقشه پروتئوس و فایل بسکام و ...
DOWNLOAD
توضیحات مدار و برنامه و هم بعدا که وقت کردم می ذارم !
فقط همینو بگم که با دکمه S می تونید مد های مختلف رو عوض کنید !
http://www.iranled.com/forum/showthread....#pid111795
و تایپیک های زیر رو هم ببین :
http://www.iranled.com/forum/showthread.php?tid=16565
http://www.iranled.com/forum/showthread.php?tid=11059
7 مدار در یک مدار با 10 عدد سون سگمنت و ATmega32
مدار زیر چنین کارهایی می کند :
1- دماسنج با دقت 0.25 درجه
2- ساعت با نمایش ثانیه و به صورت 24 ساعته با تنظیم منو بندی شده و راحت ! ( نکته مهمی بودش )
3- کرنومتر با دقت 1/128 ثانیه
4- شمارنده خودرو پارکینگی با روش مادون قرمز به همراه کنترل دستی
5- فرکانس متر با دقت هرتز و حداکثر یک مگاهرتز
6- شمارنده دستی ( بهش صلوات شمار هم می گن )
7- نمایش حروف روان !!!!
و اینم برنامه مدار فوق :
کد php:
$regfile = "m32def.dat" : $crystal = 8000000
Config Adc = Single , Prescaler = Auto , Reference = Internal
Ddra.3 = 0 : Ddra.4 = 0 : Ddra.5 = 0 : Ddra.6 = 0 : Ddra.7 = 0
Ddrc = 63 : Ddrd = 255 : Ddrb = &B11111101
Dim B As Byte , F As Byte , Sectic As Byte , Ff As Byte
Dim Out_1 As Byte , Out_2 As Byte , Out_3 As Byte , Out_4 As Byte
Dim Out_5 As Byte , Out_6 As Byte , Out_7 As Byte , Out_8 As Byte
Dim Out_9 As Byte , Out_10 As Byte , Fff As Byte , Ww As Word
Dim Ol As Byte , Frq As Long , W As Word , L As Long , E As Word , C As Word
Dim Cornometr_ms As Word , Cornometr_s As Byte , Cornometr_m As Byte , Cornometr_h As Word
Dim Dama As Word , Car As Word
Dim Cc As Byte , Mm As Byte , Ss As Byte
Config Timer2 = Timer , Async = On , Prescale = 1
On Timer2 Sectic : Enable Interrupts : Enable Timer2
Config Timer1 = Counter , Edge = Rising : On Timer1 Ol : Enable Timer1
Config Timer0 = Timer , Prescale = 8 : On Timer0 Scan : Enable Timer0
Start Timer0 : Start Timer2 : F = 2 : Gosub Res_data : Gosub Sectic : Sectic = 126
'###############################################################################
Star:
Do
Debounce Pina.3 , 1 , Set1
Loop
Set1:
If F = 7 Then :
F = 2 : Start Timer2
L = Frq / 100000 : Out_8 = L + 1 : L = L * 100000 : Frq = Frq - L
L = Frq / 10000 : Out_7 = L + 1 : L = L * 10000 : Frq = Frq - L
L = Frq / 1000 : Out_6 = L + 1 : L = L * 1000 : Frq = Frq - L
L = Frq / 100 : Out_5 = L + 1 : L = L * 100 : Frq = Frq - L
L = Frq / 10 : Out_4 = L + 1 : L = L * 10 : Frq = Frq - L
Out_3 = Frq + 1 : Out_10 = 11 : Out_9 = 12 : Out_2 = 13 : Out_1 = 14
Elseif F = 2 Then :
F = 3 : Stop Timer2 : Stop Timer1 : Gosub Res_data
Do
Debounce Pina.3 , 1 , Set2
Debounce Pina.4 , 1 , Set3 , Gosub
Debounce Pina.5 , 1 , Set4 , Gosub
Loop
Set2:
Stop Timer2 : Gosub Res_data : Goto Set1
Set3:
Start Timer2 : Return
Set4:
Stop Timer2
For C = 0 To 50000
If Pina.5 = 0 Then Return
Next
Gosub Res_data : Return
Elseif F = 3 Then :
F = 4 : Gosub Res_data : Start Timer2
Elseif F = 4 Then :
F = 5 : Stop Timer2 : Gosub Res_data
Do
Debounce Pina.3 , 1 , Set1
Debounce Pina.4 , 1 , Set6 , Gosub
Debounce Pina.5 , 1 , Set7 , Gosub
Debounce Pina.6 , 1 , In_car , Gosub
Debounce Pina.7 , 1 , Out_car , Gosub
Loop
Set6:
Incr Out_1
If Out_1 > 10 Then :
Out_1 = 1 : Incr Out_2
End If
If Out_2 > 10 Then :
Out_2 = 1 : Incr Out_3
End If
If Out_3 > 10 Then :
Out_3 = 1 : Incr Out_4
End If
If Out_4 > 10 Then :
Out_4 = 1 : Incr Out_5
End If
If Out_5 > 10 Then :
Out_5 = 1 : Incr Out_6
End If
If Out_6 > 10 Then :
Out_6 = 1 : Incr Out_7
End If
If Out_7 > 10 Then :
Out_7 = 1 : Incr Out_8
End If
If Out_8 > 10 Then :
Out_8 = 1 : Incr Out_9
End If
If Out_9 > 10 Then :
Out_9 = 1 : Incr Out_10
End If
If Out_10 > 10 Then Out_10 = 1
For C = 0 To 30000
If Pina.4 = 0 Then Return
Next
Do
Incr Out_1
If Out_1 > 10 Then :
Out_1 = 1 : Incr Out_2
End If
If Out_2 > 10 Then :
Out_2 = 1 : Incr Out_3
End If
If Out_3 > 10 Then :
Out_3 = 1 : Incr Out_4
End If
If Out_4 > 10 Then :
Out_4 = 1 : Incr Out_5
End If
If Out_5 > 10 Then :
Out_5 = 1 : Incr Out_6
End If
If Out_6 > 10 Then :
Out_6 = 1 : Incr Out_7
End If
If Out_7 > 10 Then :
Out_7 = 1 : Incr Out_8
End If
If Out_8 > 10 Then :
Out_8 = 1 : Incr Out_9
End If
If Out_9 > 10 Then :
Out_9 = 1 : Incr Out_10
End If
If Out_10 > 10 Then Out_10 = 1
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Loop
Set7:
Decr Out_1
If Out_1 = 0 Then :
Out_1 = 10 : Decr Out_2
End If
If Out_2 = 0 Then :
Out_2 = 10 : Decr Out_3
End If
If Out_3 = 0 Then :
Out_3 = 10 : Decr Out_4
End If
If Out_4 = 0 Then :
Out_4 = 10 : Decr Out_5
End If
If Out_5 = 0 Then :
Out_5 = 10 : Decr Out_6
End If
If Out_6 = 0 Then :
Out_6 = 10 : Decr Out_7
End If
If Out_7 = 0 Then :
Out_7 = 10 : Decr Out_8
End If
If Out_8 = 0 Then :
Out_8 = 10 : Decr Out_9
End If
If Out_9 = 0 Then :
Out_9 = 10 : Decr Out_10
End If
If Out_10 = 0 Then Out_10 = 10
For C = 0 To 30000
If Pina.5 = 0 Then Return
Next
Do
Decr Out_1
If Out_1 = 0 Then :
Out_1 = 10 : Decr Out_2
End If
If Out_2 = 0 Then :
Out_2 = 10 : Decr Out_3
End If
If Out_3 = 0 Then :
Out_3 = 10 : Decr Out_4
End If
If Out_4 = 0 Then :
Out_4 = 10 : Decr Out_5
End If
If Out_5 = 0 Then :
Out_5 = 10 : Decr Out_6
End If
If Out_6 = 0 Then :
Out_6 = 10 : Decr Out_7
End If
If Out_7 = 0 Then :
Out_7 = 10 : Decr Out_8
End If
If Out_8 = 0 Then :
Out_8 = 10 : Decr Out_9
End If
If Out_9 = 0 Then :
Out_9 = 10 : Decr Out_10
End If
If Out_10 = 0 Then Out_10 = 10
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Loop
In_car:
If Pina.7 = 0 Then :
For W = 0 To 60000
Debounce Pina.7 , 1 , In_car2
If Pina.6 = 0 Then Return
Next
Return
Else :
Return
End If
In_car2:
Gosub Set6 : Return
Out_car:
If Pina.6 = 0 Then :
For W = 0 To 60000
Debounce Pina.6 , 1 , Out_car2
If Pina.7 = 0 Then Return
Next
Return
Else :
Return
End If
Out_car2:
Gosub Set7 : Return
Elseif F = 5 Then : 'DAMASANJ
F = 6 : Gosub Res_data : Start Timer2
Elseif F = 6 Then :
F = 7 : Gosub Res_data : Start Timer2
Saat:
Ff = 0 : Waitms 100
Do
Debounce Pina.3 , 1 , Set_time
Loop
Set_time:
For C = 0 To 50000
If Pina.3 = 0 Then Goto Set1
Next
Ff = 1
Do
Debounce Pina.3 , 1 , Set_mm
Debounce Pina.4 , 1 , Incr_cc , Gosub
Debounce Pina.5 , 1 , Decr_cc , Gosub
Loop
Incr_cc:
Incr Cc
If Cc > 23 Then Cc = 0
C = Cc : Ww = C / 10 : Out_9 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_8 = C + 1
For C = 0 To 30000
If Pina.4 = 0 Then Return
Next
Do
Incr Cc
If Cc > 23 Then Cc = 0
C = Cc : Ww = C / 10 : Out_9 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_8 = C + 1
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Loop
Decr_cc:
Decr Cc
If Cc > 23 Then Cc = 23
C = Cc : Ww = C / 10 : Out_9 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_8 = C + 1
For C = 0 To 30000
If Pina.5 = 0 Then Return
Next
Do
Decr Cc
If Cc > 23 Then Cc = 23
C = Cc : Ww = C / 10 : Out_9 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_8 = C + 1
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Loop
Set_mm:
Ff = 2
Do
Debounce Pina.3 , 1 , Saat
Debounce Pina.4 , 1 , Incr_mm , Gosub
Debounce Pina.5 , 1 , Decr_mm , Gosub
Loop
Incr_mm:
Incr Mm
If Mm > 59 Then Mm = 0
C = Mm : Ww = C / 10 : Out_6 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_5 = C + 1
For C = 0 To 30000
If Pina.4 = 0 Then Return
Next
Do
Incr Mm
If Mm > 59 Then Mm = 0
C = Mm : Ww = C / 10 : Out_6 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_5 = C + 1
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Loop
Decr_mm:
Decr Mm
If Mm > 59 Then Mm = 59
C = Mm : Ww = C / 10 : Out_6 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_5 = C + 1
For C = 0 To 30000
If Pina.5 = 0 Then Return
Next
Do
Decr Mm
If Mm > 59 Then Mm = 59
C = Mm : Ww = C / 10 : Out_6 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_5 = C + 1
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Loop
End If
Goto Star
Res_data:
Out_1 = 1 : Out_2 = 1 : Out_3 = 1 : Out_4 = 1 : Out_5 = 1 : Out_6 = 1
Out_7 = 1 : Out_8 = 1 : Out_9 = 1 : Out_10 = 1 : Sectic = 255
Cornometr_ms = 0 : Cornometr_s = 0 : Cornometr_m = 0 : Cornometr_h = 0
If F = 3 Then :
Out_4 = 16 : Out_6 = 16 : Out_8 = 16
End If
Return
'###############################################################################
Sectic:
Incr Sectic
If F = 2 Then :
If Sectic = 127 Then :
Stop Timer1 : W = Timer1 : Timer1 = 0 : Start Timer1
Frq = Ol * 65536 : Frq = Frq + W : Ol = 0 : If Frq > 999999 Then Frq = 999999
L = Frq / 100000 : Out_8 = L + 1 : L = L * 100000 : Frq = Frq - L
L = Frq / 10000 : Out_7 = L + 1 : L = L * 10000 : Frq = Frq - L
L = Frq / 1000 : Out_6 = L + 1 : L = L * 1000 : Frq = Frq - L
L = Frq / 100 : Out_5 = L + 1 : L = L * 100 : Frq = Frq - L
L = Frq / 10 : Out_4 = L + 1 : L = L * 10 : Frq = Frq - L
Out_3 = Frq + 1 : Out_10 = 11 : Out_9 = 12 : Out_2 = 13 : Out_1 = 14
End If
Elseif F = 3 Then :
Cornometr_ms = Sectic * 8 : W = Cornometr_ms / 59
Cornometr_ms = Cornometr_ms - W : If Cornometr_ms > 999 Then Cornometr_ms = 0
If Sectic = 127 Then :
Incr Cornometr_s
If Cornometr_s > 59 Then :
Cornometr_s = 0 : Incr Cornometr_m
End If
If Cornometr_m > 59 Then :
Cornometr_m = 0 : Incr Cornometr_h
End If
End If
E = Cornometr_ms : W = E / 100 : Out_3 = W + 1 : W = W * 100 : E = E - W
W = E / 10 : Out_2 = W + 1 : W = W * 10 : E = E - W : Out_1 = E + 1
E = Cornometr_s : W = E / 10 : Out_5 = W + 1 : W = W * 10 : E = E - W : Out_4 = E + 16
E = Cornometr_m : W = E / 10 : Out_7 = W + 1 : W = W * 10 : E = E - W : Out_6 = E + 16
E = Cornometr_h : W = E / 100 : Out_10 = W + 1 : W = W * 100 : E = E - W
W = E / 9 : Out_9 = W + 1 : W = W * 10 : E = E - W : Out_8 = E + 16
Elseif F = 4 Then :
If Sectic = 127 Then :
Incr Fff : If Fff = 21 Then Fff = 0
Select Case Fff
Case 0 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 1 :
Out_10 = 1 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 2 :
Out_10 = 2 : Out_9 = 1 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 3 :
Out_10 = 3 : Out_9 = 2 : Out_8 = 1 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 4 :
Out_10 = 4 : Out_9 = 3 : Out_8 = 2 : Out_7 = 1 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 5 :
Out_10 = 5 : Out_9 = 4 : Out_8 = 3 : Out_7 = 2 : Out_6 = 1
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 6 :
Out_10 = 6 : Out_9 = 5 : Out_8 = 4 : Out_7 = 3 : Out_6 = 2
Out_5 = 1 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 7 :
Out_10 = 7 : Out_9 = 6 : Out_8 = 5 : Out_7 = 4 : Out_6 = 3
Out_5 = 2 : Out_4 = 1 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 8 :
Out_10 = 8 : Out_9 = 7 : Out_8 = 6 : Out_7 = 5 : Out_6 = 4
Out_5 = 3 : Out_4 = 2 : Out_3 = 1 : Out_2 = 0 : Out_1 = 0
Case 9 :
Out_10 = 9 : Out_9 = 8 : Out_8 = 7 : Out_7 = 6 : Out_6 = 5
Out_5 = 4 : Out_4 = 3 : Out_3 = 2 : Out_2 = 1 : Out_1 = 0
Case 10 :
Out_10 = 10 : Out_9 = 9 : Out_8 = 8 : Out_7 = 7 : Out_6 = 6
Out_5 = 5 : Out_4 = 4 : Out_3 = 3 : Out_2 = 2 : Out_1 = 1
Case 11 :
Out_10 = 0 : Out_9 = 10 : Out_8 = 9 : Out_7 = 8 : Out_6 = 7
Out_5 = 6 : Out_4 = 5 : Out_3 = 4 : Out_2 = 3 : Out_1 = 2
Case 12 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 10 : Out_7 = 9 : Out_6 = 8
Out_5 = 7 : Out_4 = 6 : Out_3 = 5 : Out_2 = 4 : Out_1 = 3
Case 13 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 10 : Out_6 = 9
Out_5 = 8 : Out_4 = 7 : Out_3 = 6 : Out_2 = 5 : Out_1 = 4
Case 14 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 10
Out_5 = 9 : Out_4 = 8 : Out_3 = 7 : Out_2 = 6 : Out_1 = 5
Case 15 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 10 : Out_4 = 9 : Out_3 = 8 : Out_2 = 7 : Out_1 = 6
Case 16 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 10 : Out_3 = 9 : Out_2 = 8 : Out_1 = 7
Case 17 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 10 : Out_2 = 9 : Out_1 = 8
Case 18 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 10 : Out_1 = 9
Case 19 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 10
Case 20 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
End Select
End If
Elseif F = 6 Then :
If Sectic = 127 Then :
Start Adc : Dama = Getadc(0) : Stop Adc : Dama = Dama * 25
L = Dama / 100000 : Out_8 = L + 1 : L = L * 100000 : Dama = Dama - L
L = Dama / 10000 : Out_7 = L + 1 : L = L * 10000 : Dama = Dama - L
L = Dama / 1000 : Out_6 = L + 1 : L = L * 1000 : Dama = Dama - L
L = Dama / 100 : Out_5 = L + 16 : L = L * 100 : Dama = Dama - L
L = Dama / 10 : Out_4 = L + 1 : L = L * 10 : Dama = Dama - L
Out_3 = Dama + 1 : Out_10 = 27 : Out_9 = 28 : Out_8 = 12 : Out_2 = 29 : Out_1 = 30
End If
Elseif F = 7 Then :
If Sectic = 127 Then :
Ss = Ss + 1
If Ss > 59 Then :
Ss = 0 : Mm = Mm + 1
End If
If Mm > 59 Then :
Mm = 0 : Cc = Cc + 1
End If
If Cc > 23 Then :
Cc = 0
End If
E = Ss : W = E / 10 : Out_3 = W + 1 : W = W * 10 : E = E - W : Out_2 = E + 1
E = Mm : W = E / 10 : Out_6 = W + 1 : W = W * 10 : E = E - W : Out_5 = E + 1
E = Cc : W = E / 10 : Out_9 = W + 1 : W = W * 10 : E = E - W : Out_8 = E + 1
Out_4 = 12 : Out_7 = 12 : Out_1 = 0 : Out_10 = 0
Elseif Sectic = 63 Then :
Out_4 = 0 : Out_7 = 0
E = Mm : W = E / 10 : Out_6 = W + 1 : W = W * 10 : E = E - W : Out_5 = E + 1
E = Cc : W = E / 10 : Out_9 = W + 1 : W = W * 10 : E = E - W : Out_8 = E + 1
Elseif Sectic = 31 Then :
If Ff = 1 Then : Out_8 = 0 : Out_9 = 0
Elseif Ff = 2 Then : Out_6 = 0 : Out_5 = 0
End If
Elseif Sectic = 95 Then :
If Ff = 1 Then : Out_8 = 0 : Out_9 = 0
Elseif Ff = 2 Then : Out_6 = 0 : Out_5 = 0
End If
End If
End If
If Sectic > 126 Then Sectic = 255
Return
Ol:
Incr Ol
Return
'###############################################################################
Scan:
Incr B : If B = 11 Then B = 1
Reset Portb.4 : Reset Portb.5 : Reset Portb.6 : Reset Portb.7 : Reset Portc.0
Reset Portc.1 : Reset Portc.2 : Reset Portc.3 : Reset Portc.4 : Reset Portc.5
Select Case B
Case 1 :
Portd = Lookup(out_1 , Number) : Set Portb.7
Case 2 :
Portd = Lookup(out_2 , Number) : Set Portb.6
Case 3 :
Portd = Lookup(out_3 , Number) : Set Portb.5
Case 4 :
Portd = Lookup(out_4 , Number) : Set Portb.4
Case 5 :
Portd = Lookup(out_5 , Number) : Set Portc.5
Case 6 :
Portd = Lookup(out_6 , Number) : Set Portc.4
Case 7 :
Portd = Lookup(out_7 , Number) : Set Portc.3
Case 8 :
Portd = Lookup(out_8 , Number) : Set Portc.2
Case 9 :
Portd = Lookup(out_9 , Number) : Set Portc.1
Case 10 :
Portd = Lookup(out_10 , Number) : Set Portc.0
End Select
Return
'###############################################################################
Number:
Data 0 , &B00111111 , &B00000110 , &B01011011 , &B01001111 , &B01100110 , &B01101101 _
, &B01111101 , &B00000111 , &B01111111 , &B01101111 , &B01110001 , &B01001000 , &B01110110 _
, &B01001001 , 0 , &B10111111 , &B10000110 , &B11011011 , &B11001111 , &B11100110 , &B11101101_
, &B11111101 , &B10000111 , &B11111111 , &B01101111 , 26 , &B00110001 , &B01111001 , &B00000001 , &B01011000
و دریافت فایل های مورد نیاز مثل نقشه پروتئوس و فایل بسکام و ...
DOWNLOAD
توضیحات مدار و برنامه و هم بعدا که وقت کردم می ذارم !
فقط همینو بگم که با دکمه S می تونید مد های مختلف رو عوض کنید !
۰۳-مهر-۱۳۸۹, ۲۳:۱۹:۳۰
(۰۹-مرداد-۱۳۸۹, ۲۰:۱۴:۱۹)Gawky نوشته است: [ -> ]مهندس اینو ببین :
http://www.iranled.com/forum/showthread....#pid111795
و تایپیک های زیر رو هم ببین :
http://www.iranled.com/forum/showthread.php?tid=16565
http://www.iranled.com/forum/showthread.php?tid=11059
7 مدار در یک مدار با 10 عدد سون سگمنت و ATmega32
مدار زیر چنین کارهایی می کند :
1- دماسنج با دقت 0.25 درجه
2- ساعت با نمایش ثانیه و به صورت 24 ساعته با تنظیم منو بندی شده و راحت ! ( نکته مهمی بودش )
3- کرنومتر با دقت 1/128 ثانیه
4- شمارنده خودرو پارکینگی با روش مادون قرمز به همراه کنترل دستی
5- فرکانس متر با دقت هرتز و حداکثر یک مگاهرتز
6- شمارنده دستی ( بهش صلوات شمار هم می گن )
7- نمایش حروف روان !!!!
و اینم برنامه مدار فوق :
کد php:$regfile = "m32def.dat" : $crystal = 8000000
Config Adc = Single , Prescaler = Auto , Reference = Internal
Ddra.3 = 0 : Ddra.4 = 0 : Ddra.5 = 0 : Ddra.6 = 0 : Ddra.7 = 0
Ddrc = 63 : Ddrd = 255 : Ddrb = &B11111101
Dim B As Byte , F As Byte , Sectic As Byte , Ff As Byte
Dim Out_1 As Byte , Out_2 As Byte , Out_3 As Byte , Out_4 As Byte
Dim Out_5 As Byte , Out_6 As Byte , Out_7 As Byte , Out_8 As Byte
Dim Out_9 As Byte , Out_10 As Byte , Fff As Byte , Ww As Word
Dim Ol As Byte , Frq As Long , W As Word , L As Long , E As Word , C As Word
Dim Cornometr_ms As Word , Cornometr_s As Byte , Cornometr_m As Byte , Cornometr_h As Word
Dim Dama As Word , Car As Word
Dim Cc As Byte , Mm As Byte , Ss As Byte
Config Timer2 = Timer , Async = On , Prescale = 1
On Timer2 Sectic : Enable Interrupts : Enable Timer2
Config Timer1 = Counter , Edge = Rising : On Timer1 Ol : Enable Timer1
Config Timer0 = Timer , Prescale = 8 : On Timer0 Scan : Enable Timer0
Start Timer0 : Start Timer2 : F = 2 : Gosub Res_data : Gosub Sectic : Sectic = 126
'###############################################################################
Star:
Do
Debounce Pina.3 , 1 , Set1
Loop
Set1:
If F = 7 Then :
F = 2 : Start Timer2
L = Frq / 100000 : Out_8 = L + 1 : L = L * 100000 : Frq = Frq - L
L = Frq / 10000 : Out_7 = L + 1 : L = L * 10000 : Frq = Frq - L
L = Frq / 1000 : Out_6 = L + 1 : L = L * 1000 : Frq = Frq - L
L = Frq / 100 : Out_5 = L + 1 : L = L * 100 : Frq = Frq - L
L = Frq / 10 : Out_4 = L + 1 : L = L * 10 : Frq = Frq - L
Out_3 = Frq + 1 : Out_10 = 11 : Out_9 = 12 : Out_2 = 13 : Out_1 = 14
Elseif F = 2 Then :
F = 3 : Stop Timer2 : Stop Timer1 : Gosub Res_data
Do
Debounce Pina.3 , 1 , Set2
Debounce Pina.4 , 1 , Set3 , Gosub
Debounce Pina.5 , 1 , Set4 , Gosub
Loop
Set2:
Stop Timer2 : Gosub Res_data : Goto Set1
Set3:
Start Timer2 : Return
Set4:
Stop Timer2
For C = 0 To 50000
If Pina.5 = 0 Then Return
Next
Gosub Res_data : Return
Elseif F = 3 Then :
F = 4 : Gosub Res_data : Start Timer2
Elseif F = 4 Then :
F = 5 : Stop Timer2 : Gosub Res_data
Do
Debounce Pina.3 , 1 , Set1
Debounce Pina.4 , 1 , Set6 , Gosub
Debounce Pina.5 , 1 , Set7 , Gosub
Debounce Pina.6 , 1 , In_car , Gosub
Debounce Pina.7 , 1 , Out_car , Gosub
Loop
Set6:
Incr Out_1
If Out_1 > 10 Then :
Out_1 = 1 : Incr Out_2
End If
If Out_2 > 10 Then :
Out_2 = 1 : Incr Out_3
End If
If Out_3 > 10 Then :
Out_3 = 1 : Incr Out_4
End If
If Out_4 > 10 Then :
Out_4 = 1 : Incr Out_5
End If
If Out_5 > 10 Then :
Out_5 = 1 : Incr Out_6
End If
If Out_6 > 10 Then :
Out_6 = 1 : Incr Out_7
End If
If Out_7 > 10 Then :
Out_7 = 1 : Incr Out_8
End If
If Out_8 > 10 Then :
Out_8 = 1 : Incr Out_9
End If
If Out_9 > 10 Then :
Out_9 = 1 : Incr Out_10
End If
If Out_10 > 10 Then Out_10 = 1
For C = 0 To 30000
If Pina.4 = 0 Then Return
Next
Do
Incr Out_1
If Out_1 > 10 Then :
Out_1 = 1 : Incr Out_2
End If
If Out_2 > 10 Then :
Out_2 = 1 : Incr Out_3
End If
If Out_3 > 10 Then :
Out_3 = 1 : Incr Out_4
End If
If Out_4 > 10 Then :
Out_4 = 1 : Incr Out_5
End If
If Out_5 > 10 Then :
Out_5 = 1 : Incr Out_6
End If
If Out_6 > 10 Then :
Out_6 = 1 : Incr Out_7
End If
If Out_7 > 10 Then :
Out_7 = 1 : Incr Out_8
End If
If Out_8 > 10 Then :
Out_8 = 1 : Incr Out_9
End If
If Out_9 > 10 Then :
Out_9 = 1 : Incr Out_10
End If
If Out_10 > 10 Then Out_10 = 1
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Loop
Set7:
Decr Out_1
If Out_1 = 0 Then :
Out_1 = 10 : Decr Out_2
End If
If Out_2 = 0 Then :
Out_2 = 10 : Decr Out_3
End If
If Out_3 = 0 Then :
Out_3 = 10 : Decr Out_4
End If
If Out_4 = 0 Then :
Out_4 = 10 : Decr Out_5
End If
If Out_5 = 0 Then :
Out_5 = 10 : Decr Out_6
End If
If Out_6 = 0 Then :
Out_6 = 10 : Decr Out_7
End If
If Out_7 = 0 Then :
Out_7 = 10 : Decr Out_8
End If
If Out_8 = 0 Then :
Out_8 = 10 : Decr Out_9
End If
If Out_9 = 0 Then :
Out_9 = 10 : Decr Out_10
End If
If Out_10 = 0 Then Out_10 = 10
For C = 0 To 30000
If Pina.5 = 0 Then Return
Next
Do
Decr Out_1
If Out_1 = 0 Then :
Out_1 = 10 : Decr Out_2
End If
If Out_2 = 0 Then :
Out_2 = 10 : Decr Out_3
End If
If Out_3 = 0 Then :
Out_3 = 10 : Decr Out_4
End If
If Out_4 = 0 Then :
Out_4 = 10 : Decr Out_5
End If
If Out_5 = 0 Then :
Out_5 = 10 : Decr Out_6
End If
If Out_6 = 0 Then :
Out_6 = 10 : Decr Out_7
End If
If Out_7 = 0 Then :
Out_7 = 10 : Decr Out_8
End If
If Out_8 = 0 Then :
Out_8 = 10 : Decr Out_9
End If
If Out_9 = 0 Then :
Out_9 = 10 : Decr Out_10
End If
If Out_10 = 0 Then Out_10 = 10
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Loop
In_car:
If Pina.7 = 0 Then :
For W = 0 To 60000
Debounce Pina.7 , 1 , In_car2
If Pina.6 = 0 Then Return
Next
Return
Else :
Return
End If
In_car2:
Gosub Set6 : Return
Out_car:
If Pina.6 = 0 Then :
For W = 0 To 60000
Debounce Pina.6 , 1 , Out_car2
If Pina.7 = 0 Then Return
Next
Return
Else :
Return
End If
Out_car2:
Gosub Set7 : Return
Elseif F = 5 Then : 'DAMASANJ
F = 6 : Gosub Res_data : Start Timer2
Elseif F = 6 Then :
F = 7 : Gosub Res_data : Start Timer2
Saat:
Ff = 0 : Waitms 100
Do
Debounce Pina.3 , 1 , Set_time
Loop
Set_time:
For C = 0 To 50000
If Pina.3 = 0 Then Goto Set1
Next
Ff = 1
Do
Debounce Pina.3 , 1 , Set_mm
Debounce Pina.4 , 1 , Incr_cc , Gosub
Debounce Pina.5 , 1 , Decr_cc , Gosub
Loop
Incr_cc:
Incr Cc
If Cc > 23 Then Cc = 0
C = Cc : Ww = C / 10 : Out_9 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_8 = C + 1
For C = 0 To 30000
If Pina.4 = 0 Then Return
Next
Do
Incr Cc
If Cc > 23 Then Cc = 0
C = Cc : Ww = C / 10 : Out_9 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_8 = C + 1
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Loop
Decr_cc:
Decr Cc
If Cc > 23 Then Cc = 23
C = Cc : Ww = C / 10 : Out_9 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_8 = C + 1
For C = 0 To 30000
If Pina.5 = 0 Then Return
Next
Do
Decr Cc
If Cc > 23 Then Cc = 23
C = Cc : Ww = C / 10 : Out_9 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_8 = C + 1
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Loop
Set_mm:
Ff = 2
Do
Debounce Pina.3 , 1 , Saat
Debounce Pina.4 , 1 , Incr_mm , Gosub
Debounce Pina.5 , 1 , Decr_mm , Gosub
Loop
Incr_mm:
Incr Mm
If Mm > 59 Then Mm = 0
C = Mm : Ww = C / 10 : Out_6 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_5 = C + 1
For C = 0 To 30000
If Pina.4 = 0 Then Return
Next
Do
Incr Mm
If Mm > 59 Then Mm = 0
C = Mm : Ww = C / 10 : Out_6 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_5 = C + 1
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Waitms 50
If Pina.4 = 0 Then Return
Loop
Decr_mm:
Decr Mm
If Mm > 59 Then Mm = 59
C = Mm : Ww = C / 10 : Out_6 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_5 = C + 1
For C = 0 To 30000
If Pina.5 = 0 Then Return
Next
Do
Decr Mm
If Mm > 59 Then Mm = 59
C = Mm : Ww = C / 10 : Out_6 = Ww + 1 : Ww = Ww * 10 : C = C - Ww : Out_5 = C + 1
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Waitms 50
If Pina.5 = 0 Then Return
Loop
End If
Goto Star
Res_data:
Out_1 = 1 : Out_2 = 1 : Out_3 = 1 : Out_4 = 1 : Out_5 = 1 : Out_6 = 1
Out_7 = 1 : Out_8 = 1 : Out_9 = 1 : Out_10 = 1 : Sectic = 255
Cornometr_ms = 0 : Cornometr_s = 0 : Cornometr_m = 0 : Cornometr_h = 0
If F = 3 Then :
Out_4 = 16 : Out_6 = 16 : Out_8 = 16
End If
Return
'###############################################################################
Sectic:
Incr Sectic
If F = 2 Then :
If Sectic = 127 Then :
Stop Timer1 : W = Timer1 : Timer1 = 0 : Start Timer1
Frq = Ol * 65536 : Frq = Frq + W : Ol = 0 : If Frq > 999999 Then Frq = 999999
L = Frq / 100000 : Out_8 = L + 1 : L = L * 100000 : Frq = Frq - L
L = Frq / 10000 : Out_7 = L + 1 : L = L * 10000 : Frq = Frq - L
L = Frq / 1000 : Out_6 = L + 1 : L = L * 1000 : Frq = Frq - L
L = Frq / 100 : Out_5 = L + 1 : L = L * 100 : Frq = Frq - L
L = Frq / 10 : Out_4 = L + 1 : L = L * 10 : Frq = Frq - L
Out_3 = Frq + 1 : Out_10 = 11 : Out_9 = 12 : Out_2 = 13 : Out_1 = 14
End If
Elseif F = 3 Then :
Cornometr_ms = Sectic * 8 : W = Cornometr_ms / 59
Cornometr_ms = Cornometr_ms - W : If Cornometr_ms > 999 Then Cornometr_ms = 0
If Sectic = 127 Then :
Incr Cornometr_s
If Cornometr_s > 59 Then :
Cornometr_s = 0 : Incr Cornometr_m
End If
If Cornometr_m > 59 Then :
Cornometr_m = 0 : Incr Cornometr_h
End If
End If
E = Cornometr_ms : W = E / 100 : Out_3 = W + 1 : W = W * 100 : E = E - W
W = E / 10 : Out_2 = W + 1 : W = W * 10 : E = E - W : Out_1 = E + 1
E = Cornometr_s : W = E / 10 : Out_5 = W + 1 : W = W * 10 : E = E - W : Out_4 = E + 16
E = Cornometr_m : W = E / 10 : Out_7 = W + 1 : W = W * 10 : E = E - W : Out_6 = E + 16
E = Cornometr_h : W = E / 100 : Out_10 = W + 1 : W = W * 100 : E = E - W
W = E / 9 : Out_9 = W + 1 : W = W * 10 : E = E - W : Out_8 = E + 16
Elseif F = 4 Then :
If Sectic = 127 Then :
Incr Fff : If Fff = 21 Then Fff = 0
Select Case Fff
Case 0 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 1 :
Out_10 = 1 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 2 :
Out_10 = 2 : Out_9 = 1 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 3 :
Out_10 = 3 : Out_9 = 2 : Out_8 = 1 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 4 :
Out_10 = 4 : Out_9 = 3 : Out_8 = 2 : Out_7 = 1 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 5 :
Out_10 = 5 : Out_9 = 4 : Out_8 = 3 : Out_7 = 2 : Out_6 = 1
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 6 :
Out_10 = 6 : Out_9 = 5 : Out_8 = 4 : Out_7 = 3 : Out_6 = 2
Out_5 = 1 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 7 :
Out_10 = 7 : Out_9 = 6 : Out_8 = 5 : Out_7 = 4 : Out_6 = 3
Out_5 = 2 : Out_4 = 1 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
Case 8 :
Out_10 = 8 : Out_9 = 7 : Out_8 = 6 : Out_7 = 5 : Out_6 = 4
Out_5 = 3 : Out_4 = 2 : Out_3 = 1 : Out_2 = 0 : Out_1 = 0
Case 9 :
Out_10 = 9 : Out_9 = 8 : Out_8 = 7 : Out_7 = 6 : Out_6 = 5
Out_5 = 4 : Out_4 = 3 : Out_3 = 2 : Out_2 = 1 : Out_1 = 0
Case 10 :
Out_10 = 10 : Out_9 = 9 : Out_8 = 8 : Out_7 = 7 : Out_6 = 6
Out_5 = 5 : Out_4 = 4 : Out_3 = 3 : Out_2 = 2 : Out_1 = 1
Case 11 :
Out_10 = 0 : Out_9 = 10 : Out_8 = 9 : Out_7 = 8 : Out_6 = 7
Out_5 = 6 : Out_4 = 5 : Out_3 = 4 : Out_2 = 3 : Out_1 = 2
Case 12 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 10 : Out_7 = 9 : Out_6 = 8
Out_5 = 7 : Out_4 = 6 : Out_3 = 5 : Out_2 = 4 : Out_1 = 3
Case 13 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 10 : Out_6 = 9
Out_5 = 8 : Out_4 = 7 : Out_3 = 6 : Out_2 = 5 : Out_1 = 4
Case 14 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 10
Out_5 = 9 : Out_4 = 8 : Out_3 = 7 : Out_2 = 6 : Out_1 = 5
Case 15 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 10 : Out_4 = 9 : Out_3 = 8 : Out_2 = 7 : Out_1 = 6
Case 16 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 10 : Out_3 = 9 : Out_2 = 8 : Out_1 = 7
Case 17 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 10 : Out_2 = 9 : Out_1 = 8
Case 18 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 10 : Out_1 = 9
Case 19 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 10
Case 20 :
Out_10 = 0 : Out_9 = 0 : Out_8 = 0 : Out_7 = 0 : Out_6 = 0
Out_5 = 0 : Out_4 = 0 : Out_3 = 0 : Out_2 = 0 : Out_1 = 0
End Select
End If
Elseif F = 6 Then :
If Sectic = 127 Then :
Start Adc : Dama = Getadc(0) : Stop Adc : Dama = Dama * 25
L = Dama / 100000 : Out_8 = L + 1 : L = L * 100000 : Dama = Dama - L
L = Dama / 10000 : Out_7 = L + 1 : L = L * 10000 : Dama = Dama - L
L = Dama / 1000 : Out_6 = L + 1 : L = L * 1000 : Dama = Dama - L
L = Dama / 100 : Out_5 = L + 16 : L = L * 100 : Dama = Dama - L
L = Dama / 10 : Out_4 = L + 1 : L = L * 10 : Dama = Dama - L
Out_3 = Dama + 1 : Out_10 = 27 : Out_9 = 28 : Out_8 = 12 : Out_2 = 29 : Out_1 = 30
End If
Elseif F = 7 Then :
If Sectic = 127 Then :
Ss = Ss + 1
If Ss > 59 Then :
Ss = 0 : Mm = Mm + 1
End If
If Mm > 59 Then :
Mm = 0 : Cc = Cc + 1
End If
If Cc > 23 Then :
Cc = 0
End If
E = Ss : W = E / 10 : Out_3 = W + 1 : W = W * 10 : E = E - W : Out_2 = E + 1
E = Mm : W = E / 10 : Out_6 = W + 1 : W = W * 10 : E = E - W : Out_5 = E + 1
E = Cc : W = E / 10 : Out_9 = W + 1 : W = W * 10 : E = E - W : Out_8 = E + 1
Out_4 = 12 : Out_7 = 12 : Out_1 = 0 : Out_10 = 0
Elseif Sectic = 63 Then :
Out_4 = 0 : Out_7 = 0
E = Mm : W = E / 10 : Out_6 = W + 1 : W = W * 10 : E = E - W : Out_5 = E + 1
E = Cc : W = E / 10 : Out_9 = W + 1 : W = W * 10 : E = E - W : Out_8 = E + 1
Elseif Sectic = 31 Then :
If Ff = 1 Then : Out_8 = 0 : Out_9 = 0
Elseif Ff = 2 Then : Out_6 = 0 : Out_5 = 0
End If
Elseif Sectic = 95 Then :
If Ff = 1 Then : Out_8 = 0 : Out_9 = 0
Elseif Ff = 2 Then : Out_6 = 0 : Out_5 = 0
End If
End If
End If
If Sectic > 126 Then Sectic = 255
Return
Ol:
Incr Ol
Return
'###############################################################################
Scan:
Incr B : If B = 11 Then B = 1
Reset Portb.4 : Reset Portb.5 : Reset Portb.6 : Reset Portb.7 : Reset Portc.0
Reset Portc.1 : Reset Portc.2 : Reset Portc.3 : Reset Portc.4 : Reset Portc.5
Select Case B
Case 1 :
Portd = Lookup(out_1 , Number) : Set Portb.7
Case 2 :
Portd = Lookup(out_2 , Number) : Set Portb.6
Case 3 :
Portd = Lookup(out_3 , Number) : Set Portb.5
Case 4 :
Portd = Lookup(out_4 , Number) : Set Portb.4
Case 5 :
Portd = Lookup(out_5 , Number) : Set Portc.5
Case 6 :
Portd = Lookup(out_6 , Number) : Set Portc.4
Case 7 :
Portd = Lookup(out_7 , Number) : Set Portc.3
Case 8 :
Portd = Lookup(out_8 , Number) : Set Portc.2
Case 9 :
Portd = Lookup(out_9 , Number) : Set Portc.1
Case 10 :
Portd = Lookup(out_10 , Number) : Set Portc.0
End Select
Return
'###############################################################################
Number:
Data 0 , &B00111111 , &B00000110 , &B01011011 , &B01001111 , &B01100110 , &B01101101 _
, &B01111101 , &B00000111 , &B01111111 , &B01101111 , &B01110001 , &B01001000 , &B01110110 _
, &B01001001 , 0 , &B10111111 , &B10000110 , &B11011011 , &B11001111 , &B11100110 , &B11101101_
, &B11111101 , &B10000111 , &B11111111 , &B01101111 , 26 , &B00110001 , &B01111001 , &B00000001 , &B01011000
و دریافت فایل های مورد نیاز مثل نقشه پروتئوس و فایل بسکام و ...
DOWNLOAD
توضیحات مدار و برنامه و هم بعدا که وقت کردم می ذارم !
فقط همینو بگم که با دکمه S می تونید مد های مختلف رو عوض کنید !
همه این مواردو میتونید برای LCD 2*16 برام قرار بدی

۰۳-مهر-۱۳۸۹, ۲۳:۳۹:۵۹
نه !
چون سرعت LCD خیلی پایینه و نمیتونه سریع نشون بده !!
البته میشه دقت کرنومتر رو آورد پایین و یه کارایی کرد !!!
واسه کرنومتر با دقت 1/16 ثانیه بهمراه ساعت و تاریخ شمسی با LCD برنامه زیر رو بگیر : ( بهمراه برنامه و تست برنامه و فایل pcb با پروتئوس )
[attachment=5577]
فکر می کنم یه کوچولو باهاش کار روالش دستت بیاد !! ( مثل بقیه برنامه های منه )
اگه مشکل داشتی بگو !!!
اینم برنامش :
چون سرعت LCD خیلی پایینه و نمیتونه سریع نشون بده !!
البته میشه دقت کرنومتر رو آورد پایین و یه کارایی کرد !!!
واسه کرنومتر با دقت 1/16 ثانیه بهمراه ساعت و تاریخ شمسی با LCD برنامه زیر رو بگیر : ( بهمراه برنامه و تست برنامه و فایل pcb با پروتئوس )
[attachment=5577]
فکر می کنم یه کوچولو باهاش کار روالش دستت بیاد !! ( مثل بقیه برنامه های منه )
اگه مشکل داشتی بگو !!!
اینم برنامش :
کد php:
$regfile = "M8DEF.dat" : $crystal = 2000000
Config Lcdpin = Pin , Db4 = Pinb.3 , Db5 = Pinb.2 , Db6 = Pinb.1 , Db7 = Pinb.0 , E = Pinb.4 , Rs = Pinb.5
Config Lcd = 16 * 2 : Cursor Off : Cls
Lcd "WWW.IRANLED.COM" : Wait 3 : Cls
Dim Cc As Byte , Mm As Byte , Ss As Byte , Sectic As Byte
Dim F As Byte , W As Word
Dim Scor As Single , Mcor As Single , Fcor As Byte , Bcor As Word
Dim Roz As Byte , Mah As Byte , Sal As Byte , Hafteh As Byte
Config Timer2 = Timer , Prescale = 8 , Async = On
Enable Interrupts : Enable Timer2 : On Timer2 Sectic
Ddrd = 128 : Portd = 7
Sw_s Alias Pind.0 : Sw_i Alias Pind.1 : Sw_d Alias Pind.2
Mah = 4 : Roz = 30 : Sal = 89 : Cls
Gosub Onlcd
Star:
F = 0 : Start Timer2 : Fcor = 0 : Gosub Onlcd
Do
Debounce Sw_s , 0 , Jj
Loop
Jj:
For W = 0 To 1000
If Sw_s = 1 Then Goto Cornometr
Waitms 2
Next
Goto Cc
Cornometr:
Bcor = 0 : Scor = 0 : Mcor = 0.00 : F = 10
Home L : Lcd Fusing(mcor , "#.&&") ; " "
Do
Debounce Sw_s , 0 , Endcor
Debounce Sw_i , 0 , Startcor , Gosub
Debounce Sw_d , 0 , Resetcor , Gosub
Loop
Startcor:
Fcor = 1
Return
Resetcor:
For W = 0 To 1000
If Sw_d = 1 Then Goto Stopmcor
Waitms 1
Next
Bcor = 0 : Scor = 0 : Mcor = 0.00
Home L : Lcd Fusing(mcor , "#.&&") ; " "
Return
Stopmcor:
Fcor = 0
Home L : Lcd Fusing(mcor , "#.&&") ; " "
Return
Endcor:
F = 0 : Fcor = 0 : Home L : Lcd " " : Gosub Onlcd
Goto Star
'===============================================================================
Sectic:
Incr Sectic
If Sectic = 4 Then :
Gosub Offlcd
Elseif Sectic = 8 Then:
Ss = Ss + 1 : Toggle Portd.7
If Ss > 59 Then : Ss = 0 : Mm = Mm + 1
End If
If Mm > 59 Then : Mm = 0 : Cc = Cc + 1
End If
If Cc > 23 Then : Cc = 0 : Incr Hafteh : Incr Roz
End If
If Hafteh > 6 Then Hafteh = 0
If Roz > 30 And Mah > 6 Then : Incr Mah : Roz = 1
End If
If Roz > 31 And Mah < 7 Then : Incr Mah : Roz = 1
End If
If Mah > 12 Then : Mah = 1 : Incr Sal
End If
If Sal > 99 Then Sal = 0
Gosub Onlcd
Elseif Sectic = 12 Then:
Gosub Offlcd
Elseif Sectic = 16 Then:
Gosub Onlcd : Sectic = 0 : Toggle Portd.7
End If
If Fcor = 1 Then :
Mcor = Bcor * 0.06666 : Mcor = Mcor + Scor
Home L : Lcd Fusing(mcor , "#.&&") ; " "
Incr Bcor
If Bcor = 16 Then : Bcor = 0 : Incr Scor
End If
End If
Locate 2 , 22
Return
'===============================================================================
Cc:
F = 2
Do
Debounce Sw_s , 0 , Mm
Debounce Sw_i , 0 , Cc1
Debounce Sw_d , 0 , Cc2
Loop
Cc1:
Incr Cc : If Cc > 23 Then Cc = 0
Gosub Showcc : Goto Cc
Cc2:
Decr Cc : If Cc > 23 Then Cc = 23
Gosub Showcc : Goto Cc
'-------------------------------------------------------------------------------
Mm:
F = 3 : Gosub Showcc
Do
Debounce Sw_s , 0 , Ss
Debounce Sw_i , 0 , Mm1
Debounce Sw_d , 0 , Mm2
Loop
Mm1:
Incr Mm : If Mm > 59 Then Mm = 0
Gosub Showmm : Goto Mm
Mm2:
Decr Mm : If Mm > 59 Then Mm = 59
Gosub Showmm : Goto Mm
'-------------------------------------------------------------------------------
Ss:
F = 4 : Gosub Showmm : Gosub Showss
Do
Debounce Sw_s , 0 , Sal
Debounce Sw_i , 0 , Ss1
Debounce Sw_d , 0 , Ss2
Loop
Ss1:
Timer2 = 0 : Sectic = 0
If Ss > 29 Then : Mm = Mm + 1
End If
If Mm = 60 Then : Mm = 0 : Incr Cc
End If
If Cc = 24 Then Cc = 0
Ss = 0 : Goto Ss
Ss2:
Timer2 = 0 : Ss = 0 : Sectic = 0 : Goto Ss
'-------------------------------------------------------------------------------
Sal:
F = 5
Do
Debounce Sw_s , 0 , Mah
Debounce Sw_i , 0 , Sal1
Debounce Sw_d , 0 , Sal2
Loop
Sal1:
Incr Sal : If Sal > 99 Then Sal = 0
Gosub Showsal : Goto Sal
Sal2:
Decr Sal : If Sal > 99 Then Sal = 99
Gosub Showsal : Goto Sal
'-------------------------------------------------------------------------------
Mah:
F = 6
Do
Debounce Sw_s , 0 , Roz
Debounce Sw_i , 0 , Mah1
Debounce Sw_d , 0 , Mah2
Loop
Mah1:
Incr Mah : If Mah > 12 Then Mah = 1
Gosub Showsal : Goto Mah
Mah2:
Decr Mah : If Mah = 0 Then Mah = 12
Gosub Showmah : Goto Mah
'-------------------------------------------------------------------------------
Roz:
F = 7
Do
Debounce Sw_s , 0 , Hafteh
Debounce Sw_i , 0 , Roz1
Debounce Sw_d , 0 , Roz2
Loop
Roz1:
Timer2 = 0 : Incr Roz :
If Roz > 30 And Mah > 6 Then : Roz = 1
End If
If Roz > 31 And Mah < 7 Then : Roz = 1
End If
Gosub Showsal : Goto Roz
Roz2:
Timer2 = 0 : Decr Roz :
If Roz = 0 And Mah > 6 Then : Roz = 30
End If
If Roz = 0 And Mah < 7 Then : Roz = 31
End If
Gosub Showroz : Goto Roz
'-------------------------------------------------------------------------------
Hafteh:
F = 8
Do
Debounce Sw_s , 0 , Star
Debounce Sw_i , 0 , Hafteh1
Debounce Sw_d , 0 , Hafteh2
Loop
Hafteh1:
Incr Hafteh : If Hafteh > 99 Then Hafteh = 0
Gosub Showhafteh : Goto Hafteh
Hafteh2:
Decr Hafteh : If Hafteh > 99 Then Hafteh = 6
Gosub Showhafteh : Goto Hafteh
'===============================================================================
Onlcd:
Gosub Showcc : Gosub Showmm : Gosub Showss : Gosub Showhafteh
If F <> 10 Then :
Gosub Showroz : Gosub Showmah : Gosub Showsal
End If
Return
'-------------------------------------------------------------------------------
Offlcd:
If F = 0 Then : Return
Elseif F = 2 Then : Locate 1 , 1 : Lcd " "
Elseif F = 3 Then : Locate 1 , 4 : Lcd " "
Elseif F = 4 Then : Locate 1 , 7 : Lcd " "
Elseif F = 5 Then : Locate 2 , 1 : Lcd " "
Elseif F = 6 Then : Locate 2 , 4 : Lcd " "
Elseif F = 7 Then : Locate 2 , 7 : Lcd " "
Elseif F = 8 Then : Locate 1 , 14 : Lcd " "
End If
Return
'-------------------------------------------------------------------------------
Showcc:
Home
If Cc < 10 Then : Lcd " " ; Cc
Else : Lcd Cc
End If
Lcd ":"
Return
Showmm:
Locate 1 , 4
If Mm < 10 Then : Lcd "0" ; Mm
Else : Lcd Mm
End If
Lcd ":"
Return
Showss:
Locate 1 , 7
If Ss < 10 Then : Lcd "0" ; Ss
Else : Lcd Ss
End If
Lcd " "
Return
Showsal:
Home L
If Sal < 10 Then : Lcd " " ; Sal
Else : Lcd Sal
End If
Lcd "/"
Return
Showmah:
Locate 2 , 4
If Mah < 10 Then : Lcd "0" ; Mah
Else : Lcd Mah
End If
Lcd "/"
Return
Showroz:
Locate 2 , 7
If Roz < 10 Then : Lcd "0" ; Roz
Else : Lcd Roz
End If
Lcd " "
Return
Showhafteh:
Locate 1 , 13
Select Case Hafteh:
Case 0 : Lcd " SAT"
Case 1 : Lcd " SUN"
Case 2 : Lcd " MON"
Case 3 : Lcd " TUE"
Case 4 : Lcd " WED"
Case 5 : Lcd " THU"
Case 6 : Lcd " FRI"
End Select
Return