Frequent problems with red TXT motors

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
hvn
Beiträge: 275
Registriert: 20 Feb 2011, 11:15

Frequent problems with red TXT motors

Beitrag von hvn » 22 Apr 2016, 09:14

Hi,

Frequently I have problems with the red motors: when programmed (in Python using ftrobopy) to run a straight line, they run into a left curve. This is the code for running in a straight line:
Motor_rechts.setSpeed(256)
Motor_links.setSpeed(256)
Motor_fan.setSpeed(-512)
Motor_rechts.setDistance(500, syncto=Motor_links)
Motor_links.setDistance(500, syncto=Motor_rechts)
Since the error doesn't always happen, could this be because of a motor malfunction?

hvn

Torsten
Beiträge: 324
Registriert: 29 Jun 2015, 23:08
Wohnort: Gernsheim (Rhein-Main-Region)

Re: Frequent problems with red TXT motors

Beitrag von Torsten » 22 Apr 2016, 12:34

Hi hvn,
hvn hat geschrieben:Hi,
Frequently I have problems with the red motors: when programmed (in Python using ftrobopy) to run a straight line, they run into a left curve. This is the code for running in a straight line:
Motor_rechts.setSpeed(256)
Motor_links.setSpeed(256)
Motor_fan.setSpeed(-512)
Motor_rechts.setDistance(500, syncto=Motor_links)
Motor_links.setDistance(500, syncto=Motor_rechts)
Since the error doesn't always happen, could this be because of a motor malfunction?
hvn
I think this problem is not related to a motor malfunction but rather to a synchronisation problem in your python program: the python thread that exchanges (motor-, output- and input-) data between the TXT and the python program is called every 10ms. (This is the same when using the TXT with ROBOPro). In your example code it may happen, that the command "Motor_rechts.setSpeed(256)" and the synchronisation commands ("...syncto=...") are not communicated to the TXT at the same time. Thus the motors run out of sync.

ftrobopy provides a way to ensure synchrony of TXT commands with the "SyncData" functions:

txt.SyncDataBegin()
Motor_rechts.setDistance(500, syncto=Motor_links)
Motor_links.setDistance(500, syncto=Motor_rechts)
Motor_rechts.setSpeed(256)
Motor_links.setSpeed(256)
Motor_fan.setSpeed(-512)
txt.SyncDataEnd()

The commands between SyncDataBegin() and SyncDataEnd() will be communicated to the TXT at the same time.

Kind regards,
Torsten

@forum-admins: I would recommend to move this thread to "Robo Pro / Computing / Software".

sven
Beiträge: 2750
Registriert: 18 Okt 2010, 18:13
Wohnort: Rahden
Kontaktdaten:

Re: Frequent problems with red TXT motors

Beitrag von sven » 22 Apr 2016, 12:45

Hallo!

Ich habe das Thema nun verschoben.

Gruß
Sven
Dieses Posting gibt ganz allein meine persönliche Meinung wieder!

hvn
Beiträge: 275
Registriert: 20 Feb 2011, 11:15

Re: Frequent problems with red TXT motors

Beitrag von hvn » 22 Apr 2016, 16:52

Hi Torsten,

Thank you for this solution.

hvn

Antworten