Difference between revisions of "VEX How-To Manual"

From EG1004 Lab Manual
Jump to: navigation, search
 
(20 intermediate revisions by 3 users not shown)
Line 10: Line 10:
** Gear train
** Gear train
** Gear ratio
** Gear ratio
* Chart of clawbot pieces
 


'''VEX CAD Assembly'''  
'''VEX CAD Assembly'''  
Line 109: Line 109:


[[File:VEX_Building_Guide_14.png|thumb|250px|frame|center|Figure 1-14: 2-Wire Motor]]
[[File:VEX_Building_Guide_14.png|thumb|250px|frame|center|Figure 1-14: 2-Wire Motor]]
====Claw Set====
*Each VEX kit is given a claw set that is pre-assembled and ready to grab and manipulate objects.
*It has a motor attached to the top of the claw bracket and is able to hold from a delicate feather to a 20 oz soda can.
*The main use of the claw is to grab and carry the plant sample back to the starting tile.
*Use this link to access the guide on how to assemble a claw set: https://content.vexrobotics.com/docs/276-2600-Claw-Assembly.pdf
[[File:VEX_Building_Guide_15.png|thumb|250px|frame|center|Figure 1-15: Pre-Assembled Claw Set]]


====Zip Ties====
====Zip Ties====
Line 154: Line 145:


Please refer to [[Robot Construction Tips]] for Center of Gravity and Drive Train.
Please refer to [[Robot Construction Tips]] for Center of Gravity and Drive Train.
==Chart of the Clawbot Pieces==
https://content.vexrobotics.com/docs/276-2600-Structure-Pieces-20140218.pdf
https://content.vexrobotics.com/docs/276-2600-Claw-Assembly.pdf
https://content.vexrobotics.com/docs/276-2600_VEXEDR_ClawbotKit_PartsList_Rev3.pdf


==Price List of the VEX Parts==
==Price List of the VEX Parts==
Line 203: Line 186:


=== Download and Import VEX Parts ===
=== Download and Import VEX Parts ===
# Download the [https://www.autodesk.com/education/competitions-and-events/vex/recommended-software?_ga=2.60373103.339762620.1577992716-288517197.1577992716#Kit-of-parts Autodesk VEX Kit of Parts (KoP)]. Make sure to download the <b>Fusion 360 KoP for VEX EDR</b>
# Download the [[Media: VEX_Fusion_360_Parts.zip | Autodesk VEX Kit of Parts (KoP)]]. Make sure to download the <b>Fusion 360 KoP for VEX EDR</b> [[File:VEX_CAD_Assembly_Guide_media_1.png|600px|thumb|center|Figure 2-2: Extract the ZIP Folder]]
# Extract the downloaded ZIP folder (Figure 2-2) [[File:VEX_CAD_Assembly_Guide_media_1.png|600px|thumb|center|Figure 2-2: Extract the ZIP Folder]]
# In Fusion 360, go to the Data tab of your project and click New Folder. Name the new folder and press the Enter key. This folder will contain all the downloaded VEX parts for the project
# In Fusion 360, go to the Data tab of your project and click New Folder. Name the new folder and press the Enter key. This folder will contain all the downloaded VEX parts for the project
# Double click the new folder that was just created. Click the Upload button
# Double click the new folder that was just created. Click the Upload button
# In the dialog that just appeared, click Select Files
# In the dialog that just appeared, click Select Files
# In the File Explorer, navigate to the unzipped folder of VEX parts  
# In the File Explorer, navigate to the unzipped folder of VEX parts  
# For Mac users, select the <b>_MACOSX</b> folder. For Windows users, select the <b>Fusion_360_VEX_EDR_KOP</b> folder. Select all the individual F3Z files in each folder to download. You can select all the F3Z files in individual folders but cannot select F3Z files from different folders. Select the files you believe you will need for your project. Click Open
# For Mac users, select the <b>_MACOSX</b> folder. For Windows users, select the <b>Fusion_360_VEX_EDR_KOP</b> folder. Select all the individual F3Z files in each folder to download. You can also drag and drop these files. You can select all the F3Z files in individual folders but cannot select F3Z files from different folders. Select the files you believe you will need for your project. Click Open
# In the window that appears, click Upload
# In the window that appears, click Upload
# The VEX parts will take a few minutes to upload from your files to Fusion 360. Once the upload is complete, click Close in the Job Status window. There should be new files in the Data Panel. You can double click one of the files to open the VEX part, or click and drag the files into your project to use them for the assembly
# The VEX parts will take a few minutes to upload from your files to Fusion 360. Once the upload is complete, click Close in the Job Status window. There should be new files in the Data Panel. You can double click one of the files to open the VEX part, or click and drag the files into your project to use them for the assembly
Line 244: Line 226:
Using this process whenever there are repeated components will greatly reduce the time needed to make the full assembly.
Using this process whenever there are repeated components will greatly reduce the time needed to make the full assembly.


= VEX Programming =  
= 3. VEX Programming =  


The VEX library is used in the EG1003 course to control the VEX robot and sensors using Arduino. The library is designed to more easily access the robot’s functionality. For more information on coding with Arduino, please reference the [[Arduino Coding Guide]]
The VEX library is used in the EG1004 course to control the VEX robot and sensors using Arduino. The library is designed to more easily access the robot’s functionality. For more information on coding with Arduino, please reference the [[Arduino Coding Guide]]


The library is intended for use with the Adafruit Motor Shield V2, and VEX EDR 2-wire motors.
The library is intended for use with the Adafruit Motor Shield V2, and VEX EDR 2-wire motors.
Line 334: Line 316:
'' Syntax ''
'' Syntax ''
*<i>nameOfVEXObject</i>.begin();
*<i>nameOfVEXObject</i>.begin();
** Example: <i>gyro</i>.begin();


'' Example ''
'' Example ''
[[File:Vex_Library_10.png|thumb|450px|center|Figure 3-9: Example of begin()]]
[[File:Vex_Library_10.png|thumb|450px|center|Figure 3-16: Example of begin()]]


=== setMotor() ===
=== setMotor() ===
Line 391: Line 374:


'' Syntax ''
'' Syntax ''
*<i>vex</i>.moveTank(motor1, motor2, power1, power2, time);
*<i>Robot</i>.moveTank(motor1, motor2, power1, power2, time);


'' Parameters ''
'' Parameters ''
Line 402: Line 385:


