Good day everyone,
I have been trying to write a code which generates a sine wave and a trigger signal and send them out to two different devices. I am trying to phase lock device-1 on a certain phase angle of the operating signal (sine wave) of the device-2.
The device-1 which receives the trigger signal also generates a trigger signal at the same time it receives the trigger. It also can not work with trigger signal with a frequency which is greater than 4 Hz.
I got that part to work and then I realized that I need to make sure that the responses of the devices have the same phase difference. So I added another part to the code which reads the trigger signal generated from the device-1 and the sine wave generated by the code (which basically goes to the device-2).
I did not have any loop in the code at the beginning, and I just set the sampling frequency and sample rate and I though that it would work at the rate which I want. Unfortunately it did not. So I added a while loop to control the speed of the writing and reading process, and slow it down to 4Hz which is the limit of device-1.
I have tried the reading process with finite sample and continuous sample on the sample clock and I got Error 200278 and Error 200279 correspondingly. Attached please see the main VI and subVIs. There are some subVis for writing data to the file which are not attached.
I really appreciate it if you can help me to solve this problem and get the code to work in a way that the whole process works at 4 Hz frequency.
I am not sure if my code is completely optimized. Any suggestion to optimize the speed of the code and the way it acquires data is also highly appreciated.
You need to add some wait delay in your while loop. Try adding a Wait Until Next Millisecond Multiple to your while loop with a constant wired in.
You are acquiring data too quickly. Here is a link that discusses this in general.
Thanks for the reply. I think the time subVI which I have in my code works just fine. It is setup so the duration of first iteration and other iterations are the same.
I found the reason which caused getting those errors. When you run the code in highlight execution mode, there is a conflict between the timing of the highlight execution and the timing of the loop. As you run the code in the normal mode there is no error and it works just fine. I think it is just the time conflict between the highlight execution and the timing of the loop.
The other option to do this is to use a timed loop to have control over the speed of the loop. This is a kind of tricky part of data acquisition with Labview.
Thank you though for the help.