This post describes what a pivot turn is, why we need an EV3 pivot turn My Block, and how to create one step by step. This post also will tell you the geometry background to calculate the pivot turn degree vs wheel motor degree ratio. In the end, we will show you how to turn your robot 90 degrees using the EV3 pivot turn My Block we created in this post.
We created and used an EV3 pivot turn My Block extensively during our first year of FLL CITY SHAPER robot game along with Move Straight Inch My Block and other reusable code. We found this My Block really useful for consistent turning. I hope this post helps you creating your own reusable EV3 Pivot Turn My Block in Mindstorms.
If you’re interested in FLL robot design, please check out our robot design principle posts. And please leave your feedback and suggestions.
Pivot turn is one wheel turn, that is, one wheel moves forward or backward and the other doesn’t move.
Spin turn is a two-wheel turn, that is, one wheel moves forward or backward and the other wheel moves in opposite direction.
Spin turn is very useful when we have limited space. Otherwise pivot turn is relatively more consistent and is suitable for most cases.
There are four kind of pivot turns: forward pivot turn left, forward pivot turn right, backward pivot turn left, and backward pivot turn right. We will create an EV3 Pivot Turn My Block which can do all four pivot turns.
Move Tank Block
Many EV3 blocks can be used to make pivot turns including Move Steering block and Move Tank Block .
We prefer to use Move Tank Block when making turns because the result is more predictable since we can control two motors separately. For pivot turn, we can set one wheels power to 0 and another one for moving forward or backward. According to online help, the Move Tank Block has five modes as shown in the following screenshot:
On for Degrees mode can be used to make pivot turn, waits until the motor has turned for the number of degrees of rotation in the Degrees input, and then turns both motors off. 360 degrees of rotation corresponds to one full turn of a motor.
The question is what’s the Degrees input we should enter if we want to turn our robot for 90 degrees for example. 🙁
Pivot Turn Degree vs Motor Degree Ratio
Let’s define the track as the distance between two wheels. We will use L for the track. To Pivot turn our robot in Theta degrees, a wheel needs to travel the following distance:
Travel distance = Theta * L
For a wheel with diameter D, to travel the same distance the wheel need to rotate in motor Degrees, we will have:
Travel distance = Theta * L = Degrees * D / 2.
Now let’s define Pivot Turn Degree vs Motor Degree Ratio as:
Ratio = 2 * L / D
Pivot Turn Degree vs Motor Degree Ratio means that to spin turn 1 degree, motor B or C needs to rotate 2* L/D degrees.
The geometry of Pivot Turn Degree vs Motor Degree Ratio is illustrated in the following image:
For example, if the wheel diameter D is 6.88 cm. and the track length L is 11 cm. the ratio will be calculated as:
Ratio = 2 * 11 / 6.88 = 3.2
Once we have the Pivot Turn Degree vs Motor Degree Ratio we can use a math block to simplify the input motor Degree calculation based on the degree a robot needs to pivot turn.
Using Pivot Turn Degree vs Motor Degree Ratio
Once we have the Pivot Turn Degree vs Motor Degree Ratio, we can calculate the Pivot Turn Degrees we wanted. The following screenshot shows how to program using a Move Tank block and a Math block.
Reusable EV3 Pivot Turn My Block
Now, let’s make a My Block so our program will be reusable. First, we select the Math block, the Move Tank block, and the comment. Then we select My Block Builder from the Tools menu.
Next, let’s enter the My Block name and select an icon as shown below.
Now let’s add two parameters for Motor B and C Power Inputs.
Now let’s add the parameter for Pivot Turn Degrees.
At last we use data wire to connect input parameters to Move Tank Block’s Motor B and Motor C Power and Math Blocks.
Using The Pivot Turn My Block
Once we have created the EV3 Pivot Turn My Block (MyPivotTurn) we can reuse it whenever we need it. MyPivotTurn has three input parameters:
b: motor B power; c: motor C power; and pivot turn degree.
To forward pivot turn left, set motor B power positive and C power 0.
To forward pivot turn right, set motor B power 0 and C power positive.
To backward pivot turn left, set motor B power 0 and C power positive.
To backward pivot turn right, set motor B power negative and C power 0.
By setting the three input parameters, we can achieve four types of pivot turns. The following screenshot is an example of using the MyPivotTurn.