Reading cycle time

Hello

Is there a way to access a given task's cycle time so that it can be read as a variable in the PLC? I've been trying to use either common_scheduler_fbs_Task (from the CXA_AUTOMATIONCORE_FBS library)  or plc_cmp_datalayer_fbs_AppTaskInfo (from the CXA_PLC_FBS library), but when I change the corresponding task's cycle time, the values remain unchanged. The former yields 0, and the latter yields 20000, regardless of the cycle time. My cycle time is set to 20ms but, as I said, changing its value results in no change in the aforementioned variables. I feel like this should be something somewhat straightforward, but I'm probably doing something wrong. Also, apologies if this question has already been posted, but I couldn't find a solution for it, here in the forum. Many thanks in advance, for all your help.

Best reply by HmiGuide

You can use the CoDeSys library: SysTask, which provides functions to create, change and get info of tasks.

PROGRAM PLC_PRG
VAR
	hTask:       SysTask.RTS_IEC_HANDLE; // task handle
	udiInterval: UDINT; // intervall in micro seconds
END_VAR

// **** Implementation ***
// get handle of current task
SysTaskGetCurrent(ADR(hTask));
// get task interval
SysTaskGetInterval(hTask, udiInterval);

 

View original
1
4 replies