Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

visa synchronized while loops

I am reading data streams from two rs232 with different baud rates ,so I used two timed while loops and connected the error out from the first loop to the second to synchronize two loops. for the first 10 sec or so I get relativly synchronized data but then the diffrential time between two loops accumulates and I end up with bunch of unmatched data. My attempt to use VISA assert trigger failed since probably two dvices are using different protocols. Is there any other ways to synchronize two VISA while loops?
 
Thanks
0 Kudos
Message 1 of 4
(3,742 Views)
hi
i think that you are just not synchronizing the two timed loops ; there are several exemples in the labview help (definitely better than my explanations here).
N
0 Kudos
Message 2 of 4
(3,730 Views)

Hi Shimbloo,

You are going to have trouble synchronizing two visa sessions that have different baud rates.  The VISA session with the high baud rate will execute faster than the other session, and receive data faster.  Also, serial communication is event based, and by nature not deterministic.  Because serial is not deterministic, using timing and synchronization does not guarantee that you will get your data when you expect.  About the assert trigger, it may be that your devices do not support the *trg\n command.

This being said, Nitad is right, you should be able to use two synchronous timed loops to "synchronize" your VISA write and reads.  Make sure that your timed loop gives enough time for both of your VISA sessions to finish execution before reiterating the loop.  The issue with using timed loops is that you are relying on software timing and synchronization which does not offer good determinism/resolution.  If milisecond resolution is sufficient for your application then software timing with serial communication will work for you. 

Keep in mind, this solution will ensure that you make your write/read commands and receive your data during the same loop iteration, but will not synchronize when you make your command or receive your data within the loop interation. I hope this information helps.

Ted

Ted H
Applications Engineering
National Instruments
0 Kudos
Message 3 of 4
(3,708 Views)

Thank you both for the information, I did not even know that timed loop functions are avaiable in the new version.I used two timed loops within the main while loop, fortunately one of the devices had an optional baud rate at 9600 so I set both baud rates at 9600, but since one loop uses SLIP and the other rs-232  the result is not that great and still I get unsynchronized loops when the data rate increases, even within the range of 9600 baud. Tthis solution, using timed loop, seems to be satisfactory for now.

Thanks again,

0 Kudos
Message 4 of 4
(3,680 Views)