🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Manufacturing & Marine › Robotics / Mechatronics › Industrial Sensors and Signal Conditioning for Mechatronics › Lesson 4
MFG-MECH15-04 · Lesson 4 · 12.5 clock hours · demo

Ultrasonic and Vision Sensors

Objective. Students configure an ultrasonic distance sensor for analog output and demonstrate basic vision sensor setup for part-presence and label-verification tasks on a simulated production line.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by a licensed engineer or certified journey-level tradesperson or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Ultrasonic and Vision Sensors in Mechatronics

Modern automated production lines rely on non-contact sensors to detect, measure, and inspect parts without slowing throughput. Two of the most common types are ultrasonic distance sensors and vision sensors. Each has distinct operating principles, configuration steps, and failure modes. Understanding both prepares you to specify, commission, and troubleshoot sensing systems on industrial robots and packaging lines.

---

How Ultrasonic Sensors Work

An ultrasonic sensor emits a burst of high-frequency sound (typically 40–400 kHz) from a piezoelectric transducer. The burst travels through air, reflects off a target, and returns to the sensor. The sensor measures the time of flight (TOF) — the round-trip travel time — and converts it to distance using the speed of sound (approximately 343 m/s at 20 °C).

Distance = (Time of Flight × Speed of Sound) / 2

The division by 2 accounts for the signal traveling out and back.

Analog Output and the 4–20 mA Signal

Many ultrasonic sensors offer a 4–20 mA analog output, which maps a configured distance window to a proportional current. 4 mA corresponds to the near (minimum) end of the window and 20 mA to the far (maximum) end. This live signal travels over a two-wire loop to a PLC analog input card, a meter, or a data recorder.

To configure the output window you use teach buttons on the sensor housing or a configuration interface. The procedure is:

1. Place a target at the near-limit distance. Press the near-teach button. The sensor records that position as the 4 mA point.

2. Place the target at the far-limit distance. Press the far-teach button. The sensor records that position as the 20 mA point.

3. Verify by moving the target to known intermediate distances and reading the meter.

Always apply the 4–20 mA scaling formula to convert a measured current back to distance:

Distance = [(I − 4 mA) / 16 mA] × (D_max − D_min) + D_min

where I is the measured current, D_min is the near-limit distance, and D_max is the far-limit distance.

---

How Vision Sensors Work

A vision sensor captures a digital image using a CMOS or CCD camera, then runs inspection algorithms on that image in real time. Unlike a full machine vision system (which uses a separate PC with complex software), a vision sensor integrates the camera, processor, and I/O into one compact housing. Examples include the Keyence IV Series and the Cognex In-Sight Micro.

Common inspection types include:

Setting Up a Presence/Absence Inspection

Using the sensor's PC-based configuration software:

1. Mount and focus the sensor so the part fills an appropriate portion of the field of view.

2. Set lighting — use the sensor's built-in illuminator and adjust angle and intensity to create consistent contrast between the part and background.

3. Teach a reference image with a known-good part in the correct position.

4. Define the inspection region of interest (ROI) — a window drawn around the area to inspect.

5. Set the inspection tool (e.g., brightness, area, or pattern matching) and define pass/fail thresholds.

6. Run a calibration sample of known good and bad parts, adjust thresholds, and confirm that the system produces correct outputs before going live.

Outputs from the vision sensor (PASS / FAIL digital signals) connect to PLC discrete inputs. Many sensors also support Ethernet (EtherNet/IP or PROFINET) for result logging.

---

Evaluating Performance: The Confusion Matrix

When you run a test batch you record results in a confusion matrix:

| | Sensor says PASS | Sensor says FAIL |

|---|---|---|

| Actually good | True Positive (TP) | False Negative (FN) |

| Actually bad | False Positive (FP) | True Negative (TN) |

A false positive (passing a bad part) is usually the more costly error in manufacturing. A false negative (rejecting a good part) wastes yield. Your goal is to minimize both.

---

Common Failure Modes and Mitigations

| Failure Mode | Sensor Type | Mitigation |

