ايران ويج

نسخه‌ی کامل: کورنومتر
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
صفحه‌ها: 1 2
نه

نمیشه !

فابریکی میکرو رو نوسان ساز داخلیش تنظیم شده و شما لازم نیست کریستال خارجی بذاری !!!

فقط نوسان ساز داخلی میکرو رو 1000000 هرتز تنظیم شده و نه 6553500 هرتز که شما تو برنامه گفتی !!!

این مقاله رو بخون : http://forum.iranled.com/attachment.php?aid=3891

این فایل هم همینطور : http://azarrobot.blogfa.com/post-9.aspx

میکرو داخلی 1-2-4-8 مگاهرتز داره و فرکانس شما رو نداره !!
$regfile = "m32def.Dat"
$crystal = 1000000

Config Lcdpin = Pin , Db4 = Pinb.3 , Db5 = Pinb.2 , Db6 = Pinb.1 , Db7 = Pinb.0 , Rs = Pinb.6 , E = Pinb.7

Config Lcd = 16 * 2
Cursor Off
Cls

Config Portd = Input



Dim Hour As Byte , Minute As Byte , Second As Byte , Ms As Byte

Yasaman:

Do

If Pind.0 = 1 Then :
Goto Cornometr
End If

If Pind.2 = 1 Then :
Ms = 0
Second = 0
Minute = 0
Hour = 0

Locate 1 , 1
Lcd Hour ; ":" ; Minute ; ":" ; Second ; ":" ; Ms ; " "
End If

Loop



Cornometr:

Do
Locate 1 , 1
Lcd Hour ; ":" ; Minute ; ":" ; Second ; ":" ; Ms ;" "

Incr Ms


If Ms = 100 Then :
Incr Second
Ms = 0
End If

If Second = 60 Then :
Incr Minute
Second = 0
End If

If Minute = 60 Then :
Incr Hour
Minute = 0
End If

If Hour = 24 Then :
Hour = 0
End If

If Pind.1 = 1 Then : Goto Yasaman
End If

If Pind.2 = 1 Then :
Ms = 0
Second = 0
Minute = 0
Hour = 0

Locate 1 , 1
Lcd Hour ; ":" ; Minute ; ":" ; Second ; ":" ; Ms ;" "
End If


Loop
End


--------------------------------------------------------------------------------
سلام به همه این برنامه دقیق نیست و چند قدم جلو تر از ساعت می زنه
در ضمن بر چه اساسی می شمره؟
کریستال یا wait?
دستوری که باعث ایجاد تاخیر بشه نمی بینم
راهنماییم می کنین؟؟؟
مهندس چون بر اساس Wait هستش پس دقیق نیست !!!
البته هیچ تاخیری نذاشته و از تاخیر تو نوشتن lcd استفاده کرده !!!!

با تایمر می تونین خودتون راحت بنویسینش !!!!
من که الان یک کورنومتر ساخته ام با دقت 9 رقم اعشار. از ساعت کامپیوتر هم دقیق تر است. ولی وقتی در بیسکام با مگا8 کامپایل کردم ، حجمش 98 درصد شد.
خوب برنامشو بذار !!!

منم یه ساعت خالی نوشتم و 95 درصد اتمگا 16 رو پر کرد !
خودت ببین : http://iranled.com/node/75
منم یک چراغ چشمک زن درست کردم 95 درصد مگا 128 رو پر کرد!!!!!!!!!!!!!!!!!!!!!!!!

کد: (کرنومتر)

کد:
$regfile = "M8DEF.DAT"
$crystal = 8000000
O:

Dim Ma As Byte
Dim A As Single
Dim A1 As Single
Dim B As Word
Dim Aa As Single
Dim Decimal1 As Single
Dim Ns As Integer
Dim Np As Integer

Readeeprom Ns , 17
  Readeeprom Np , 25

If Ns < 1 Then : Ns = 1 : Writeeeprom Ns , 17 : End If
If Np < 1 Then : Np = 1 : Writeeeprom Np , 25 : End If
Np = Np + 1
Writeeeprom Np , 25
Config Portb.1 = Output : Reset Portb.1
Config Portd.0 = Output                                    ':Reset Portd.0   0
Config Portd.0 = Output