'' Example ''
'' Example ''
[[File:Vex_Library_14.png|thumb|450px|center]]
[[File:Vex_Library_14.png|thumb|450px|center|Figure 3-13: Example of moveTank()]]


==Gyro Class==
==Gyro Class==
Line 412: Line 395:


Figure 2 shows how to wire the MPU6050 sensor. Note that the Int pin on the MPU6050 <b>must be connected to digital pin 2</b> on the Arduino board for the sensor to work within this library
Figure 2 shows how to wire the MPU6050 sensor. Note that the Int pin on the MPU6050 <b>must be connected to digital pin 2</b> on the Arduino board for the sensor to work within this library
[[File:Vex_Library_15.png|thumb|450px|center|Figure 2: Circuit Diagram for the MPU6050]]
[[File:Vex_Library_15.png|thumb|450px|center|Figure 3-14: Circuit Diagram for the MPU6050]]


====Pins:====
====Pins:====
Line 428: Line 411:
*In order to create a Gyro object, the constructor must be called. Creating a Gyro object allows you to call on the methods, which can also be referred to as functions, within the Gyro Class. The constructor for a Gyro object is empty (has no parameters).  
*In order to create a Gyro object, the constructor must be called. Creating a Gyro object allows you to call on the methods, which can also be referred to as functions, within the Gyro Class. The constructor for a Gyro object is empty (has no parameters).  


'' Parameters ''
'' Syntax ''
*None
*Gyro a<i>NameForTheGyroObject</i>;
 
** Example: Gyro <i>gyro</i>
'' Returns ''
*None


'' Example ''
'' Example ''
[[File:Vex_Library_16.png|thumb|450px|center]]
[[File:Vex_Library_16.png|thumb|450px|center|Figure 3-15: Constructor for a Gyro]]


=== begin() ===
=== begin() ===
Line 460: Line 441:
'' Syntax ''
'' Syntax ''
*<i>gyro</i>.getZAngle();
*<i>gyro</i>.getZAngle();
'' Parameters ''
*None


'' Returns ''
'' Returns ''
Line 468: Line 446:


'' Example ''
'' Example ''
[[File:Vex_Library_18.png|thumb|450px|center]]
[[File:Vex_Library_18.png|thumb|450px|center|Figure 3-17: Example of getAngle()]]


=== getYAngle() ===
=== getYAngle() ===
Line 476: Line 454:
'' Syntax ''
'' Syntax ''
*<i>gyro</i>.getYAngle();
*<i>gyro</i>.getYAngle();
'' Parameters ''
*None


'' Returns ''
'' Returns ''
Line 484: Line 459:


'' Example ''
'' Example ''
[[File:Vex_Library_19.png|thumb|450px|center]]
[[File:Vex_Library_19.png|thumb|450px|center|Figure 3-18: Example of getYAngle()]]


=== getXAngle() ===
=== getXAngle() ===
Line 492: Line 467:
'' Syntax ''
'' Syntax ''
*<i>gyro</i>.getXAngle();
*<i>gyro</i>.getXAngle();
'' Parameters ''
*None


'' Returns ''
'' Returns ''
Line 500: Line 472:


'' Example ''
'' Example ''
[[File:Vex_Library_20.png|thumb|450px|center]]
[[File:Vex_Library_20.png|thumb|450px|center|Figure 3-19: Example of getXAngle()]]


==Ultrasonic Class==
==Ultrasonic Class==


The Ultrasonic Sensor is used to determine how far away an object is. This is useful for obstacle avoidance. The HC-SR04 ultrasonic sensor uses a process similar to echolocation to operate. The sensor transmits a high-frequency signal, then it receives the signal after it gets reflected by the object. The sensor determines the time elapsed between transmission and reception. This can be used to calculate the distance from the sensor to the object using the speed of sound (343m/s).
The Ultrasonic Sensor is used to determine how far away an object is. This is useful for obstacle avoidance. The HC-SR04 ultrasonic sensor uses a process similar to echolocation to operate. The sensor transmits a high-frequency signal, then it receives the signal after it gets reflected by the object. The sensor determines the time elapsed between transmission and reception. This can be used to calculate the distance from the sensor to the object using the speed of sound (343 m/s).
 
[[File:Vex_Library_21.png|thumb|450px|center|Figure 3]]


[[File:Vex_Library_21.png|thumb|450px|center|Figure 3-20:Ultrasonic Functionality]]


===Wiring===
===Wiring===
The ultrasonic sensor has four pins: Voltage (VCC), Ground (GND), Trigger (TRIG), and Echo. VCC and GND need to be connected to voltage and ground, respectively. Trigger (or transmitter) is used for the sensor to create the high-frequency signal that gets transmitted, while Echo (or receiver) is used to receive the reflected signal. Trig and Echo can be connected to any digital I/O pins. The working voltage for ultrasonic sensor is 5V, its maximum range is 4m, and its minimum range is 2cm. Male/female jumper wires can be used to connect the ultrasonic sensor to the breadboard. Figure 4A & 4B show how to correctly wire the ultrasonic sensor.  
The ultrasonic sensor has four pins: Voltage (VCC), Ground (GND), Trigger (TRIG), and Echo. VCC and GND need to be connected to voltage and ground, respectively. Trigger (or transmitter) is used for the sensor to create the high-frequency signal that gets transmitted, while Echo (or receiver) is used to receive the reflected signal. Trig and Echo can be connected to any digital I/O pins. The working voltage for ultrasonic sensor is 5V, its maximum range is 4 m, and its minimum range is 2 cm. Male/female jumper wires can be used to connect the ultrasonic sensor to the breadboard. Figure 3-21 & 3-22 show how to correctly wire the ultrasonic sensor.  
[[File:Vex_Library_22.png|thumb|450px|center|Figure 4A: Arduino Ultrasonic Wiring Guide]]
[[File:Vex_Library_22.png|thumb|450px|center|Figure 3-21: Arduino Ultrasonic Wiring Guide]]


[[File:Vex_Library_221.png|thumb|450px|center|Figure 4B: VEX Ultrasonic Wiring Guide]]
[[File:Vex_Library_221.png|thumb|450px|center|Figure 3-22: VEX Ultrasonic Wiring Guide]]


