Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sincronize 3 Visa reads

Hi,

 

I am working on a project that has 3 places of measurement of pressure and flow.

2 of those device are connected by bluetooth and it serial code is COM 4 and COM 6.

The other one is a USB device thats change it serial code by the usb port that I plug it.

 

For the read, I used a Visa Read for each one but when I put the devices on serie, I can see that there is a big delay between them.

Another problem that I am having is a timeout error in Visa Read that crash the program. It read everything but, in a random time, it crashes and a error appears.

 

Info of the code

- The bluetooth devices has a Terminal Char \r\n and the usb device has a Terminal Char \r\00. I can't change this Terminal Char, but Labview read the exact buffer. I confirm this using Tera Term.

 

- It's a new project, so I am trying to deal with this bug first and then I will see how can I put time stamp on Waveform Chart, put all the waves below each other and export the data on a sheet or another file to work with on Matlab.

 

Thanks for the help.

 

PS: I attach a video of the problem to help to see the delay between them. On top are the flow signals and below the pressure signal. The first device of the video is COM 6, second USB (COM 3) and last one is COM 4. By the video, you can see that the flow signal has to appear first on COM 6, than COM 3 and the last on COM 4 but this is not whats happening.

Download All
0 Kudos
Message 1 of 34
(4,316 Views)

Hi

Just to be able to measure better where the problems exactly occur I would not put all three reads in the same loop. If one instrument is faster (measuring more data items per second), It will be slowed down by the other instruments.

I would each give its own while and send the data via a queue to a "main" loop that gathers the data.

Anyhow I would try to optimize each of the instruments in speed, maybe you need a special serial buffer setting to make the instrument react faster.

greetings from the Netherlands
0 Kudos
Message 2 of 34
(4,259 Views)


@Albert.Geven  escreveu:

Hi

Just to be able to measure better where the problems exactly occur I would not put all three reads in the same loop. If one instrument is faster (measuring more data items per second), It will be slowed down by the other instruments.

I would each give its own while and send the data via a queue to a "main" loop that gathers the data.

Anyhow I would try to optimize each of the instruments in speed, maybe you need a special serial buffer setting to make the instrument react faster.


 

When I get each one alone, I don't have this delay for my blow. So I don't think that the problem is the sensor buffer because using Tera Term, I don't have any delay using the three sensors.

I was thinking on use three of the same program that read each sensor indivudually and try to sync them with the time stamp of windows. But I really wanted them all syncronize in the same file because my experiment will have a lot of data.

 

About the loop of each instrument, with your tip, I was think on using time loop, but they would never be syncronized. I had thought on put three loop inside this big one but I am thinking that when the first one started, the others ones will only start when the first one is over. So how can I do that?

 

Before I go, thanks for the help.

 

PS: I will try something and if I got, I put it here.

 

 

0 Kudos
Message 3 of 34
(4,234 Views)

As I said, when I got them in each program, I can record them and I can syncrozine with windows time stamp. But I really wanted to do it in a single file.

0 Kudos
Message 4 of 34
(4,223 Views)

@MrBadgerBR wrote:

As I said, when I got them in each program, I can record them and I can syncrozine with windows time stamp. But I really wanted to do it in a single file.


Yes, this is the way to do it.

   - Run data collection in separate while loops.  Record a time stamp for every measurement and synchronise data afterwards.

   - This approach is still single file, just multiple while loops in a single  file.

   - Rather than plotting your data on a chart use an XY graph with time as X-axis.  You can plot all three measurements in the same plot to visualise the synchronisation.

 

Some other comments:

 - it looks to me like your code can be simplified into 2 subvis (initialize and measure+calculate).

 - the instruments use termination characters, so why limit the reading to 14/17 bytes?  I think that is why it seems to pause/crash on occassion.  Use 1024 bytes for all readings.  Measure the length of string and then parse.  If it isn't the expected 14 or 17 bytes then examine why not and either accept or reject that data.

 - use these 2 subvis for each of the 3 data collection loops.

 - use the "High Resolution Relative Seconds.vi" to measure time between measurements

 - save all the data in arrays while measuring, then save to file afterwards or implement TDMS logging.

 

Craig

 

0 Kudos
Message 5 of 34
(4,200 Views)