Dim Secr As Byte : Secr = 0

   Disable Int1
Dim Lcdled As Byte : Readeeprom Lcdled , 15
Dim Decimal As Byte : Readeeprom Decimal , 10
Dim Lenght As Single : Readeeprom Lenght , 1
Dim Show As Byte : Readeeprom Show , 30

   If Show > 1 Then
    Show = 1
    Writeeeprom Show , 30
End If
If Show < 0 Then
    Show = 0
    Writeeeprom Show , 30
End If


  If Lcdled > 1 Then
    Lenght = 1
    Writeeeprom Lcdled , 15
End If
If Lenght < 0 Then
    Lenght = 0
    Writeeeprom Lcdled , 15
End If

If Lenght > 100 Then
    Lenght = 100
    Writeeeprom Lenght , 1
End If
If Lenght < 1 Then
    Lenght = 1
    Writeeeprom Lenght , 1
End If

  If Decimal > 9 Then
    Decimal = 9
    Writeeeprom Decimal , 10
End If
If Decimal < 1 Then
    Decimal = 1
    Writeeeprom Decimal , 10
End If
Config Portb.0 = Input                                     ' : Portb.0 = 0
Config Portd.7 = Input                                     ' : Portd.7 = 0
Config Portd.4 = Input                                     ': Portd.4 = 0
Config Portd.3 = Input                                     ' : Portd.3 = 0
Config Adc = Single , Prescaler = Auto
Config Debounce = 25
Cursor Off
Enable Interrupts
Cls
Config Timer0 = Counter , Edge = Rising

Config Int1 = Change

Config Timer1 = Timer , Prescale = 8
Enable Timer1
Enable Ovf1
On Ovf1 T1
Waitms 500
A:
  Readeeprom Lcdled , 15

If Lcdled = 1 Then
    Set Portb.1
Else
    Reset Portb.0
End If

Stop Timer1

Timer1 = 0
Tcnt0 = 0
A = 0
B = 0
Locate 1 , 1
Lcd "STOPWATCH  READY"


If Pind.3 = 1 Then

    Secr = Secr + 1
    Waitms 200
End If


Debounce Pind.7 , 1 , Ne1
'On Int0 B
'Do
'Loop

If Tcnt0 = 1 Then
Start Timer1
Cls
Enable Int1
On Int1 Ee
Ns = Ns + 1
Writeeeprom Ns , 17
Sound Pind.0 , 70 , 500
jmp B
Else
jmp A
End If


B:
If Tcnt0 = 2 Then
Stop Timer1

A = B * 65536
A = A + Timer1
A = A / 1000000
Readeeprom Decimal , 10
Readeeprom Lenght , 1

A1 = A ^ 2
A1 = A1 * 0.5
Decimal1 = Lenght / 100
A1 = Decimal1 / A1
Cls
If Decimal = 9 Then

Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#########")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#########")

End If
  If Decimal = 8 Then

Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.########")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.########")
End If
  If Decimal = 7 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#######")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#######")
End If
  If Decimal = 6 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.######")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.######")
End If
  If Decimal = 5 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#####")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#####")
End If
  If Decimal = 4 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.####")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.####")
End If
  If Decimal = 3 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.###")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.###")
End If
  If Decimal = 2 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.##")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.##")
End If
  If Decimal = 1 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#")
End If
  If Decimal = 0 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.")
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.")
End If
Sound Pind.0 , 70 , 500
jmp C
Elseif Tcnt0 = 1 Then
A = B * 65536
A = A / 1000000
Readeeprom Decimal , 10
Readeeprom Lenght , 1
Readeeprom Show , 30

If Show = 1 Then
A1 = A ^ 2
A1 = A1 * 0.5
Decimal1 = Lenght / 100
A1 = Decimal1 / A1
End If
If Decimal = 9 Then

Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#########")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#########")
End If
End If
  If Decimal = 8 Then

Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.########")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.########")
End If
End If
  If Decimal = 7 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#######")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#######")
End If
End If
  If Decimal = 6 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.######")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.######")
