اطلاعیه

Collapse
No announcement yet.

یک برنامه نوشتم اشکال داره

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    یک برنامه نوشتم اشکال داره

    سلام دوستان کلی دنبال یه برنامه نویس برای avr گشتم که نتونستم پیدا کنم خودم کتاب برداشتم و اینو نوشتم اما جواب نمیده
    لطفا کمک کنید اشتباهاتم رو بگین

    $regfile = "m16def.dat"
    $crystal = 1000000

    Config Pina.0 = Input 'S close
    Config Pina.1 = Input 'S vasat
    Config Pina.2 = Input 'S Open

    Config Pina.3 = Input 'Z out
    Config Pina.4 = Input 'Z In

    Config Pina.5 = Output 'R1
    Config Pina.6 = Output 'R2
    Config Pina.7 = Output 'r3

    Config Pinc.0 = Input 'open
    Config Pinc.1 = Input 'close
    Config Pinc.2 = Input '1
    Config Pinc.3 = Input '2

    Sc Alias Pina.0
    Sv Alias Pina.1
    So Alias Pina.2

    Zo Alias Pina.3
    Zi Alias Pina.4

    R1 Alias Pina.5
    R2 Alias Pina.6
    R3 Alias Pina.7

    Swo Alias Pinc.0
    Swc Alias Pinc.1
    Sw1 Alias Pinc.2
    Sw2 Alias Pinc.3

    Dim Sc As Bit
    Dim Sv As Bit
    Dim So As Bit

    Dim Zo As Bit
    Dim Zi As Bit

    Dim R1 As Bit 'close
    Dim R2 As Bit 'open
    Dim R3 As Bit '12\24

    Dim Swo As Bit
    Dim Swc As Bit
    Dim Sw1 As Bit
    Dim Sw2 As Bit

    Do

    If Swo = 0 Then
    Goto Open
    If Swc = 0 Then
    Goto Close
    If Sw1 = 0 Then
    Goto 1tarafe
    If Sw2 = 0 Then
    Goto 2tarafe
    End If
    End If
    End If
    End If

    Loop

    Close:
    Set R1
    Bitwait Sc , Reset
    Reset R1
    Bitwait Sc , Set
    Set R1
    If Sv = 0 Then
    Set R3
    Wait 3
    Reset R3
    End If
    Goto Close

    Open:
    Set R2
    If So = 0 Then
    Reset R2
    Reset R3
    End If
    Goto Open

    1tarafe:
    Set R1
    If Zi = 0 Then
    Reset R1
    Set R2
    If So = 0 Then
    Reset R2
    Reset R3
    Wait 5
    Set R1
    If Sc = 0 Then
    Reset R1
    Reset R3
    If Sv = 0 Then
    Set R3
    End If
    End If
    End If
    End If
    Goto 1tarafe

    2tarafe:
    Set R1
    If Zi = 0 Then
    Reset R1
    Set R2
    If Zo = 0 Then
    Reset R1
    Set R2
    If So = 0 Then
    Reset R2
    Reset R3
    Wait 5
    Set R1
    If Sc = 0 Then
    Reset R1
    Reset R3
    If Sv = 0 Then
    Set R3
    End If
    End If
    End If
    End If
    End If
    Goto 2tarafe



    End$regfile = "m16def.dat"
    $crystal = 1000000

    Config Pina.0 = Input 'S close
    Config Pina.1 = Input 'S vasat
    Config Pina.2 = Input 'S Open

    Config Pina.3 = Input 'Z out
    Config Pina.4 = Input 'Z In

    Config Pina.5 = Output 'R1
    Config Pina.6 = Output 'R2
    Config Pina.7 = Output 'r3

    Config Pinc.0 = Input 'open
    Config Pinc.1 = Input 'close
    Config Pinc.2 = Input '1
    Config Pinc.3 = Input '2

    Sc Alias Pina.0
    Sv Alias Pina.1
    So Alias Pina.2

    Zo Alias Pina.3
    Zi Alias Pina.4

    R1 Alias Pina.5
    R2 Alias Pina.6
    R3 Alias Pina.7

    Swo Alias Pinc.0
    Swc Alias Pinc.1
    Sw1 Alias Pinc.2
    Sw2 Alias Pinc.3

    Dim Sc As Bit
    Dim Sv As Bit
    Dim So As Bit

    Dim Zo As Bit
    Dim Zi As Bit

    Dim R1 As Bit 'close
    Dim R2 As Bit 'open
    Dim R3 As Bit '12\24

    Dim Swo As Bit
    Dim Swc As Bit
    Dim Sw1 As Bit
    Dim Sw2 As Bit

    Do

    If Swo = 0 Then
    Goto Open
    If Swc = 0 Then
    Goto Close
    If Sw1 = 0 Then
    Goto 1tarafe
    If Sw2 = 0 Then
    Goto 2tarafe
    End If
    End If
    End If
    End If

    Loop

    Close:
    Set R1
    Bitwait Sc , Reset
    Reset R1
    Bitwait Sc , Set
    Set R1
    If Sv = 0 Then
    Set R3
    Wait 3
    Reset R3
    End If
    Goto Close

    Open:
    Set R2
    If So = 0 Then
    Reset R2
    Reset R3
    End If
    Goto Open

    1tarafe:
    Set R1
    If Zi = 0 Then
    Reset R1
    Set R2
    If So = 0 Then
    Reset R2
    Reset R3
    Wait 5
    Set R1
    If Sc = 0 Then
    Reset R1
    Reset R3
    If Sv = 0 Then
    Set R3
    End If
    End If
    End If
    End If
    Goto 1tarafe

    2tarafe:
    Set R1
    If Zi = 0 Then
    Reset R1
    Set R2
    If Zo = 0 Then
    Reset R1
    Set R2
    If So = 0 Then
    Reset R2
    Reset R3
    Wait 5
    Set R1
    If Sc = 0 Then
    Reset R1
    Reset R3
    If Sv = 0 Then
    Set R3
    End If
    End If
    End If
    End If
    End If
    Goto 2tarafe



    End
    این برنامه قراره برای درب های اتومات باشه درب های فروشگاهها البته میخوام جایگزین برد سوخته یه درب اتومات کنم
    سه تا سنسور داره که اول آخر و وسط درب رو تشخیص میدهد
    وسطی برای کنترل سرعت درب
    دوتا زوم هم داره که درب رو باز میکنن

    #2
    پاسخ : یک برنامه نوشتم اشکال داره

    توی پروتئوس شبیه سازی گردی
    اگر بله :
    فایل رو بزار
    اگر خیر :
    این کار رو بکن

    اگه مردم می دونستن زمان چقدر با ارزشه دیگه هیچ وقت کفش بند دار نمی خریدن البرت انیشتن

    دیدگاه


      #3
      پاسخ : یک برنامه نوشتم اشکال داره

      این برنامه قراره چیکار کنه؟ باید حتما با اسمبلی باشه؟ من سی بلدم، بگو برنامت قراره چیکار کنه؟

      دیدگاه


        #4
        پاسخ : یک برنامه نوشتم اشکال داره

        چرا برنامرو دو بار پیست کردی ؟
        درست کن
        :nice:
        اگه هم میشه بگو کلا چی کار کردی ؟
        نمیشه فهمید :agree:
        [move][img width=133 height=100]http://bargiri.persiangig.com/aks/0.306310001356499787_taknaz_ir.gif[/img][/move]

        دیدگاه


          #5
          پاسخ : یک برنامه نوشتم اشکال داره

          ببخشید از اینکه دوبار کپی شده بود
          این برنامه رو برای یک درب اتومات کشویی نوشتم ولی اشکال داره
          سه عدد سنسور مگنت داره که مکان درب رو نشان می دهد (بسته باز و وسط )
          دوتا زوم دارد که هر گاه کسی وارد و خارج میشود درب را باز و بسته میکند
          چهار تا کلید دارد که حالت های مختلف رو نشان می دهد (باز بسته یک طرفه دوطرفه )
          سه عدد رله گزاشتم یکی برای اینکه برق متور رو 12 یا 24 کنه . و اون دو تای دیگه برای اینکه چهت چرخشش رو عوض کنه
          دوستان هر چه سریع تر اشکالات من رو بگید ممنون میشم



          $regfile = "m16def.dat"
          $crystal = 1000000

          Config Pina.0 = Input 'S close
          Config Pina.1 = Input 'S vasat
          Config Pina.2 = Input 'S Open

          Config Pina.3 = Input 'Z out
          Config Pina.4 = Input 'Z In

          Config Pina.5 = Output 'R1
          Config Pina.6 = Output 'R2
          Config Pina.7 = Output 'r3

          Config Pinc.0 = Input 'open
          Config Pinc.1 = Input 'close
          Config Pinc.2 = Input '1
          Config Pinc.3 = Input '2

          Sc Alias Pina.0
          Sv Alias Pina.1
          So Alias Pina.2

          Zo Alias Pina.3
          Zi Alias Pina.4

          R1 Alias Pina.5
          R2 Alias Pina.6
          R3 Alias Pina.7

          Swo Alias Pinc.0
          Swc Alias Pinc.1
          Sw1 Alias Pinc.2
          Sw2 Alias Pinc.3

          Dim Sc As Bit
          Dim Sv As Bit
          Dim So As Bit

          Dim Zo As Bit
          Dim Zi As Bit

          Dim R1 As Bit 'close
          Dim R2 As Bit 'open
          Dim R3 As Bit '12\24

          Dim Swo As Bit
          Dim Swc As Bit
          Dim Sw1 As Bit
          Dim Sw2 As Bit

          Do

          If Swo = 0 Then
          Goto Open
          If Swc = 0 Then
          Goto Close
          If Sw1 = 0 Then
          Goto 1tarafe
          If Sw2 = 0 Then
          Goto 2tarafe
          End If
          End If
          End If
          End If

          Loop

          Close:
          Set R1
          Bitwait Sc , Reset
          Reset R1
          Bitwait Sc , Set
          Set R1
          If Sv = 0 Then
          Set R3
          Wait 3
          Reset R3
          End If
          Goto Close

          Open:
          Set R2
          If So = 0 Then
          Reset R2
          Reset R3
          End If
          Goto Open

          1tarafe:
          Set R1
          If Zi = 0 Then
          Reset R1
          Set R2
          If So = 0 Then
          Reset R2
          Reset R3
          Wait 5
          Set R1
          If Sc = 0 Then
          Reset R1
          Reset R3
          If Sv = 0 Then
          Set R3
          End If
          End If
          End If
          End If
          Goto 1tarafe

          2tarafe:
          Set R1
          If Zi = 0 Then
          Reset R1
          Set R2
          If Zo = 0 Then
          Reset R1
          Set R2
          If So = 0 Then
          Reset R2
          Reset R3
          Wait 5
          Set R1
          If Sc = 0 Then
          Reset R1
          Reset R3
          If Sv = 0 Then
          Set R3
          End If
          End If
          End If
          End If
          End If
          Goto 2tarafe



          End

          دیدگاه

          لطفا صبر کنید...
          X