ROBOTC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817 - PowerPoint PPT Presentation

Loading...

PPT – ROBOTC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817 PowerPoint presentation | free to download - id: 659010-ZjlmY



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

ROBOTC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817

Description:

ROBOTC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817 Tanya Mishra 06/2012 We can see that the motor value pairs of 0 and 40 cause the robot to make sharp ... – PowerPoint PPT presentation

Number of Views:85
Avg rating:3.0/5.0
Slides: 110
Provided by: midlandis
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: ROBOTC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817


1
ROBOTC for VEX Cortex Llano Estacado RoboRaiders
FRC Team 1817
2
Humans and Machines
  • Machines are built to perform useful tasks.
  • The way a Machine works depends entirely on the
    way the Human build it.
  • Since Machines and Robots need a medium of
    communication, a language called Programming
    Language is used.
  • EASYC, ROBOTC, C, C all are programming
    languages.
  • The instructions in the language are called
    Programs and the human that writes the
    instructions is called the Programmer.

3
  • Task of Programmer Understand Problem, Find a
    solution, Write a program to solve the problem in
    the required Programming language.
  • Task of Machine Follow the program provided.
  • A ROBOT is a Machine.

4
Planning and Behavior
  • Behavior Action the Robot has to take.
  • Big Behavior Solving a maze
  • Small Behavior Turn Left, Move Forward, etc.
  • Big Behavior is made up of Smaller Behaviors.
  • Plan a Solution to the problem.
  • Break down the plan into detailed smaller steps.
  • Each step is a behavior the robot needs to
    follow.
  • Sequence of these steps in English is called
    pseudo-code.

5
(No Transcript)
6
  • Flow charts are a visual representation of the
    program flow.
  • Start and End Rounded Rectangles. They contain
    the word Start or End, but can be more
    specific such as Power Robot Off or Stop All
    Motors.
  • Actions Rectangles. They act as basic commands
    and process steps.
  • Decision blocks Diamonds. These typically
    contain Yes/No questions. Based on the choice,
    the next step is determined.

7
(No Transcript)
8
Introduction to C Programming
  • EasyC is based on the the principles of C
    Programming.
  • We will cover the following concepts
  • 1. Basic Components of a C Program
  • 2. Data Types and Variables
  • 2. Conditional operators
  • 3. Control Structures and Loops
  • 4. Methods and Functions

9
A Basic C Program
  • includeltstdio.hgt // Header File
  • void main(void) // Main function
  • // Body of the main function
  • Header file Includes all the required words and
    instructions needed to write a program
  • Main function Execution starts from here
  • Body stepwise Instructions to the Robot

10
  • Each Instruction to the robot is also called a
    Statement.
  • When the list of instruction is send to the VEX
    cortex, it read them from top to bottom and left
    to right.
  • Different Commands use different paired
    Punctuations such as ()
  • .. defines a body of one or more
    instructions. Also called a Compound Statement.
  • Every instruction in the body ends with a .
    It shows the end of a instruction.

11
  • Comments are for the programmer to understand
    what a particular statement does.
  • Two kinds of comments
  • 1. // This is a one line comment
  • 2. / This is a more than one line
  • Comment./
  • C language is case sensitive Upper and lower
    cases are considered different.

12
Data types and Variables
  • A Variable is a place to store a value.
  • A variable has a Type and a Name
  • Type deals with the type of Data the variable
    will hold.
  • Type of Data
  • Int Whole Numbers. Positive, Negative, Zero
  • float(Floating Point) Decimal Point Numbers.
    Positive and Negative.
  • String Text. Letters, Spaces and characters.

13
  • char(Characters) Single characters
  • bool(Boolean) True and False values
  • Declare a variable
  • int Age
  • float Score
  • string Name
  • char Grade
  • bool Pass

14
  • Assign a variable
  • Age 18
  • Score 90.5
  • Name William
  • Grade 'A'
  • Pass True
  • Declare and assign
  • int Age 18
  • float Score 90.5
  • string Name William
  • char Grade 'A'
  • bool Pass True

