* Start of 'motors' topics * Draft the 'motor motion' side doc * Add / update more topics * Last blast of edits * Capture some more edits * Put in movement and steering details
1.9 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:
- Record the current tacho count
- Run the motor for 60 seconds
- Get the tacho count again
- Subtract the first tacho count from the second one
- 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.setSpeed(50)
loops.pause(5000)
motors.largeA.stop()
brick.showString("Motor rotations:", 1)
brick.showNumber(motors.largeA.tacho() / 360, 3)
motors.largeA.setSpeed(50)