====Pins====
====Pins====
Line 535: Line 506:
*<b>triggerPin</b>: an integer representing the digital pin used for the trigger
*<b>triggerPin</b>: an integer representing the digital pin used for the trigger
*<b>echoPin</b>: an integer representing the digital pin used for the echo
*<b>echoPin</b>: an integer representing the digital pin used for the echo
'' Returns ''
*None


'' Example ''
'' Example ''
[[File:Vex_Library_23.png|thumb|450px|center]]
[[File:Vex_Library_23.png|thumb|450px|center|Figure 3-23: Constructor for a Ultrasonic object
]]


===begin()===
===begin()===
Line 548: Line 517:
'' Syntax ''
'' Syntax ''
*<i>ultrasonic</i>.begin();
*<i>ultrasonic</i>.begin();
'' Parameters ''
*None
'' Returns ''
*None


'' Example ''
'' Example ''
[[File:Vex_Library_24.png|thumb|450px|center]]
[[File:Vex_Library_24.png|thumb|450px|center|Figure 3-24: Example of begin()]]


===checkUltrasonic()===
===checkUltrasonic()===
Line 565: Line 528:
'' Syntax ''
'' Syntax ''
*<i>ultrasonic</i>.checkUltrasonic();
*<i>ultrasonic</i>.checkUltrasonic();
'' Parameters ''
*None


'' Returns ''
'' Returns ''
*A <b>long</b> representing the distance (in centimeters) between the sensor and the first object it detects.  
*A <b>long</b> representing the distance (in centimeters) between the sensor and the first object it detects. Note: A <b>long</b> data type to contain integer numbers that are too large to fit in the integer data type.


'' Example ''
'' Example ''
[[File:Vex_Library_25.png|thumb|450px|center]]
[[File:Vex_Library_25.png|thumb|450px|center|Figure 3-25: Example of checkUltrasonic()]]


==Touch Class==
==Touch Class==
Line 580: Line 540:


===Wiring===
===Wiring===
The Touch Sensor is connected to two pins on the Arduino/Adafruit MotorShield, Ground (GND) and a Digital Pin. In Figure 5, the Digital Pin is connected to Digital Pin 3. The Touch Sensor works so that whenever it is pressed, a certain line of code or function can occur.


[[File:Vex_Library_26.png|thumb|450px|center|Figure 5: Touch Sensor Wiring Diagram. This wiring can be replicated for connecting the Limit Switch as well.]]
The Touch Sensor is connected to two pins on the Arduino/Adafruit MotorShield, Ground (GND) and a Digital Pin. In Figure 3-26, the Digital Pin is connected to Digital Pin 3. The Touch Sensor works so that whenever it is pressed, a certain line of code or function can occur.  


[[File:Vex_Library_26.png|thumb|450px|center|Figure 3-26: Touch Sensor Wiring Diagram. Note: The wiring for a Limit Switch is the same.]]


====Pins:====
====Pins:====
Line 600: Line 560:
'' Parameters ''
'' Parameters ''
*Pin: an <b>integer</b> representing the <b>digital</b> pin used by the sensor
*Pin: an <b>integer</b> representing the <b>digital</b> pin used by the sensor
'' Returns ''
*None


'' Example ''
'' Example ''
[[File:Vex_Library_27.png|thumb|450px|center]]
[[File:Vex_Library_27.png|thumb|450px|center|Figure 3-27: Constructor for a Touch object]]


===begin()===
===begin()===
Line 613: Line 570:
'' Syntax ''
'' Syntax ''
*<i>touch</i>.begin();
*<i>touch</i>.begin();
'' Parameters ''
*None
'' Returns ''
*None


'' Example ''
'' Example ''
[[File:Vex_Library_28.png|thumb|450px|center]]
[[File:Vex_Library_28.png|thumb|450px|center|Figure 3-28: Example of begin()]]


===isPushed()===
===isPushed()===


*The isPushed() method returns a boolean value depending on whether or not the button on the sensor has been pressed.
*The isPushed() method returns a boolean value depending on whether or not the button on the sensor has been pressed


'' Syntax ''
'' Syntax ''
*<i>touch.</i>isPushed();
*<i>touch.</i>isPushed();
'' Parameters ''
*None


'' Returns ''
'' Returns ''
Line 637: Line 585:


'' Example ''
'' Example ''
[[File:Vex_Library_29.png|thumb|450px|center]]
[[File:Vex_Library_29.png|thumb|450px|center|Figure 3-29: Example of isPushed()]]


==IRObstacle Class==
==IRObstacle Class==
Line 644: Line 592:
The sensor uses an infrared emitter LED. This signal is then received by an infrared receiver to determine whether or not there is an obstacle. The distance adjust terminal can be used to adjust the detection distance. Turning the screw counterclockwise will decrease the distance while turning the screw clockwise will increase the distance.  
The sensor uses an infrared emitter LED. This signal is then received by an infrared receiver to determine whether or not there is an obstacle. The distance adjust terminal can be used to adjust the detection distance. Turning the screw counterclockwise will decrease the distance while turning the screw clockwise will increase the distance.  


[[File:Vex_Library_30.png|thumb|450px|center|Figure 6]]
[[File:Vex_Library_30.png|thumb|450px|center|Figure 3-30: Diagram of IR Obstacle Avoidance Sensor]]
 


<i>Note: As the IRObstacle class is made specifically for this function, it cannot be used to access the additional functionalities of the MPU6050 device. Any other use of the MPU6050 outside of this class is at the discretion of the student.</i>
<i>Note: As the IRObstacle class is made specifically for this function, it cannot be used to access the additional functionalities of the MPU6050 device. Any other use of the MPU6050 outside of this class is at the discretion of the student.</i>


===Wiring===
===Wiring===
*Figure 7 shows how to wire the IR obstacle avoidance sensor
*Figure 3-31 shows how to wire the IR obstacle avoidance sensor


[[File:Vex_Library_31.png|thumb|450px|center|Figure 7: Wiring Diagram for the IR Obstacle Avoidance Sensor]]
[[File:Vex_Library_31.png|thumb|450px|center|Figure 3-31: Wiring Diagram for the IR Obstacle Avoidance Sensor]]


====Pins:====
====Pins:====
Line 670: Line 617:
'' Parameters ''
'' Parameters ''
*Pin: an <b>integer</b> representing the digital pin used for the sensor
*Pin: an <b>integer</b> representing the digital pin used for the sensor
'' Returns ''
*None


