Sensor Signals in Robotics: From Physical Quantities to Digital Data

Capítulo 1

Estimated reading time: 9 minutes

+ Exercise

What a Sensor Measures in Robotics

In robotics, a sensor converts a measurand (the physical quantity you care about) into a signal your controller can process. Examples of measurands include distance (m), angular velocity (rad/s), acceleration (m/s2), magnetic field (T), pressure (Pa), temperature (°C or K), light intensity (lux), and force/torque (N, N·m).

Measurand, units, and dynamic range

  • Measurand: the physical quantity being measured (e.g., wheel speed).
  • Units: the standardized representation (e.g., m/s, rpm). Be careful with datasheets that mix units (e.g., °/s vs rad/s).
  • Dynamic range: the span of measurable values from minimum to maximum (e.g., 0.05 m to 4 m for a range sensor). Dynamic range is often limited by physics (signal-to-noise) and electronics (saturation, ADC range).

In practice, you also care about the operating range (where specs like accuracy hold) versus the absolute maximum range (where the device may still output something but performance is degraded).

From Physical Phenomena to Electrical Signals to Digital Data

Most sensors follow a chain: measurand → transduction → conditioning → digitization → software interpretation.

  • Transduction: the physical effect that creates an electrical change (e.g., piezoresistive strain changes resistance; Hall effect changes voltage with magnetic field; photodiode current changes with light).
  • Signal conditioning: amplification, filtering, biasing, linearization, temperature compensation, and protection.
  • Digitization: converting an analog quantity into numbers (ADC) or counting events (pulses) or receiving already-digital packets (I2C/SPI/UART).
  • Interpretation: scaling to engineering units, calibration, and time alignment with other sensors.

Common Sensor Signal Types

1) Analog voltage output

Many sensors output a voltage proportional (approximately) to the measurand, e.g., 0.5–4.5 V for pressure, or 0–3.3 V for a potentiometer angle sensor. The controller reads this with an ADC.

  • Pros: simple wiring, continuous signal.
  • Cons: susceptible to noise, requires careful grounding and ADC considerations.

2) Analog current loop (e.g., 4–20 mA)

Industrial sensors often use current output because current is less sensitive to voltage drops over long cables. A resistor converts current to voltage for the ADC.

Continue in our app.
  • Listen to the audio with the screen off.
  • Earn a certificate upon completion.
  • Over 5000 courses for you to explore!
Or continue reading below...
Download App

Download the app

V_meas = I_loop * R_shunt

Example: with a 250 Ω shunt, 4–20 mA becomes 1–5 V.

3) Digital pulses (frequency, duty cycle, quadrature)

Encoders, flow sensors, and tachometers often output pulses. The measurand is encoded in:

  • Frequency: pulses per second proportional to speed/flow.
  • Period: time between pulses (useful at low speeds).
  • Duty cycle: PWM where duty encodes value.
  • Quadrature A/B: two phase-shifted signals for direction and higher resolution.

4) Digital serial packets (I2C, SPI, UART)

Many modern sensors include an internal ADC and DSP, then transmit digital measurements as packets. This reduces analog noise sensitivity but introduces protocol timing, bus contention, and sometimes internal filtering latency.

Key Measurement Characteristics (What the Numbers Really Mean)

Resolution

Resolution is the smallest change in input that produces a distinguishable change in output. For an ADC-based measurement, resolution is often limited by quantization.

Example: a 12-bit ADC over 0–3.3 V has 4096 codes, so one LSB is:

LSB = 3.3 V / 4096 ≈ 0.000805 V

If a sensor sensitivity is 100 mV per unit, then one LSB corresponds to about 0.00805 units (ignoring noise).

Sensitivity

Sensitivity is the slope between output and input, e.g., 10 mV/°C or 1.5 mV/Pa. Higher sensitivity generally makes it easier to resolve small changes, but can also saturate sooner if the output range is limited.

Linearity