15
  • Variable Naming Rules
  • A variable name can not have spaces in it.
  • A variable name can not have symbols in it.
  • A variable name can not start with a number.
  • A variable name can not be the same as an
    existing reserved word.
  • Scope of a Variable
  • Local variables Within a certain block of code
    or function. Cannot be accessed outside.
  • Global variables Can be accessed anywhere in the
    code.

16
  • Using Variables in a print to screen function
  • When printing a variable on the screen, the
    following syntax is used
  • Print to screen function(type,Variable)
  • Signed and - , unsigned - , short less
    range , long more range

17
  • Conditional Operators
  • Comparison operators

Relational Operator Example
gt (Greater Than) 7 gt 5
gt (Greater Than or Equal To) 7 gt 5 , 7 gt 7
lt (Less Than) 5 lt 7
lt (Less Than or Equal To) 5 lt 7 , 7lt7
(Equal To) 7 7
! (Not Equal To) 7 ! 5
(Assignment Operator) number 7
18
  • Logical operators
  • Boolean Truth Table
  • Joining two or more statements using And and
    Or

A Its a Sunny Day B My Car is working Can I go out? (A and B) Can I go out? (A or B)
Yes Yes Yes Yes
Yes No No Yes
No Yes No Yes
No No No No
19
  • And
  • Or
  • Not !

A B !A A B A B
True True False True True
True False False False True
False True True False True
False False True False False
20
Control Structures and Loops
  • Control Structure
  • IF statements
  • if(condition)
  • Instructions, if condition is True

21
  • IF-ELSE Statements
  • if(condition)
  • // Instructions, if condition is true
  • else
  • // Instructions, if condition is false

22
  • ELSE-IF Statements
  • if(condition1)
  • // Instructions, if condition 1 is true
  • else if(condition 2)
  • // Instructions, if condition 2 is true
  • else
  • // Instructions, if condition 1 and condition
    2 are false

23
  • Switch Statements
  • switch(expression) //expression can only be an
    int or char
  • case Value-1
  • // Instructions, if expression Value-1
  • break
  • case Value-2
  • // Instructions, if expression Value-2
  • break
  • default
  • // Instructions, if expression does not match any
    Value

24
  • Example
  • char Grade 'A'
  • switch(Grade)
  • case A
  • Your Grade is A
  • break
  • case B
  • Your Grade is B
  • break
  • default
  • This is the default
    choice

25
  • Loops
  • While loops
  • while(condition)
  • // Instructions, if condition is true
  • Note Control Structures execute only once. On
    the other hand, while loops execute continuously
    until the condition is false.
  • If the condition in the loop is always true, the
    loop never ends. Such a loop is called an
    Infinite Loop.
  • A loop will end only when the condition is false
    or there is a break statement.

26
  • Example
  • int count 0 //Initialization
  • while(count lt 2) //Condition
  • PrintToScreen( I have d apple \n, count)
  • count count 1 //Increment
  • Output I have 0 apple
  • I have 1 apple
  • I have 2 apple

27
  • For Loop
  • for(initialization condition increment)
  • // Instructions, If condition is true
  • Similar to a while loop except that the
    initialization and increment are all together.
  • Note Initialization is done only when the loop
    first starts. After that it is skipped.

28
  • Example
  • int count
  • for(count 0 count lt 2 count count 1)
  • PrintToScreen( I have d apple \n, count)
  • Output I have 0 apple
  • I have 1 apple
  • I have 2 apple
  • Note \n is called new lines. It prints the next
    sentence in a new line.

29
Methods and function
  • Functions are named sections of code that can be
    called from other sections of code.
  • Also called subroutines.
  • Every executable statement in C must live in a
    function.
  • Functions have a Data type, name and input
    values.
  • Input values are called Parameters. They are the
    values you want the function to work with.

