- 3D-Druck Einstieg und Tipps         
Ergebnis 1 bis 6 von 6

Thema: benötige Hilfe bei meinem Code

  1. #1
    Erfahrener Benutzer Roboter Experte
    Registriert seit
    17.08.2005
    Alter
    39
    Beiträge
    685

    benötige Hilfe bei meinem Code

    Anzeige

    LiFePo4 Akku selber bauen - Video
    Hallo,

    Ich habe mein Bot jetzt schon sehr weit vorangebracht, kann ich alles einzeln per Programm sehr gut steuern. Nun will ich einiges zusammenbringen, aber ich erhalte immer versch. Errors (46, 60, ).
    Das komische: Schon beim config der Servos erhalte ich eine Fehlermeldung (sehr merkwürdig), welche beim programmieren des servo subs durch den Error 46 ersetzt wird ;-(

    Bis jetzt habe ich schon sehr viel im Forum darüber gelesen, aber weder stacks noch framesize konnten es bei mir beheben (habe versch. Werte getestet und auch komplett weggenommen).

    Hier der Code:

    Code:
     $regfile = "m32def.dat"
      $framesize = 32
      $swstack = 256
      $hwstack = 128
      $crystal = 16000000
      $baud = 9600
      $lib "mcsbyte.lbx"
    
    Config Pind.6 = Input
    Config Rc5 = Pind.6
    Portd.6 = 1
    Config Pinc.2 = Output
    
    Config Pinc.4 = Output
    Config Pinc.3 = Input
    
    'Ports für linken Motor
    Config Pinb.0 = Output
    Config Pinb.4 = Output
    Config Pind.5 = Output
    'Ports für rechten Motor
    Config Pinb.1 = Output
    Config Pinb.2 = Output
    Config Pind.4 = Output
    
    Config Servos = 2 , Servo1 = Portd.7 , Servo2 = Portb.3 , Reload = 10
    Config Pinb.3 = Output
    Config Pind.7 = Output
    
    Enable Interrupts
    
    Dim Address As Byte , Command As Byte
    Dim Pulses As Word , Periods As Word
    Pulses = 65535 : Periods = 10000
    Speaker Alias Portc.2
    Dim I As Integer
    
    Declare Sub Vorwaerts
    Declare Sub Rueckwaerts
    Declare Sub Halt
    Declare Sub Links
    Declare Sub Rechts
    Declare Sub These
    Declare Sub Servo
    
    Do
    
    Portc.4 = 1
    Gosub Servo
    Gosub Vorwaerts
    
    Loop
    
    Sub Servo
    Servo(2) = 95
    Print "Mittelstellung"
    Wait 1
    Servo(1) = 95
    Print "Mittelstellung"
    Wait 1
    End Sub
    Return
    
    Sub Vorwaerts
    Do
    Portb.1 = 1
    Portb.2 = 0
    Portb.4 = 0
    Portb.0 = 1
    Portd.4 = 1
    Portd.5 = 1
    Getrc5(address , Command)
    Loop Until Pinc.3 = 0 Or Command = 11 Or Command = 12 Or Command = 13 Or Command = 14 Or Command = 15
    Gosub Halt
    End Sub
    Return
    
    Sub Halt
    Portb.1 = 1
    Portb.2 = 1
    Portb.4 = 1
    Portb.0 = 1
    Portd.4 = 1
    Portd.5 = 1
    Wait 1
    Getrc5(address , Command)
    Waitms 150
    If Command = 11 And Command = 12 And Command = 13 And Command = 14 And Command = 15 Or Command = 12 And Command = 13 And Command = 14 Then
    Gosub Rueckwaerts
    Elseif Command = 11 Or Command = 12 Then
    Gosub Rechts
    Elseif Command = 13 Or Command = 14 Or Command = 15 Then
    Gosub Links
    Elseif Command = 255 Then
    Gosub These
    End If
    End Sub
    Return
    
    Sub Rueckwaerts
    Portb.1 = 0
    Portb.2 = 1
    Portb.4 = 1
    Portb.0 = 0
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Portb.1 = 1
    Portb.2 = 1
    Portb.4 = 1
    Portb.0 = 1
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Gosub Rechts
    End Sub
    Return
    
    Sub Rechts
    Portb.1 = 1
    Portb.2 = 0
    Portb.4 = 1
    Portb.0 = 0
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Gosub Vorwaerts
    End Sub
    Return
    
    Sub Links
    Portb.1 = 0
    Portb.2 = 1
    Portb.4 = 0
    Portb.0 = 1
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Gosub Vorwaerts
    End Sub
    Return
    
    Sub These
    Portb.1 = 1
    Portb.2 = 0
    Portb.4 = 1
    Portb.0 = 0
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Gosub Vorwaerts
    End Sub
    Return
    
    End

  2. #2
    Erfahrener Benutzer Fleißiges Mitglied
    Registriert seit
    25.02.2005
    Beiträge
    175
    Hi,

    schau mal hier:
    "Declare Sub Servo"

    "Servo" ist ein Steuerwort, versuch doch mal, Deine eigene Subroutine anders zu benennen...

    Viele Grüße

    Torsten

  3. #3
    Erfahrener Benutzer Roboter Experte
    Registriert seit
    17.08.2005
    Alter
    39
    Beiträge
    685
    Guter Einwurf, war ein Fehler.
    Doch nun erhalte ich den vorherigen Fehler (Error 60 , 60 und 221) mit dem Code:

    Code:
      $regfile = "m32def.dat"
      $framesize = 32
      $swstack = 256
      $hwstack = 128
      $crystal = 16000000
      $baud = 9600
      $lib "mcsbyte.lbx"
    
    Config Pind.6 = Input
    Config Rc5 = Pind.6
    Portd.6 = 1
    Config Pinc.2 = Output
    
    Config Pinc.4 = Output
    Config Pinc.3 = Input
    
    'Ports für linken Motor
    Config Pinb.0 = Output
    Config Pinb.4 = Output
    Config Pind.5 = Output
    'Ports für rechten Motor
    Config Pinb.1 = Output
    Config Pinb.2 = Output
    Config Pind.4 = Output
    
    Config Servos = 2 , Servo1 = Portd.7 , Servo2 = Portb.3 , Reload = 10
    Config Pinb.3 = Output
    Config Pind.7 = Output
    
    Enable Interrupts
    
    Dim Address As Byte , Command As Byte
    Dim Pulses As Word , Periods As Word
    Pulses = 65535 : Periods = 10000
    Speaker Alias Portc.2
    Dim I As Integer
    
    Declare Sub Vorwaerts
    Declare Sub Rueckwaerts
    Declare Sub Halt
    Declare Sub Links
    Declare Sub Rechts
    Declare Sub These
    Declare Sub Camera
    
    Do
    
    Portc.4 = 1
    Gosub Camera
    Gosub Vorwaerts
    
    Loop
    
    Sub Camera
    Servo(2) = 95
    Print "Mittelstellung"
    Wait 1
    Servo(1) = 95
    Print "Mittelstellung"
    Wait 1
    End Sub
    Return
    
    Sub Vorwaerts
    Do
    Portb.1 = 1
    Portb.2 = 0
    Portb.4 = 0
    Portb.0 = 1
    Portd.4 = 1
    Portd.5 = 1
    Getrc5(address , Command)
    Loop Until Pinc.3 = 0 Or Command = 11 Or Command = 12 Or Command = 13 Or Command = 14 Or Command = 15
    Gosub Halt
    End Sub
    Return
    
    Sub Halt
    Portb.1 = 1
    Portb.2 = 1
    Portb.4 = 1
    Portb.0 = 1
    Portd.4 = 1
    Portd.5 = 1
    Wait 1
    Getrc5(address , Command)
    Waitms 150
    If Command = 11 And Command = 12 And Command = 13 And Command = 14 And Command = 15 Or Command = 12 And Command = 13 And Command = 14 Then
    Gosub Rueckwaerts
    Elseif Command = 11 Or Command = 12 Then
    Gosub Rechts
    Elseif Command = 13 Or Command = 14 Or Command = 15 Then
    Gosub Links
    Elseif Command = 255 Then
    Gosub These
    End If
    End Sub
    Return
    
    Sub Rueckwaerts
    Portb.1 = 0
    Portb.2 = 1
    Portb.4 = 1
    Portb.0 = 0
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Portb.1 = 1
    Portb.2 = 1
    Portb.4 = 1
    Portb.0 = 1
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Gosub Rechts
    End Sub
    Return
    
    Sub Rechts
    Portb.1 = 1
    Portb.2 = 0
    Portb.4 = 1
    Portb.0 = 0
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Gosub Vorwaerts
    End Sub
    Return
    
    Sub Links
    Portb.1 = 0
    Portb.2 = 1
    Portb.4 = 0
    Portb.0 = 1
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Gosub Vorwaerts
    End Sub
    Return
    
    Sub These
    Portb.1 = 1
    Portb.2 = 0
    Portb.4 = 1
    Portb.0 = 0
    Portd.4 = 1
    Portd.5 = 1
    Waitms 500
    Gosub Vorwaerts
    End Sub
    Return
    
    End
    Veränderung der Stack Werte bzw. framesize beheben leider nicht den Fehler.

  4. #4
    Erfahrener Benutzer Robotik Einstein
    Registriert seit
    22.05.2005
    Ort
    12°29´ O, 48°38´ N
    Beiträge
    2.731
    Hallo,
    ist es nicht bei Verwendung von Gosub so, das man da keine Sub's definiert sondern nur Labels !?

    Return steht auch immer nach dem End sub,
    schaut meiner Meinung nach auch komisch aus !

  5. #5
    Erfahrener Benutzer Fleißiges Mitglied
    Registriert seit
    09.11.2004
    Ort
    Hard, Vorarlberg
    Beiträge
    155
    Hallo,

    Das Problem ist, dass SERVO und RC5 beide den Timer0 benötigen.
    Bei RC5 hast Du aber die Möglichkeit mit dem Zusatz Timer = 2 auszuweichen. Schau mal in Hilfe unter CONFIG RC5 nach.

    Generell sollte man bei Routinen welcher Timer/Counter verwenden in der Hilfe nachsehen, welche HW-Ressourcen benötigt werden, damit hier keine Konflikte entstehen.

    SUB werden mit END SUB beendet. Das RETURN hinter Deinen END SUB ist nicht notwendig (macht hier aber auch kein Problem).
    Viele Grüße
    Josef
    -------------------------------------------------------------------------------------
    DOS-File System für BASCOM-AVR auf http://members.aon.at/voegel

  6. #6
    Erfahrener Benutzer Roboter Experte
    Registriert seit
    17.08.2005
    Alter
    39
    Beiträge
    685
    Danke euch allen vielmals, mit Timer 2 für rc5 funktioniert es jetzt, danke wirklich

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Labornetzteil AliExpress