Presentation is loading. Please wait.

Presentation is loading. Please wait.

RobotC Sensors.

Similar presentations


Presentation on theme: "RobotC Sensors."— Presentation transcript:

1 RobotC Sensors

2 Learning Objectives Take a look at some of the options for VEX Sensors
Be able to configure sensors Be able to use a touch sensor/limit switch to limit the movement of an arm Be able to implement functions to help organize code Be able to use the Ultrasonic Sensor to drive forward until you are near an object Be able to use light sensors to track a line

3 Sensor Ports UART (Universal Asynchronous Receiver/Transmitter) Ports 1, 2 Analog Ports 1-8 I2C Inter-integrated Circuit Protocol Allows several devices to be chained to one port. Digital Ports 1-12 Speaker

4 Analog Sensors Light Sensor: 0 – 6 Feet
0 = Very Bright 255 = Dark Line Tracker: LED Light + Light Sensor

5 Analog: Line Tracker Infrared light sensor and infrared LED.
Lights the surface and measures the light reflected. Analog: 0 = Bright, Full Scale (4096 for Cortex, 1023 for PIC) = Dark More Info at Tracker-Instr-0312.pdf

6 Potentiometer: Analog
Measure the angle position Measures 0 to 250 degrees +/- 20 Return values from 0 to 4096 Be careful, the sensor should not rotate beyond 250 degrees.

7 Analog Accelerometer Measures acceleration non three axis simultaneously Each channel being used connects to the controller (Cortex)

8 Digital: Limit Switch/ Bumper Switch
Can sense when arms reach their limit.

9 Digital Sensors Ultrasonic Uses two digital ports
Sensitivity: Detects a 3cm diameter pole at greater than 2m Usable Range: 3.0 cm to 3.0 m / 1.5 in – 115 in

10 Digital Optical Shaft Encoder
Takes two digital ports Can detect of to 1700 pulses per second = 18.9 rev/sec = rev/min

11 I2C Sensor Integrated motor encoders
Since it is I2C you can chain several (8?) encoders onto one I2C port. cessories/sensors/encodermodules.html Measures ticks per revolution when the motor is geared for torque.

12 We will use the Squarebot for Sensors Section

13 Configuring the Limit Switch
1) Select the Digital Sensors Tab Robot -> Motors and Sensors Setup 3) Use the pull-down menu to select Touch. 2) Name the Sensor frontLimit 4) Apply and OK.

14 Configuring the Potentiometer
Robot -> Motors and Sensors Setup Select Analog Sensors tab Using port 6 Name the variable: armPot Select ‘Potentiometer’ from the drop down menu Apply OK

15 Using the Limit Switch Can sense when arms reach their limit.
0 when not pressed 1 when pressed

16 Preventing the Arm From Lowering Too Far
Pseudo Code If the down button is pressed AND the limit switch is not pressed Go down AND? Remember the conjunctions?

17 Conjunctions Conditions can be combined using conjunctions && (AND)
while ((SensorValue[rightEncoder]<1800) && (SensorValue[leftEncoder] <1800)) { //while both encoders are less than 1800 it will repeat the code in the {} block } || (OR) while ((SensorValue[rightEncoder]<1800) || (SensorValue[leftEncoder] <1800)) { // While either the leftEncoder<1800 or the rightEncoder is <1800 it will //repeat the code inside the {} block ! (NOT) Turns true to false and false to true while !(SensorValue(leftEncoder)>1800)

18 The && can only combine two complete conditions.
Putting it together Pseudo Code If the down button is pressed AND the limit switch is not pressed Go down The && can only combine two complete conditions.

19 Using the Potentiometer to Limit
Go to And follow the video trainer lesson


Download ppt "RobotC Sensors."

Similar presentations


Ads by Google