30
  • The function definition specifies the return
    value and the parameters of the function
  • ltdata typegt FunctionName(ltparam1gt, ltparam2gt, ...)
  • ltfunction bodygt
  • ltreturn typegt
  • Return type and Data type should be of the same
    kind.
  • Return type is void if nothing is to be
    returned.
  • Parameters is void if nothing is to be passed
    in.

31
  • Example
  • int addition(int x, int y)
  • int z
  • z x y
  • return z
  • void main(void)
  • addition(2, 3)

32
Some Useful terms
  • Compiler Turns C program into the machine
    language for the controller.
  • Loader Loads the machine language output of the
    compiler (along with other stuff) into the robot
    controller.
  • Machine Language What the robot controller
    actually understands. Found in .HEX files.
  • 10110100
  • 11100101
  • 00001011

33
Download ROBOTC
  • Download Link ROBOTC for CORTEX and PIC
  • www.robotc.net-gtDownload-gtROBOTC 3.0 for CORTEX
    and PIC
  • or
  • http//www.robotc.net/download/cortex/

34
ROBOTC Rules
  • task main()
  • motorport3 127
  • wait1Msec(3000)
  • Important words are highlighted.
  • Uppercase and Lowercase matters.
  • White spaces and tabs are for programmer
    convenience
  • Sentences or Instructions are separated by
    semicolon.
  • Instructions are read from T B and L-R.

35
Error Messages
  • Compiler analyzes your programs to identify
    syntax errors, capitalization and spelling
    mistakes, and code inefficiency (such as unused
    variables).
  • Errors Major issues. misspelled words, missing
    semicolons, and improper syntax. Errors are
    denoted with a Red X.
  • Warnings Minor issues. These are usually
    incorrect capitalization or empty, infinite
    loops. Warnings are denoted with a Yellow X.

36
  • Information ROBOTC will generate information
    messages when it thinks you have declared
    functions or variables that are not used in your
    program. These messages inform you about
    inefficient programming. Information messages are
    denoted with a White X.

37
System Configurations
  • Firmware is a piece of software that accessing
    the operating system in the processor enabling it
    to perform its task.
  • Update firmware to make sure it is compatible
    with the ROBOTC and latest Vex Hardware
  • Update Firmware on Cortex
  • Cortex Micro controller is the Brain

38
  • It has two separate processors inside
  • 1. User Processor Handles all ROBOTC
    programming instructions.
  • 2. Master Processor Handles all lower level
    operations like Motor Control and VexNet
    Communication.
  • Make sure you have the following first
  • 1. A USB A-A cable.
  • 2. A charged robot battery
  • 3. The cortex Powered Off
  • 4. Latest version of ROBOTC installed on PC

39
  • Step 1 Connect Cortex and PC
  • using A-A cable.
  • Step 2 Turn Cortex ON.
  • Step 3 Go to ROBOTC
  • Robot-gtPlatform Type-gtInnovation First(IFI)-gtVex
    2.0 Cortex

40
  • Step 4 View-gtSelect Communication Port-gtUSB
    wired Cable or Vex Robotics COMM Port (if Cortex
    recognized) otherwise Automatic
  • Step 5 Robot-gtDownload Firmware-gtAutomatically
    update Vex Cortex

41
  • Update Firmware on Joystick
  • Make sure you have the following first
  • 1. A USB A-A cable.
  • 2. Latest version of ROBOTC installed on PC
  • Step 1 Connect Joystick and PC
  • using A-A cable.
  • Step 2 Go to ROBOTC
  • Robot-gtPlatform Type-gtInnovation First(IFI)-gtVex
    2.0 Cortex

42
  • Step 4 View-gtSelect Communication Port-gtUSB
    wired Cable or Vex Robotics COMM Port (if Cortex
    recognized) otherwise Automatic
  • Step 5 Robot-gtDownload Firmware-gtAutomatically
    update VexNET Joystick

43
  • Download Firmware when
  • You start using a particular Vex Cortex or VexNET
    Joystick
  • You update a newer version of ROBOTC.

