ايران ويج

نسخه‌ی کامل: بازم مشکل با کورنومتر
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
صفحه‌ها: 1 2 3
سلام...
من چند هفته پيش يک کورنومتر درست کردم که دقت اونتا 9 رقم اعشار بود. اما اين کورنومتر يک اشکال دارد وقتي که مي خواهم که مي خواهم دکمه شروع را فشار دهم بعضي موقع ها ميکرو ريست مي شود و يا بعضي وقت ها نوشته هاي ال سي دي کاملا پاک مي شوند. در مواقع اندکي هم ميکرو کارش را درست انجام مي دهد و شروع به کار مي کند. مطمئن هستم که مشکل سخت افزاري ندارد. چندين کليد را هم عوض کردم ولي باز هم مشکل بر طرف نشد . مي خواهم يه جاي کليد در اين دستگاه به جاي کليد از رله استفاده کنم چون کليد شروع آن با دستگاه ديگري کنترل مي شود. اما وقتي با رله امتحان مي کنم باز هم درست کار نمي کند.
من براي اين کورنومتر از Mega8 استفاده می کنم. و وقتی با بیسکام کامپایل می کنمريال حجم آن را 99 درصد نشان می دهد. به نظر شما اگر مدارم را با Mega16 درست کنم، مشکل حل می شود؟؟


کد برنامه:

کد:
$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
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"
Do


   If Pind.4 = 1 Then
      Start Timer1
      Cls
      Enable Int1
      On Int1 Ee
'Ns = Ns + 1
'Writeeeprom Ns , 17
              'Sound Pind.0 , 10 , 500
              waitms 500
              jmp B
   End If
   Loop
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

'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

  End If
  Sound Pind.0 , 70 , 300                                   '@@@@@@@@@@@
  jmp O
Return

[تصویر:  1.jpg]
[تصویر:  2.jpg]
چند تا پیشنهاد :

بردتون رو تمیز کنین !
چون هشت مگ کریستال اطرافش کثیف باشه چون فرکانسش بالاست .... ( دیگه فکر نمی کنم نیازی به توضیح باشه و منظورمو گرفتین )

میکروتون سری ال نباشه و تغذیه مناسب فراموش نشه !
این قسمت خیلی مهمه !!!
ترجیحا یه خازن 220 نانو هم مستقیم به پایه های تغذیه میکرو 7-8 بچسبونین !!!

برد بزنید و از برد سوراخ دار استفاده نکنین !!
چاپ سبز داشته باشه بهتره !!


اونجاهایی که از eeprom می نویسه یه 5 میلی ثانیه تاخیر بذارین بعد از نوشتن در داخل eeprom !!


نمی دونم چجوریه ولی مگا 32 خیلی بهتر از 16 و 8 هستش و کمتر هنگ می کنه !!!!
هیچ دلیل علمی هم وجود نداره ولی تو عمل اینجوریه !!!

1) چرا باید از خازن 220 نانو استفاده کنم؟؟
2) چاپ سبز؟؟ یعنی بدم بیرون برد بزنن؟؟
1-
نویز تغذیه رو بگیره !

2-
اگه واستون مهمه خوب باید واسش خرج کنین !!
اگه مقاومت پول داون نذاشتین حتماً واسه کلیدا بذارین. و اگه اون مقاومتهای 10 اهمی پول داون هستن اونا رو 10 کیلو بکنیدشون. چون وقتی میان تو مدار جریان زیادی که میکشن افت ولتاژ ایجاد میکنن و میتونن موجب ریست شدن میکرو بشن
ممنون می شم اگه بگید مقاومت پول داون چیه؟؟
یعنی شما پیشنهاد می کنید مقاومت پول داون 10 کیلو اهم بزارم؟؟
Biggrin
اینقدر حال میده وسط بحث پریدن Biggrin
سلامHappy
نقل قول: ممنون می شم اگه بگید مقاومت پول داون چیه؟؟
مقاومت پول آپ : Pull Up : مقاومتی که یه سرش به + وصل هست.
مقاومت پول داون: Pull Down: مقاومتی که یه سرش به - وصل هست.


یه مقاومت بین اون پایه میکرو و زمین !!!
میشه پول دوون !

بین پایه میکرو و برق مثبت میشه پول آپ !


وقتی پایه میکرو ول باشه نویز میگیره و واسه اونه که در صورت ازاد بودن تو سطح مورد نظر نگه داره !!
یعنی حتی اگه تعریف نشده باشه تو برنامه بازم نویز میگیره؟
میشه یکم دقیق در مورد کاربورد مقاومت پول داون و پول آپ توضیح بدین؟
نه !
ولی بی تاثیر نیست !
همینطور که تو سری cmos می گن ورودی پایه های گیت هایی که استفاده نشده رو زمین کنین !!

یعنی مثلا وقتی یه کلید معرفی کردیم که اگه قرار بود یک بشه در نتیجه یه عملی انجام بشه ما بیایم یه پول داون بزاریم بین کلید و میکرو بهتره ؟
وبرعکسشم اگه قرار بود در صورت صفر شدن این اتفاق بیفتهباید پول آپ بزاریم؟
صفحه‌ها: 1 2 3