ROBOTC for VEX On-Site Professional Development Troubleshooting • Student: My robot won’t stop turning. Troubleshooting • Student: I used the auto straightening code, and it compiles, it isn’t working, it’s just being weird. Troubleshooting • Student: One of my encoders is counting down even though it’s spinning forward. Troubleshooting • Student: My code won’t compile. Radio Control Radio Control • An out-of-box VEX Microcontroller comes with basic built-in Radio Control functionality – The Radio Control Transmitter can be configured to allow some customization of that built-in functionality – Still very limited customizability and usefulness! • The ROBOTC firmware enables full customization of how the Radio Control Transmitter signals controls the VEX – By default ROBOTC turns off reception from the transmitter to save battery life during autonomous programming – One line of code turns it back on Radio Control • One Transmitter continuously sends out 6 separate values over 6 separate channels – Values range from -127 to 127 – Doesn’t something else have values that range from -127 to 127? • The “crystal” number must match on the transmitter and receiver – The crystal is what controls the frequency of the transmission – One transmitter can control multiple robots, so be careful in your classrooms – 13 different crystals/frequencies are available Radio Control Reset • Since the Radio Control Transmitter can be configured, there’s the possibility that it’s configured inappropriately for our purposes. – Watch the Radio Control Setup and Values and Axes (Part 1) Videos in TRC4V, found in Radio Control > Control Mapping – Be sure to follow along with the Radio Control Setup Video! Radio Control Signals Radio Control • Direct Value Mapping – Values from the transmitter are directly used to control the motors (1:1 ratio) • Program Flow Tracing – Radio Control with Wait States – Radio Control with a Loop (real-time control) • Indirect Value Mapping – Values from the transmitter are modified before being used to control motors – Can make the robot easier to control – Appropriate in situations that require more “delicate” movements – Notice: the robot reads the right side of the equal sign first Advanced Radio Control • Attach the Arm! • Use the Transmitter buttons to control the arm – The Transmitter buttons send values of -127, 0, or 127 – Would direct mapping or indirect mapping be most appropriate for controlling the arm? Why? • More loop control please? – Is remote controlling the robot forever always appropriate? – Question: Where would the wait statement go if we wanted the robot to be remote controlled for a controlled amount of time? – Answer: Nowhere! We need something else. • Solution: Timers – Can be thought of as internal stopwatches (4 available) – Like encoders, timers should be “cleared” anytime before they are used • Watch where you clear them! Advanced Radio Control • Wasting Time? – The time it takes to turn on the VEX and start Radio Control is wasted time. – Could we make the robot wait to start it’s timer until we were ready? Any ideas? • Wait for a Transmitter Button press – – – – The robot won’t start the timer until we say so The robot also can’t move until we says so Program Flow Trace Could this idea also be used to make a “more friendly” start button on a non-radio controlled robot? • Other ideas of how to improve radio control? – Use the buttons to initiate common actions • Turn 90 degrees, move straight forward, ect Advanced Radio Control • Assigning a function to a button press – Auto pickup Radio Control Challenges • TRC4V Videos (recommended) – Watch remaining Control Mapping videos 3-5 • Race to the Finish – Remember to Journal – Remember to Pseudocode • Shut off your transmitter when it’s not in use! – Drastically saves the battery life (and your ears) • The transmitter is always transmitting, even if the robot isn’t on Advanced Radio Control Challenges • TRC4V Videos (recommended) – Watch remaining Radio Control Videos (Control Mapping, Timers, Buttons sections) • Minefield Level 1 Challenge – Remember to Pseudocode – Remember to Journal • RoboDunk – First try it Tele-Operated, then Autonomously Competition Templates • VEX Competitions have a “Field Management System” in place – Manages when robots are enabled/disabled – Determines whether the robots are in autonomous/tele-operated mode • A Competition Template is available that can be programmed in to work with the Field Management System – Contains autonomous and tele-operated sections – Found in the Sample Programs > Competition folder Troubleshooting • Student: My loop should only be running for 1 minute, but it never stops. Touch Sensors • Touch Sensor Check – Front sensor plugged into A/D 1 – Rear Sensor plugged into A/D 4 • How they work – Digital sensor - Pressed or Released – Watch out for “bouncing” • Two Types – Limit Switches – on Squarebot 3.0 – Bumper Switches • Setting them up – ROBOTC Motors and Sensors Setup window • Using them – The SensorValue[] command Touch Sensors • Start Button – Remember back to how we used the Transmitter button to start the timer portion of the program. How would we implement the same thing with the limit switch? • Fine-tuned arm control – Using the limit switches to tell the robot when it has reached it’s minimum and maximum points Touch Sensor Challenges • Quick-tap Challenge – Incorporating Sensors, Variables, Loops, If Statements, Timers, Boolean Logic, Pseudocoding, and FUN all into one activity • Addition & Subtraction – Everything you just learned, but with another twist The Ultrasonic Rangefinder • Ultrasonic Rangefinder Check – Input wire plugged into A/D Port 5 – Output wire plugged into INT Port 1 • How they work – Similar to how bats and submarines work – Digital sensor – but returns distance values between 0 & 255 • (Can also return values of -1 or -2 if used improperly) – Resolution is in inches (a value of 5 = 5 inches away) • Setting them up – ROBOTC Motors and Sensors Setup window • Using them – Be careful not to use them immediately as your program starts – they take time to initialize and will return negative values – The SensorValue[] command The Ultrasonic Rangefinder • Forward until Near – Move forward until the robot is “near” an object, then stop – Thresholds • Automatic Pick-up – Forward until Near + picking up the mine – Assign to a button Sensor Challenges • TRC4V Videos (recommended) – Watch Remaining Sensing Section Videos • Minefield Level 2 Challenge – Remember to Pseudocode – Remember to Journal – The two are not mutually exclusive! • The Speed of Sound • Sonic Scanner Level 2 (Start) Potentiometers • Potentiometer Check – Sensor plugged into A/D 1 • How they work – Analog sensor – Measures rotation of a shaft between 0 and ~265 degrees – Returns values 0 – ~1023 – Internal mechanical stop • Setting them up – ROBOTC Motors and Sensors Setup window – Using Analog and Digital Sensors • Using them – The SensorValue[] command Potentiometers • Variable Speed Program – Use the rotation of the potentiometer to control how fast the robots motors spin • Arm Control – Instead of using the limit switches, use the potentiometer to control how far the arm is allowed to swing up and down Servo Motors • Very similar in appearance to the normal motor • Very different in operation – Rotates between 0 and 120 degrees – Where the motor is set to a “power value” the servo is set to a “position value” – -127 = 0 degrees, 0 = 60 degrees, 127 = 120 degrees, ect – Servo motors are programmed exactly the same way as normal motors in ROBOTC, so the programmer must know the hardware and intent Pneumatics Pneumatics • Solenoids operate as Digital Outputs • Are plugged into Analog/Digital Ports – Are set to open by setting them to 1 – Are set to close by setting them back to 0 • Demo in ROBOTC End of Day Challenge • Minefield Level 2 – Incorporate an autonomous scoring behavior before your tele-operated code begins – One “mine” should always be in the same place, near the goal