AsIoTrcget reading X20AI4632 trace buffer

Hello!

I would like to ask community how to set X20AI4632 trace configuration properly and read the buffer with AsIoTrcGet. Scan time in analog module is set to 200 useconds, PLC task cylcle time is 2 ms. I’d like to read constantly 4 channels (8 bytes) - mode infinite. Therefore each PLC cycle there in the AI module’s buffer should be 10x4 new values.. I set size for my buffer in PLC application to 40 bytes as well. But I get AsIoTrcget() error 26066"No data available to read (Device would block in blocking mode)". But trace buffer should be full

I can see that at least your bufferLen is way too small (10 bytes), you should use the size of the actual buffer variable you are using, preferrably with SIZEOF().

In the Automation Help there is a sample in ST for this.
Automation Help: Example for AsIoTrcGet in Structured Text

Additional information the usage of the trace function
Automation Help: X20AI4632 Trace

Information:

The trace mechanism cannot be used if the module is operated behind a bus controller, but only when it is directly connected to the controller.

Is the AI module connected directly to the PLC is it after a bus controller? The Trace functionality can only be used when directly connected to the PLC.

Hello Tommi,

I found that the X20AI4632 sample time and parameter Asynsize were not set correctly, but I didn’t have chance to test it yet .

AsynSize > 2 * X2X Cycletime/Sampletime * activated trace channels

I’d like to ask what is the exact purpose of the TRACE FUNCTION parameter “NUMBER OF TRACE BUFFER”. What is a difference if there is 1 or 10?