Laser sensor integration
Couldn't load pickup availability
Description
The FB_LaserDistanceCheck function block evaluates a 16-bit laser signal, scales the raw value linearly to 0–1000 mm, checks against a threshold, handles sensor errors, and can be deactivated. The code, written in SCL, runs directly in the Siemens TIA Portal.
Note: All modules are designed exclusively as a learning and optimization basis and are not approved for live operation. System modules, in particular, must be finally tested and commissioned by qualified personnel before productive use.
Functionality (compact)
-
Inactive (
Aktiv=FALSE
): immediately RETURN,StatusText=„System inaktiv“
,ErgebnisOK=FALSE
,Alarm=FALSE
-
Sensor error detected:
Alarm=TRUE
,ErgebnisOK=FALSE
,StatusText=„Sensorfehler erkannt!“
, RETURN -
Test (
Trigger=TRUE
):
– compare scaled distance value with threshold value
– if distance ≤ threshold →ErgebnisOK=TRUE
,Alarm=FALSE
,StatusText=„Distanz OK“
– otherwise →ErgebnisOK=FALSE
,Alarm=TRUE
,StatusText=„Distanz zu groß!“
Technical details (compact)
-
Scaling: Raw value × 1000 / 27648 →
Dist_mm
-
Variables/Outputs:
–Dist_mm
(REAL),ErgebnisOK
(BOOL),Alarm
(BOOL),StatusText
(STRING) -
Inputs:
LaserRaw
(INT),Aktiv
(BOOL),Trigger
(BOOL),Schwellwert
(REAL) - Logic: IF conditions with RETURN on inactivity or error, simple comparison on trigger
Possible applications
Distance testing in assembly and packaging lines, dimensional control in production, position detection in safety systems, demo module in PLC training.
compatibility
Siemens S7-1200/S7-1500, TIA Portal ≥ V13 (V16+ recommended for HMI/PLCSIM).
Scope of delivery
.scl
file with declarations of all inputs/outputs, variables, and feedback parameters. Download link after purchase.
Support
Adjustment of the threshold value, integration of additional sensors or HMI layouts – individual advice is available via shop message or email.