LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot multiple functions on the same chart

Or do something like this.

 

Plot Multiple Functions2.png

0 Kudos
Message 11 of 20
(1,328 Views)

Ok, this is getting rediculous, and I am about ready to put this down for the day.  How something that should be so stupidly simple is giving me such a hard time is beyond me.  Honestly, I feel like a 3rd grader who can't add 2 numbers together. 

 

So I tried moving what I ended up with into the real program I am writing, and of course, I am using a state machine, and not a for loop.  That means when I index those arrays of x and y values (before I made clusters) with the state machine, I get extra data points (from all the states that don't take data) that mess up my graph hardcore, and aside from creating another incrimenting constant loop that only incriments in the data collection state, and using that to direct exactly where each data point should be placed in each of the 4 arrays,  

0 Kudos
Message 12 of 20
(1,321 Views)

Use shift registers for the data in the inner while loop (wire through all states). Since there is not a lot of data points you can use the build array function in the data state.

 

Ben64

Message 13 of 20
(1,313 Views)

Hooray incomplete sentences! Let me try that one again.

 

A couple posts ago I posted an image called XY reset, where the data is indexed out of the for loop, bundled into clusters, and then bundled into an array before being sent to the graph.

 

Since in the real program I am writing, I will be using a state machine, there are cases that don't collect data, so I cannot index them into arrays out of the while loop in the state machine because there are erroneous data points that are added.

 

I also cannot move the graphing function inside the for loop by just bundling the individual points into clusters (without indexing them to arrays first) because the data type is wrong.

 

The only thing I can think of is to use shift registers to incriment a constant, and use that constant in conjunction with an "insert into array" to manually make my data arrays myself, and then pass the completed array out of the state machine, bundle them into clusters, etc, as I did before.

 

The only way I can make the graph work properly is I collect ALL the data first (i.e. run the whole routine until the end) and THEN make the graph all at once.  How would I go about graphing 3 functions point by point on the same XY chart?

 

 

 

0 Kudos
Message 14 of 20
(1,312 Views)

Ahh thanks, I'll try that, you must have posted that when I was writing my last one.

0 Kudos
Message 15 of 20
(1,310 Views)

Well now that Ben has escorted you through how to create the XY graph and format the data the way you want and you are now faced with the challenge of updating it one state, clearing in another, I'll add a little spice to soup in the hopes you will find this idea appetizing.

 

In this Nugget I introduced the idea of an Action Engine.

 

If you create an action engine with methods like

 

Init - clears the SR

Add Value - adds a new value to your SR array.

Get Plot - Pulls what is in the array and packs it in a foramt that fits the XY graph.

 

You can simply you code a bit and end  up with something that is more readable since all of those nast little details of the XY graph could distract from the work going on in each of your states.

 

Just another idea for you to concider,

 

Another Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 16 of 20
(1,303 Views)

It is for sure an excellent occasion to discover the benefit of an Action Engine. I recommend you take the time to look at the link Ben posted.

 

Ben64 

Message 17 of 20
(1,296 Views)

I’m not sure that I fully understand what you need to do with your program, but you sound as though you’re having problems putting limits onto your XY data plots and possibly problems adding more data plots.

 

Take a look at the attached program which uses a crude action engine, it may give you some ideas. If you have large array sizes you may need to optimise some of the array processing in the sub vi.

 

Regards

Ian

Download All
Message 18 of 20
(1,286 Views)

Hey everyone, thanks for all your help, I have it working now.

 

Just want to ask if putting the routine to reset the XY graph up in the producer loop is bad programming form.  The user won't need to hit the reset button while the consumer loop is running, it is in between the runs that it is important.  I figure that I could throw it down in the consumer loop and set the control to latch until it is read, but it won't be immediate, and if it is in the producer loop it should clear instantly (again, so long as the consumer loop doesn't have any events qued up).

 

So, bad form or is this ok?

0 Kudos
Message 19 of 20
(1,275 Views)

Since there is no timeout event the producer loop will wait until an event to execute so no action will be perform when you hit the reset button, why don't you create a reset (value change) event and put the code in it. As an alternate if you have a start measurement event you can put the reset code there before queuing the action. Since the code do not take a lot of time it's ok to put it in the producer loop. You wired the error cluster status to the stop of the while loop so the shift registers of the error cluster is useless, you can replace it with tunnel.

 

Ben64

Message 20 of 20
(1,269 Views)