Hi Gianluca Mammone,
In Simulink, the rate at which the PLC Controller Suite task executes is determined by the sample time specified in the task properties. If the PLC task is running too slow and not able to detect changes in input variables, you can try increasing the sample time of the task to a smaller value. This will make the task run more frequently, allowing for more frequent updates of the control logic.
To change the sample time of a task in Simulink, you can follow these steps:
- Open the Simulink model that contains the PLC Controller Suite task.
- Locate the PLC Controller Suite block in the model that represents the task.
- Right-click on the block and select "Properties" from the context menu. This will open the properties dialog for the PLC Controller Suite block.
- In the properties dialog, go to the "Parameters" tab.
- Look for the "Sample time" parameter and specify a smaller value, such as 0.001 seconds, in the input field. This will make the task run at a higher frequency.
- Click "OK" to close the properties dialog and apply the changes.
Alternatively, if you have an input variable that changes quickly and you want to update the control block whenever the input changes, you can use a trigger-based approach. In Simulink, you can use the "Triggered Subsystem" block to create a subsystem that is triggered by a specific event, such as a change in an input variable. The triggered subsystem will only execute when the event occurs, allowing for more frequent updates of the control logic.
To create a triggered subsystem in Simulink, you can follow these steps:
- Drag and drop a "Triggered Subsystem" block from the Simulink library into your model.
- Connect the input variable that you want to use as the trigger to the "Trigger" input of the triggered subsystem block.
- Implement your control logic inside the triggered subsystem. This can include any blocks or algorithms that you want to execute when the trigger event occurs.
- Set the sample time of the triggered subsystem to a suitable value that matches the frequency of the input variable changes. This can be done in the "Parameters" tab of the triggered subsystem properties.
- Connect the output of the triggered subsystem to the appropriate inputs of your PLC Controller Suite block or other blocks in your model.
By using a triggered subsystem, you can update the control logic more frequently based on the changes in the input variables, without having to increase the overall sample time of the PLC Controller Suite task. This can help ensure that changes in input variables are not ignored by the PLC controller, even if the task sample time is relatively slow.
For more understanding kindly go through the following link –