'' Example ''
'' Example ''
[[File:Vex_Library_32.png|thumb|450px|center]]
[[File:Vex_Library_32.png|thumb|450px|center|Figure 3-32: Constructor for a IRObstacle object]]
 


===begin()===
===begin()===


*The begin() method initializes the IR obstacle avoidance sensor. It must be called in the setup() function to use any other IRObstacle methods
*The begin() method initializes the IR obstacle avoidance sensor. It must be called in the setup() function to use any other IRObstacle methods
<i>Note: begin() only initializes the IR obstacle avoidance sensor. Refer to the documentation for the wanted sensor for reference on initializing other modules.</i>
<i>Note: begin() only initializes the IR obstacle avoidance sensor. Refer to the documentation for the wanted sensor for reference on initializing other modules.</i>


'' Syntax ''
'' Syntax ''
*<i>irobstacle.</i>begin();
*<i>irobstacle.</i>begin();
'' Parameters ''
*None
'' Returns ''
*None


'' Example ''
'' Example ''
[[File:Vex_Library_33.png|thumb|450px|center]]
[[File:Vex_Library_33.png|thumb|450px|center|Figure 3-33: Example of begin()]]


=== isObstacle() ===
=== isObstacle() ===


*The isObstacle() method returns a boolean value depending on whether or not the sensor detects an obstacle.
*The isObstacle() method returns a boolean value depending on whether or not the sensor detects an obstacle


'' Syntax ''
'' Syntax ''
*<i>irobstacle.</i>isObstacle();
*<i>irobstacle.</i>isObstacle();
'' Parameter ''
*None


'' Returns ''
'' Returns ''
Line 709: Line 644:


'' Example ''
'' Example ''
[[File:Vex_Library_34.png|thumb|450px|center]]
[[File:Vex_Library_34.png|thumb|450px|center|Figure 3-34: Example of isObstacle()]]

Latest revision as of 20:07, 24 February 2024

Goals for this Guide

VEX Building

  • Specify restrictions on the VEX robots
  • Basic introduction to kit components
    • What are the parts and how to use them correctly
    • Choice of pieces given different building purposes
  • Robots motion
    • Gear train
    • Gear ratio


VEX CAD Assembly

  • Tips on troubleshooting the design and common CAD problems
  • Design and implement CAD drawings in Fusion 360 for a VEX robot

VEX Programming

  • Introduction to the VEX Arduino Library
    • How to import the library into Arduino to program the VEX Robot
    • Classes and objects available to code the VEX robots’ movements

1. VEX Building

Restrictions

  • Size Limitation
    • A typical VEX robot should be smaller than 15x15 in. (slightly less than a tile).
    • There’s no limitation in height, but if you plan to go for the extra credit ramp, there is a soft limitation in height.
  • Robot Design
    • No projectile or anything too crazy
    • No jumping off the ramps for path planning
  • For LAZ, a claw set MUST be attached to the robot. Sensors are optional.

NOTE: Your VEX robot CANNOT be identical to the traditional VEX clawbot. There must be something different and unique about your robot.

Components

Hardware

Nuts, Screws, and Wrench

  • The Vex Kit that you received contains many materials, such as nuts, screws, and standoffs, designed to connect two or more bodies. The black screws are found in three sizes (Figure 1-1) and must be tightened by one of the keps nuts or nylock nuts (Figure 1-2).
Figure 1-1: Black Screws
Figure 1-2: Keps Nut
Figure 1-3: Nylock Nut
  • Keps Nuts are used for strong, yet removable bonds.
  • Nylock Nuts are used for stronger, permanent bonds.
  • To remove a nut, you need the help of the open end wrench (Figure 1-4) to keep it from turning. It provides grip and mechanism advantage in applying torque. The wrench you are given fits all nuts and standoffs.
Figure 1-4: Open End Wrenches
  • The second type of screw that you will see in your kit is the locking screw. Again, these golden screws come in a few sizes. They have a smaller width than the black screws, so they CANNOT be tightened by the Keps Nuts.
  • These screws will be mainly used to secure the motors (Figure 1-5) into place.
Figure 1-5: Locking Screw with Motors
  • The screws can be tightened with the help of hex keys (Figure 1-6). The hex keys come in two different sizes (one with diameter 3/32” and one with diameter 5/64”), corresponding to the dimensions of the hole in screws. So try each hex key until the hex key’s end perfectly fits inside the drive of the screw.
Figure 1-6: Hex Keys


Standoffs, Shaft Couplers, and Motor Post

  • Instead of Keps Nuts, standoffs can also be used to secure screws in place. Standoffs are used to connect two different parts through screws or shafts, depending on the type of standoff.
  • The screw standoff is used to connect two black screws (Figure 1-7). The shaft counterpart is called the shaft coupler. Motor posts (Figure 1-8) are used to connect shaft couplers to motors.
Figure 1-7: Screw Standoffs
Figure 1-8: Shaft Couplers and Motor Posts

Note that standoffs and the couplers are NOT completely secured and can disassemble easily. Standoffs and couplers should only be used to connect parts that are already secured in place.

Shafts and Shaft Collars

  • Your kit contains square shafts of two different lengths. The shafts are used by the motors to turn the gears and your wheels. Shafts can be secured in place by shaft collars (Figure 1-9).
  • Shaft collars can be tightened with the thinner/longer (3/32”) hex key.
  • Use two shaft collars to completely lock a part in place.
Figure 1-9: Gear Secured in a Square Shaft by Two Shaft Collars

Bearing Flat and Bearing Attachment Rivet

  • The square shafts are inherently smaller than the square holes in the structural metal pieces. Due to this, there will be rattling once the motor starts spinning.
  • In order to minimize the rattling, bearing flats are used in conjunction with the structural part because the bearing flat’s hole is much more accommodating of the shaft’s size.
  • The unused holes of the bearing flat can be tightly and smoothly secured with bearing attachment rivets (Figure 1-10, Figure 1-11).
Figure 1-10: From Bottom to Top: Square Shaft, Bearing Flat, and Bearing Attachment Rivet
Figure 1-11: Bearing Flat Contraption

Spacers

  • Spacers are used in order to properly position certain components of your robot, such as a gear. They come in different sizes and types, depending on the displacement needed.
  • A regular spacer (Figure 1-12) can be put in anywhere in a shaft, while wheel spacers are designed to lock the wheels on the shafts.
  • Bearing flats and shaft collars can also be used as spacers, if necessary.