|---|---|---|

| Glare / specular reflection | Vision | Diffuse lighting; polarizing filter |

| Ambient light variation | Vision | Enclose inspection station; use triggered strobe |

| Target angle (echo miss) | Ultrasonic | Keep target perpendicular (±3°) to sensor face |

| Vibration blurring image | Vision | Shorter exposure; mechanically isolate camera mount |

| Temperature drift (speed of sound) | Ultrasonic | Use sensors with built-in temperature compensation |

| Foam or soft surfaces absorbing sound | Ultrasonic | Use higher-frequency transducer; reduce range |

---

Safety During Sensor Configuration

Before accessing sensor wiring or making connections:

These standards are not optional. Sensor configuration is routine work — but routine work inside a machine cell carries real hazards.

Key terms8

Time of Flight (TOF)The elapsed time between emission of an ultrasonic pulse and reception of its echo; divided by two and multiplied by the speed of sound to calculate distance to the target.
4–20 mA analog outputAn industry-standard current-loop signal where 4 mA represents the minimum of a measured range and 20 mA represents the maximum, allowing distance or other process values to be transmitted to a PLC analog input with high noise immunity.
Teach (near/far)A sensor configuration method in which a physical target is placed at the desired near-limit and far-limit positions and a button or software command is pressed to record those positions as the output-range endpoints.
Region of Interest (ROI)A user-defined rectangular or geometric window within a camera's field of view that limits where the vision sensor's inspection algorithm runs, reducing processing time and isolating the inspection area.
Confusion MatrixA 2×2 table that categorizes inspection results into true positives, false positives, false negatives, and true negatives, used to evaluate the accuracy of a sensor or inspection system.
False PositiveAn inspection error in which a defective or absent part is incorrectly reported as passing; often the most costly error type because nonconforming product advances downstream.
Specular ReflectionMirror-like reflection of light off a shiny surface at a predictable angle; a common cause of vision sensor failure because the reflected beam misses the camera lens or creates hot spots that saturate the image.
4–20 mA Scaling FormulaThe equation Distance = [(I − 4 mA) / 16 mA] × (D_max − D_min) + D_min, which converts a measured loop current to an engineering-unit value using the configured near and far limits.

Worked examples4

1. An ultrasonic sensor is configured with a near limit of 100 mm (4 mA) and a far limit of 500 mm (20 mA). The loop calibrator reads 12 mA. What is the distance to the target?
  1. Identify values: I = 12 mA, D_min = 100 mm, D_max = 500 mm.
  2. Subtract the live-zero offset: I − 4 mA = 12 − 4 = 8 mA.
  3. Divide by the span: 8 mA / 16 mA = 0.5 (50% of range).
  4. Multiply by the distance span: 0.5 × (500 − 100) = 0.5 × 400 = 200 mm.
  5. Add the near-limit offset: 200 + 100 = 300 mm.
Answer: The target is 300 mm from the sensor face.
2. What mA output should you expect when the same sensor (100 mm = 4 mA, 500 mm = 20 mA) detects a target at 350 mm?
  1. Calculate how far the target is above the near limit: 350 − 100 = 250 mm.
  2. Calculate the fraction of the full distance span: 250 / (500 − 100) = 250 / 400 = 0.625.
  3. Scale to the 16 mA current span: 0.625 × 16 mA = 10 mA.
  4. Add the live-zero offset: 10 + 4 = 14 mA.
Answer: The sensor should output 14 mA when the target is at 350 mm.
3. During a 20-part vision sensor run, 15 parts are good and 5 are intentional rejects. The sensor reports: 14 good parts as PASS, 1 good part as FAIL, 4 reject parts as FAIL, and 1 reject part as PASS. Build the confusion matrix and calculate the percentage of parts the sensor classified correctly.
  1. Identify the four categories: True Positive (TP) = good part called PASS = 14; False Negative (FN) = good part called FAIL = 1; True Negative (TN) = reject part called FAIL = 4; False Positive (FP) = reject part called PASS = 1.
  2. Total correct classifications = TP + TN = 14 + 4 = 18 out of 20 parts.
  3. Calculate accuracy: (18 / 20) × 100 = 90%.
  4. Note: one false positive (bad part passed) and one false negative (good part rejected) were recorded.
