time.sleep() geht auf einmal nicht mehr

Alles rund um TX(T) und RoboPro, mit ft-Hard- und Software
Computing using original ft hard- and software
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
BobbyWander
Beiträge: 7
Registriert: 21 Aug 2025, 15:07

time.sleep() geht auf einmal nicht mehr

Beitrag von BobbyWander » 20 Feb 2026, 21:09

Hallo Torsten,

ich versuche eine Box auf meinen Plotter zu zeichnen. Wenn der Plotter versucht zu plotten, dann geht der Stift von der Geraden ab und zeichnet eine Kurve, wo er eigentlich einen Strich zeichnen sollte und ingnoriert den time.sleep(). Ich habe die neueste Version von Python 3.14.3, TX2013 firmware version 4.7.0 und ftrobopy 2.0.2 installiert. Vor zwei Tagen ging noch alles einwandfrei.

Code: Alles auswählen

def move_to_line(dx, dy, speed=340):
    dx_l = to_counts(dx / 10, 'x')
    dy_l = to_counts(dy / 10, 'y')
    
    mg = justagecheck(dx, dy)
    if mg:
        return mg
    else:
        try:
            if dx < 0 and dy == 0:
                motorX.setDistance(-dx_l)
                motorX.setSpeed(-speed)
            elif dx > 0 and dy == 0:
                motorX.setDistance(dx_l)
                motorX.setSpeed(speed)
            elif dy < 0 and dx == 0:
                motorY.setDistance(-dy_l)
                motorY.setSpeed(-speed)
            elif dy > 0 and dx == 0:
                motorY.setDistance(dy_l)
                motorY.setSpeed(speed)
            print(dx_l, dy_l)
            # Warte bis beide fertig sind
            while not motorX.finished() or not motorY.finished():
                if motorX.finished():
                    motorX.stop()
                    break
                if motorY.finished():
                    motorY.stop()
                    break
            txt.updateWait()
             
        except Exception:
            print("Fallback-Synchronisation: setDistance nicht verfügbar, fahre getrennt.")
            motorX.setSpeed(speed if dx_l>0 else -speed)
            motorY.setSpeed(speed if dy_l>0 else -speed)
            est = max(abs(dx_l), abs(dy_l)) / 100.0
            time.sleep(est)
            motorX.setSpeed(0)
            motorY.setSpeed(0)
 
Jetzt kommt die Box-Funktion:

Code: Alles auswählen

def box(xa, xe, ya, ye):
    """
      Box zeichnen:
      xa, ya: Wo geplottet werden soll
      xe, ye: Einzelne Striche zeichnen
    """      
    tv = 0.9
    move(xa, ya)
    mg_on()
    print("Box wird gezeichnet...", xa, xe, ya, ye)
    move_to_line(xe, 0)
    time.sleep(tv)
    move_to_line(0, ye)
    time.sleep(tv)
    move_to_line(-xe, 0)
    move_to_line(0, -ye)
    mg_off()
    print("Fertig!")
    print()
Kannst Du mir bitte weiterhelfen? Was ist an diesem Code falsch? Ich hoffe auf eine baldige Antwort und verbleibe

Mit freundlichen Grüßen
BobbyWander

Antworten