LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I make LavVIEW run faster?

I have written a VI that sends commands to an external instrument (a Uniblitz shutter driver), and it works.  However, I want to be able to send the command to the instrument up to 1000 times per second.  Right now, I can only manage a frequency of about 10 times per second.  When the specified frequency is above 10, it takes longer than it should (e.g. if the frequency is 15 times per second, it actually takes about 1.5 seconds to send the command 15 times).  Is there any way to make the VI run faster?
0 Kudos
Message 1 of 28
(3,810 Views)
I am not sure of your level of expertise, so take this with a grain of salt if you already know this.

Typically, the most time consuming component of Instrument I/O is the configuration. If you are configuring your instrument in a loop... this is BAD. Move your config out of the loop, use the reference to the instrument in the loop, then after the loop executes, close the instrument session.

As a side, what instrument do you have that will respond quickly enough to receive commands 1000 times per second?
I have to wait for instruments to send a verification response in almost all my drivers.
0 Kudos
Message 2 of 28
(3,797 Views)

Adding to Matt's comments...

To determine IF the application can run that fast, we should first ID what are the bottle-knecks and what is required in each step to achieve that rate.

Ussually the transport medium (serial, GPIB, etc) is the slow part.

Tell us more about your interface and the nature of the interaction and we may be able to help further.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 28
(3,779 Views)
I just started learning LabVIEW about three weeks ago, so I don't know much at all.  I don't really understand how LabVIEW communicates w/ the instrument or if it actually receives a verification response from the instrument.  I'm not telling the VI to read anything from the instrument, and the instrument still executes the command. 

Right now, I have the VISA write inside a for loop, and then the instrument configuration and the for loop are inside a case structure, and then a button controlling that case structure is inside another case structure.  I have no idea if all these case structures are necessary, but it's the only way I've gotten the VI to do what I want it to do.  On the other hand, I'm also probably not using the most efficient code.  I also don't have a session to close the instrument at all (and it doesn't seem to be a problem thus far, but at the same time, I honestly don't know if it's absolutely necessary).
0 Kudos
Message 4 of 28
(3,777 Views)
You might be right about the number of structures.  Also, it's not mandatory (but should be) that you close your sessions, but it is good practice to do so.  It helps keep everything in check so to speak.  Never start something you can't finish, as the old saying goes.

As far as code optimisation...perhaps if you posed it (save as a development distribution if it's more than one vi), and someone will be able to help out with the optimisation.  Altenbach, tst, et al?
0 Kudos
Message 5 of 28
(3,771 Views)
Also:  the interface is an RS232 serial port. 

Specified by the Uniblitz shutter driver:  The baud rate is "300".  The data bits value is "8".  The parity is "none".  The stop bits value is "1.0". 

Not specified any where that I've seen:  The flow control is "none".

The instrument recieves commands in a hexadecimal form, so I am inputting the ASCI representation of the correct commands into the VISA write. 
0 Kudos
Message 6 of 28
(3,772 Views)
Ok, so I'm not sure how to post the VI, but I'm attempting to include it as an attachment.
0 Kudos
Message 7 of 28
(3,764 Views)
Also, the red LEDs on the front panel are there to indicate when the command is being sent so that I can continue to alter and test the code even when I'm not connected to the shutter driver.

Another thing:  This VI is only being tested with the shutter driver.  Once it is working exactly as I want it to, it will be connected to a different instrument (an SGD box of a pulsed laser) that specifies a baud rate of 9600.  I don't know how much a difference that would make to the speed of execution of the VI. 
0 Kudos
Message 8 of 28
(3,759 Views)
hi there
 
a baud rate of 300 means ~25ms per byte. tell us about the communication. do you need to send some command bytes before receiving a data byte or how many data bytes are send? the best would be to post some code.
 
check your shutter manual for higher baud rates.
Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 9 of 28
(3,754 Views)
As far as I can tell, I don't need to receive any data from the instrument.  I just send a command (either to open or close the shutter) and the Uniblitz driver opens or closes the shutter.  I have no idea how to find the number of data bytes that are sent.  All I know about the communication is how I needed to configure the serial port (as described above). 
0 Kudos
Message 10 of 28
(3,746 Views)