[Basic Example 1] Single-Axis Cylinder Forward & Backward Sequence
DSL Hands-On Example 1 · Serial Progression & Single-Cycle Reset (
ds2 v2;)A single-axis transfer cylinder advances to push a part, holds position for
200ms, and retracts to home with mutual exclusion protection.
1. Scenario Overview
A Transfer Cylinder (TransferCylinder) pushes a part into position (Advance), holds for 200ms (HoldPosition), and retracts (Retract) to complete one cycle:
- Safety Rule:
AdvanceandRetractsolenoid valves must never turn on together (Advance <|> Retract;). - Initial State: At power-on, the cylinder sits at its retracted home position (
work Retract finished). - Cycle Hand-off:
PushPart => HoldPosition =|> ReturnHome;steps through the three stages and clears the terminal completion flag on the next start.
2. Full ds2 v2; Source Code
Hover over any work or flow statement below to see how the code maps to the causal diagram on the right:
ds2 v2;
project Basic_SingleCylinder {
active StationController;
system TransferCylinder {
flow Motion {
work Advance { duration 300ms; }
work Retract finished { duration 300ms; }
Advance <|> Retract;
}
api Advance = Motion.Advance;
api Retract = Motion.Retract;
}
system StationController {
origin flow HomeSequence {
work CylinderHome {
TransferCylinder.Retract reuse completed;
}
}
flow MainCycle {
work PushPart {
TransferCylinder.Advance;
}
work HoldPosition {
duration 200ms;
}
work ReturnHome {
TransferCylinder.Retract;
}
PushPart => HoldPosition =|> ReturnHome;
}
api StartOneCycle = MainCycle.PushPart;
}
}
3. Key Checkpoints
work Retract finished { duration 300ms; }— At power-on (B0),TransferCylinder.Motion.Retractstarts in the Finished (F) state, soHMI_AT_ORIGINisTRUE.Advance <|> Retract;— Generates cross-interlocked rungs in Zone 2/3 ST & LD so both outputs never energize together.PushPart => HoldPosition =|> ReturnHome;— Runs a 1-cycle sequence (300ms→200ms→300ms=800mstotal) and returns toHMI_AT_ORIGIN = TRUE.