pxt-ev3/docs/reference/motors/motor/tacho.md

1.8 KiB

tacho

Get the current number of degress of rotation.

motors.largeA.tacho()

The motors that come with your @boardname@ have a way to detect their own turning motion. They count the amount of motor rotation in degrees. The motor will count each degree of angle rotation up to 360 degrees for a full rotation. As the motor continues to turn, the tacho count keeps adding up the degrees even past one full rotation. So, if the motor makes 3 complete rotations, the count will be 1080.

The name tacho comes from the first part of the word tachometer which is a device to measure how fast something is turning. The motor controller in the brick uses the tacho count to regulate the motor's speed.

~hint

Measure RPM

A standard way to know how fast a motor is turning is by measuring its revolutions per minute (rpm). One revolution is the same thing as a rotation, or one turn. How do you measure rpm? Well, here's a simple way:

  1. Record the current tacho count
  2. Run the motor for 60 seconds
  3. Get the tacho count again
  4. Subtract the first tacho count from the second one
  5. Divide that number by 360

~

Returns

  • a number which is the total count of degrees of rotation that the motor has turned since it was first started or reset.

Example

Run the motor connected to port A at half speed for 5 seconds. Display the number of full rotations on the screen.

motors.largeA.run(50)
pause(5000)
motors.largeA.stop()
brick.showString("Motor rotations:", 1)
brick.showNumber(motors.largeA.tacho() / 360, 3)
motors.largeA.run(50)

See also

angle, speed, set regulated, reset, clear counts