ROBOTC for VEX Online Professional Development
Student: “My motor should spin forward for 3 Student: “My motor should spin forward for 3 seconds, stop for 2 seconds, then reverse for 3 seconds, but it never stops in the middle.”
Sensor Information: Touch Sensors
Touch Sensors Touch Sensor Check How they work Two Types Plugged into Digital 6 on the Cortex How they work Digital sensor - Pressed or Released 1 = Pressed, 0 = Released Watch out for “bouncing” Two Types Limit Switches (top) Bumper Switches (bottom) Setting them up ROBOTC Motors and Sensors Setup window Using them The SensorValue[] command untilTouch(), untilRelease(), until Bump()
Move Forward until Pressed
Natural Language - Until Commands that allow you to create behaviors where the robot acts “until” a certain event untilTouch() untilRelease() untilBump()
Touch Sensors Other Properties Limitations Limit Switch arm can be bent to create a more ideal “hit area” Both sensors spring back to “open” position Limitations Watch out for “bouncing”. As the sensor is pressed or released, it may bounce between 0 and 1 very briefly and quickly. A very brief wait can be inserted as part of the untilBump() command, or after the untilTouch() and untilRelease() commands to reduce the bouncing effect:
Natural Language Move Forward until Pressed
Touch Sensors Start Button Remember how we used the Remote Control button to start the timer portion of the program? How would we implement the same thing with the limit switch?
Additional Resources
Sensor Information: Potentiometer
Potentiometers Potentiometer Check Analog Port 6 on Cortex How they work Analog sensor Measures rotation of a shaft between 0 and ~265 degrees Cortex returns values 0 - ~4095 Using them The SensorValue[] command untilPotentiometerGreaterThan, untilPotentiometerLessThan NL commands
Potentiometers Other Properties Limitations Internal mechanical stops prevent the potentiometer from turning a full revolution. Limitations Caution: Excess torque against the internal mechanical stops (can be caused by hand or by a VEX motor) will cause them to wear away. The potentiometer will continue to function, but will have a “dead zone” where the mechanical stops were, where no new values are sent. Switching the direction the potentiometer is facing will also switch the direction it “counts”. For example: counter-clockwise turns will count 0 to 4095 on one side; on the other counter-clockwise turns will count 4095 – 0.
Potentiometers
Natural Language - Until Commands that allow you to create behaviors where the robot acts “until” a certain event untilPotentiometerGreaterThan() untilPotentiometerLessThan()
Natural Language Autonomous Arm Control
Potentiometers Variable Speed Program Use the rotation of the potentiometer to control how fast the robots motors spin
Advanced Arm Control Use the Touch Sensor and Potentiometer to control the minimum and maximum values of the arm. Follow videos in the VEX Cortex video Trainer.
Sensor Information Ultrasonic Rangefinder
The Ultrasonic Rangefinder Ultrasonic Rangefinder Check Input into Digital Port 8 (Always lower port number) Output wire plugged into Digital Port 9 How they work Similar to how bats and submarines work Digital sensor – but returns distance values between 0 & 648 cm (Can also return values of -1 or -2) Cortex resolution can be in inches, cm, or even mm 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 untilSonarLessThan(), untilSonarGreaterThan()
Ultrasonic Rangefinder Other Properties The Ultrasonic Rangefinder is able to detect objects in a “cone” field of view. As objects get further away, the sensor is able to detect them further away from the center of the sensor. The sensor bases distance calculations off of sound waves, which means that some objects may not be detectable: soft objects that absorb sound, sharp objects that deflect sound, etc. Do not use the ultrasonic sensor as the very first command in your code. Until the first sound echo returns to the sensor, it will have a value of -1. A simple delay at the beginning of your program solves this.
Forward until Near
Natural Language - Until Commands that allow you to create behaviors where the robot acts “until” a certain event untilSonarGreaterThan() untilSonarLessThan()
Natural Language Forward until Near
The Ultrasonic Rangefinder Forward/Straight until Near Move straight forward until the robot is near an object, then stop Follow along with videos in VCVT
Straight until Near