Shared Variables In Different Tasks

This example shows how a Shared Variable block works in different Tasks.

Introduction

The Shared Variable block works as virtual connection between blocks. These blocks can be in different tasks like a Global Variable. Nevertheless, the Shared Variable value is only updated in one task at a time.

A Shared Variable do not change its value during a task execution, only at the end

. As an example, consider the diagrams below.

Figure 1 - Diagram in Task 0

Figure 2 - Diagram in Task 1

Simulation

In this example, Task 0 runs at 1Hz and Task 1 at 2Hz. Task 1 has a higher priority (because it runs at a higher rate) and gets executed first. In Figure 3, there is the Simulation Information Tab from

QFIRE Studio

. The blue squares mean Task 1 being executed and the orange ones mean Task 0 being executed.

Figure 3 - Simulation Information Tab

This scheduled execution using the same Shared Variable created the signal plotted in Figure 4. In this signal, it is possible to see both of the diagrams incrementing the signal.

Figure 4 - Shared Variable 0 signal

About MWF

MWF is a traditional Brazilian company that provides a wide range of electronic and mechatronic products for industry sectors such as automotive, agricultural machinery and aerospace.

Contact Us

Rua Doutor Siqueira, 139 / Sala 804 Campos dos Goytacazes - RJ, Brasil

contact@mwf-technologies.com

© 2018-2026 MWF. All rights reserved.