Solution
Hardware input and output latency depends on the execution mode specified in the System Definition file. On the Controller page in the System Explorer, you can choose either
Parallel Execution mode or
Low Latency Execution mode. The following behavior applies to both DAQ and FPGA hardware input/output in these execution modes:
Parallel Execution (DAQ and FPGA - default)
- First loop cycle - hardware input is acquired and passed to the model.
- Second loop cycle - the model processes the acquired data and generates the output data. This data is sent to the output buffer, but not generated yet.
- Third loop cycle - hardware output is generated.
Thus, there is a two tick delay from input to output.
Low Latency Execution (DAQ and FPGA - default)
- First loop cycle - hardware input is acquired and passed to the model. The model processes the acquired data and generates output data. This data is sent to the output buffer, but not generated yet.
- Second loop cycle - hardware output is generated.
Thus, there is a single tick delay from input to output.
For DAQ hardware, input and output tasks use the same hardware sample clock, so it is necessary to wait for the next tick to update the output signal. FPGA tasks, on the other hand, use Feedback Nodes to cause the data to be written to the output with hardware timing. These Feedback Nodes can be removed, and thus the output signal would be generated within the same loop iteration. However, doing this will cause the FPGA IO output to not be hardware-timed. This will cause more jitter in the code, so keep in mind that this method sacrifices some determinism. The following behavior applies in this case:
Parallel Execution (FPGA - without hardware timing)
- First loop cycle - hardware input is acquired and passed to the model.
- Second loop cycle - the model processes the acquired data and generates output data. This data is sent to the output buffer and generated by the hardware.
Thus, there is a single tick delay plus approximately the High Priority (HP) Loop duration from input to output.
Low Latency Execution (FPGA - without hardware timing)
- First loop cycle - hardware input is acquired and passed to the model. The model processes the acquired data and generates output data. This data is sent to the output buffer and generated by the hardware.
Thus, there is a delay of approximately the HP Loop duration from input to output. The HP loop duration will be longer in this scenario than in the parallel execution setting, because HP loop duration includes the model execution time.