Sensor Units

Due to a lack of accessibility and clarity from the Vex Forum and Vex Website, I want to create this topic to compile a list of all the different units for all the available sensors. This will allow me and others to readily access what kind of units are used for each type of sensor.

For example, a gyro measures angular displacement in tenths of a degree. As for the positive or negative direction, I am not entirely sure.

Specifically, I need to know what is the range of a potentiometer and what units is it measured in. I know the physical range is 260 degrees but what is the analog reading?

2 Likes

potentiometers range from 0 to 4095 I think. or something close to that anyways.
I know ultrasonics measure in centimeters away from the object its hitting.

I want to get a list of certain values. Here are all the sensors that you can use:

  • Gyro
  • Potentiometer
  • Line Tracker
  • Light Sensor
  • Limit Switch
  • Shaft Encoder
  • Ultrasonic Sensor
  • Bumper Switch
  • Accelerometer

(Am I missing any?) I only care about the analogy sensors for now as the digital ones only return a value of 1 or 0.

1 Like

Pretty sure limit switch and bumper switch only return 1 or 0, with 1 being pressed and 0 being not pressed.

1 Like

What about the line tracker what values does that have?

Yeah, I said that here:

Just to clarifiy, any sensor that has only two states is a digital sensor and thus reuturns a 1 or 0. 1 being the state of the sensor is true (pressed) or false (not pressed). Usually analog sensors are rotational in nature.

I’m not sure as I’ve never used one but I’d like to know.

There are many digital sensors that do not simply report true or false.

Digital is simply the method of relaying the sensor information, where values are sent as combinations of 1 and 0, with various sensors encoding different types of data. This is opposed to analog sensors, which report values in a voltage scale.

An example of a digital sensor is a quadrature encoder:

While the signal is digital, there is more data underlying that signal.
I believe encoders report in degree units.

Another example of a digital sensor is the ultrasonic sensor. In this case, one digital wire is used for sending the ultrasonic signal pulse, and the other is for receiving that pulse. The code (VEXos in this case) then has to calculate the delay between the two wires and figure out the distance. I don’t have the ultrasonic units off the top of my head, though I think it might be cm.

As for potentiometers, which are analog sensors, the units are completely arbitrary. Since potentiometers are literally just variable resistors, they can only be defined as percent of a range. In this case, the range is 260 degrees. That range is then scaled into voltage, which is sent to the V5 as a scale from a minimum voltage to a maximum voltage. Then, it is up to the code to decide how to use that percentage information, and to what precision to store it.

The standard in VEX is to use a unsigned 12-bit integer to store that percentage. That provides enough precision without being too memory-consuming. A characteristic of an unsigned 12-bit integer is that the number of values it can hold is 4096. Thus the scale is established.

Most analog sensors such as the line tracker operates in a similar way. It gives values as a percentage, and the actual scale depends on the format the code delivers to you. Just know the standard is usually a 12-bit int with a max of 4095 (why not 4096? see below).

Other analog sensors such as Gyro and Accelerometer require a more complex algorithm called an integrator to convert voltage “rate” signals into actual static degrees. Since those sensors only report the rate of change of their angular velocity, the integrator needs to run in a rapid loop and add all the increments together to keep track of the angle.

PROS actually provides two potentiometer/analog API commands that give you different ranges - one a 12-bit integer and the other a 16-bit integer (for extra precision to avoid rounding errors).

The best advice I can give you when reading sensor values it to check the documentation of the language you are using, as the units or scale can vary. Even joystick value and motor power ranges/percentages are inconsistent across the APIs.

Note:
The maximum 12-bit value is actually 4095 (not 4096), as a 12-bit integer can hold 4069 different numbers, but when you count from 0 the maximum value is 4095.

10 Likes

Thanks for thoroughly explaining this. I had a general understanding but I think that in order to program you need to have a very strong foundation for the way each hardware component works.