3

The CPU usage of non-RT cores is available in MDP (either over ADS or UA), but I'm unable to find any way to get the CPU usage of isolated cores from user land (i.e. Windows).

I feel like there should be an easy way to read this since TcXaeShell is able to display the RT core usage in a chart.

Does anyone know how to do this, or, as a last resort, how to sniff out the protocol that TcXaeShell is using to get this info?

Real time usage chart in TwinCAT XAE Shell

UPDATE: Thanks to the insight from the comments below that the TC_CpuUsage FB is just using ADS reads in the background, I was able to find the ADS parameters I needed inside the TC_CpuUsage FB:

enter image description here

At first I had missed the detail that the AMS port should be that of the TwinCAT Real Time Server (200), and not that of the runtime port (default 851), so I was getting an ADS error. Once I changed the port, I was able to get the CPU usage of RT cores over ADS in my .NET application.

Jay
  • 33
  • 4

1 Answers1

1

Isn't TC_CpuUsage function block what you are looking for? If you wish to get CPU usage of more than 1 core, you need to run an instance of this FB in each program that is assigned to task from each core.

Jacek Domański
  • 563
  • 3
  • 7
  • If I was trying to get the the CPU usage from within the PLC program, you are correct, I could just use that. However, I need to get the RT CPU usage from "outside", and in an "unobtrusive" way, i.e. I cannot modify the PLC program to use that FB, save to a variable, and then read that variable over e.g. ADS. I don't have control of the PLC code, only access to the IPC running the code. – Jay May 01 '22 at 20:31
  • Shame, that's what I was hoping you can do. How about running this FB on different machine with the actual targets Ams Net Id at NETID input? – Jacek Domański May 01 '22 at 20:37
  • It's possible but not ideal - I would always need a second XAR, and if I was interested in monitoring a large and ever-changing list of PLCs, it would be a challenging thing to automate/manage. I just wish there was a way to get the information over ADS "for free" as it were... I appreciate the ideas! – Jay May 01 '22 at 21:06
  • 1
    I have a feeling, that TC_CpuUsage is just ADSREADEX with IDXGRP and IDXOFFS hardcoded. If that is correct, you should be able to read this data over ADS. You just need, to know IDXGRP and IDXOFFS. Have you tried calling Beckhoff support? They tend to know things like this :) – Jacek Domański May 02 '22 at 08:25
  • Hi @Jay, do you have access to the IPC? Can you install a program on it? – dwpessoa May 03 '22 at 10:37
  • @dwpessoa Yes, I can install programs on the IPC – Jay May 03 '22 at 14:48
  • I found a solution thanks to the insight from @JacekDomański that ADS reads were going on in the background. I was going to update this answer with the final solution, but I was getting the dreaded "edit queue is full", so I've added the update to the question instead and will still mark this solution as accepted anyway. I appreciate all the help! – Jay May 03 '22 at 15:49
  • Glad you found it, mate :) Thanks for sharing the final solution, might come in handy one day – Jacek Domański May 03 '22 at 17:30