LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with parallel tasks

Heey everyone, i`m having a small problem here.

I`m using a spider8 for data acquisition, this spider8 measures with 200Hz. I am reading in the data with labview, inside labview the data gets processed and eventually saved. Now i have to be able to see the data immediatly while I`m still measuring. I addapted the "reading-data" part of my labviewprogram so that it processess the data immediatly after measuring.


My problem now is that the read-data program has become too slow, because of the extra process part it measures too slow.

I was thinking of using parallel tasks like:

 

Task 1: Measuring and filling buffer.

Task 2: Processing (and displaying) data from buffer and put the processed data into an other buffer.

Task 3: Emptying buffer.

 

Of course task 3 needs to start a bit later then task 1 and 2 but eventually they will run all three to gether. My problem is that I dont know for sure if using parallel tasks is going to solve my problem and I don`t have a clue on how to make such parallel tasks.

 

In the appendix of this post is the program which reads (and process) all the data.

 

 

 

Thank you all!!

--------------------------------------------------
Currently using labview 8.2.1
0 Kudos
Message 1 of 7
(3,545 Views)

First I would do some things to clean up and improve your program.

1. Get rid of the flat sequence structure and use a state machine. It is more flexible and easier to maintain.

2. Get rid of all of the local variables. Use shift registers and wires for your data. If you do need to use something like a local variable I would recommend using an action/engine instead.

3. Do so general clean up.

 

Now, I don't see any parallel processing that you are doing in this code. If this your current code or the code where you believe you are processing things in parallel? Your idea about the tasks is the correct approach. If I were developing this application I would have the following tasks:

 

1. A simple UI task that uses an event structure for capturing and processing user interactions. (This is not necessary if you will have no user interaction at all.)

2. A task that continually reads your data from the device. As it reads data it posts it to a queue for other further processing. By using a queue you eliminate the need for your third task which only empties the buffer.

3. I would possibly include a third task for displaying the data. If this task were used task 2 would most like feed it the data via a queue.

 

The most flexible queue message is one that is a cluster. (Use a typedef for your cluster) The cluster would contain a Message Id/Type and a variant. This allows you to pass any type of data and the message type will dictate how the data in the variant should be interpreted. If your data is well defined you could use a cluster with your data in place of the variant.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 7
(3,535 Views)

Heey mark, i did some cleaning up in my program and i deleted a lot of the local variables but now i have an other problem. When i run the program i can see the values in the small chart perfectly, but the values in the XY-graph are wrong (I think the X-values are ok but not the Y-values). For some reason the only thing i see is a dead line (plot on the XY-grapy is always '0'). Do you have any idea how to solve this?

 

PS: in the appendix there is the new reading.vi

 

Thank you

--------------------------------------------------
Currently using labview 8.2.1
Download All
0 Kudos
Message 3 of 7
(3,502 Views)

Your Array buffer looks suspicous. How does the values before the "Array buffer" look? I think that module is the problem.

 (cant really try the program)

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 7
(3,496 Views)

Heey mark, yeah the buffers were not good. I changed them and now they work fine but i still see a dead line on the xy-graph, could this be because of the case structure?

 

Thank you.

--------------------------------------------------
Currently using labview 8.2.1
0 Kudos
Message 5 of 7
(3,486 Views)

I agree with Mark and would add a few more comments (on the original code😞

The newer version is getting better 🙂  

 


Mark Yedinak wrote:

First I would do some things to clean up and improve your program.

1. Get rid of the flat sequence structure and use a state machine. It is more flexible and easier to maintain.

2. Get rid of all of the local variables. Use shift registers and wires for your data. If you do need to use something like a local variable I would recommend using an action/engine instead.

3. Do so general clean up.

4. Get rid of Stacked Sequence Structures.  You could use sub-vi's as an easy way to clean up the code.

5. Never wire from right to left.  That's also a caveat from using Stacked Sequences.

Now, I don't see any parallel processing that you are doing in this code. If this your current code or the code where you believe you are processing things in parallel? Your idea about the tasks is the correct approach. If I were developing this application I would have the following tasks:

 

1. A simple UI task that uses an event structure for capturing and processing user interactions. (This is not necessary if you will have no user interaction at all.)

2. A task that continually reads your data from the device. As it reads data it posts it to a queue for other further processing. By using a queue you eliminate the need for your third task which only empties the buffer.

3. I would possibly include a third task for displaying the data. If this task were used task 2 would most like feed it the data via a queue.

 

The most flexible queue message is one that is a cluster. (Use a typedef for your cluster) The cluster would contain a Message Id/Type and a variant. This allows you to pass any type of data and the message type will dictate how the data in the variant should be interpreted. If your data is well defined you could use a cluster with your data in place of the variant.


 

Additional observations (on original code😞

 

Why are you using so many Time Array Local Variables?  Were you expecting different values?  Eliminating the Local Variables will help you clean up the code.

 

 

I just looked at the second posting...

 

What are you trying to do with array-buffer 2?  It looks like you should use an Action Engine or better yet, a Functional Global Variable (a special form of Action Engine).   Do a search on the forum and you'll find many examples.

Message Edited by Ray.R on 11-26-2009 08:30 AM
0 Kudos
Message 6 of 7
(3,476 Views)

As i interpret it you only get the last samples taken from S8_ACQRead into your graph, that'd explain the flatness. Is the buffer meant to be a memory for each line? If so i'd connect them to the loop with a shift register and build the arrays that way.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(3,470 Views)