📏 Hardware · Build Quality

Sensor Mounting

Where you put the distance sensor matters more than how you program it. A sensor mounted 10° off-square produces errors that no amount of code can fix. Get the hardware right first.

// Section 01
Why Mounting Matters
Bad hardware produces bad data. No software fix can compensate for a sensor that is physically in the wrong position.

The Chain: Mount → Data → Auton

Every step in your distance-sensor workflow depends on the step before it. The code is only as good as the data. The data is only as good as the mount.

📏 Sensor Mount
📊 Distance Reading (mm)
🏆 Auton Positioning Decision

A sensor angled 10° off-square reads ~2% longer than the true distance. At a 300 mm target that's a 6 mm error — enough to miss a goal position or cause a collision. At 15° the error reaches 3.5%, over 10 mm. These errors are consistent and repeatable, which means they look fine in practice but fail silently at competition when table heights differ by a few millimeters.

🚫
Angle error is invisible in practice and fatal at competition. A slightly angled sensor reads consistently wrong. You tune your code to compensate, it works on your mat, then the wall at the competition venue is a different material or texture — and the compensation is off. Fix the angle. Don't tune around it.

What Bad Mounting Actually Causes

Test every wall, not just one. After mounting, drive the robot to face each of the four field walls and check the live reading on the Brain screen. All four readings at the same physical distance should agree within 5 mm. If they don't, something in the mount is off.
// Section 02
Mounting Positions
Three configurations. Choose based on which walls your auton uses for alignment.
▶ FRONT MOUNT
Wall Approach & Pre-Score Alignment
  • Sensor faces forward — reads the wall the robot is driving toward
  • Most common position on Spartan Design robots
  • Best for: stopping at a target distance before scoring, aligning to the back wall at the start of a skills run
  • Limitation: cannot read while driving away from a wall; blocked by front mechanisms (intake, descorer)
ℹ️
Mount behind the intake or descorer when possible — the sensor needs a clear sightline beyond the mechanism. Extend the mechanism fully and verify the reading still reaches the wall before locking the mount position.
Top View — Front Mount
FIELD WALL ╔═══════════════════════════════════╗ beam ↑ ┌──────[S]──────┐ │ ROBOT │ └───────────────┘ ╚═══════════════════════════════════╝ [S] = sensor = beam direction
▶ SIDE MOUNT
Parallel Alignment & Wall Tracking
  • Sensor faces sideways — reads the wall beside the robot as it drives parallel to it
  • Used for: lateral alignment when approaching a scoring zone from the side, maintaining a consistent distance from a side wall during a long drive
  • Limitation: only useful when robot is travelling parallel to that wall; large angle during turns makes readings temporarily unreliable
Top View — Side Mount (reading left wall)
WALL ╔══════╗ ←←←←←← beam ← ┌────────────────┐ ←←←←←← [S] ROBOT │ └────────────────┘ ╚══════╝ [S] = sensor on left face, beam pointing left
★ DUAL SENSOR — ADVANCED
Corner Alignment & Position Verification

One sensor front, one sensor side. Together they give you X and Y position relative to a corner — no odometry required for that region of the field.

  • Use front sensor to stop at distance from back wall, side sensor to verify lateral offset from side wall
  • Costs one extra Smart Port — worth it for high-stakes skills positioning
  • Code checks both sensors before executing the scoring move — only proceeds if both readings are in range
