How to change Simulink PLC Controller Suite's working frequency.

4 views (last 30 days)
Hello, I am trying to implement a ladder diagram directly on Simulink to control and simulate some dynamic models.
I am using a PLC Controller Suite, containing a task which implements a LD. The problem is that sometimes the plc runs too slow and can't detect changes in the input variables.
For example i have a variable that goes to 1 for 0.02 seconds and then return to zero that is often ignored by the PLC controller. is there any way to increase PLC frequency or use an input as event to update the control block?
Thank you for your time,
GM

Answers (1)

Sugandhi
Sugandhi on 24 Apr 2023
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:
  1. Open the Simulink model that contains the PLC Controller Suite task.
  2. Locate the PLC Controller Suite block in the model that represents the task.
  3. Right-click on the block and select "Properties" from the context menu. This will open the properties dialog for the PLC Controller Suite block.
  4. In the properties dialog, go to the "Parameters" tab.
  5. 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.
  6. 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:
  1. Drag and drop a "Triggered Subsystem" block from the Simulink library into your model.
  2. Connect the input variable that you want to use as the trigger to the "Trigger" input of the triggered subsystem block.
  3. 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.
  4. 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.
  5. 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 –
  2 Comments
Gianluca Mammone
Gianluca Mammone on 24 Apr 2023
Hello, thank you for your answer.
Sadly PLC Controller Suite block hasn't the parameter tab in the properties.
Concerning the the triggered subsystem, i tried that too by activating the PLC with a pulse generator and rising edge trigger, but returns the error:
"EX/Subsystem1/PLC Controller Suite/__Logic/MAIN_TASK/MAIN_PROGRAM/__Logic/XIC6/__Format' has sample time '0.1'. Only inherited (-1) sample times are allowed in triggered subsystem 'EX/Subsystem1'."
It seems a particular XIC in the Ladder diagram has a predefined sample time. I have no idea how I managed to set it, because even this block has no parameter tab in the property window, and at this point I am unable to edit it.
I also tried to study a bit the schedule editor, but it seems i can't change frequencies there.
Sugandhi
Sugandhi on 25 Apr 2023
Hello,
I understand that you are unable to set sample time and facing errors on using triggered subsystem.
Try to go through the links given below on Ladder Diagram Integration and Simulink PLC Coder app for better understanding.This would provide direction to your problem.

Sign in to comment.

Categories

Find more on Get Started with Simulink PLC Coder in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!