PacDrive LMC controllers offer two ways to manage the data transfer between the application and the fieldbus:
Polling mode
Interrupt mode
In Polling mode, the bus cycle task runs as a regular cyclic application task and tries to get new fieldbus data in each cycle. The fieldbus task runs on the dedicated netX component of the Profinet IO controller. If there is no new valid fieldbus data, the next attempt to read new data is made after a fixed waiting time. This is repeated until new fieldbus data is available. The execution of the application code of this task is suspended until new valid fieldbus data is available. The bus cycle task is triggered independently of the fieldbus cycle. While this is hardware-independent, it incurs longer cycle times.
In Interrupt mode, the netX component of the Profinet IO controller sends an interrupt signal as soon as new fieldbus data is available. This immediately triggers the application task. Interrupt mode is considerably faster than Polling mode since no waiting time is involved. The order of magnitude of the speed benefit depends on your application.
Step |
Action |
---|---|
1 |
Double-click the Profinet IO controller to open its device editor, and click on the PNIO I/O Mapping tab. |
3 |
From the Bus cycle task listbox, select the required task. For example, you can select TASK_SR_Main or a different task that you have created. |
4 |
Double-click the task you have selected in the previous step. |
5 |
In the Configuration tab, select External from the Type listbox. |
6 |
From the External Event listbox, select the appropriate event, depending on the fieldbus interface you have configured for your Profinet IO controller on the NetX Settings tab of the device editor:
NOTE: As opposed to other tasks triggered by external events, the priorities of PROFINETCONTROLLER_IRT_n events are used by the system.
|
Interrupt mode can result in shorter cycle times as compared to Polling mode. However, depending on your application, factors such as the number of Profinet IO devices, the frequency at which new fieldbus data is available, the complexity of your application task and the task priorities, may have side effects that require additional tuning of the I/O update task and the application task.
For example, a given Profinet IO device sends new fieldbus data every millisecond, while the application task cycle time is 10 ms. In this case, the fieldbus data is updated more often than required which incurs, among other things, unnecessary CPU load.
In addition, if the I/O update task has a higher priority than the application task, the application task is interrupted by the I/O update task whenever new fieldbus data is available. This may cause fieldbus data to be changed while the application task is still running.
The property IoUpdateActive of the Profinet IO controller allows you to temporarily ignore I/O updates in your application.
Example 1: Using IoUpdateActive in the application task
When the application task starts, it uses the latest I/O update data available. In the application task you can set the property IoUpdateActive to FALSE before executing extensive application code whose execution you do not want to be interrupted by one or multiple I/O update events. In this case, the I/O update task is still performed at fieldbus level, but the data is ignored.
Set the property IoUpdateActive to TRUE after the application code has been executed. When the next I/O update event is received, the fieldbus data is updated.
// Application task:
PNC.Controller.IoUpdateActive := FALSE;
// extensive application code
PNC.Controller.IoUpdateActive := TRUE;
Example 2: Using IoUpdateActive in the application task and in the I/O update task
To further minimize the load on the controller CPU, you can set the property IoUpdateActive to TRUE at the end of the application task. At the beginning of the I/O update task, you set the property IoUpdateActive to FALSE. In this case, after the I/O update has been performed, it is suspended until the end of the application task, which means that there is only one update per cycle.
// I/O update task:
PNC.Controller.IoUpdateActive := FALSE;
// Application task:
// application code
PNC.Controller.IoUpdateActive := TRUE;