Counting / calculating in Runtime Utility Center

Runtime Utility Center is a very powerful tool for setting up PLCs, getting information from the PLCs software, and so on.
For my usecase, I needed to repeat some functionality / commands for a limited number of calls, and then go on with the pil instructions, but as I know RUC doesn’t have internal counters or calcuation instructions.

I used a batch file for counting, and I want to share a simple sample here, maybe someone else also have the need for doing something similar.
The sample is pretty easy:

  • use a RUC internal variable as counter value storage
  • call a batch file with the counter value as input parameter
  • do the calculation inside the batch file (in the sample, adding +1 to the input value), and return the calculation result as batch file return value
  • store the batch file return value in the RUC internal variable

In this example, the IF GOTO statement and the internal variable of RUC is used together with the “increase by 1” batch file to realize a limited number (10 times) of executions of the same RUC actions … here, opening a message box showing the counter value, which of course makes pretty less sense…
… But the’re also serious use-cases out there for basic counting / calculations in PIL lists, so happy RUC’ing :smiley:


TestCounterInPil.zip (869 Bytes)

7 Likes

Yesterday, I had a 2.nd interesting use-case for RUC together with batch files:
for some testing, we needed to reboot a PLC after a random number of seconds.

Since “wait x random seconds until do something” could be interesting for other use-cases too, I added this info here.

We solved it with a tiny batch file, where parameter 1 is the minimum number of seconds to wait, and parameter 2 is the random number range as offset.
So calling the batch for example with “randomwait.bat 5 10” means, that the batch will wait a random number between 5 and 15 seconds.

image

Together with RUC (only a simple sample):

image

If you only need a random number without waiting, just remove the TIMEOUT line and use the return value for example like described in the post above.

TestRandomWaitInPil.zip (803 Bytes)

3 Likes