Seite 1 von 1
Frequent problems with red TXT motors
Verfasst: 22 Apr 2016, 09:14
von hvn
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
Re: Frequent problems with red TXT motors
Verfasst: 22 Apr 2016, 12:34
von Torsten
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".
Re: Frequent problems with red TXT motors
Verfasst: 22 Apr 2016, 12:45
von sven
Hallo!
Ich habe das Thema nun verschoben.
Gruß
Sven
Re: Frequent problems with red TXT motors
Verfasst: 22 Apr 2016, 16:52
von hvn
Hi Torsten,
Thank you for this solution.
hvn