Figure 1-12: Regular Spacer
Figure 1-13: Wheel Spacers


Motors and High-Speed Gear

  • The 2-Wire Motor 393 is the primary actuator you have for VEX. It can be used to build a rotational mechanism, drive bases, rotational joints, conveyor belts - anything that can spin. It can be configured to a “high speed” version with the help of the high-speed gear. Follow the Gear Change Procedure to increase your output speed by 60%.
Figure 1-14: 2-Wire Motor

Zip Ties

  • Zip ties are used to secure parts together are unable to be fixed in place with the conventional hardware components.
  • Zip ties are more flexible in areas of usage but are limited by the lack of secureness compared to nuts and screws. There are zip ties of two different lengths in the kit.
  • In order to tie a zip tie, wrap the long stem of the zip tie around such that the tail of the zip tie is inserted into the flat side of the head. Pull the tail of the zip tie into the desired length(Figure 1-16). If done correctly, the zip tie cannot be undone and can only be tightened.
Figure 1-16: Zip Tie

Motion

Gear Train

  • The VEX robot that you build will have to travel on the course. In order for the wheels to move, the wheel either has to be directly connected to the motor with a shaft or indirectly connected to the motor with a gear train.
  • A gear train is made of a series of interlocking gears, either of varying sizes or similar sizes, with one gear of the gear train connected to an input source, such as a motor. As the motorized gear spins, every single gear in the gear train also turns.
  • A wheel could be connected to any adjacent gears in order to turn that wheel as well. The length of the gear train depends on the distance between the motor and the desired wheel. Keep in mind that an odd number of gears in the gear train will cause the driven gears to spin in the same direction and an even number of gears in the gear train will cause the driven gears to spin in the opposite direction. Therefore, it is essential that gear trains have an odd number of gears in order to spin correctly. Gear trains are advantageous if both sets of wheels are traction wheels in order to have a smoother turn.
Figure 1-17: Simple Gear Train with Idler(NO EFFECT on Gear ratio)
  • Another method to induce motion is to let one set of wheels be freely spun due to the friction caused by another set of wheels that are powered by a motor. In this case, no gear train is used. This is advantageous if one set of wheels is omni-wheels that can freely turn. But for VEX MRR, having a gear train is recommended as we plan the robot to climb up a hill that is more than 30 degrees. Besides, the robot would perform point turn better with the help of the gear train.

Gear Ratio

  • Making a gear ratio is one of the easiest ways to change the Mechanical Advantage in a mechanism or system to achieve the desired speed or torque. It expresses the relationship between a driving gear(the gear connected to the input power source, such as a motor) and a driven gear(the gear connected to the output, such as a wheel) in a system.
Figure 1-18: Different Gear Ratio
  • When you have a system with a driving gear that is LARGER than the driven gear, you will increase the speed and decrease the torque. Otherwise, if the driving gear is SMALLER than the driven gear, you will increase the torque and decrease the speed.
  • Gear ratio is expressed in this way: (Driving Gear Teeth):(Driven Gear Teeth), and gear reduction(another mathematical expression that describes the relationship) is expressed in reverse:(Driven Gear Teeth) /(Driven Gear Teeth). The following are a 12-teeth driving gear with a 36-teeth driven gear.
Figure 1-19: Example Driving Gear and Driven Gear

The gear ratio is 12:36, and the gear reduction is 36/12 = 3/1 = 3. That means that the output (driven gear) shaft is 3 times slower than the input (driving gear) shaft and has 3 times as much torque.

Please refer to Robot Construction Tips for Center of Gravity and Drive Train.

Price List of the VEX Parts

Figure 1-20: List of Prices of the VEX Parts

Tips for Troubleshooting

  • Before building:
    • In the design process, make sure that wires of all motors can reach the motor shield located in the center of the robot, or the motors will break easily.
    • Calculate the gear ratio and consider the feasibility of the design before putting them all together.
  • While building:
    • Always remember to add wheel spacers before putting wheels on shafts, or the wheels won’t sit steady.
    • Wrap all cables with electrics tapes to prevent them from touching each other or the metal frame of the robot.
    • Zip ties can be used to tie up your wires and secure batteries in place.
  • While testing:
    • If the robot can not climb up the ramp, make sure you are using gear train and rubber bands to add traction to your wheels.
    • If the tips of wires connected to the motor came off, solder another pin to the motor/ask a TA for help.
    • Weight distribution REALLY matters. Due to the importance of the center of gravity to the orientation and balance of the robot, it is important to consider where the center of gravity is when the robot is on unbalanced terrains, such as a ramp, and when the robot’s structure is being manipulated, such as a moving claw.

Here are a number of suggestions for the weight distribution:

  • Generally, the center of gravity should be low on the robot in order for the robot to be stable on flat ground. If the center of gravity is too high, the robot might tilt and fall over.
  • In addition, due to the effects of gravity, if the robot traverses up a ramp, the back of the robot contributes to the center of gravity more than the front of the robot. Thus it is optimal to have the center of gravity near the front of the robot in order to balance the robot on the hill. Otherwise, the robot would either not have enough power to travel up the hill.

Likewise, if the robot is traveling down a hill, the center of gravity should be adjusted towards the back of the robot in order to account for the effects of gravity. It is important that the center of gravity is aligned with the location of the motors in these scenarios or else the robot would tip over.

2. VEX CAD Assembly

Disclaimer

Please thoroughly read the entire guide before starting your Fusion 360 assembly. There are some tips that will make creating your model much easier. Also, keep in mind it might take more than three Aligns to get your parts to snap into place at first, but once you complete a few and start to become comfortable with it, it should become faster. If you have any questions, feel free to ask a TA.

Preparation of Software

Invite to Collaborate in Fusion 360

  1. Download Fusion 360 from the Autodesk website
  2. Create an account with your NYU email or sign in
  3. Once downloaded, open Fusion 360
  4. In the top left corner of the window, click the Data Panel icon (Figure 2-1)
    Figure 2-1: Data Panel Icon
  5. In the Data Panel, click New Project. Name your project and press the Enter key
  6. Double click on the box with your project name. Go to the People tab at the top of the page
  7. Enter the email addresses of your teammates and click the Invite button