Linearity describes how closely the sensor output follows a straight line relationship with the measurand. Datasheets may specify nonlinearity as a percentage of full scale (FS).

Practical implication: if you assume a linear scale but the sensor is nonlinear, your error grows in certain regions. Some sensors provide polynomial coefficients or lookup tables to correct this.

Hysteresis

Hysteresis means the output depends on whether the measurand is increasing or decreasing. It is common in mechanical and magnetic sensors (e.g., force sensors with elastic elements, magnetic switches).

Practical implication: approaching a target from different directions can yield different readings; control loops may need deadbands or compensation.

Saturation and clipping

Saturation occurs when the sensor or conditioning electronics cannot represent higher (or lower) values, so the output “clips” at a maximum/minimum. Saturation can happen in:

  • the transducer (physical limit),
  • the amplifier (rail-to-rail limits),
  • the ADC input range (0–Vref),
  • the digital output format (e.g., max code).

Practical implication: once saturated, you lose information; filtering cannot recover it. Design so expected peaks stay within the specified measurement range.

Latency and group delay

Latency is the time between the physical event and when your software receives the corresponding measurement. Latency comes from conversion time, internal filtering, bus transfer, and scheduling.

In control and sensor fusion, latency matters as much as noise: a clean but delayed measurement can destabilize fast loops or misalign multi-sensor data.

Sampling Concepts for Robotics

Sample rate and update rate

Sample rate is how often you take samples (Hz). Update rate is how often the sensor produces a new value. They are not always the same:

  • You might sample an analog sensor at 1 kHz, but the physical system bandwidth is only 20 Hz (oversampling).
  • A digital IMU might output at 200 Hz internally, but you poll it at 100 Hz (you will miss updates unless you use a FIFO/interrupt).

Aliasing (what goes wrong when sampling too slowly)

Aliasing happens when higher-frequency components appear as lower-frequency artifacts after sampling. In robotics, aliasing can come from vibration, motor commutation, or mechanical resonance leaking into sensors.

Example intuition: if a vibration at 120 Hz is sampled at 100 Hz, the sampled data can look like a 20 Hz oscillation (because you are “strobing” the signal too slowly).

Nyquist intuition

A practical rule: to represent a signal with maximum frequency content f_max, sample faster than 2 * f_max. In real systems, you typically sample well above this and add an anti-aliasing low-pass filter so that frequencies above half the sample rate are attenuated before sampling.

GoalRule of thumb
Capture dynamics up to f_maxSample at 5–10× f_max when possible
Avoid aliasingLow-pass filter below Fs/2 (analog or sensor internal)
Stable control loopKeep total sensing+compute+actuation delay small relative to system time constants

Time stamping and synchronization

Robots rarely use one sensor; they fuse many. To fuse correctly, you need to know when each measurement was valid.

  • Time stamp at acquisition: record the microcontroller time when the sample was taken (or when an interrupt fired), not when it was processed later.
  • Account for known delays: some sensors specify internal filter delay or “output data rate” behavior; incorporate this into your time model.
  • Use hardware triggers when available: camera/IMU sync lines, encoder index pulses, or shared PPS signals improve alignment.

How Embedded Systems Read Sensors

ADC basics (for analog sensors)

An ADC maps an input voltage to a digital code based on a reference voltage Vref and resolution (bits). Key practical points:

  • Input range: ensure sensor output stays within 0–Vref (or the ADC’s specified range). Use dividers or amplifiers if needed.
  • Source impedance: many ADCs need a low-impedance source to charge a sample-and-hold capacitor quickly; otherwise readings drift or become noisy.
  • Reference stability: a noisy Vref directly appears as measurement noise.
  • Conversion time: limits maximum sampling rate; also affects latency.

