ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
422 stars 146 forks source link

EV3dev Python3: tacho_counts #742

Closed monsfortis1940 closed 4 years ago

monsfortis1940 commented 4 years ago

Question

How do you ...?

I have a question about tacho counts.

Is it possible to run the tacho motors based upon the tacho counts. for instance:

count_left = tacho_count_left count_right = tacho_count_right error = count_left - count_right tank_pair.on (left_speed = speed + error, right_speed = speed - error)

thank you in advance mario

Screenshots If applicable, add screenshots to help explain your question.

Desktop (please complete the following information):

Robot (please complete the following information):

Please paste the system info from the ev3dev VS Code extension or the output of `ev3dev-sysinfo -m` here!
WasabiFan commented 4 years ago

If you're asking whether you can provide speed in tacho counts per second, yes you can; you should use SpeedNativeUnits. So something like:

tank_pair.on (left_speed = SpeedNativeUnits(speed + error), right_speed = SpeedNativeUnits(speed - error))

The units are documented here for more info: https://python-ev3dev.readthedocs.io/en/ev3dev-stretch/motors.html#units

monsfortis1940 commented 4 years ago

Hello WasabiFan,

Thank you for your prompt answer. but it is not exactly what I mean. What I like to know for both motors ( f.i large_motor_B and large_motor_C) is the tacho_counts/ time_unit.

With f.i. the following routine I will control the both motors large _motor_B.on(SpeedRPM(30)) large_motor_C.on(SpeedRPM(30))

How can I be informed about the tacho_counts/time_unit ?

I hope You can help me

Thank you in advance mario

WasabiFan commented 4 years ago

Ah, sorry, I misunderstood. To read the current motor speed you can use the .speed attribute of a Motor: https://ev3dev-lang.readthedocs.io/projects/python-ev3dev/en/ev3dev-stretch/motors.html#ev3dev2.motor.Motor.speed

If you are using a pair of motors (e.g. MoveTank), you can use tank_pair.right_motor.speed (or equivalently for left_motor).

monsfortis1940 commented 4 years ago

hallo Wasabifan

Problem solved. Thank you very much

kind regards Mario

WasabiFan commented 4 years ago

Glad to hear it!