LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem multithreading with FTP (internet toolkit) repost

Dear All,
First of all, my apologies for the previous aborted posts.
 
I need to write a VI which continuously acquires data from number of sources and writes them to a file, in a loop.  Most sources are relatively fast devices connecting over a custom 8-bit parallel port from which the data can be acquired in a few mS.  The VI also needs to d/l data from a remote FTP server, in a loop and log that to the file too.  The FTP d/l takes many seconds which unacceptably slows data logging from the fast parallel ports devices.  So I cannot simply put the FTP client code in the main while loop which handles the parallel port devices.   According to the application note: "Using LabVIEW to Create multi-threading VIs for Maximum Performance and Reliability", it should be possible to run time critical code and the slower (FTP d/l) code in separate threads within the execution system but I cannot get this to work.
 
I wrote a simple demo with one VI calling another, both VIs have reentrant execution set and the subvi is set to run in the 'other1' thread. The calling VI has a while loop containing a fast mS counter and the subvi.  My understanding is, both sets of code should execute in parallel, with the mS counter counting rapidly.  Instead, they appear to execute serially, with the mS counter only updating every few seconds -- after each FTP d/l. 
 
 
Note: It does not deal with inter-thread synchronisation -- I'm happy to play with semaphores etc. later.  I just need to get parallel execution running.
 
What am I doing wrong? 
Are the FTP VIs in the Internet Toolking not capable of multithreading?
Short of running the two sets of code in separate top level VIs and communicating between them with global variables, is there another solution?
 
Thanks
Tom
 
System details: Win2k, LV6.1.
 
0 Kudos
Message 1 of 3
(2,702 Views)

Hello Tom,

The way you have the code setup at the moment, is that you have one loop in which all the code executes (including the subvi with the slower ftp code in it). The loop will always run as you have said, so the ms counter wont run as expected and only updates once the subvi call is finished.

What you actually need to do to get parallel execution in LabVIEW is to have multiple while loops. So within the same vi have one loop doing the acquiring, and the another loop doing the ftp side of things.

In LabVIEW, code will run sequentially if thats how you have wired the functions together. If you have a set of functions which are independent (no wires between them) of each other, then they will run in parallel (as best as they can on a single processor machine).

Take a look at the following example, which shows how to pass data between functions that are running in parallel

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=CC15A52074250FB5E034080020E74861&p_...

I hope this helps

Hannah
NIUK & Ireland

Message 2 of 3
(2,676 Views)
Dear Hannah,
Many thanks.  That was the information I needed.  The docs could have been clearer on this point though.
 
Regards
Tom.
0 Kudos
Message 3 of 3
(2,666 Views)