LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass dynamic data into parallel loops

Hello All,

 

1. I am trying to generate a waterfall plot with my data from a JSON string. SO far I am able to parse the string and process it for required elements, however now I need to pass the data in other loop to generate a water fall plot. I have tried queues and shift register but nothing seems to work out.

Attached is the VI using channel wire which gives out a data mismatch.

 

2. Also is there a way to make this loop work faster and read all the data from the channel from beginning and not just last data points.

 

Kindly Help,  The data is a dynamic data from my things speak channel.

 

-Layman93

 

 

 

 

0 Kudos
Message 1 of 8
(2,593 Views)

The Title of this post is wrong -- there are (fortunately) no Dynamic Data (except for the unwired Convert from Dynamic Data, which I deleted) in your code.  Try connecting an Indicator or a Constant to the PSD Output of the Spectral Measurement Express VI (better yet, resolve to never (well, hardly ever) use Express VIs, learn to use the "normal" VIs ...

 

Now look at the wire the connects the PSD Output to whatever you created.  What is the "type" of the wire?  Does it look like any other LabVIEW construct(s) that you might recognize?  Is there anything in there that looks like an Array?

 

Bob Schor

 

0 Kudos
Message 2 of 8
(2,530 Views)

Hello @Bob_Schor,

 

I know the data coming from the PSD vi is not an array hence there is a data mismatch. I came here to see if there is someone who could help me fix this. What do you mean by normal VI's if you could explain.

 

Also the primary question being how do i pass this generated data between loops.

 

 

0 Kudos
Message 3 of 8
(2,492 Views)

@layman93 wrote:

Hello @Bob_Schor,

 

I know the data coming from the PSD vi is not an array hence there is a data mismatch. I came here to see if there is someone who could help me fix this.


Look at the broken wire coming out of PSD.  If you hover over it, you should see

PSD type.png

If you connect the wire to an "Unbundle-by-Name" function, you can learn about this type of Cluster.  It should make you think of another "cluster-like" LabVIEW data type that you used in the previous loop.


Also the primary question being how do i pass this generated data between loops.

Well, you used a Stream Channel to pass a Waveform (why did you build a Waveform, without specifying dt?) from your JSON loop to a processing loop.  That's a perfectly good way to do it (one that I highly recommend).

 

In your original Post, you said "I have tried queues and shift register but nothing seems to work out.  Attached is the VI using channel wire which gives out a data mismatch."  But it doesn't!  There are no errors in the Stream Channel Wire -- Waveform In, Waveform Out.  The problem is with the Express VI, whose PSD output you didn't wire to an appropriate "receiver", as I mentioned above.

 

Look at your first loop.  You are gathering data from JSON, adding the data to a growing Array, plotting the ever-growing Array in a Graph (which means drawiing 1 points, then 2 points, then 3, ... (until you run out of memory?), and for every point, passing an ever-growing Waveform to the second, analysis, loop, where you analyze 1 point, 2 points, ... over and over again.

 

This is what you told your code to do.  Is this what you want your code to do?  One problem with Programming Languages (such as LabVIEW) is that the programs tend (usually) to do what we tell them to do, not (necessarily) what we want them to do.


What do you mean by normal VI's if you could explain.

Sorry, that was sloppy writing.  I should have said "When possible, use LabVIEW functions that you can find on the Block Diagram Palettes instead of Express VIs, which hide too many details, and tend to encourage bad habits such as relying on the Dynamic Data Type rather than the much simpler and more logical Waveform.

 

Bob Schor

Message 4 of 8
(2,482 Views)

@Bob_Schor wrote:

The Title of this post is wrong -- there are (fortunately) no Dynamic Data (except for the unwired Convert from Dynamic Data, which I deleted) in your code.  Try connecting an Indicator or a Constant to the PSD Output of the Spectral Measurement Express VI (better yet, resolve to never (well, hardly ever) use Express VIs, learn to use the "normal" VIs ...

...

 

Bob Schor

 


I don't like Express VIs either (they hide things that should be outside).  For a file dialog, I still use this:

fd.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 8
(2,478 Views)

Hello @Bob_Schor,

 

Thank for the direction I was able to rectify my data, and it seems to transmit in the second loop smoothly.

 

Attached is the modified VI.

 

However the problem now is that the VI runs very slow. Infact the json parser is reading data with a delay. is there any way to fix it.  I tried to modify the url for JSON parser from results=2 to results=10000 so that it reads the whole availible data and not only the last data point.

 

It is still not working, is there a way to make this work?

0 Kudos
Message 6 of 8
(2,422 Views)

@layman93 wrote:

 

It is still not working, is there a way to make this work?


Well, there's a lot "going on in the code".  It is not clear to me (and I have no practical way to run your program myself to figure it out) what you are trying to do, what is working, what is not working, and where the problems lie.

 

You have two loops running in parallel.  Loop 1 does "something" with getting data from "somewhere" of "sometype", appears to be building an array one element at a time, and passing each of the growing arrays (of size 1, then size 2, then size 3) out to the second loop.

 

Curiously, there are a pair of those stupid To DDE and From DDE functions in the first loop whose only purpose is to create a DDE "wire" for a Chart!  But Charts do Arrays just fine.  (Hint -- if you are concerned with time, don't put "slow" things like updating displays inside critical loops).

 

More stupid DDE functions in the second loop.  If my analysis of Loop 1 is correct, Loop 2 will also be working with first 1 element, then the first 2, then the first 3, etc.  As I remember, the sum of the numbers 1 to N is N*(N+1)/2, so it grows as N².  Thus if it takes, say, 10 seconds to process 1000 points when you do it all at once, if you try to do it by processing 1, then 2, ... then 1000, it should take 55 seconds, quite a difference.

 

I'd suggest that you try to create a fixed, static Data Array to test your loops.  If the first loop is supposed to be building a Waveform, write the simplest loop you can that gets the numbers one at a time and builds the array by tunneling it out in an Indexing tunnel (the kind of tunnel that the For Loop uses as its default Output tunnel -- do you know how to specify/change the type of the Tunnel?).  Don't put any displays inside this simple loop -- let the loop churn through the data (I'll bet it is pretty speedy, though that may depend on the speed of your HTTP Get) and just display the Final Result.  If this looks OK (and the speed is acceptable), then (if you want) you can try putting the display inside the loop.  Note you should only be plotting the last acquired point on a Waveform Chart, not the entire (growing) Array.

 

Bob Schor 

0 Kudos
Message 7 of 8
(2,403 Views)

Hello All,

 

@Bob thanks for pointing out the dynamic convertor which was indeed taking sometime. Also the loop works much faster now as required.

 



Well, there's a lot "going on in the code".  It is not clear to me (and I have no practical way to run your program myself to figure it out) what you are trying to do, what is working, what is not working, and where the problems lie.

This program can be run directly as the sensor uploads the data on free things speak server,

 

My problem lies with thingspeak since it only writes data only every 15 secs which is the fastest for a free license due to which the labview program reads same value 10 times and the 11th time the new value is received. 

 

My one solution is to to create a counter in second loop to wait till next unique value arrives and the  further execute the process,  I tried finding a solution but no luck.  It will be really helpful if someone can help me figure how to just process the unique value.

 

I really appreciate this forum member for responding and helping me build the code.

 

-Layman93

0 Kudos
Message 8 of 8
(2,376 Views)