Download and Import VEX Parts

  1. Download the Autodesk VEX Kit of Parts (KoP). Make sure to download the Fusion 360 KoP for VEX EDR
    Figure 2-2: Extract the ZIP Folder
  2. In Fusion 360, go to the Data tab of your project and click New Folder. Name the new folder and press the Enter key. This folder will contain all the downloaded VEX parts for the project
  3. Double click the new folder that was just created. Click the Upload button
  4. In the dialog that just appeared, click Select Files
  5. In the File Explorer, navigate to the unzipped folder of VEX parts
  6. For Mac users, select the _MACOSX folder. For Windows users, select the Fusion_360_VEX_EDR_KOP folder. Select all the individual F3Z files in each folder to download. You can also drag and drop these files. You can select all the F3Z files in individual folders but cannot select F3Z files from different folders. Select the files you believe you will need for your project. Click Open
  7. In the window that appears, click Upload
  8. The VEX parts will take a few minutes to upload from your files to Fusion 360. Once the upload is complete, click Close in the Job Status window. There should be new files in the Data Panel. You can double click one of the files to open the VEX part, or click and drag the files into your project to use them for the assembly

Creating the Assembly

In CAD, an assembly is a group of individual components that are aligned to each other using mating conditions. Mating conditions are definitions for the relative positions of components in respect to each other. Individual components usually require multiple mating conditions to become fully defined in 3D space. The general purpose of assemblies is to visualize how components become geometrically constrained in a system, and how these geometric constraints allow engineers to simulate, analyze, and evaluate their designs as to mimic real-life conditions. In Fusion 360, there are a few functions to generate mating conditions for assemblies. This guide will specifically cover the Align tool, Joint tool, and Rigid Group tool.

Note: "Connecting pieces" are screws, rods, shaft collars, wheels, etc.

Align Tool

The Align tool aligns the geometry from one component to the geometry of another component. The aligned geometry can be a surface, edge, or point. The Align tool is a simplified mating condition generator that makes all selected geometry coincident to each other.

  1. Move the two bodies being aligned close to one another using the Move/Copy tool (Figure 2-3)
    Figure 2-3: Move/Copy Tool
  2. Under the Modify section of the toolbar, select the Align tool (Figure 2-4)
    Figure 2-4: Align Tool
  3. The Align dialog will appear on the right side of the window (Figure 2-5). For the From profile, select the first surface, edge, or point being aligned. For the To profile, select the second surface, edge, or point. The first profile will become aligned to the second profile
    Figure 2-5: Align Dialog
  4. Repeat steps 1 - 3 using different points on the bodies being aligned until they are oriented as desired (Figure 2-6). Make sure the bodies are aligned as desired in the x-, y-, and z-directions
    Figure 2-6: Aligned Bodies

Rigid Group Tool

The Rigid Group tool locks the relative position of the selected components. The components are treated as a single object when moved or when joints are applied. Note that components like the wheels and motors are already sub-assemblies consisting of two or more bodies. They will have to be joined as a Rigid Group prior to being aligned with additional components.

  1. Select all the bodies of interest from the Browser on the left side of the window
  2. Go to the Assemble tab in the toolbar and select the Rigid Group tool (Figure 2-7). If prompted with a warning that states "some components have been moved", select Capture Position
    Figure 2-7: Rigid Group Tool
  3. The Rigid Group dialog will appear on the right side of the window. Click OK to make the Rigid Group

Replicating Sub-Assemblies

In some instances, such as for the wheels, it will be required to align the gears of the drivetrain to the wheel before aligning the entire sub-assembly of the gears and wheel to the frame. Seeing that most designs have four wheels, repeating the process of aligning over and over can become tedious and time-consuming. Using the method below, sub-assemblies can be joined as one body and copied as many times as needed:

  1. Go to File > New Design in the same project as the rest of the VEX files
  2. Click and drag in desired components from the Data Panel
  3. Under the Modify tab of the toolbar, select the Align tool
  4. Align the components to each other
  5. Save the file in the same folder as all the downloaded Vex components
  6. Now you can drag newly made rigid group into the main robot assembly as many times as needed

Using this process whenever there are repeated components will greatly reduce the time needed to make the full assembly.

3. VEX Programming

The VEX library is used in the EG1004 course to control the VEX robot and sensors using Arduino. The library is designed to more easily access the robot’s functionality. For more information on coding with Arduino, please reference the Arduino Coding Guide

The library is intended for use with the Adafruit Motor Shield V2, and VEX EDR 2-wire motors.

The library allows you to interface with the following sensors:

  • MPU6050 Accelerometer and Gyroscope Sensor
  • HC SR04 and VEX Ultrasonic Sensor
  • VEX Touch/Button and VEX Limit Switch Sensor
  • IR Obstacle Avoidance Sensor

The library also allows for the following functions of the motor board:

  • Control single motor speed and direction
  • Control two motors speed and direction simultaneously

Download the library files here

Library Structure

This library relies on multiple 3rd party libraries, including MPU6050, I2Cdev, and Adafruit Motor Shield V2, as well as inbuilt Arduino libraries including Wire.

There is one main class that controls the robot:

  • Vex: commands the motor shield, and controls the motors for all robot movement

There are 2 classes that control different sensors:

  • Gyro: reads data from the MPU6050 and provides the Euler angles around 3 axises
  • Ultrasonic: reads the distance from itself to the nearest object it senses

Examples

Example files can be found by clicking on File>Examples>Vex. These Arduino C codes provided show the possibilities of the robot and provide tests for different functions.

  • Movement Test: tests the standard robot movements, such as forward, turns, and claw movement
  • Gyro Library Test: tests the gyro sensor to display the x,y, and z Euler angles
  • Gyro Turning Test: tells the robot to do a 90o left and right turn based on the gyro sensor
  • IR Obstacle Test: tests the IR obstacle avoidance sensor
  • Touch Test: tests the touch sensor/limit switch to display whether or not the button/switch is pressed
  • Ultrasonic Test: test the ultrasonic sensor by telling the robot to move forward until it is 5cm away from an obstacle

Importing the Library

  1. Open your main Arduino File.
  2. At the top of your screen, click on ‘Sketch,’ then ‘Include Library,’ then ‘Add .ZIP Library’’
    Figure 3-1: Arduino Sketch Tab
  3. Next, find the library you would like to include. Make sure the file is unzipped. (If using Windows, to unzip a file, right-click the file and select ‘Extract All’). You must upload all four files in ‘EG VEX Libraries.’ Note: Arduino does not let you upload all of the libraries at once so repeat steps 2 and 3.
    Figure 3-2: EG VEX Libraries
  4. Make sure to have ‘#include <Vex.h> ‘ at the top of your file.
