In this unit, you will learn about V5 motors, their capabilities and how to get information about motors in your programs.
This Unit uses the V5 simple drive base, which is essentially a Clawbot without the claw. You can do this with or without the claw. If you do not have a robot, please follow the instructions in the VEX manual "Clawbot Assembly Instructions." Complete steps 1-22 to build the drive base, or all steps for the Clawbot.
Prepare your robot:
Prepare Robot Mesh Studio:
In this lesson, we will use Blockly to program our robot autonomously to send commands to the robot, and in this activity you will create an autonomous program that the robot will follow without your help.
It's easiest to visualize V5 motors as an object that you can tell to do things using commands called "methods," and have certain characteristics which you can read and use, called "properties." In our program in the last activity, we had a V5 motor object called "motor_right" and we started it turning using the method "spin." In this activity we will focus on properties, and in the next activity we will go over motor methods.
Our program for this activity will turn on a motor using a motor method, then read the properties of the motor. We will then discuss what each property might be used for on a robot.
Here are the Blockly blocks for reading or setting motor properties:
Is done: This is a Boolean, true if the motor has completed executing the current operation, false if not
Get rotation in degrees/rotations/raw: When you turn a motor on, it is considered to be at 0 degrees. This property shows the current deflection from that starting location. The results can be in degrees (360 makes a circle), rotations, and raw ("ticks" on the encoder in the motor). Raw gives you the best precision, but degrees can be more usful for arm rotational lifts, and rotations is best used for a motor that you expect to make a lot of rotations, such as the motor driving an elevator lift. A green motor running at its full 200RPM is generating 900 ticks every revolution.
Get velocity in %/rpm/degrees per second: While the last property shows you how far the motor has turned from its "zero" starting position, this returns the current velocity of the motor rotation. Programmers can have this returned in percent (%) of maximum RPM, and remember that red gear packs have a maximum speed of 100RPM and the green ones have a maximum of 200RPM. The second option is revolutions per minute (RPM) or degrees per second. A 100RPM red motor at 80% of max would be 80RPM. Degrees per second can be calculated by multiplying the number of revolutions in one second 80/60 revolutions per second, or 1.33 by the number of degrees in one revolution (360) for a total of 479 degrees per second. The motor controller does the math for you, though, you can just read it using this property.
Get current in amps: Amps is a measure of how much electricity is moving through a conductor. Using the old garden hose analogy, the pressure of the water in the hose is "volts" and the diameter of the hose is "amps."
Get power in watts: Electrical power in a DC circuit, like the motors, is pretty simple - amps x voltage. Motors have a maximum amount of power thay can use, and in the case of the V5 motor this is 11 watts.
Get torque in Nm/inch-pounds: Torque is the twisting force of the motor shaft. You can increase the torque in your robot by gearing the motor shaft speed down which reduces the RPM, or can decrease torque by gearing up to increase RPM.
Get efficiency in %: How much of the power used by the motor is used to generate rotational torque. Because of friction and other power loss, this is never 100%
Get temperature %: Motor heat is function of how much power it is using and how long it has been running. This value is a measure of how hard your motor is working.
Is spinning: This is a Boolean value (meaning either true or false), and is true if the motor shaft is turning.
Has motor finished its last task (T/F): This is true if the motor has no pending programmatic instructions.
We are going to introduce the Print command, and use it to show you how to read the properties of the V5 motors. We will use the properties in future activities so that you will learn them as you use them. Open project V5B 4 Motor Concepts in RM Studio. For this exercise, we have entered the code for you.
The Print command takes the information plugged into its right side, and displays it in the program status area below the code window. You will find the Print command and quotes text block in the "Robot Mesh" area of the Blockly toolbox. You will need to have your robot plugged into your computer to run this code. We put a small box underneath our test robot to keep its wheels off the table, so we could keep it cabled during this test.
Plug your robot into your computer, and make sure the VEX V5 Brain is turned on.
Caution! Your program will run as soon as you download it, so make sure your robot is on the floor or someone is holding it. You do not want to drive it off the table!
Click Run to download your program to the robot. You should now see "Download Done" in a green bar at the bottom of the screen.
Unplug your robot, and set it on the floor.
On the Brain, use the up-arrow and down-arrow buttons to highlight the program you downloaded.
Making sure that you robot is in a safe area and no one has their hands or eyes near it (wear safety glasses), push the check-mark button on the Brain to start your program. Run it more than once if you want to.
Review the results in the Program Status Area. Try some different options in the Get Rotation, Get Velocity, Get Torque and Motor Stop blocks. Can you see how the different options change the results?
The motor started off set at 100% power. Try changing that to different levels and see how the numbers change. Try something like 20%, 40% and 75%.
Change the Motor Stop block to try brake or hold instead of coast. Run your program and see if you can see a difference in how the motor stops turning.
1. Using Ohm's Law, wattage = voltage x amps. The system gives you the amps and wattage, can you use those to calculate the voltage applied? (Hint: volts = watts/amps)
2. When might you use the degrees property in Get Rotation instead of Rotation or Raw? When would it be best to use rotation?
3. Your program "knows" that you have turned a motor on, so how would the Motor is Spinning help you as a programmer? (Hint: think of what happens if your robot hits a wall.)