Coding Individual VEX IQ Motors to Turn
Learn how to calculate the number of wheel turns needed in order for the BaseBot to autonomously turn right for 360 degrees, and then use this calculation in VEXcode IQ to code the individual VEX IQ motors based on the Distance = Circumference x Turn(s) equation.
(upbeat music)
Hello and welcome to the VEX Classroom. My name is Lauren. In this video, we're going to be talking about coding individual VEX IQ motors in order to turn. More specifically, how do I code individual motors instead of using a drivetrain? We'll be using individual motor commands to turn my BaseBot 360 degrees. The concepts covered in this video can be applied to any robot design, but I'll be using the BaseBot as an example.
In this particular video, we'll build on conclusions and calculations from a previous video about coding individual VEX IQ motors to drive a straight distance. If you haven't watched that video yet, I'll link it below. It's important to watch it first to understand the initial calculations we'll be using. The original calculations and motor configurations were discussed in that video as well. If you need more information, you can refer to the linked video.
So, what do we already know from the previous video about coding individual motors? One key finding was the actual circumference or distance traveled by one wheel turn of a VEX IQ wheel. By rolling the wheel along a VEX ruler, we concluded that one revolution of the wheel is 200 millimeters. This is also written on the wheel for reference. I'll note that here: 200 millimeters for the circumference of the wheel, which we'll use in our calculations.
Now, what's the difference between turning and driving a set distance? In the previous video, both motors moved forward in tandem to drive the robot forward. For turning, such as turning right, the left motor goes forward while the right motor goes in reverse. This allows the robot to turn. Conversely, turning left involves the right motor going forward and the left motor going backward. The main difference is that instead of both motors driving forward, one motor goes forward and the other goes backward to rotate.
In this video, I'll demonstrate rotating the entire robot 360 degrees. I've created a program and downloaded it to my robot to show you how it looks. I've slowed the robot down to observe the 360-degree turn. I'll set both wheels in the center of the tile and watch how the robot turns 360 degrees.
Thank you for watching this video on coding individual VEX IQ motors for turning. I hope you found it helpful. If you have any questions or need further clarification, feel free to reach out. Happy coding!
Number one, let the left wheel go forward, and the right wheel go in reverse for that right turn. Exactly turned 360 degrees, right back to where I started. Let's watch it one more time. You can see that I already drew on the tile there, a red circle. That is the circle that's being made by the wheels, by these driving wheels.
So if you could imagine I had markers right underneath, two pencils maybe, right underneath the center of these wheels. As I turned, they were tracing a circle. This is what's actually going to be made. So this is the circle that these two wheels are actually traveling. Each wheel has to travel this distance in order to complete that 360 degrees of the final robot.
What does that mean? Well, thinking back to our formula, distance equals circumference times the number of turns. I know that one wheel turn, one revolution of one of these wheels, is 200 millimeters. So I'm basically trying to figure out how many turns do I need in order to spin the entire robot 360 degrees? How many times do the individual motors, each of those wheels, need to turn for the entire robot to spin 360 degrees? That's what we're trying to figure out. We're trying to calculate the number of turns.
Again, we know from the previous video that the circumference of each wheel is actually 200 millimeters. So what do we need to figure out? I need to figure out turns, but in order to do so, I need to know what the distance is that each of those wheels is going to travel. In the previous video, we were doing a straight line distance. It's very easy to measure a straight line distance. I can use a ruler or a lot of different methods to measure a straight line.
However, when we are turning, our distance is now circular or curved. It's very hard to bend a ruler to measure that. So there are different ways that we can measure the distance around a circle, which is actually called circumference. The distance that each wheel needs to travel in order to spin the entire robot 360 degrees is the circumference of this circle that I just showed you here, traced from this robot.
Let me make this a little bit more clear. This is going to be the robot distance, found by the wheel circumference times the number of wheel turns. It's the same formula, same idea. Everything is still the same. We're still doing robot distance. It was robot distance in a straight line, and it's still robot distance if it's in a circle. Distance is distance, whether I'm going in a straight line or curved or anything like that. We need to calculate that. We know the wheel circumference is 200 millimeters, so I'm gonna put that in. We're trying to figure out the number of wheel turns.
What do I need to plug in? I need to plug in the robot distance. How far is this? Or how big, I should say, is this circle? How far does each wheel need to travel along this circle? How do I calculate the distance around a circle, also known as circumference? The formula for circumference is going to be pi times diameter. I'm gonna use the pi symbol and times D for diameter. You could also use approximately 3.14 if you wanted to for pi, if you don't want to use the pi symbol or you're using some sort of calculator that may not have access to it. 3.14 approximately times the diameter.
What is the diameter of this circle? Obviously, we can just measure that. We can take our VEX IQ ruler and measure along there. However, if you think about it, what I'm actually doing is taking the center of each of those wheels, and that is what's tracing this circle.
Thank you for watching and following along with this explanation. I hope this helps you understand how to calculate the number of wheel turns needed for a 360-degree spin. If you have any questions, feel free to reach out.
Thank you again, and happy building!
So the distance between the center of these two driving wheels is known as the wheelbase. Now, the wheelbase, if I actually go through and measure this on our BaseBot, is approximately 145 millimeters. So I'm gonna write that down. The diameter, or in this case, the wheelbase of that robot, is approximately 145 millimeters. I'm going to multiply that by pi, and that's going to give me my circumference. Again, you could have also used 3.14, if you wanted to, for approximation. I'm also using millimeters. You could use inches if you wanted to as well.
Now I can verify that by also measuring here. I can see that that's 145 millimeters, approximately, which makes sense, because again, the center of those two wheels is going to trace this circle that I have here. All right, so let's do this calculation. What exactly is the circumference? Pi times 145 millimeters is approximately 455.5 millimeters. Now I'm carrying it out to one decimal place. Again, you could carry it out to more if you want, for more precision. I'm just gonna round it to one decimal place for now. So this is the distance, the robot distance. This is the distance that each wheel needs to travel in order to turn 360 degrees.
So this is what we have now. 455.5 millimeters is the distance. Now, we just calculated that 455.5. I just want to drive home that distance, whether it's linear distance or curve distance or circular distance, is still distance. So when I'm looking here. Now I cut this out to show this piece of paper is 455 millimeters approximately. So we have 455 millimeters here in this circular distance. 455 millimeters here, linear distance. I could just measure that with a ruler and see that it's approximately 455.5 millimeters.
Now, if I take this and I attach it right there, and I put it on our circle, you can see that it's almost identical. Just to show you distance is distance, whether it's linear or curve, circular, still distance. I know sometimes there's a misconception, especially among students, when we're talking about measuring the distance of a circle or measuring distance linear, again, still the same concept, still using the same formula that we have here. It's just a different way to measure that distance, depending on if it's circular or not.
All right, now that we have all of this information, we can start to solve for the number of turns. So, here I have 455 millimeters, 200 millimeters over there, and I'm trying to calculate the number of turns. I'm gonna represent that by a capital T. So let me change this here. Instead of a question mark, I'm gonna change it to a capital T to represent turns. Again, this is the number of wheel turns. So I'm gonna divide each side by 200 millimeters. My millimeters are gonna cancel out on the right side. So are the 200, leaving me with just turns. On the left side, I have 455.5 millimeters divided by 200 millimeters. It's approximately 2.28. My millimeters also cancel. Leaving me with, again, approximately 2.28 turns. So each wheel has to travel 2.28 turns in order to complete that 360 degrees, the robot will travel 360 degrees.
Now, just to confirm this, I cut this out from our IQ ruler. This is 200 millimeters, or one wheel revolution, one wheel turn. Now, if I start at the very center of that top black line, you can see, if I'm trying to trace this, that's approximately one. Approximately two, and then just a little bit left right there. So about two and a third, or 2.28, which is exactly what we calculated. So you can even see this visually, again, about one, two, and then about a third left. So this validates our calculation, and you can actually see that if I were to unravel one wheel, which is exactly what we did here with the GO ruler, and wrap it around this distance, you can see that that calculation actually makes sense.
So now that we have that, let's go into our software, VEXcode IQ.
Thank you for following along with this explanation. I hope it was helpful in understanding how to calculate wheel turns and distances for your robot.
If you have any questions or need further clarification, feel free to reach out. Happy building and coding!
Now, I already made this project very similar to the last project, driving in a straight line. The only difference, let me make it a little bigger here to see, is that I slowed each of these wheels down a little. So we can actually watch it move a little bit slower. Instead of both wheels now going forward, I have that right motor going in reverse. We already talked about that when we looked at the robot actually turning right. One wheel has to be going forward, and the other wheel has to be going backwards. I just calculated that we're going to have approximately 2.28 turns of each wheel in order to travel the full 360 degrees of the robot.
Now, the other thing that I want to show is that I actually want to print some stuff here to the brain. I'm going to set the print precision to one decimal place. What I want to print to the brain is the motor position in degrees, so that I can actually see that my calculations are what actually is happening. So I'm going to print the left motor, and then the right motor in degrees. I'm going to print those both on the brain. Basically, what I'm trying to do here is I want to validate that 2.28 turns.
In order to get that into degrees, all that I have to do is one last calculation to kind of validate this. We have turns, which is 2.28, and I can multiply that by 360 in order to change it to degrees. That gives me approximately 820.8 degrees. So I can convert turns to degrees by multiplying it by 360, 'cause remember, one revolution is going to be that 200 millimeters. Again, I can change the turns to degrees by multiplying it by 360. Here, I get approximately 820.8 degrees. The number that I'm looking for here, when this is actually being printed on the brain, is to be approximately 820.8, or approximately 821, with a little bit of rounding. That will validate that each wheel did actually travel about 2.28 turns.
All right, now let's actually test this. So I already downloaded this project to my robot. I'm gonna set that in the center there, and let's watch.
(robot whirring)
Trace that circle. I know it's hard to see printed to the brain. We have 822, and then approximately negative 819, which makes sense, because again, the right motor is actually traveling backwards. So it makes sense that that one is negative. Watching it one more time.
(robot whirring)
Tracing that circle about 820 for both, which validates exactly what we just talked about.
In summary, what is everything that we calculated? The difference between calculating or coding our individual motors to travel a straight distance or in a straight line, compared to actually turning. The difference there is that, number one, instead of both wheels going forward, we have one going forward and one going backwards. Secondarily, when that happens, the wheelbase of the robot actually traces a circle based on how far we actually turn. If I turn the full 360 degrees, you can see that each wheel is actually tracing that circle where the diameter of that circle is the wheelbase.
We just said that measuring the distance of a straight line is easy. You could do it with a ruler. Measuring circular distance is a little bit more complicated, not as simple. So we had to actually calculate the distance around this circle, or the circumference. Once we found that, we could use our same formula, knowing what the circumference of each wheel was, to determine how many turns I needed of each wheel in order for the robot to complete that 360-degree turn. Now I can use a couple of other things that we have in the software, such as the print function, the different print blocks that I have, and the sensing blocks, to actually see what those turns are equating to in degrees. So each wheel turned 820 degrees for the entire robot to spin 360 degrees.
Thank you for following along with this project. I hope this explanation was helpful and that you can apply these concepts to your own projects. If you have any questions or need further clarification, feel free to reach out. Happy building!
So again, there's a little bit of a difference between how many of each individual wheel turns are needed to spin the entire robot. I hope that all of this information was helpful, and I can't wait to see how you code your individual VEX IQ motors on your robot to make different turns.
(upbeat music)
And I will see you in another video.
Hello and welcome to the VEX Classroom. My name is Lauren. In this video, we're going to be talking about coding individual VEX IQ motors in order to turn. More specifically, how do I code individual motors instead of using a drivetrain? We'll be using individual motor commands to turn my BaseBot 360 degrees. The concepts covered in this video can be applied to any robot design, but I'll be using the BaseBot as an example.
In this particular video, we'll build on conclusions and calculations from a previous video about coding individual VEX IQ motors to drive a straight distance. If you haven't watched that video yet, I'll link it below. It's important to watch it first to understand the initial calculations we'll be using. The original calculations and motor configurations were discussed in that video as well. If you need more information, you can refer to the linked video.
So, what do we already know from the previous video about coding individual motors? One key finding was the actual circumference or distance traveled by one wheel turn of a VEX IQ wheel. By rolling the wheel along a VEX ruler, we concluded that one revolution of the wheel is 200 millimeters. This is also written on the wheel for reference. I'll note that here: 200 millimeters for the circumference of the wheel, which we'll use in our calculations.
Now, what's the difference between turning and driving a set distance? In the previous video, both motors moved forward in tandem to drive the robot forward. For turning, such as turning right, the left motor goes forward while the right motor goes in reverse. This allows the robot to turn. Conversely, turning left involves the right motor going forward and the left motor going backward. The main difference is that instead of both motors driving forward, one motor goes forward and the other goes backward to rotate.
In this video, I'll demonstrate rotating the entire robot 360 degrees. I've created a program and downloaded it to my robot to show you how it looks. I've slowed the robot down to observe the 360-degree turn. I'll set both wheels in the center of the tile and watch how the robot turns 360 degrees.
Thank you for watching this video on coding individual VEX IQ motors for turning. I hope you found it helpful. If you have any questions or need further clarification, feel free to reach out. Happy coding!
Number one, let the left wheel go forward, and the right wheel go in reverse for that right turn. Exactly turned 360 degrees, right back to where I started. Let's watch it one more time. You can see that I already drew on the tile there, a red circle. That is the circle that's being made by the wheels, by these driving wheels.
So if you could imagine I had markers right underneath, two pencils maybe, right underneath the center of these wheels. As I turned, they were tracing a circle. This is what's actually going to be made. So this is the circle that these two wheels are actually traveling. Each wheel has to travel this distance in order to complete that 360 degrees of the final robot.
What does that mean? Well, thinking back to our formula, distance equals circumference times the number of turns. I know that one wheel turn, one revolution of one of these wheels, is 200 millimeters. So I'm basically trying to figure out how many turns do I need in order to spin the entire robot 360 degrees? How many times do the individual motors, each of those wheels, need to turn for the entire robot to spin 360 degrees? That's what we're trying to figure out. We're trying to calculate the number of turns.
Again, we know from the previous video that the circumference of each wheel is actually 200 millimeters. So what do we need to figure out? I need to figure out turns, but in order to do so, I need to know what the distance is that each of those wheels is going to travel. In the previous video, we were doing a straight line distance. It's very easy to measure a straight line distance. I can use a ruler or a lot of different methods to measure a straight line.
However, when we are turning, our distance is now circular or curved. It's very hard to bend a ruler to measure that. So there are different ways that we can measure the distance around a circle, which is actually called circumference. The distance that each wheel needs to travel in order to spin the entire robot 360 degrees is the circumference of this circle that I just showed you here, traced from this robot.
Let me make this a little bit more clear. This is going to be the robot distance, found by the wheel circumference times the number of wheel turns. It's the same formula, same idea. Everything is still the same. We're still doing robot distance. It was robot distance in a straight line, and it's still robot distance if it's in a circle. Distance is distance, whether I'm going in a straight line or curved or anything like that. We need to calculate that. We know the wheel circumference is 200 millimeters, so I'm gonna put that in. We're trying to figure out the number of wheel turns.
What do I need to plug in? I need to plug in the robot distance. How far is this? Or how big, I should say, is this circle? How far does each wheel need to travel along this circle? How do I calculate the distance around a circle, also known as circumference? The formula for circumference is going to be pi times diameter. I'm gonna use the pi symbol and times D for diameter. You could also use approximately 3.14 if you wanted to for pi, if you don't want to use the pi symbol or you're using some sort of calculator that may not have access to it. 3.14 approximately times the diameter.
What is the diameter of this circle? Obviously, we can just measure that. We can take our VEX IQ ruler and measure along there. However, if you think about it, what I'm actually doing is taking the center of each of those wheels, and that is what's tracing this circle.
Thank you for watching and following along with this explanation. I hope this helps you understand how to calculate the number of wheel turns needed for a 360-degree spin. If you have any questions, feel free to reach out.
Thank you again, and happy building!
So the distance between the center of these two driving wheels is known as the wheelbase. Now, the wheelbase, if I actually go through and measure this on our BaseBot, is approximately 145 millimeters. So I'm gonna write that down. The diameter, or in this case, the wheelbase of that robot, is approximately 145 millimeters. I'm going to multiply that by pi, and that's going to give me my circumference. Again, you could have also used 3.14, if you wanted to, for approximation. I'm also using millimeters. You could use inches if you wanted to as well.
Now I can verify that by also measuring here. I can see that that's 145 millimeters, approximately, which makes sense, because again, the center of those two wheels is going to trace this circle that I have here. All right, so let's do this calculation. What exactly is the circumference? Pi times 145 millimeters is approximately 455.5 millimeters. Now I'm carrying it out to one decimal place. Again, you could carry it out to more if you want, for more precision. I'm just gonna round it to one decimal place for now. So this is the distance, the robot distance. This is the distance that each wheel needs to travel in order to turn 360 degrees.
So this is what we have now. 455.5 millimeters is the distance. Now, we just calculated that 455.5. I just want to drive home that distance, whether it's linear distance or curve distance or circular distance, is still distance. So when I'm looking here. Now I cut this out to show this piece of paper is 455 millimeters approximately. So we have 455 millimeters here in this circular distance. 455 millimeters here, linear distance. I could just measure that with a ruler and see that it's approximately 455.5 millimeters.
Now, if I take this and I attach it right there, and I put it on our circle, you can see that it's almost identical. Just to show you distance is distance, whether it's linear or curve, circular, still distance. I know sometimes there's a misconception, especially among students, when we're talking about measuring the distance of a circle or measuring distance linear, again, still the same concept, still using the same formula that we have here. It's just a different way to measure that distance, depending on if it's circular or not.
All right, now that we have all of this information, we can start to solve for the number of turns. So, here I have 455 millimeters, 200 millimeters over there, and I'm trying to calculate the number of turns. I'm gonna represent that by a capital T. So let me change this here. Instead of a question mark, I'm gonna change it to a capital T to represent turns. Again, this is the number of wheel turns. So I'm gonna divide each side by 200 millimeters. My millimeters are gonna cancel out on the right side. So are the 200, leaving me with just turns. On the left side, I have 455.5 millimeters divided by 200 millimeters. It's approximately 2.28. My millimeters also cancel. Leaving me with, again, approximately 2.28 turns. So each wheel has to travel 2.28 turns in order to complete that 360 degrees, the robot will travel 360 degrees.
Now, just to confirm this, I cut this out from our IQ ruler. This is 200 millimeters, or one wheel revolution, one wheel turn. Now, if I start at the very center of that top black line, you can see, if I'm trying to trace this, that's approximately one. Approximately two, and then just a little bit left right there. So about two and a third, or 2.28, which is exactly what we calculated. So you can even see this visually, again, about one, two, and then about a third left. So this validates our calculation, and you can actually see that if I were to unravel one wheel, which is exactly what we did here with the GO ruler, and wrap it around this distance, you can see that that calculation actually makes sense.
So now that we have that, let's go into our software, VEXcode IQ.
Thank you for following along with this explanation. I hope it was helpful in understanding how to calculate wheel turns and distances for your robot.
If you have any questions or need further clarification, feel free to reach out. Happy building and coding!
Now, I already made this project very similar to the last project, driving in a straight line. The only difference, let me make it a little bigger here to see, is that I slowed each of these wheels down a little. So we can actually watch it move a little bit slower. Instead of both wheels now going forward, I have that right motor going in reverse. We already talked about that when we looked at the robot actually turning right. One wheel has to be going forward, and the other wheel has to be going backwards. I just calculated that we're going to have approximately 2.28 turns of each wheel in order to travel the full 360 degrees of the robot.
Now, the other thing that I want to show is that I actually want to print some stuff here to the brain. I'm going to set the print precision to one decimal place. What I want to print to the brain is the motor position in degrees, so that I can actually see that my calculations are what actually is happening. So I'm going to print the left motor, and then the right motor in degrees. I'm going to print those both on the brain. Basically, what I'm trying to do here is I want to validate that 2.28 turns.
In order to get that into degrees, all that I have to do is one last calculation to kind of validate this. We have turns, which is 2.28, and I can multiply that by 360 in order to change it to degrees. That gives me approximately 820.8 degrees. So I can convert turns to degrees by multiplying it by 360, 'cause remember, one revolution is going to be that 200 millimeters. Again, I can change the turns to degrees by multiplying it by 360. Here, I get approximately 820.8 degrees. The number that I'm looking for here, when this is actually being printed on the brain, is to be approximately 820.8, or approximately 821, with a little bit of rounding. That will validate that each wheel did actually travel about 2.28 turns.
All right, now let's actually test this. So I already downloaded this project to my robot. I'm gonna set that in the center there, and let's watch.
(robot whirring)
Trace that circle. I know it's hard to see printed to the brain. We have 822, and then approximately negative 819, which makes sense, because again, the right motor is actually traveling backwards. So it makes sense that that one is negative. Watching it one more time.
(robot whirring)
Tracing that circle about 820 for both, which validates exactly what we just talked about.
In summary, what is everything that we calculated? The difference between calculating or coding our individual motors to travel a straight distance or in a straight line, compared to actually turning. The difference there is that, number one, instead of both wheels going forward, we have one going forward and one going backwards. Secondarily, when that happens, the wheelbase of the robot actually traces a circle based on how far we actually turn. If I turn the full 360 degrees, you can see that each wheel is actually tracing that circle where the diameter of that circle is the wheelbase.
We just said that measuring the distance of a straight line is easy. You could do it with a ruler. Measuring circular distance is a little bit more complicated, not as simple. So we had to actually calculate the distance around this circle, or the circumference. Once we found that, we could use our same formula, knowing what the circumference of each wheel was, to determine how many turns I needed of each wheel in order for the robot to complete that 360-degree turn. Now I can use a couple of other things that we have in the software, such as the print function, the different print blocks that I have, and the sensing blocks, to actually see what those turns are equating to in degrees. So each wheel turned 820 degrees for the entire robot to spin 360 degrees.
Thank you for following along with this project. I hope this explanation was helpful and that you can apply these concepts to your own projects. If you have any questions or need further clarification, feel free to reach out. Happy building!
So again, there's a little bit of a difference between how many of each individual wheel turns are needed to spin the entire robot. I hope that all of this information was helpful, and I can't wait to see how you code your individual VEX IQ motors on your robot to make different turns.
(upbeat music)
And I will see you in another video.
Share
Like this video? Share it with others!
Additional Resources
View the following resources related to the concepts covered in the video as you continue your learning.
- Coding Individual Motors to Drive Distances in VEXcode IQ
- BaseBot Build Instructions
- Printable VEX IQ Ruler
- Code.vex.com
- Configuring Smart Motors in VEXcode IQ
Like this video? Discuss it in the VEX Professional Learning Community.