44
Download Sample Program
  • Step 1 Go to ROBOTC
  • File-gtOpen Sample Program-gtTraining
    Samples-gtMotor port 3 forward.c

45
  • Before Downloading, make sure
  • Your cortex and VexNet remote control are paired
    and equipped with VexNet USB keys.
  • Batteries connected to remote control and cortex.
  • Robot propped up.
  • Orange programming kit connecting PC and remote
    control.
  • Turn on Remote Control and Robot.
  • Robot and VexNet status lights should blink green
    on both remote control and Robot.

46
  • Step 2 View-gtpreferences-gtDetailed
    Preferences-gtPlatform Vex 2.0 Cortex and
    Communication Port Prolific USB-Serial Comm
    port.
  • Step 3 Robot-gtVex Cortex Communication
    Mode-gtVexNet or USB

47
  • Step 4 Robot-gtCompile and Download Program
  • Step 5Debugger Window-gtStart

48
Motors
  • task main()
  • motorport3 127
  • motorport2 127
  • wait1Msec(3000)
  • Running this program makes the Robot spin because
    the motors on the robot are mirrored. So making
    the motor on port2 move forward in the code,
    makes it move in reverse in real time.

49
  • Reverse Motor Polarity
  • Robot-gtMotors and Sensors Setup-gtMotors tab-gt
    Port 2 reversed check box is checked.

50
  • pragma config(Motor, port2, ,
    tmotorNormal, openLoop, reversed)
  • The pragma statement contains configuration
    information from the motors and sensors settings
    and should only be changed from the window.

51
  • The Motors and Sensor Window can also be opened
    by double clicking on the pragma statement.
  • Motors and Sensor Window
  • Name Name of the Motor eg. leftMotor, rightMotor
  • Type Motor Equipped or Type of Motor
  • Reversed Checked if Motor needs to be reversed.
  • task main()
  • motorleftMotor 127
  • motorrightMotor 127
  • wait1Msec(3000)

52
(No Transcript)
53
Turning of Motors
  • Assigning Positive power Values(127) on both
    motors makes the robot go forward.
  • Lower speed of robot by assigning values less
    than full power(127).
  • Assigning negative power values(-127) on both
    motors makes the robot go reverse.
  • Assigning zero power values(0) on both motors
    makes the robot stay in place.

54
  • Point Turn Turn in place (-63 and 63)
  • Swing Turn Making one motor on and the other off
    makes the robot swing around the stationary
    wheels. (0 and 63)

55
  • Sometimes the power assigned in the code to the
    motors does not reach the motors. Reasons
    friction or construction. Manual adjustments to
    the power levels.
  • task main()
  • //Makes the robot go forward at half speed
    for 2 seconds.
  • motorleftMotor 63
  • motorrightMotor 63
  • wait1Msec(2000)
  • //Makes the Robot turn left in place for 0.7
    seconds.
  • motorleftMotor -63
  • motorrightMotor 63
  • wait1Msec(700)

56
Shaft Encoders/Rotation Sensor
  • Manual adjustments of power are not same for all
    robots and as the battery power drains, the robot
    is move shorter distances.
  • Shaft Encoders are used to control how far the
    Robot Moves.
  • Number of counts per Revolution on a axle mounted
    through the encoder center.
  • Max 360 up for forward movements and 360 down for
    reverse movements.

57
  • ROBOTC-gtFile-gtOpen Sample Program-gtShaft
    Encoder-gtForward for Distance.c

58
(No Transcript)
59
  • Encoders need to be set to zero before you use
    them.
  • On the Cortex Micro controller, the Analog and
    Digital Ports are used to connect sensors.
  • In Motors and Sensors setup
  • Digital Port, Sensor Name and Sensor Type
  • Naming Conventions No special Characters, No
    spaces and Not a reserved word in ROBOTC.
  • Both Encoder wired on the Right and Left side of
    the robot must be in neighboring ports.

60
(No Transcript)
61
  • Clear the encoders for better consistency and
    precision on your robots movements.

