Join us today!

Notifications
Clear all

Measuring the scan cycle of PLC

6 Posts
4 Users
7 Reactions
494 Views
twinControls
Posts: 114
Admin
Topic starter
(@twincontrols)
Member
Joined: 2 years ago

Write a PLC program to measure the scan cycle (scans per second) of PLC continuosly. Share your solution along with your PLC scan cycle settings and the measured scan cycle value. 

Happy coding! 😊 

Reply
5 Replies
4 Replies
benhar-dev
(@benhar-dev)
Joined: 2 years ago

Eminent Member
Posts: 17

@twincontrols are you looking to read the Task Cycle time, for example, from PlcTaskSystemInfo.CycleTime or are you looking to see how long your task took to execute PlcTaskSystemInfo.LastExecTime?  

I guess that scans per second would always be consistent with the CycleTime, unless you are seeing PlcTaskSystemInfo.CycleTimeExceeded.  In which case you could recalculate your scans / second accordingly. I'd advise against allowing your task to exceed.  Rather to increase the Task time to accommodate the actual time required, or move some lower priority code to a slower task.

Reply
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 114

@benhar-dev It is actually a simple challenge question to calculate how many cycle it takes a plc task in a second. For example, the plc task cycle time below is set to 10ms, therefore it will be executed 100 times in one second. 

taskcycletime

 

cyclecount

 

Thank you for mentioning the PlcTaskSystemInfo type. I make use of it in my programs sometimes. 

Reply
runtimevictor
(@runtimevictor)
Joined: 2 years ago

Estimable Member
Posts: 156

@twincontrols ,

I do it in the following way:

FB StopWatch Level
Reply
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 114

@runtimevictor Thank you for sharing your solution! Could you also share your program output and the screenshot of PlcTask settings page?

Reply
Posts: 11
(@chrisk)
Active Member
Joined: 2 years ago

Hi All,

Not sure if this is helpful, but I also like to measure the PLC code execution itself, the task related times encapsulate all the task related operations, like process data mapping updates for example, you can see more info in the TE1010 docus on infosys.

 

But to monitor execution times i use the Profiler block, call it before and after a code section to see how long it really took.

Reply
Share: