TON and TOF Timer Blocks in Simulink Ignore Preset Time (PRE)

3 views (last 30 days)
Hello,
I tried to simulate a very similar PLC model like presented in here https://nl.mathworks.com/help/plccoder/ug/ladder-logic-using-timers.html . The differences are Im using step signal which is converted into boolean for the input, you can see my model in the attached file.
However, it seems like the preset time just doesn't work. Everytime the switch is on, then the lamp is automatically "on", while it is supposed to be delayed for around 6 seconds (the preset time). I have tried everything, even mirroring every setting and values set in the file from here https://nl.mathworks.com/help/plccoder/ug/ladder-logic-using-timers.html. I have also ensured the initfcn, etc. But still doesnt work as it should be. Im using matlab R2024b. I also put the sceenshots of the windows below.
Thanks for the help.

Answers (1)

Epsilon
Epsilon on 27 Jan 2025
Hi Granto,
In the above provided model the preset is depending on the sample time (single step size) rather than the preset values defined in the IntFcn. This can be observed by setting the step size in model configuration to 2. On doing so the motor start/stop gets delayed by the same time. Response with sample time 2 :
This seems to be due to discrepancy in the initialization of the ‘delayer_Data’ and ‘delayerOFF_Data’ data store memory. The desired preset delay is observed in the original example file on replacing the start/stop blocks with the step block. Response of the updated model in original example with preset of 10000 for both start & stop:
Please find the implemented model attached for reference.

Categories

Find more on Schedule Model Components in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!