Answer: The sensor correctly classified 18 of 20 parts (90% accuracy). One bad part passed (FP) and one good part was rejected (FN).
4. A sensor teach window is set from 50 mm to 250 mm. The PLC analog input reads a raw value of 6,400 counts on a 0–32,000 count card that represents 4–20 mA. What is the distance?
  1. Convert counts to current: the card spans 32,000 counts over 16 mA (4–20 mA). Current per count = 16 / 32,000 = 0.0005 mA/count. I = 4 + (6,400 × 0.0005) = 4 + 3.2 = 7.2 mA.
  2. Apply the scaling formula: I − 4 = 7.2 − 4 = 3.2 mA.
  3. Fraction of span: 3.2 / 16 = 0.2.
  4. Distance span: 250 − 50 = 200 mm. Scaled distance above minimum: 0.2 × 200 = 40 mm.
  5. Add near limit: 40 + 50 = 90 mm.
Answer: The target is 90 mm from the sensor face.

The math in this lesson2

Learners compute vision sensor accuracy rates from pass and fail counts in a 20-part run.
7.RP.3F-LE.1
Brush up in the math halls at newSchoolWorks.com:
In class: Instructor-led demo: configure an ultrasonic sensor's analog output window using teach buttons; display the 4–20 mA output on a meter and correlate distance to mA reading using the scaling formula. · Guided practice: students use a vision sensor's PC-based configuration software to set up a presence/absence inspection for a cylindrical part; run 20 parts (including 5 intentional rejects) and record pass/fail versus actual result in a confusion matrix. · Discussion and debrief: class reviews common failure modes (glare, target angle, ambient light, vibration) and documents mitigation strategies on a shared whiteboard summary.
Materials: Ultrasonic analog sensor (e.g., Pepperl+Fuchs), vision sensor with PC software (e.g., Keyence IV or Cognex In-Sight Micro), 4–20 mA loop calibrator, laptop, cylindrical parts (accept and reject samples), projector.
Check: Students demonstrate sensor configuration to instructor with no assistance; vision sensor achieves 95% correct detection on 20-part run; verbal explanation of one failure mode and its fix.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Siemens SMSCP Level 1 — Electrical Components and Sensors
1. An ultrasonic sensor transmits a pulse and receives the echo after 1.16 milliseconds. Using a speed of sound of 343 m/s, what is the distance to the target?
PMMI Mechatronics — Industrial Electricity 1
2. A technician is configuring a 4–20 mA ultrasonic sensor with a window of 200 mm to 600 mm. What current output corresponds to a target at 600 mm?
PMMI Mechatronics — Programmable Logic Controllers (inspection outputs)
3. During a vision sensor inspection run of 20 parts, the sensor produces 2 false positives and 1 false negative. How many parts were correctly classified?
Siemens SMSCP Level 1 — Mechanical Components and Electrical Drives
4. Which failure mode is most likely to cause an ultrasonic sensor to miss an echo return from a foam-covered conveyor pallet?
FANUC CERT — Safety and Robot Cell Safeguarding
5. Before connecting wiring to an ultrasonic sensor installed inside a running machine cell, which OSHA standard requires you to lock out and verify absence of hazardous energy?
Siemens SMSCP Level 1 — Digital Fundamentals and PLCs
6. A vision sensor repeatedly fails shiny cylindrical aluminum parts as false rejects because the lighting creates a bright hot spot that saturates the image. What is the best corrective action?
PMMI Mechatronics — Industrial Electricity 2
7. When the loop calibrator reads 8 mA on a sensor configured from 0 mm (4 mA) to 400 mm (20 mA), what is the indicated distance?
FANUC CERT — Safety and Robot Cell Safeguarding
8. Which ANSI/RIA and ISO standard governs safeguarding and safe working distances when a technician enters a robot cell to teach a sensor position?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.