LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem creating threads

Hi,

I'm trying to make a LabView application that creates threads, which set and
unset digital lines. For some reason I can't include attachments to my posts,
but I'll try to explain what I have done so far.

I have a one VI that runs forever in a while loop and sets a digital line to 1 or 0
every 500 ms. This VI is defined to be reentrant. From this VI I would like to have
numerous of instances with different digital lines. This VI is supposed to be the
base from the threads. The digital port is the only thing that is different in each
thread.

I use another VI to create these threads with Invoke Method. First this VI uses
Open VI Reference. Then I use Invoke Method to get the type descriptor of the
control I want to change in the VI. Next I call Invoke Method to set the digital port
to be used with parameters gotten from the previous Invoke Method. And finally
I call Invoke Method: Run VI.

I get an error that states "Memory or data structure corrupt". The source is in the
set value.

Hopefully this makes at least some sense and someone can give me some tips
on how to do this.

Thanks.

P.S. I'm trying add files to my posts from the "Browse..." button that is located at
the bottom of this message writing page, but for some reason the attachments
does not show. Am I doing something wrong?
0 Kudos
Message 1 of 11
(3,716 Views)
Could you provide us with a little more info, i.e. LabVIEW version, operating system, etc.


Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 11
(3,688 Views)


@kaêm wrote:
P.S. I'm trying add files to my posts from the "Browse..." button that is located at
the bottom of this message writing page, but for some reason the attachments
does not show. Am I doing something wrong?

You should attach your file right before posting. For example every time you click on "preview", the attachment will be lost.

I am a bit confused about your problem description. Why do you think you need to do it this way? Can you explain from a more global perspective what you are trying to achieve? Maybe there is a better way.

0 Kudos
Message 3 of 11
(3,683 Views)
Thank you LV_Pro and altenbach for your replies.

I will try to explain this matter more clearly. First of all I'm using the evaluation
version of LabView 8.2 on Windows 2000. I also have LV 6.2 which I have tried
this, but we're propably  going to use a 8.x version, so 8.2 will be my main
environment now.

I need to make a DLL that will be called from another  application. In the library
the functions/VIs should run in threads for parallel execution and the application
using the DLL can't wait for the execution to end. I'm trying to make the functions
inside the library as general purpose as possible, because those same functions
are needed for different things.

If there's some other way to create threads in LabView, please let me know, since
this is the only way I know, and it's not even working.

Hope this explains it better. If not let me know and I will draw a diagram or something.

Thanks.
Download All
0 Kudos
Message 4 of 11
(3,661 Views)
Can you please post an image of the block diagram (png), I don't have LV on the network computer, but I am interested in that topic as well.

Felix
0 Kudos
Message 5 of 11
(3,649 Views)
Hi Felix,

Here are the images of the block diagrams. Not pngs but jpgs.
Download All
0 Kudos
Message 6 of 11
(3,638 Views)
My guesses:
I would use a type specifier for the open vi ref. Had a similar problem recently, when I registered for the front panel closed event of a dynamically called vi, it returned an error without the type specifier.
Next (if still not working) you can try to use a call by reference node. To have it running without blocking, use it with an init-flag, that puts your digital channel in a shift register and terminates the loop imidiatly (and unset the init-falg). Call Invoke run for normal behaviour.

Felix
0 Kudos
Message 7 of 11
(3,633 Views)
There are several direct problems, for example, you need to open the reference with a full path, not just with a path constant containing a file name. Also your flattened data is definitely wrong. You currently feed it a formatted string instead of flattened data.
 
Sorry, I don't have time to further look into this at the moment.
Message 8 of 11
(3,619 Views)
Thank you guys for your replies.

I got it working by adding a Flatten To String function when sending the digital
port as parameter like altenbach noted. The path is relative so it is ok as long
as the two VIs are in the same directory.

Felix, I didn't quite understand what you meant. Can you explain it more clearly,
I'm relatively new to LabView.

I'll attach the modified version of the Thread Runner VI. If you see something wrong
or something that should be done differently, please comment.

Thanks.
Download All
0 Kudos
Message 9 of 11
(3,603 Views)
The open VI reference node has a terminal, which allows you to specify the kind of VI you open, that is the terminals connectors. Then you can use call by reference node to acess your VI like a normal sub VI, although it's dynamically loaded. It is similar to specifying an interface for functions/procedures/objects in text based programming.

In your case my suggestion would be more complicated (intended to be a workaround); as it works now, don't care about it. If you think you might find it useful, there should be an example provided how it works.

But if a specific point I mentioned is of interst to you, feel free to ask.

Felix
Message 10 of 11
(3,591 Views)