04-03-2025 03:50 AM
Hello,
I am trying to synchronise a for loop with an on board clock.
The shared ni is juste a partition of the global algorithm, other tasks are temporised by the clock and I need the actions to be simultaneous with each iterations of the for loop.
I don't want to temporise the task but the loop.
This for loop read some channels and change the value to write based on real digital sensors values.
Is it possible ?
test_gene_bench.vi is the main
Read_config_switch.vi loads the configuration associating the channels (read/write channels)
Read_Write_Switches.vi read and write the switches if asked in "LI modificateur"
04-03-2025 03:54 AM
Hi Baptiste,
@Baptiste.Guilleux wrote:
I am trying to synchronise a for loop with an on board clock.
Is it possible ?
The FOR loop doesn't know about any Onboard clocks, it just follows DATAFLOW mechanisms…
In which way do you want to "synchronise" the FOR loop with your DAQ hardware? What are the (specific) requirements?
04-03-2025 04:12 AM
Hello GerdW,
Thank you very much for your answer.
I am developing a test bench for a control software associated with a motorized bench on which there are physical switches. Depending on my test scenarios, I must either simulate the outputs that are sent to the software via the CompactDAQ or use the actual values provided by the switches on the motorized bench.
During scenario execution, different inputs are read and different outputs are generated, so all actions in a single step must be simultaneous (or as close to it as possible).
The aim of our for loop is to read a value from one channel and write it to another. The iterations of this loop must be timed to be synchronized with the other actions.
I can't time out the task because I'm sending the samples one by one, so I'm looking to time out the loop (if possible).
Don't hesitate to ask if you need more information.
Best Regards,
Baptiste
04-03-2025 07:34 AM
@Baptiste.Guilleux wrote:
During scenario execution, different inputs are read and different outputs are generated, so all actions in a single step must be simultaneous (or as close to it as possible).
The aim of our for loop is to read a value from one channel and write it to another. The iterations of this loop must be timed to be synchronized with the other actions.
I can't time out the task because I'm sending the samples one by one, so I'm looking to time out the loop (if possible).
The Application Case 1 in NI-DAQmx Hardware-Timed Single Point Lateness Checking is what you are looking for. Unfortunately, HWTSP mode is not supported on cDAQ. To use that mode, you need cRIO-904x/905x. See DAQ Devices with Hardware-Timed Single Point Sampling Mode Support
If you only have cDAQ, the workaround would be the example in Application Case 5, using software-timed I/O. You should expect some degree of jitter.
04-03-2025 09:19 AM
Hi ZYOng,
Thanks for these informations.
We are using only the cDAQ in our case. I'm not sure to understand well the solution in Application case 5. In our case, its means that we have to adjust our whole program to use the Software-timed I/O, or can we juste use it for this loop ?
Best regards,
Baptiste
04-04-2025 06:41 AM
There is only one loop in your program that you want to control the timing. So yea, you can try replacing the for loop with the timed loop. However, you should know that the timed loop still has significant jitter in Windows.
04-04-2025 08:13 AM
Yes, in the file I shared there is only one loop to test individualy all my functions, but I want to synchronise this loop with others.
I don't understand something, with the cDAQ I can use the on board clock to temporise tasks, however this doesn't work to synchronise my for loop ?