Figure 3-3: Code to include VEX Library

Alternative Way to Import the Library

  1. Download the zipped EG VEX Libraries file here
    Figure 3-4: Downloaded EG VEX Libraries
  2. Extract the four libraries to separate folders
    Figure 3-5: Extracted EG VEX Libraries
  3. Move the four libraries to the Arduino libraries folder
    1. This is usually Documents/Arduino/Libraries
      Figure 3-6: Moved EG VEX Libraries
  4. Restart the Arduino IDE to load the libraries

Vex Class

This class is used to interface with the motors connected to the Adafruit Motor Shield. The shield can support up to 4 DC motors and uses its own power source separate from the Arduino RedBoard.

Wiring

The Adafruit Motor Shield comes with pins that connect the shield directly on top of the microcontroller. The shield can then be used just like the microcontroller, as it also has the standard pins used for the Arduino. In order to use the motor terminals labeled M1, M2, M3, and M4, the shield must be powered. For the VEX library, this should be done by connecting an external power source to the terminal shown in Figure 1. Figure 1 shows how to wire the motor shield with four DC motors and an external battery.

Figure 1: Adafruit Motor Shield Circuit

Methods

Constructor

  • In order to create a Vex object, the constructor must be called. Creating a Vex object allows you to call on the methods, which can also be referred to as functions, within the Vex Class. The constructor for a Vex object is empty meaning it has no parameters.

Syntax

  • Vex aNameForTheObject;
    • Example: Vex Robot

Example

  • Create a Vex object named robot:
Figure 3-8: Constructor for a VEX Object named “Robot”

Note: All constructors should be called outside of functions setup() and loop(). Additionally, your Vex object can have any name (i.e Robot, vex, etc).

begin()

  • The begin() method initializes the VEX robot. It must be called in the setup() function to use any other Vex methods.

Note: begin() does not initialize sensors. Refer to the documentation for the wanted sensor for reference on initializing these other modules.

Syntax

  • nameOfVEXObject.begin();
    • Example: gyro.begin();

Example

Figure 3-16: Example of begin()

setMotor()

  • The setMotor() method sets up the motors for use with the motor shield. This function must be called in order to create the motor objects needed for the moveMotor() and moveTank() methods. It also cannot be used alone and must be called when setting an Adafruit_DCMotor object. See the example below for correct usage of the setMotor() method

Syntax

  • Adafruit_DCMotor* motor = vex.setMotor(port);
    • In Figure 3-10, the third line of code creates a pointer (*) of type Adafruit_DCMotor that is named “motorA” and assigns it to the port in which the physical motor is connected to on the motor shield.

Parameters

  • port: An integer between 1 and 4, representing the motor port being used on the motor shield

Returns

  • An Adafruit_DCMotor* object

Example

Figure 3-10: Example of setMotor()

end()

  • The end() method stops all robot movement. It is meant for use at the end of the code, to stop the robot from looping the original code over and over again.

Note: this method places the code within an infinite loop, therefore any code written after this method is called will not be run.

Syntax

  • nameOfVEXObject.end();
  • Example: Robot.end();

Example

Figure 3-11: Example of end()

moveMotor()

  • The moveMotor() method allows for the movement of a single motor, for a set power and time

Syntax

  • vex.moveMotor(motor, power, time);

Parameters

  • motor: an Adafruit_DCMotor* object, previously created using the setMotor() method.
  • power: a double between -100 and 100. Positive numbers will move the motor clockwise, while negative numbers will move the motor counterclockwise. 0 will cause the motor to not move.
  • time: a positive double, representing the number of seconds to run the motor.

Returns

  • None

Example

Vex Library 13.png

moveTank()

  • The moveTank() method allows for the movement of two motors simultaneously, for two different power values, over a set period of time

Syntax

  • Robot.moveTank(motor1, motor2, power1, power2, time);

Parameters

  • motor1: an Adafruit_DCMotor* object, previously created using the setMotor() method
  • motor2: an Adafruit_DCMotor* object, previously created using the setMotor() method
  • power1: a double between -100 and 100. This value controls the power of motor1. Positive numbers will move the motor clockwise, while negative numbers will move the motor counterclockwise. 0 will cause the motor to not move.
  • power2: a double between -100 and 100. This value controls the power of motor2. Positive numbers will move the motor clockwise, while negative numbers will move the motor counterclockwise. 0 will cause the motor to not move.
  • time: a positive double, representing the number of seconds to run the motor

Example

Figure 3-13: Example of moveTank()

Gyro Class

This class is used to interface with the MPU6050 Accelerometer and Gyroscope. It is created specifically to provide the values of the Euler Angles as calculated from the gyroscope. Note: As the Gyro class is made specifically for this function, it cannot be used to access the additional functionalities of the MPU6050 device. Any other use of the MPU6050 outside of this class is at the discretion of the student.

Wiring

Figure 2 shows how to wire the MPU6050 sensor. Note that the Int pin on the MPU6050 must be connected to digital pin 2 on the Arduino board for the sensor to work within this library

Figure 3-14: Circuit Diagram for the MPU6050

Pins:

VCC: 3V or 5V

  • GND: ground
  • SCL: analog pin 5
  • SDA: analog pin 4
  • INT: Digital Pin 2

Methods

Constructor

  • In order to create a Gyro object, the constructor must be called. Creating a Gyro object allows you to call on the methods, which can also be referred to as functions, within the Gyro Class. The constructor for a Gyro object is empty (has no parameters).

Syntax

  • Gyro aNameForTheGyroObject;
    • Example: Gyro gyro

Example

Figure 3-15: Constructor for a Gyro

begin()

  • The begin() method initializes the gyro. It must be called in the setup() function to use any other Gyro methods

Note: begin() only initializes the gyro sensor. Refer to the documentation for the wanted sensor for reference on initializing other modules

Syntax

  • gyro.begin();

Parameters

  • None

Returns

  • None

Example

Vex Library 17.png

getZAngle()

  • The getZAngle() method returns the calculated Euler angle about the Z-axis

Syntax

  • gyro.getZAngle();

Returns

  • A float (decimal) value representing the angle.

Example

Figure 3-17: Example of getAngle()

getYAngle()

  • The getYAngle() method returns the calculated Euler angle about the Y-axis

