LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fast communication with a number of identical devices through a single RS232

Hello Everyone,

I am using an altered version of the driver for my instrument that I got from NI website. I have a serial connection that is made between the devices (output of 1st goes to input of the 2nd and so on) and only one SR232 connection is made to the computer. Each device has a unique address that will allow me to address it individually. I edited the example file in the driver that I downloaded and basically duplicated the interface where I would have several instance of the subVIs but only one initialize VI to open the VISA resoruce. The only difference between the input into the subVIs are the address and the data for each specific device.

 

My trouble is that LabVIEW is slow is passing from one subVI to the other (even before I made any edition or with only one deivce). This is contrary to MATLAB, where for example an ASCII command get passed to the device is less than a second! I am looking to achieve something similar if possible.

As well, can someone please set me straight as to whether I should have used several instances of the subVIs or should I have done anything else?

To summarize, I can control my devices but the process is slow.

 

Sorry the long post.

Thanks for helping,

Aym

0 Kudos
Message 1 of 9
(3,122 Views)

How slow is it.  RS232 is a slow communications protocol.  Are you writing then reading to each device?  Is there any delay between writing and reading?  Are you waiting for bytes at port before reading?  Why don't you attach your code so we can look at it.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 9
(3,117 Views)

Hi tbob,

Slow as in 30 second to a minute to read go over all the VIs. So whenever I press a button it takes ~1 min to be executed. I had a similar interface for MATLAB and it is much much faster to change values and send ASCII commands. Yes there is some reading, but the delay is 50ms. Yes it waits for bytes before reading...

The code is here:

http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=6EC1C0BB412C19D7E04400144FB7D2...

0 Kudos
Message 3 of 9
(3,105 Views)

There is a lot of code there.  Can you just attach the vi you are having trouble with, the one that sends and receives from the com port?

How many devices are you communicating with?  How many seconds per device.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 9
(3,085 Views)

Hi tbob,

Thanks for checking the code.

I am not having any errors, but it is slow. If I highlight execution in the block diagram, I can see that the program is slow. Same observation is for example if I press the stop button. I have to wait for more than 10 seconds for a new iteration of the code/while loop. What I am looking for is to make the code/front panel interface faster.

 

Aym

0 Kudos
Message 5 of 9
(3,082 Views)

I downloaded the code.  Which one is the main vi?  Which vi has the serial comm?

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 9
(3,070 Views)

The VI that I use is the Harvard Apparatus PHD Ultra Series Push Button.vi inside the Example folder. The serial set up is in the Initialize.vi which is in the Public folder.

 

Aym

0 Kudos
Message 7 of 9
(3,060 Views)

Your serial vi is performing a buffer flush, write, 2 reads, another write, and another 2 reads.  How long is this vi taking to run?  Create a flat sequence structure.  Put a timer in the first frame, your entire code in the second frame, and another timer in the third frame.  At the end, subtract the third frame timer minus the first frame timer to get the total run time.  What is the run time?

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 9
(3,056 Views)

I would also suggest you turn on NI-Spy and log the result. I;m sure you will find that the example is doing quite a bit more than your Matlab program.

0 Kudos
Message 9 of 9
(3,048 Views)