62
  • Sensor Debug Window
  • In order to see the values in the encoders as the
    robot runs, we can use the debugger window.
  • Compile and Download the program.
  • Press continuous on the debugger window instead
    of start.
  • Robot-gtDebugger Windows-gtSensors
  • Scroll down and find your encoders in the list.
  • Press start on the debugger window to start
    your robot and watch the values change.

63
(No Transcript)
64
  • Forward movement and Turning
  • Not controlled by power or time but rotation
    counts.

65
Joystick Mapping
  • Vex Remote control provides you with two
    joysticks (each having a x- axis and y-axis),
    eight buttons on the front and four additional
    buttons on the top.

66
  • The remote control sends streams of data to the
    Robot over the VexNet.
  • The Vertical motion of the joysticks on the
    remote control range from 127 to -127, where
    127 is full power forward, 0 is stop and -127 is
    full power reverse.
  • To access the values in the joystick in ROBOTC,
    we use the following command
  • vexRTchannel Number
  • VexRT is short for Vex Remote Transmitter.
  • The channel number for each input is shown on the
    remote.

67
  • For example, the right joystick's vertical motion
    is on channel 2.
  • vexRTch2
  • Pairing each motor with each joystick we can make
    the robot move forward, turn or go in reverse.
  • motorport number vexRTchannel number

68
  • Sample Program
  • ROBOTC-gtfile-gtOpen Sample Program-gtRemote
    Control-gtDual Joystick Control.c

69
(No Transcript)
70
  • Limiting the range of power from 127, -127 to
    half power 63,-63 to achieve accurate
    movements.
  • Similarly, many other possible mapping
    combinations are possible.

71
Timers
  • Timers are like Stopwatches.
  • Used in competition to know how long the robot
    has been working.
  • Four Timers provided in ROBOTC T1 , T2, T3 and
    T4.
  • ClearTimer(TimerName)
  • This command resets the Timer to 0 and
    immediately starts counting again.

72
  • To check the elapsed time on the Timer T1, we use
    the following command
  • time1T1
  • It returns the elapsed time in milliseconds.
  • To check elapsed time in 10 milliseconds or 100
    milliseconds, the commands are
  • time1T1, time10T1, or time100T1

73
  • Thus, to make your robot unresponsive for 90
    seconds

74
Buttons Mapping
  • The 8 buttons on front of the remote control are
    divided into two groups and the four buttons on
    top are also divided into two groups. The group
    number is written next to the numbers.

75
  • Unlike joysticks, the buttons have two values 1
    when pressed and 0 when released.
  • VexRTBtn Group Direction,
  • where Direction U(Up), D(Down), L(Left),
    R(Right)
  • For example, to access the Down button on Group 7
    (Left side buttons on the remote)
  • VexRTBtn 7 D

76
  • To make your robot respond to user control on a
    button press

77
Sensor Configuration
  • Vex Cortex allows us to incorporate various
    sensors on the robot which provides valuable
    sensor feedback for intelligent decision making.
  • There are 8 Analog Sensor ports for sensors like
    Line Follower, Accelerometer and Potentiometer.
  • There are 12 Digital Sensor ports for sensors
    like the limit switch, Shaft Encoder and
    Ultrasonic Rangefinder.

78
(No Transcript)
79
  • These sensors are configured in the same way we
    have configured motors and shaft encoders before.
  • The ROBOTC Motors and Sensors setup allows you to
    setup these sensors depending on if it is a
    Digital or Analog Sensor.
  • If you are unsure of the type of sensor being
    Analog or Digital, you can see it in the drop
    down menus in the Motor and Sensor Setup.

80
  • Limit Switch
  • Limit Switch is a Digital Sensor(0 and 1) and is
    plugged into the Digital port 6 on the Cortex.
  • When pressed, it provides a sensor value 1, when
    released, it provides a sensor value 0.
  • SensorValueLimit switch name

81
  • Potentiometers
  • A potentiometer is a Analog Sensor and is plugged
    into port 6 of the Analog board on the cortex.
  • It measures rotation between 0 to 250 (not 360
    due to internal mechanical stops) degrees and
    return value ranging from 0 to approximately
    4095.