Step-by-step: reading an analog voltage sensor

  • Check sensor output range (min/max voltage) and compare to ADC range.
  • Choose Vref and any scaling (divider/amplifier) so the sensor uses most of the ADC range without clipping.
  • Set ADC sample time to match source impedance and required speed.
  • Take multiple samples and average if noise is high and bandwidth allows.
  • Convert code to voltage, then apply sensor sensitivity/offset to get engineering units.

Counters/timers for pulse sensors

For pulse outputs, microcontrollers use timers in capture/count modes.

  • Frequency measurement: count pulses in a fixed time window (good at high speeds).
  • Period measurement: measure time between edges using input capture (good at low speeds).
  • Quadrature decoding: hardware encoder interfaces count edges and infer direction.

Step-by-step: measuring speed from an encoder

  • Determine encoder resolution (pulses per revolution) and whether you count x1/x2/x4 edges.
  • Choose method: period (low speed) or count-in-window (high speed), or combine both.
  • Configure timer input capture or encoder mode.
  • Time stamp counts (or capture times) to compute speed with known interval.
  • Apply filtering appropriate to control bandwidth (avoid adding too much delay).

I2C, SPI, UART: reading digital sensor frames

Digital sensors send structured data frames. You must handle bus timing and data interpretation.

  • I2C: address-based shared bus; good for many low/medium-speed sensors; watch pull-ups and bus capacitance.
  • SPI: fast, full-duplex, chip-select per device; good for high-rate IMUs/ADCs; watch mode (CPOL/CPHA).
  • UART: asynchronous serial; common for GPS, lidar modules; watch baud rate, framing, and parsing.

Step-by-step: reading a register-based digital sensor (typical I2C/SPI)

  • Read datasheet register map: identify data registers, scale factors, and status bits.
  • Initialize configuration: output data rate, full-scale range, filter settings.
  • Decide acquisition method: polling, data-ready interrupt, or FIFO.
  • Read raw bytes and verify integrity (CRC if provided; otherwise sanity checks).
  • Convert raw counts to physical units using scale factors and offsets.
  • Time stamp each sample at read time or using data-ready interrupt time.

Practical Checklist: Interpreting a Sensor Datasheet

  • Measurement range: operating range vs absolute limits; does it cover expected peaks without saturation?
  • Units and scaling: sensitivity (e.g., mV/unit), digital LSB/unit, and any offset/bias terms.
  • Accuracy vs precision: accuracy (closeness to true value) vs precision/repeatability (scatter). Check how accuracy is defined (temperature, calibration, typical vs max).
  • Resolution and noise: ADC bits alone are not enough; look for noise density, RMS noise, or effective number of bits (ENOB).
  • Linearity and hysteresis: nonlinearity (%FS), hysteresis specs, and whether compensation is required.
  • Update rate and bandwidth: output data rate, internal filtering, and any group delay/latency.
  • Interface: analog (voltage/current) or digital (I2C/SPI/UART), logic levels, timing requirements, CRC, FIFO, interrupts.
  • Power: supply voltage range, current consumption (active/standby), startup time, and any warm-up requirements.
  • Environmental limits: temperature range, vibration/shock, ingress protection, magnetic/EMI susceptibility, and mounting constraints.
  • Calibration and drift: zero offset, scale factor tolerance, temperature coefficients, long-term drift, and recalibration procedure if needed.

Now answer the exercise about the content:

Which approach best helps prevent aliasing when sampling a sensor signal that may contain high-frequency vibration?

You are right! Congratulations, now go to the next page

You missed! Try again.

Aliasing occurs when sampling too slowly. Sampling well above 2*f_max and applying an anti-aliasing low-pass filter below Fs/2 attenuates high-frequency content before digitization.

Next chapter

Encoders for Robot Motion: Position, Velocity, and Odometry Reliability

Arrow Right Icon
Free Ebook cover Sensors in Robotics: From Signals to Reliable Measurements
7%

Sensors in Robotics: From Signals to Reliable Measurements

New course

14 pages

Download the app to earn free Certification and listen to the courses in the background, even with the screen off.