Hi hvn,
hvn hat geschrieben:I have a problem using getCurrentDistance(). According to the github manual, it should return the distance, but for me it always returns 0 (no matter which counter it's connected to). When I use getCurrentCounterValue(), I mostly get the expected counter value.
The getCurrentDistance() command is a method of the motor class (within the ftrobopy class).
Example:
- Code: Alles auswählen
txt = ftrobopy.ftrobopy('auto')
motor1 = txt.motor(1)
motor1.setDistance(1000)
motor1.setSpeed(400)
txt.updateWait()
while not motor1.finished():
print(motor1.getDistance())
txt.updateWait()
For this to work it is necessary that the motor output (M1-M4) and the fast counter input (C1-C4) of a connected motor correspond to each other (e.g. it is not possible to connect the motor to M1 and its counter to C2).
In contrast to this the getCurrentCounterValue() command is a method of the ftTXT class and can return any current counter input (C1-C4) independent of whether a motor object has been defined or not.
Example:
- Code: Alles auswählen
txt = ftrobopy.ftrobopy('auto')
while txt.getCurrentCounterValue(0) < 1000:
print(txt.getCurrentCounterValue(0))
txt.updateWait()
(meaning of getCurrentCounterValue()'s parameter: 0=C1, 1=C2, 2=C3, 3=C4, empty=all counters as list)
hvn hat geschrieben: Here's also a strange finding: when I read its value from C3 and C4, using Python I always get a good return but in ROBOPro ( the test panel) C4 always returns 0 (actually, the field stays empty). I haven't updated the CFW in a while, but could it have anything to do with it?
I don't really understand this observation ... but I assume it has nothing to do with the cfw version ... are you sure that the connections are correct ... does it only happen with C3 and C4 or also with C1 and C2 ... did you define a motor output in ROBOPro ?
Best wishes,
Torsten