82
  • The values returned by the Potentiometers can be
    seen using the Sensor Debug Window that we used
    with the Shaft encoders.
  • SensorValuePotentiometer name

83
Ultrasonic Range Finder
  • Ultrasonic Range Finder allows us to sense
    obstacles in the path of the robot and avoid
    bumping into them.

84
  • It measures distance to the obstacle using sound
    waves. It calculates the Distance depending on
    how long it takes for the sound wave to bounce
    back.
  • Distance Speed Time / 2
  • Digital Sensor and connections on the Cortex are
    as follows

85
  • Motors and Sensor Setup
  • Choose type depending on what distance scale you
    want cm or mm or inch

86
  • According to the program, till the distance to
    the obstacle is greater than 25 cm, the robot
    will move forward. As soon as it is 25 cm away
    from the obstacle, to robot will stop.

87
  • Sometimes the echo of the sound wave does not
    reach the range finder on soft surfaces like a
    sweater or certain surfaces such as a slope
    deflect the wave in another direction.
  • In the debugger window, we can see that when the
    sonar does not detect any sound, the sensor value
    if set to -1.

88
  • If the sonar value will be -1, the condition in
    the code will always be false and the robot will
    not move when no obstacle is detected.
  • To make the robot move forward when no obstacle
    is detected, the condition needs to be changed.

89
Line Tracking Sensors
  • Below is shown a set of three Line tracking
    Sensors. Line tracking sensors work on the bases
    of Infrared Light. Each sensor has an Infrared
    LED and an Infrared Light sensor.

90
  • The LED emits light and the sensor detects the
    amount the light reflected back.
  • Light Surfaces Low Sensor Reading
  • Dark Surfaces High Sensor Reading

91
  • The cortex gives a Sensor reading from 0 to 4095.
    The value does not correspond to any unit of
    measurement.
  • Thus it is important to take care of lighting
    conditions around the robot and the height at
    which the sensors are placed in order to
    determine the threshold of reading.

92
  • Motors and Sensor Setup

93
  • Calculate Threshold Values (Example)
  • Leaving the task main() empty, if we run the
    robot on a light surface, we get the the
    following values in the Sensor Debugger Window
  • For Dark Surfaces we get the following values

94
  • Light Surface Average Value
  • Average 165 167 160 492 /3 164
  • Dark Surface Average Value
  • Average 2795 2821 2837 8453 / 3 2817.66
    2818
  • Threshold Value
  • 164 2818 2982 / 2 1491

95
  • Using all three sensors allows us to detect the
    line as well as border of the line, corners and
    intersections, which is not possible if you use
    just one line tracking sensor.

96
  • Sample Program
  • File-gtOpen Sample Program-gtVEX2-gtTraining
    Samples-gtSimple Line Tracking.c

97
(No Transcript)
98
  • We can see that the motor value pairs of 0 and 40
    cause the robot to make sharp swings as it steers
    itself on to the line. This causes waste of
    energy. To simplify, use pairs of motor values
    close enough lie 20 and 40.
  • For sharp turns and curves on the lines, we can
    optimize the motor values, shaft encoder rotation
    counts and threshold values to work together in
    order to perfect the different sections of the
    path.

99
  • Tips on Line Tracking
  • Break the entire path into sections depending on
    how the line curves.
  • Instead of programming the entire path at once,
    implement and test each section one after
    another.
  • The behaviour in each section will almost eb the
    same. The only difference will be the values of
    the motors, encoders or threshold. This can be
    achieved by implementing a LineTracking()
    function with different parameter values!

100
Reserved words
  • Motors
  • Motor control and some fine-tuning commands.
  • motoroutput power
  • The VEX has 8 motor outputs port1, port2... up
    to port8. The VEX supports power levels from
    -127 (full reverse) to 127 (full forward). A
    power level of 0 will cause the motors to stop.
  • bMotorReflectedoutput 1 (or 0)