End If
End If
  If Decimal = 5 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#####")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#####")
End If
End If
  If Decimal = 4 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.####")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.####")
End If
End If
  If Decimal = 3 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.###")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.###")
End If
End If
  If Decimal = 2 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.##")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.##")
End If
End If
  If Decimal = 1 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.#")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.#")
End If
End If
  If Decimal = 0 Then
Locate 1 , 1 : Lcd "T : " : Lcd Fusing(a , "##.")
If Show = 1 Then
Locate 2 , 1 : Lcd "A : " : Lcd Fusing(a1 , "##.")
End If
End If
jmp B
End If

Return
C:
Do
If Tcnt0 = 3 Then
Tcnt0 = 0
Cls
JMP A
End If
Loop



T1:
Timer1 = 0
Incr B
Return


Ee:
Tcnt0 = 2

'Stop Timer1

'A = B * 65536
'A = A + Timer1
'A = A / 1000000
'Locate 1 , 1
'Lcd Fusing(a , "##.######")
'Lcd "  SecC  "
'Tcnt0 = Tcnt0 + 1
'jmp c

Return


Ne1:
Sound Pind.0 , 70 , 500                                     '################################
Readeeprom Decimal , 10
Cls
Do

Home
Lcd "Decimal : "
Lcd Decimal
Lcd "       "
Debounce Pind.7 , 1 , Goback1

If Pind.4 = 1 Then
     If Decimal < 9 Then
         Decimal = Decimal + 1

         Waitms 200
     Else
         Decimal = 9
     End If
End If
If Pind.3 = 1 Then
      If Decimal > 1 Then
          Decimal = Decimal - 1

          Waitms 200
      Else
          Decimal = 0
      End If
End If

Loop
Return
Goback1:
Writeeeprom Decimal , 10
  Tcnt0 = 0
  Sound Pind.0 , 70 , 500                                   '@@@@@@@@@@@
  jmp ne2
Return
Ne2:                                                        '#############################
Readeeprom Lenght , 1
Cls
Do

Home
Lcd "Length : "
Lcd Fusing(lenght , "##.#")
Lcd "       "
Debounce Pind.7 , 1 , Goback2

If Pind.4 = 1 Then
   Lenght = Lenght + 0.1

   Waitms 200
End If
If Pind.3 = 1 Then
   Lenght = Lenght - 0.1

   Waitms 200
End If

Loop
Return
Goback2:
Writeeeprom Lenght , 1
  Tcnt0 = 0
  Sound Pind.0 , 70 , 500                                   '@@@@@@@@@@@
  jmp ne4
Return

Ne4:                                                        '#############################
Readeeprom Show , 30
Cls
Do

Home
Lcd "Shwo accelerate:"
Locate 2 , 1
If Show = 1 Then : Lcd "True" : Else : Lcd "False" : End If
Lcd "        "
Debounce Pind.7 , 1 , Goback4

If Pind.4 = 1 Then
   Show = 1
   Waitms 200
End If
If Pind.3 = 1 Then
   Show = 0
   Waitms 200
End If


Loop

Goback4:
Writeeeprom Show , 30
  Tcnt0 = 0
  Sound Pind.0 , 70 , 500                                   '@@@@@@@@@@@
  jmp ne3
Return


Ne3:                                                        '#############################
Readeeprom Lcdled , 15
Cls
Do

Home
Lcd "Lcd Light: "
If Lcdled = 1 Then : Lcd "True" : Else : Lcd "False" : End If
Lcd "             "
Debounce Pind.7 , 1 , Goback3

If Pind.4 = 1 Then
   Lcdled = 1
   Waitms 200
End If
If Pind.3 = 1 Then
   Lcdled = 0
   Waitms 200
End If

Loop
Return
Goback3:
Writeeeprom Lcdled , 15
  Readeeprom Lcdled , 15

If Lcdled = 1 Then
    Set Portb.1
Else
    Reset Portb.0
End If
  Tcnt0 = 0
  If Secr = 7 Then
     Secr = 0
     Sound Pind.0 , 70 , 500
     jmp secret
  End If
  Sound Pind.0 , 70 , 300                                   '@@@@@@@@@@@
  jmp O
