Four drop targets, four wait loops, four near-identical pick routines: this is the shape most first vision-guided cells grow into, and it holds until the fifth target appears. The fix is architectural. Your vision sensor already answers the only question that differs between the loops — which part did you find? Read that answer once, look up where that part goes, and run a single pick-and-place routine whose only variable is the row you looked up.
This how-to collapses a per-target loop program into one state machine driven by a target table: the result record both sides agree on, where the logic should live, the timeout arithmetic, and the pre-run checks. You need a vision sensor or smart camera that outputs a part ID with a position, and a robot program you can edit. If the guidance approach itself is still open, start with 2D vision pick and place: selecting a planar guidance system.
The decision: one wait loop and a target table
Your four loops differ in exactly one line: the drop waypoint. Everything else — the wait, the approach, the grip, the retreat — is the same code pasted four times. So make the waypoint data, not code. One wait loop reads the sensor: a valid flag, a part ID, a position. The ID indexes a table of drop poses, and one pick-and-place routine takes its pose, release height and gripper rotation from that row.
Collapse to this structure the day the second drop target appears. A fifth target then costs one table row and one taught pose instead of a fifth copy of the loop. Miss handling exists exactly once, and an empty window can never fall through into the next loop with a stale located flag — the failure your current version avoids only by accident.
Collapse the loops in seven steps
- Agree the result record first: valid flag, part ID, X, Y, angle, and a sequence counter that increments with every new result. Fix the units now — millimeters or pixels, degrees or radians — and convert in exactly one place.
- Declare the target table beside the robot program: one row per part ID, columns for drop pose, approach height, release height, gripper rotation and speed percentage.
- Replace the four loops with a single wait that exits only when the flag is valid and the ID falls inside the table range.
- Treat an out-of-range ID as a miss: log it and keep waiting. Never fall back to the nearest known pose.
- Rewrite the drop as one parameterized routine that consumes the table row; variable pick approach offsets for vision-guided picking keeps the approach vector out of hard-coded waypoints.
- Add the miss path: on timeout, log a no-part entry and stay waiting. Define the alarm — in the worked example below, a part present at the infeed with no valid result for 1 s.
- Test at reduced speed override in this order: every part type, then an empty window, then a stale result.
Where the state machine runs
WAIT, PICK, PLACE, back to WAIT — the logic is small, and it has three legitimate homes. The choice follows what the cell already contains, not the program shape.
| Logic runs on | Typical hardware | Choose it when | Trade-off |
|---|---|---|---|
| Smart camera | LS-SMC-0063 | one sensor, one robot, no separate computer | the table lives in the robot program |
| Vision controller | MV-VC3301H-128G66 | several cameras, strobed lights, recipes | one more program to version-control |
| Robot program alone | your existing script | retrofits and prototype cells | sequencing and vision get entangled |
For a single sensor and a single robot, a smart camera keeps the cell at two devices:
- Interface
- GigE
- Resolution
- Up to 3 MP
The LS-SMC-0063 is a 1.6 MP smart camera with a 16 mm lens, polarized white light and a 60 fps rate. One frame every 16.7 ms means result freshness never bottlenecks the cell — the robot cycle does.
When strobed lights, several cameras or recipes join the cell, a vision controller is the natural home: it sequences the lights, collects every result and hands the robot one line per cycle:
- LAN ports
- 5+ LAN ports
- USB 3 ports
- 3-4 USB 3 ports
- Light outputs
- 4 built-in channels
- Memory
- 8 GB
The MV-VC3301H-128G66 pairs a Core i3 with 8 GB of RAM, drives 4 built-in light channels and includes the VM6200Pro license, so the sequencing software runs where the images arrive.
One result record, read once
Whatever carries the logic, the sensor writes one record and the robot reads one record — anything else invites torn data, half old and half new. The sequence counter is what makes this safe: read the counter, read the fields, read the counter again. If it moved, a new result overwrote the old one mid-read, so read again. At this frame rate you lose a millisecond, never a cycle.
Poll or push: below roughly 10 updates per second, let the robot poll on a fixed period; above it, have the sensor push and use the counter to drop late arrivals. Either works — pick one and write it into the record definition. The camera-side half of the same discipline is in frame timeout: one wait call per frame, and asynchronous vision result frame matching with timestamps covers pairing a result with the physical part that produced it.
Serial links follow the same rule — one command code per action, as RS232 vision recipe selection shows. If the robot controller side needs attention, communication set-up for vision-guided pick cycles is a configuration task, not a logic change.
A basic vision sensor is fully equal to this job. The HK-TD032-12-WBN is a 1.6 MP mono vision sensor on Fast Ethernet with a global shutter; set it to send ID, X and Y in one telegram and the state machine never asks what produced them.
- Interface
- Fast Ethernet
- Resolution
- Up to 3 MP
- Sensor format
- 1/2.9"
- Shutter
- Global
The target table
Every row is taught once with the pendant and stored as data:
| ID | Part | Drop X, Y, Z (mm) | Release height (mm) | Gripper rotation | Speed |
|---|---|---|---|---|---|
| 0 | Red cap | 410, -120, 85 | 25 | 0° | 100% |
| 1 | Blue cap | 410, 40, 85 | 25 | 0° | 100% |
| 2 | Bracket | 560, -120, 60 | 15 | 90° | 60% |
| 3 | Cover | 560, 40, 60 | 20 | 180° | 80% |
Keep IDs contiguous from zero, so an ID outside the table is one range check. The rotation column earns its place the first week: a wrist that turns 270° where the table says -90° still hits the coordinates and still puts the part down wrong — gripper rotation between pick and place: find the full turn is the diagnostic. The X and Y in the result are robot coordinates only because someone taught the mapping; robot hand-eye calibration: how nine-point alignment works is that step.
The table is only as stable as the sensor mount. Fix the sensor relative to the robot base — an eye-to-hand mount — and neither the mapping nor the table drifts; eye-in-hand vs eye-to-hand camera mounting for robots lays out when the camera-on-wrist alternative wins. The LS-MNT-0040 is a slide-table stand, 700 mm high on a 400 x 450 mm base, with X/Y travel to center a pick window without redrilling the cell.
- Type
- Camera stands
Worked example: four drop targets, a 60 fps sensor, a 5.8 s cycle
Inputs, with the source of each: four part types and four nests, from the cell layout. A sensor running at 60 fps, from the smart camera above. A robot poll period of 25 ms, your controller's scan time. A 320 mm pick window, from the fixture. Move times from the pendant: approach 1.2 s, grip 0.5 s, retreat 0.8 s, transfer to nest 1.6 s, release 0.4 s, return 1.3 s.
Latency: 1 / 60 = 16.7 ms per frame. Two frames from exposure to output plus the 25 ms poll gives 2 × 16.7 + 25 = 58.4 ms — call it 60 ms normal. Timeout = 10 × 60 ms = 600 ms: after 0.6 s without a valid record the robot logs a no-part entry and keeps waiting. At 60 fps that is 36 skipped frames, so one blurred image cannot stop the cell.
Position: 1440 pixels across the window (the horizontal count of a 1.6 MP sensor) over a 320 mm pick area gives 320 / 1440 = 0.22 mm per pixel. Allow ±2 pixels of detector jitter and vision contributes ±0.45 mm against a ±2.5 mm nest clearance — under a fifth of the tolerance, leaving the rest for robot repeatability and part variation. A ±0.5 mm clearance would instead demand about 0.10 mm per pixel, roughly 3200 pixels across the window; the calculator below converts that requirement into camera pixels in one step.
Throughput: 1.2 + 0.5 + 0.8 + 1.6 + 0.4 + 1.3 = 5.8 s per part, so 60 / 5.8 = 10.3 parts per minute. Decision: feed this cell up to 8 parts per minute — a 22% margin. At 12 parts per minute, overlap the return move with the next wait or bring the nests closer; the structure does not change, only the numbers in it.
The whole program, for reference, is shorter than the loop version it replaces:
state = WAIT
loop:
if state = WAIT:
r = read_result() # valid, id, x, y, angle, counter
if r.valid and 0 <= r.id <= 3: target = TABLE[r.id]; state = PICK
elif r.valid: log('unknown id')
elif waited > 0.6 s: log('no part')
if state = PICK:
move_above(r.x, r.y); descend; grip; ascend; state = PLACE
if state = PLACE:
move_above(target); descend_to(target.release); open; ascend; state = WAIT
Verify before the first part
- Place each part type in turn: the robot must visit its own nest, 20 consecutive picks per type, all inside clearance.
- Empty the window: a no-part entry logs at most every 0.6 s and the robot does not move — the behavior your four loops gave you by accident, now guaranteed.
- Unplug the sensor cable mid-wait: alarm inside the timeout, no motion toward any pose; reconnect and the cell resumes without a restart.
- Present two parts back to back: the counter check rejects the torn read, and the log counts it.
- Load the second recipe: the table row set must follow the recipe ID before the first trigger fires.
Run the first 50 cycles at 20% speed override. The state machine does not care about speed; your fixtures do.
When one loop is the wrong answer
The lookup assumes each ID maps to one destination and any order will do. Break that deliberately, not by accident:
- Same part, fixed build order, such as a kit: keep the table, add a sequence index that steps after each place. Order becomes data; the machine is unchanged.
- Several parts in one image: still one loop — add a sort rule, nearest first, and pick the head of the list.
- Unknown part height, parts in a bin: a 2D pose is not enough. 3D bin picking for flat parts: choosing a vision approach is that fork in the road.
- Parts on a moving conveyor: the drop table still holds, but the pick side needs tracking; whether a delta pick-and-place cell needs conveyor vision covers when that layer is worth adding.
- Destinations that move every cycle, such as pallet layers: compute the pose from the layer model. The table becomes a function and the routine never notices.
Next steps
Rewrite the program first and buy hardware second: the structure runs on any sensor that reports an ID and a position. When the cell grows, the smart cameras, vision controllers and camera stands finders list the parts that fit each role, and the system configurator walks camera, lens, light and controller together. For a specific part-and-robot pairing, the contact page puts the numbers that matter — window width, parts per minute, part IDs — in front of the applications team. More integration write-ups sit on the systems topic page.
Questions
Should the drop-target table live in the robot program or in the vision system?
Wherever it is edited least. If poses are taught with the pendant, keep the table in the robot program, so retaught points stay where maintenance looks for them. If the vision side already stores per-part data such as gripper offsets, keep the table there and send the finished pose over the wire. One side must own it: a copy on both sides drifts apart the first week.
How many drop targets can one table hold?
Hundreds — memory is not the limit. The real cost is teaching, because every row needs a pose, a release height and a rotation, each verified. Past about 20 rows, group rows by recipe so an operator loads one set per product, and keep IDs contiguous from zero so a single range check still catches an untaught ID at run time.
What if the sensor reports two parts in the image at once?
Still one loop. Add a sort rule before the lookup — nearest part first is the default because it shortens the next approach — and pick the head of the sorted list. The other part becomes the head on the next cycle, so no new state and no new wait are needed. The only requirement on the sensor is that it reports each part with the same fields: ID, X, Y, angle.
How do I add a fifth drop target without touching the loop?
Teach the new pose with the pendant, add one row — ID, drop pose, release height, rotation, speed — and extend the valid-ID range if the new ID breaks the contiguous run. The state machine, the wait logic and the pick routine stay untouched, which is the point of the structure: new targets are data, and data cannot break control flow the way a pasted fifth loop can.
Why does the robot pick correctly in testing but miss after a changeover?
Nine times out of ten the robot is running recipe two against recipe one's table. Send the recipe ID inside the result record and refuse to trigger when it does not match the loaded recipe — one comparison at start-up, before the first trigger. The same check catches a sensor that rebooted into its default recipe after a power cut, which no amount of loop restructuring will.



