VEX Sensors Overview

From ROBOTC API Guide
Revision as of 17:02, 30 April 2012 by Bfeher (Talk | contribs)

Jump to: navigation, search

Main >> PIC >> Sensors Overview


For ROBOTC PIC Sensor functions, check out the PIC Sensor Functions page!


The VEX is equipped with 16 sensor ports. These can be either analog (e.g. voltage level from a photocell detecting light intensity) or digital (e.g. a touch or switch sensor). Analog sensors should be connected to lower numbers ports and digital sensors connected to higher numbered ports. This is restriction in the VEX hardware where analog sensors are assigned ports 1 to N where N is the total number of ports.

There are a variety of functions and variables used for configuring these ports and accessing their values.

Configuring sensors can be complicated. ROBOTC has a built-in wizard that can be used to configure the VEX sensors. The wizard contains a number of PC windows that allow you to set the following fields for the sensor:

  • The variable name that you want to assign to the sensor. Using a name like “leftBumper” makes for a more readable program than IN3!
  • The port that the sensor is connected to.
  • The type of sensor – touch, wheel encoder, sonar, line follower, light brightness, etc.




Analog Sensors

Raw Value - Returns an analog value between 0 and 1023 - Used for testing new sensors or reading raw data from sensors.
Reflection - Returns an analog value between 0 and 1023.
Line Follower - Returns an analog value between 0 and 1023.


Digital Sensors

There are 5 main types of Analog Sensors for the VEX PIC:
Touch- Returns a digital value. A "1" means a closed circuit and a "0" means an open circuit.
Rotation - A digital sensor that returns a counter value keeping track of how many "counts" the encoder has seen. This sensor will increment regardless of direction. The VEX rotation sensor uses this type of sensor.
SONAR - Returns an analog value in inches (i.e. a value of 20 means 20 inches away). A value of "-1" means the sensor does not receive a "reflection". The sonar sensor requires the "Input" wire to be attached the interrupt port int1 or int2 to function properly.
Quadrature Encoder - A digital sensor that returns a counter value keeping track of how many "counts" the encoder has seen. This sensor will increment when traveling in the forward of direction and decrement when traveling in the reverse direction.The Quadrature Encoder requires one of the input wires be attached the interrupt port "int3" through "int6" to function properly.
Digital In - This will make the sensor port act as just a digital input, very similar to a touch sensor.
Digital Out - This will cause the sensor port to send out a digital high ("1") signal. Useful for using the controller to power 5V devices.