Reading CPU load from within Codesys

Kim
2015-10-08
2020-08-30
  • Kim - 2015-10-08

    We're running Codesys on it's own core in a multi-core CPU.
    We would like to present the Codesys CPU load in a HMI application running on another core.
    Which Codesys library/function can be used for getting the CPU load percentage?

    I messed around and tried some different functions but never got it to work, hopefully you can provide me with the right answer.

    Regards
    Kim Hansen
    Beijer Electronics Automation

     
  • eschwellinger

    eschwellinger - 2015-10-08

    Hi Kim,

    udiProzessorLoad:=SchedGetProcessorLoad(Result);

    BR
    Edwin

    IMG: GetProcessorLoad.jpg

     
  • Araforn - 2018-03-01

    Edwin Schwellinger hat geschrieben:
    Hi Kim,
    udiProzessorLoad:=SchedGetProcessorLoad(Result);
    BR
    Edwin

    Been searching a lot for this one. Thanks for the info.

     
  • fleaplc

    fleaplc - 2020-08-29

    I'm testing the call udiProzessorLoad:=SchedGetProcessorLoad(Result); but the CPU load I get is very different from "htop" value (In codesys I read 8, in htop I get less than 4%).. Why?

     

    Last edit: fleaplc 2020-08-29
    • Ingo

      Ingo - 2020-08-29

      SchedGetProcessorload only gives the load of Realtime IEC Tasks. As the rest are background jobs with few to none realtime constraints. You can imagine, that with 100% background load, the system is still responsive. But when you have 100% load in realtime taks, your CPU is stuck, and no communication possible anymore. That's the reason why CODESYS monitors this load.

       
  • fleaplc

    fleaplc - 2020-08-30

    Hi Ingo, thanks for clarification. Do you know some function to read the "total" CPU load? (to get same value as in htop?)

     
    • Ingo

      Ingo - 2020-08-30

      Depending on the PLC, SysCpuMulticore might give you that info. But I am
      not at the PC to check the exact interface.

       

Log in to post a comment.