Return




Secret:
Cls : Home : Lcd "Secret Screen..."
Locate 2 , 1 : Lcd "Made by SMNsoft"
Do
Debounce Pind.3 , 1 , Secret1
Loop
Return

Secret1:
Sound Pind.0 , 70 , 500
Waitms 300
Cls : Home : Lcd "Number of start:"
Readeeprom Ns , 17
Locate 2 , 1 : Lcd Ns
Do
Debounce Pind.3 , 1 , Secret2
Loop
Return

Secret2:
Sound Pind.0 , 70 , 500
Waitms 300
Cls : Home : Lcd "Number of Power:"
Readeeprom Ns , 25
Locate 2 , 1 : Lcd Np
Do
Debounce Pind.3 , 1 , Secret3
Loop
Return

Secret3:
Sound Pind.0 , 70 , 500
Waitms 300
Cls : Home : Lcd "Last Update :"

Locate 2 , 1 : Lcd "July 11, 2010"
Do
Debounce Pind.3 , 1 , Secret4
Loop
Return

Secret4:
Sound Pind.0 , 70 , 300
jmp o
Return

البته با این کد می تونین مقدار اعشار کرنومتر رو تعیین کنید.
(۰۱-اسفند-۱۳۸۸, ۰۰:۳۹:۱۱)t3r!p3000 نوشته است: [ -> ]مهندس میشه ولی نمیشه رو LCD نمایش داد !

خود LCD زمان بیشتری می طلبه !!

این یه برنامه نمونه :

کد php:
$regfile "m32def.Dat"
$crystal 1000000

Config Lcdpin 
Pin Db4 Pinb.3 Db5 Pinb.2 Db6 Pinb.1 Db7 Pinb.0 Rs Pinb.6 Pinb.7

Config Lcd 
16 2
Cursor Off
Cls

Config Portd 
Input



Dim Hour 
As Byte Minute As Byte Second As Byte Ms As Byte

Yasaman
:

Do

 If 
Pind.0 1 Then :
 Goto 
Cornometr
 End 
If

 If 
Pind.2 1 Then :
 
Ms 0
 Second 
0
 Minute 
0
 Hour 
0

 Locate 1 
1
 Lcd Hour 
":" Minute ":" Second ":" Ms " "
 
End If

Loop



Cornometr
:

 Do
 
Locate 1 1
 Lcd Hour 
":" Minute ":" Second ":" Ms ;" "

 
Incr Ms


 
If Ms 100 Then :
 
Incr Second
 Ms 
0
 End 
If

 If 
Second 60 Then :
 
Incr Minute
 Second 
0
 End 
If

 If 
Minute 60 Then :
 
Incr Hour
 Minute 
0
 End 
If

 If 
Hour 24 Then :
 
Hour 0
 End 
If

 If 
Pind.1 1 Then : Goto Yasaman
 End 
If

 If 
Pind.2 1 Then :
 
Ms 0
 Second 
0
 Minute 
0
 Hour 
0

 Locate 1 
1
 Lcd Hour 
":" Minute ":" Second ":" Ms ;" "
 
End If


 
Loop
 End 

**********************************************
سلام من این برنامه امتحان کردم جواب میده اما زمانش دقیق نیست
برای تاخیر از چه روالی استفاده کرده؟؟؟
wait یا کریستال؟؟؟
تابلویه که واسه تاخیر از wait استفاده کرده !!


این یکی رو ببین و تست کن ! : http://www.iranled.com/forum/showthread....#pid111795
چون با کریستاله !!
من هم اولش دقیقا این مشکلو داشتم یعنی هر 3 یا 4 ثانیه 30 صدم عقب میفتاد.

بعدش به جای کریستال داخلی، یک کریستال خارجی 8 مگاهرتز گذاشتم. دقیق دقیق شد.

تمام پایه هاش هم یکی یکی ( پایه ها کلید) با رله به یک کورنومتر دیگه وصل کردم(از کورنومتر اطمینان داشتم)، بعد تستش کردم.درست نشون داد. یعنی عددlcdبا کورنومتر یکی بود.
صفحه‌ها: 1 2