Real-Time Performance
This topic explains real-time performance concepts, measurement methods, and optimization techniques for OpenPLC on VisionFive 2 or VisionFive 2 Lite.
Understanding Real-Time Performance
Real-time performance refers to the ability of the operating system to respond to external events in a timely and deterministic manner. A system with real-time capabilities can guarantee that a certain task is completed within a defined time frame.
- System-level testing (Cyclictest): RT-tests is a collection of programs that test the real-time capabilities of Linux. Cyclictest is one of the programs in the RT-tests suite that most commonly used for benchmarking RT systems.
- Application-level testing: The real-time performance testing of OpenPLC during operation, measured by the delay between input and output signals and the minimum scanning time
Cyclictest
Cyclictest is a benchmark tool that measures the latency of the Linux kernel's real-time scheduling capabilities.
git clone git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git
git checkout -b stable/v1.0Alternatively,wget https://mirrors.edge.kernel.org/pub/linux/utils/rt-tests/rt-tests-1.10.tar.gz
make all
sudo make installrun ./cyclictest -S -p 95 -d 0 -i 1000 -D 24h -m -n- Hackbench tool in the rt-tests package. For details, run the following
command:
Hackbench: run ./hackbench --help under the path rt-test/ - Official load simulation script
- stress-ng tool
Application-Level Testings
Measure the performance of OpenPLC by the delay between input and output signals and the minimum scanning time.
| Test | Details |
|---|---|
| Delay between Input and Output Signals |
|
| Minimum Scanning Time | Scan time is the time a PLC takes to read all inputs,
execute the logic program, and write all outputs back. The
proposed minimum scan time test is comprised of a single
ladder logic line with one input and one output, as shown
below. By running this program and physically wiring
the output %QX0.0 and the input %IX0.2 on the PLC together, it
is possible to create an oscillator. This oscillator outputs a
square wave with the highest frequency the PLC can generate in
software. Since the output toggles at every scan, the scan time
is defined by equation
, where f is the square wave frequency measured by an
oscilloscope. In addition to the difference in the ladder
diagram, to measure the minimum scan time, the program of the
minimum scan time in the scan interval of the Res0 file is set
to T#1ms, while in the delay test, it is
T#5ms.
|
Improve OpenPLC Runtime Performance
- Isolate CPU core and bind OpenPLC process to the isolated CPU core
- Run OpenPLC runtime in RT-Linux
| Task | Details |
|---|---|
| Isolate CPU Core |
|
| Bind OpenPLC to the Isolated CPU Core | After isolating a CPU core, bind the OpenPLC process to the
core by using either of the following methods:
|
| Run OpenPLC on RT-Linux | See Real-Time Linux. |