02-21-2023 11:33 AM
Hi, I am writing a code to control some actuators which need a 24V signal. Very simple ON/OFF. My code is structured with one while loop that scans a boolean matrix which contains the state of each actuator every dt of the loop.
I have initially developed this code with a CRIO 9174 USB, but since I needed more than 4 slots I am now using a CRIO 9189 which works through ethernet. Since I have changed the CRIO I have noticed that the speed of the while loop has decreased. Is that normal or is there any settings on the ethernet that I should check?
To give you an idea, if I operate with 8 channels DO it goes from 9ms to 13ms, 12 channels 14ms vs 23ms, 20 channels 43ms vs 65ms.
I have attached screenshot of the code and the boolean. Is there any quick fix to make the loop faster? Ideally I would like the square wave to be at 20Hz which would need at least 25ms. At max I have a total of 64 channels which makes things worse. I have planned to move to a PXI in the future, but perhaps there is something I can do now.
Many thanks for the suggestions!
02-21-2023 04:14 PM
The pic doesn't show enough to answer this question:
Do you explicitly call DAQmx Start *before* entering the loop? If not, try that as your first step.
A better overall approach for faster and more consistent timing is to include a call to DAQmx Timing to set up a hardware sample clock and a buffer. Have a look at some shipping examples for hardware-timed output and experiment a bit.
If you know your output sequence ahead of time, a Finite Sampling task can be just as simple to program as your software-timed approach. Continuous Sampling tasks *can* require a little more programming finesse, but they offer a lot of advantages when you need higher sample rates, data bandwidth, and unknown durations.
-Kevin P
03-03-2023 08:24 AM
Many thanks for you prompt reply. Since there is a deadline coming up, I had to accept to operate at 5 Hz for the time being, but I will go back to this in two weeks time and try your suggestions. I will update here regarding the progress.