Visualizing the RFID sensor range
- Ivaylo Fiziev
- 6 hours ago
- 2 min read

Sensors implemented with SCL are nice to have but we currently cannot show any graphical indication of their detection range or field of view. This would help us understand better how they work. The LiDAR sensor does it already but the logic there is not reusable.
What if we could manipulate some primitive geometrical shapes straight out from the SCL code? Imagine that we can render a sphere indicating the RFID sensor range for example. Also we can render a cone indicating the field of view.
For this to happen we need to introduce some new function blocks.
Let's focus on the sphere for now.
We can have a SPHERE_R (sphere renderer) FB that knows how to draw a sphere in the graphics. Parameters are: center point, radius, color, visibility. You create a static variable of this type and call it just like any other FB. This does not sound too complicated, right?
Here is the modified code for the RFID sensor:
FUNCTION_BLOCK "MAIN"
VERSION:1.0
VAR_INPUT
range : LREAL := 350;
showRange : BOOL;
END_VAR
VAR_OUTPUT
id : DINT;
END_VAR
VAR
sphere : SPHERE_R;
END_VAR
VAR_TEMP
tag : STRING;
END_VAR
BEGIN
#sphere(RADIUS:=#range, // draw the sphere at the location of the resource
COLOR:=16#00FFFF20, // providing the radius and the RGBA color
VISIBLE:=#showRange);
#tag := DETECT_PART_APPEARANCE(RANGE:=#range); // detect part appearance
if LEN(#tag) > 0 then
#id := STRING_TO_UDINT(#tag);
else
#id := 0;
end_if;
END_FUNCTION_BLOCKThe end result is that you can use a signal to show/hide the sensor's range. You can change the range. You can change the color as well. It looks like this:

To override the center point of the sphere use the LOC argument. It is a location, not a point, simply because you can offset only locations for now. Still it does the job.
The SPHERE_R is a reusable block. Use it where you need it.
In 2512 use the SCL_GRAPHIC_RENDERERS feature toggle to enable the FB.
The same approach can be used to implement a CONE_R (cone renderer), BOX_R (box renderer), LINE_R (line renderer) etc. Hopefully one day we'll come to these.
See yah!
More on the RFID sensor can be found here: Practical use case: RFID sensor (PoC)




Comments