101
  • Timing
  • The VEX allows you to use Wait commands to insert
    delays into your program. It also supports
    Timers, which work like stopwatches they count
    time, and can be reset when you want to start or
    restart tracking time elapsed.
  • wait1Msec(wait_time)
  • Maximum wait_time is 32768Msec, or 32.768
    seconds.

102
  • wait10Msec(wait_time)
  • Maximum wait_time is 32768, or 327.68
    seconds.
  • time1timer
  • It returns the current value of the
    referenced timer as an integer. The
    maximum amount of time that can be referenced
    is 32.768 seconds The VEX has 4 internal
    timers T1, T2, T3, and T4.
  • time10timer
  • The maximum amount of time that can be
    referenced is 327.68 seconds.

103
  • time100timer
  • The maximum amount of time that can be
    referenced is 3276.8 seconds.
  • ClearTimer(timer)
  • This resets the referenced timer back to zero
    seconds.
  • SensorValue(sensor_input)
  • SensorValue is used to reference the integer
    value of the specified sensor port. Values will
    correspond to the type of sensor set for that
    port. The VEX has 16 analog/digital inputs
    in1, in2... to in16

104
Type of Sensor Digital/Analog? Range of Values
Touch Digital 0 or 1
Reflection (Ambient) Analog 0 to 1023
Rotation (Older Encoder) Digital 0 to 32676
Potentiometer Analog 0 to 1023
Line Follower (Infrared) Analog 0 to 1023
Sonar Digital -2, -1, and 1 to 253
Quadrature Encoder Digital -32678 to 32768
Digital In Digital 0 or 1
Digital Out Digital 0 or 1
105
  • Sounds
  • The VEX can play sounds and tones using an
    external piezoelectric speaker attached to a
    motor port.
  • PlayTone(frequency, duration)
  • This plays a sound from the VEX internal speaker
    at a specific frequency (1 1 hertz) for a
    specific length (1 1/100th of a second).

106
  • Radio Control
  • ROBOTC allows you to control your robot using
    input from the Radio Control Transmitter.
  • BvexAutonomousMode ltvaluegt
  • Set the value to either 0 for radio enabled or 1
    for radio disabled (autonomous mode). You can
    also use true for 1 and false for 0.
  • vexRTjoystick_channel
  • This command retrieves the value of the specified
    channel being transmitted.

107
  • If the RF receiver is plugged into Rx 1, the
    following values apply

If the RF receiver is plugged into Rx 1, the
following values apply
Control Port Joystick Channel Possible Values
Right Joystick, X-axis Ch1 -127 to 127
Right Joystick, Y-axis Ch2 -127 to 127
Left Joystick, Y-axis Ch3 -127 to 127
Left Joystick, X-axis Ch4 -127 to 127
Left Rear Buttons Ch5 -127, 0, or 127
Right Rear Buttons Ch6 -127, 0, or 127
If the RF receiver is plugged into Rx 2, the
following values apply
108
Control Port Joystick Channel Possible Values
Right Joystick, X-axis Ch1Xmtr2 -127 to 127
Right Joystick, Y-axis Ch2Xmtr2 -127 to 127
Left Joystick, Y-axis Ch3Xmtr2 -127 to 127
Left Joystick, X-axis Ch4Xmtr2 -127 to 127
Left Rear Buttons Ch5Xmtr2 -127, 0, or 127
Right Rear Buttons Ch6Xmtr2 -127, 0, or 127
bVexAutonomousMode false //enable radio
control while(true) motorport3
vexRTCh3 //right joystick, y-axis //controls
the motor on port 3 motorport2 vexRTCh2
//left joystick, y-axis //controls the motor on
port 2
109
Reference
  • VEX Cortex Video Trainer using ROBOTC
  • http//www.education.rec.ri.cmu.edu/products/teac
    hing_robotc_cortex/index.html
  • ROBOTC A C Programming language for Robotics
  • http//www.robotc.net/
About PowerShow.com