Dual sensors eliminate an entire class of auton failure: the robot that reaches the right distance from one wall but is 3 inches off laterally. Both axes confirmed before scoring = no surprise misses.
// Section 03
Mounting Rules
Five rules. All of them are critical. Break one and the sensor data becomes unreliable.
Rule 1 — Square to the Wall
The sensor face must be parallel to the wall surface — perpendicular beam path. Any angle introduces a cosine error that grows with distance. At 500 mm and 15° off-square, the error is ~18 mm. Verify with a speed square or right-angle bracket during assembly.
Rule 2 — No Tilt (Level Face)
The sensor must sit level — not tilted up or down. A downward tilt clips the beam toward the floor and produces an early stop. An upward tilt misses the wall entirely at close range. Both cause inconsistent readings that change based on approach speed.
Rule 3 — Clear Line of Sight
Nothing should cross the beam path during any part of the robot's motion — intake, arm, cable, or other mechanism. Test with all mechanisms extended to their full range of motion. If anything intersects the beam at any position, the mount needs to move.
🚮
Rule 4 — Avoid Interference Sources
Keep the sensor away from spinning motors, pneumatic solenoids, and high-current wires. Electrical interference can cause occasional false readings. Physical vibration from motors mounted on the same C-channel can gradually loosen the sensor mount. Use rubber grommets or separate brackets where possible.
⬇️
Rule 5 — Consistent Height
Mount the sensor so the beam hits the field wall face cleanly — not the floor, not the top edge. Field walls extend from ~0.5" off the floor to ~14". Any height within 2"–12" works reliably. Avoid the very bottom (beam bounces off floor) and the very top (beam clips the wall edge at an angle).
⚠️
Rule 1 (square to wall) breaks Rules 3 and 5 if you fix it wrong. Rotating a sensor to make it perpendicular can move it into the path of a mechanism or tilt it. Make alignment changes as a bracket change, not a sensor rotation.

Quick Verification Checklist

// Section 04
Good vs Bad Mounting
Diagrams and comparisons for the three most common mounting failures.

Straight vs Angled

✅ Correct — Square to Wall
WALL ┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃ ↑ ↑ ↑ ┌──[S]──┐ ← beam hits │ROBOT │ wall at 90° └───────┘ Reading: 300 mm (accurate)
❌ Bad — Angled Mount
WALL ┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃ ↗ ↗ ↗ ┌─[S]───┐ ← beam hits wall │ROBOT │ at ~15° angle └───────┘ Reading: 310 mm (10 mm error)

A 10° angle adds ~1.5% to the reading. At 300 mm that's 4–5 mm. At 600 mm it's nearly 10 mm — enough to misalign a scoring attempt.

Clear Beam vs Blocked Beam

✅ Correct — Clear Path
WALL ┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃ ↑ ↑ ↑ (no obstruction in beam) [S] intake retracted │ROBOT │ Reading: reaches wall correctly
❌ Bad — Mechanism Blocking Beam
WALL ┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃ ↑ ↑ (beam blocked) [S] ■ ← intake arm │ROBOT │ Reading: 85 mm (reads the arm)

A mechanism in the beam path returns the distance to the mechanism, not the wall. The robot stops mid-field thinking it reached the target. Test by extending all mechanisms and watching the live reading — it should stay stable at the wall distance.

Correct Height vs Too Low

✅ Correct Height — Hits Wall Face
Side view: ═══ wall top ════ ~14" ━━━━━━━━ beam ━━━━━━━ 6" [S] mounted at 6 inches ═══ floor ═══════ 0" Beam hits flat wall face
❌ Too Low — Beam Hits Floor First
Side view: ═══ wall top ════ ~14" [S] mounted at 1 inch \\\\ beam hits floor \\\\ ═══ floor ═══════ 0" Reads floor distance — wrong
🔬 Check for Understanding
A robot's distance sensor reads 340 mm when pushed straight at the wall from 300 mm away. The sensor is not blocked. What's the most likely cause?
The sensor is mounted too high
The sensor face is angled — not square to the wall
The sensor is reading in inches instead of mm
The Smart Cable is loose
Correct. An angle between the sensor face and the wall increases the measured distance because the beam travels a longer path to hit the surface and return. A 10° angle at 300 mm produces ~5 mm of error — exactly what you'd expect here. Re-square the mount using a right-angle reference.
// Section 05
CAD, Build Solutions & Competition Proofing
Design the mount before you cut. Competition-proof it before you ship.