Syntax

  • gyro.getYAngle();

Returns

  • A float value representing the angle

Example

Figure 3-18: Example of getYAngle()

getXAngle()

  • The getXAngle() method returns the calculated Euler angle about the X-axis

Syntax

  • gyro.getXAngle();

Returns

  • A float value representing the angle

Example

Figure 3-19: Example of getXAngle()

Ultrasonic Class

The Ultrasonic Sensor is used to determine how far away an object is. This is useful for obstacle avoidance. The HC-SR04 ultrasonic sensor uses a process similar to echolocation to operate. The sensor transmits a high-frequency signal, then it receives the signal after it gets reflected by the object. The sensor determines the time elapsed between transmission and reception. This can be used to calculate the distance from the sensor to the object using the speed of sound (343 m/s).

Figure 3-20:Ultrasonic Functionality

Wiring

The ultrasonic sensor has four pins: Voltage (VCC), Ground (GND), Trigger (TRIG), and Echo. VCC and GND need to be connected to voltage and ground, respectively. Trigger (or transmitter) is used for the sensor to create the high-frequency signal that gets transmitted, while Echo (or receiver) is used to receive the reflected signal. Trig and Echo can be connected to any digital I/O pins. The working voltage for ultrasonic sensor is 5V, its maximum range is 4 m, and its minimum range is 2 cm. Male/female jumper wires can be used to connect the ultrasonic sensor to the breadboard. Figure 3-21 & 3-22 show how to correctly wire the ultrasonic sensor.

Figure 3-21: Arduino Ultrasonic Wiring Guide
Figure 3-22: VEX Ultrasonic Wiring Guide

Pins

  • VCC: 5V
  • Trigger: digital I/O pin
  • Echo: digital I/O pin
  • GND: ground

Methods

Constructor

  • In order to create an Ultrasonic object, the constructor must be called. The Ultrasonic constructor takes two parameters, one for the trigger pin and one for the echo pin.

Note: The Trigger and Echo Pins refer to the pin number on the Arduino/Motor Shield the trigger/echo pins are wired to.

Syntax

  • Ultrasonic ultrasonic(triggerPin, echoPin);

Parameters

  • triggerPin: an integer representing the digital pin used for the trigger
  • echoPin: an integer representing the digital pin used for the echo

Example

Figure 3-23: Constructor for a Ultrasonic object

begin()

  • The begin() method initializes the ultrasonic sensor. It must be called in the setup() function to use any other ultrasonic methods.

Syntax

  • ultrasonic.begin();

Example

Figure 3-24: Example of begin()

checkUltrasonic()

  • The checkUltrasonic() method returns the distance (in centimeters) between the sensor and the first object it detects.

Note: The minimum distance the sensor can detect is 2cm, while the maximum distance is 4m.

Syntax

  • ultrasonic.checkUltrasonic();

Returns

  • A long representing the distance (in centimeters) between the sensor and the first object it detects. Note: A long data type to contain integer numbers that are too large to fit in the integer data type.

Example

Figure 3-25: Example of checkUltrasonic()

Touch Class

The Touch Class is used to interface with the VEX touch sensor or VEX limit switch. The class provides boolean values representing when the switch on the sensor has been pressed.

Wiring

The Touch Sensor is connected to two pins on the Arduino/Adafruit MotorShield, Ground (GND) and a Digital Pin. In Figure 3-26, the Digital Pin is connected to Digital Pin 3. The Touch Sensor works so that whenever it is pressed, a certain line of code or function can occur.

Figure 3-26: Touch Sensor Wiring Diagram. Note: The wiring for a Limit Switch is the same.

Pins:

  • GND: ground
  • touchPin: Digital Pin

Methods

Constructor

  • The constructor takes one parameter, for the digital pin. The constructor must be called in order to create a Touch object

Syntax

  • Touch touch(pin);

Parameters

  • Pin: an integer representing the digital pin used by the sensor

Example

Figure 3-27: Constructor for a Touch object

begin()

  • The begin() method is used to initialize the touch sensor. It must be called in the setup() function in order to use any other Touch methods

Syntax

  • touch.begin();

Example

Figure 3-28: Example of begin()

isPushed()

  • The isPushed() method returns a boolean value depending on whether or not the button on the sensor has been pressed

Syntax

  • touch.isPushed();

Returns

  • A boolean value. True indicates the button has been pushed, while false indicates the button has not been pushed

Example

Figure 3-29: Example of isPushed()

IRObstacle Class

This class is used to interface with the IR Obstacle Avoidance Sensor. This sensor will only return whether or not there is an obstacle directly in front of the sensor.

The sensor uses an infrared emitter LED. This signal is then received by an infrared receiver to determine whether or not there is an obstacle. The distance adjust terminal can be used to adjust the detection distance. Turning the screw counterclockwise will decrease the distance while turning the screw clockwise will increase the distance.

Figure 3-30: Diagram of IR Obstacle Avoidance Sensor

Note: As the IRObstacle class is made specifically for this function, it cannot be used to access the additional functionalities of the MPU6050 device. Any other use of the MPU6050 outside of this class is at the discretion of the student.

Wiring

  • Figure 3-31 shows how to wire the IR obstacle avoidance sensor
Figure 3-31: Wiring Diagram for the IR Obstacle Avoidance Sensor

Pins:

  • VCC: 3V or 5V
  • GND: ground
  • OUT: digital pin

Methods

Constructor

  • In order to create an IRObstacle object the constructor must be called. It has one parameter for the digital pin.

Syntax

  • IRObstacle ir(pin);

Parameters

  • Pin: an integer representing the digital pin used for the sensor

Example

Figure 3-32: Constructor for a IRObstacle object

begin()

  • The begin() method initializes the IR obstacle avoidance sensor. It must be called in the setup() function to use any other IRObstacle methods

Note: begin() only initializes the IR obstacle avoidance sensor. Refer to the documentation for the wanted sensor for reference on initializing other modules.

Syntax

  • irobstacle.begin();

Example

Figure 3-33: Example of begin()

isObstacle()

  • The isObstacle() method returns a boolean value depending on whether or not the sensor detects an obstacle

Syntax

  • irobstacle.isObstacle();

Returns

  • A boolean value. HIGH indicates an obstacle is detected, while LOW indicates no obstacle was detected

Example

Figure 3-34: Example of isObstacle()