Skip to main content

Assembly Station

TIA Device Name = Configuration Tool Site Name (e.g., asm-st-01).

Hardware Specifications​

  • PLC: Siemens S7-1200 × 1 (fixture clamping / release / NG rejection)
  • Industrial PC:Windows 10 × 1 + Intel i5 × 1, running Darra Profinet Slave
  • Vision: Industrial area-scan camera × 1 + lens × 1 + ring light × 1
  • Clamping Fixture: Air cylinder × 1, magnetic switch for clamping position × 1. PLC controls clamping, releasing, passing,NG and rejecting.
  • Network: Standard Gigabit network card × 1 (on the same PROFINET network as the PLC)

Cost Analysis​

CategoryModel/SpecificationsReference Unit Price (¥)QuantitySubtotal (¥)
PLCSiemens S7-1200 CPU 1214C1,00011,000
Industrial Computeri5 Fanless Dual Ethernet Ports1,20011,200
Area-scan cameraHikvision MV-CA013 130 Wan USB39501950
LensC-Mount Industrial Fixed-Focus Lens2001200
Ring LightMachine Vision LED1501150
Pneumatic FixturesYadek Magnetic Cylinder + Magnetic Switch1201120
Total Reference for the Entire Line≈ ¥3,620

Common transaction prices on Taobao (2026-09), excluding racks, air tubes, cables, and fixture base plates. For PLCs, use the typical price range for genuine 1214C models; for cameras, use the store price for the Hikvision 130 Wan USB3—do not include board-level products priced at just a few dozen yuan.

Performance Metrics​

  • Alignment Check: Completed locally; process data returns only "OK" / NG / "Completed"
  • Formula: For the "Structure" field, select "Recipe" as the local template; multiple sets can be assigned to a workstation.
  • Takt time: Visual count less than 150 ms/piece (simulation uses "sleep" as a substitute)
  • Figure: Offset Details Are Not Included in Process Data

Use Cases​

Assembly station before press-fitting, tightening, or dispensing. Compared with Small-Scale Visual Quality Inspection it adds three paths: clamped-in-place, done edge, and multi-recipe templates. The PLC handles clamping, release, and NG rejection; the industrial PC aligns locally by recipe.

Workstation Sequence​

  1. Part present — the PLC sets Present.
  2. Trigger only when clamped — the PLC clamps and waits for the magnetic switch Clamped. Do not pull Trigger before clamping. The industrial PC side does the same: discard any rising edge without Clamped.
  3. Alignment rising edge — after Clamped, the PLC pulls Trigger high. The industrial PC only recognizes 0→1, and only when Present and Clamped are set and it is not busy.
  4. Busy mutual exclusion — once the edge is recognized, clear the previous OK/NG/Done, then set Ready=0 and Busy=1. New edges during busy are dropped.
  5. Recipe selects a local template — Recipe is only a template number; the alignment bitmap and offsets stay on the industrial PC.
  6. Done edge — judgement ends: Ok or Ng, Busy=0, Ready=1, and Done 0→1. The PLC steps on the rising Done edge (OK release / NG reject / unclamp). Done is held until the next piece's edge is recognized and pulled back to 0, and the next piece's finish produces a new rising edge.
  7. Disconnect — once connected and later disconnected: Fault=1 and Ready is taken away. After reconnecting, ready is set again; the current Trigger level is not treated as a new edge.
Process Data

Process data returns only "OK" / NG / "Complete" and the recipe number. Bitmaps, offset details, and archive paths remain on the industrial PC.

Process Data​

DirectionFieldDefinition of a Workstation
From PLC (I)PresentPart present
From PLC (I)ClampedClamp is fully engaged; the trigger will not be recognized if it is not fully engaged.
From PLC (I)TriggerPositive-edge triggering; recognizes only the rising edge
From PLC (I)RecipeFormula Number, Select the Correct Local Template
Send to PLC (Q)ReadyI can take the next one.
Send to PLC (Q)BusyAligning positions, mutually exclusive
Send to PLC (Q)OkAlignment Passed → PLC Approved
Send to PLC (Q)NgMismatch → PLC rejects the item
Send to PLC (Q)FaultDisconnection/Outage
Send to PLC (Q)DoneThis decision is complete; the PLC detects the rising edge.

Once connected, do the reading and writing with the handshake described above. The simulation fakes OK/NG by part count (1 NG every 7 parts). On real hardware, replace Thread.Sleep with image capture and alignment.

using System;
using System.Runtime.InteropServices;
using System.Threading;
using Darra.PnS;

[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct FromPlc
{
public bool Present;
public bool Clamped;
public bool Trigger;
public short Recipe;
}

[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct ToPlc
{
public bool Ready;
public bool Busy;
public bool Ok;
public bool Ng;
public bool Fault;
public bool Done;
}

using (var device = new DarraPnS())
{
PnSErrorCode rc = device.Start();
if (rc != PnSErrorCode.Success)
return;

string[] templates = { "default.bin", "housing-a.bin", "housing-b.bin" };
ToPlc output = default;
bool lastTrigger = true;
bool wasConnected = false;
bool busy = false;
int piece = 0;
bool running = true;

while (running)
{
if (!device.Connected)
{
if (wasConnected)
{
output = new ToPlc { Fault = true };
device.ProcessData.Write(ref output);
lastTrigger = true;
busy = false;
}
wasConnected = false;
Thread.Sleep(20);
continue;
}

if (!wasConnected)
{
output = new ToPlc { Ready = true };
device.ProcessData.Write(ref output);
lastTrigger = true;
busy = false;
wasConnected = true;
}

FromPlc input = new FromPlc();
device.ProcessData.Read(ref input);

bool rising = input.Trigger && !lastTrigger;
lastTrigger = input.Trigger;

if (rising && input.Present && input.Clamped && !busy)
{
busy = true;
output = new ToPlc { Busy = true };
device.ProcessData.Write(ref output);

string template = templates[0];
int recipe = input.Recipe;
if (recipe >= 0 && recipe < templates.Length)
template = templates[recipe];

Thread.Sleep(120);

piece++;
bool ok = (piece % 7) != 0;

output = new ToPlc { Ready = true, Ok = ok, Ng = !ok, Done = true };
device.ProcessData.Write(ref output);
busy = false;

Console.WriteLine(
"第 " + piece + " 件 模板 " + template + " → " + (ok ? "OK 放行" : "NG 剔除") + " Done");
}

Thread.Sleep(10);
}

device.Stop();
}