CAD Best Practices (Onshape)

ℹ️
Document the mount in your notebook. A CAD screenshot of the sensor mount, annotated with the angle constraint and beam clearance check, is exactly the kind of design evidence the rubric rewards. It shows the decision was deliberate, not accidental.

Simple Mounting Solutions

OPTION A
C-Channel + Collar Screws
  • Mount the sensor to the face of a 1×2 or 2×2 C-channel using M3 screws through the sensor's mounting holes
  • Attach the C-channel to the robot frame at 90° using a corner gusset
  • Cheapest, lightest, most common solution — works for most front-mount configurations
  • Add Loctite Blue on the two mounting screws after final angle verification
OPTION B
Standoff + Flat Plate Bracket
  • Attach a small flat plate (1×5 or custom cut) to the robot frame
  • Use standoffs at two corners to hold the sensor at a fixed offset from the plate
  • Good for situations where the sensor needs to be inset from the robot frame edge — protects it from collisions
  • Two-point contact via standoffs is more resistant to twist than a single screw
OPTION C
Slotted Adjustment Bracket
  • Cut or order a bracket with 5 mm slotted holes on one axis
  • Allows ±5° angle adjustment after mounting — useful if you find a small alignment error at competition
  • Tighten fully after final position is confirmed; mark the final position with a marker so you can reset it if bumped
  • Slightly heavier but adds the ability to fine-tune without tools beyond a 3/32" hex key

Competition-Proofing

Build two identical sensor mounts. After the first one is verified good, build a second identical one. Keep it with a spare sensor in the pit box. If the primary gets damaged, the replacement takes 3 minutes to install and is pre-aligned.
⚙ STEM Highlight
Physics: Angle Error & Cosine Loss
When a sensor beam hits a surface at an angle instead of perpendicular, the measured distance is longer than the true gap. The relationship follows cosine: measured = true ÷ cos(θ). At 10° off-square the error is 1.5%. At 20° it reaches 6%. At a 300 mm target, a 10° mount angle adds 5 mm to your reading. At 20°, 18 mm — enough to reliably miss a scoring position.

This can't be fixed in code. The mount is the only fix.
🎤 Interview line: "We verified the sensor mount with a right-angle reference because angle error follows cosine — even a 10-degree offset shifts our stopping position by 5 mm. That's the difference between scoring and missing, so we treated mount squareness as a build quality requirement."
📝
Notebook color guide for sensor work:
■ Orange — Mount position diagram or CAD screenshot with sensor location annotated. Include your measured target distance.
■ Cyan — Consistency test data: target distance, measured stop positions, pass/fail results across n≥10 runs.

Common Mistakes

✖ Slight Angle from Eyeballing the Mount

Tightening the sensor to "looks about right" is the most common source of angle error. The human eye can't reliably detect 5°.

Fix: Use a machinist's square, speed square, or right-angle bracket as a reference during assembly. Tighten the screws while holding the reference in place.
✖ Sensor Blocked by Extended Mechanism

Tested with the intake retracted, worked fine. Then the intake extended during auton — sensor read the intake at 80 mm and stopped the robot in the middle of the field.

Fix: Always test with every mechanism at every position. Extend the arm, raise the lift, deploy the descorer. Watch the live reading during each motion — it should stay stable at the wall value throughout.
✖ Cable Management Not Done

Cable flops loose, gets caught during a match, pulls the sensor 8° to the left. Works in practice, fails at the worst time.

Fix: Route the cable with enough slack for all robot motions, secure it with a cable tie anchor within 2 inches of the sensor mount. Run the full autonomous once and watch whether the cable moves — if it does, anchor it better.

Key Takeaways

Related Guides
📏 Distance Sensor Positioning → ⚡ Wiring & ESD → 🔍 Robot Pre-Check → ⚙️ Mechanism Sprint → 🌍 GPS Sensor →
📝
← ALL GUIDES