LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with plotting averaged data points in XY graph.

Hi all,
 
(please refer to the attached picture)
 
i am trying to create a vi which interfaces with a few nanovoltmeters and current sources for electrical measurements.
 
In essence, I was trying to plot out a I vs V graph.
 
The sequence is as follows ideally:
1) User inputs minimum and maximum current outputs, the number of data points he wishes to obtain for the graph, and the number of times V is read at the same current setting for averaging purposes.
 
2) VI will take the difference between min and max output, divide it by the number of data points to get each current 'step'
 
3) for each current step, the Volt is read over 10 times (for eg) and averaged.
 
4) each average V is paired with the current output and plotted as a point on the XY graph.
 
However, I have been getting very weird results from the way i implemented my VI. Would appreciate anyone who could shed some light into the matter for I must admit that I'm rather weak in the concepts of arrays and indexing.
 
Thanks in advance!
Download All
0 Kudos
Message 1 of 13
(3,535 Views)
A couple of things that I noticed that may help clean things up and maybe solve your problems.

I would suggest looking at the state machine architecture using the examples ship with labview.  This will make your program much more flexibile and readable.  Sequence structures have their place, but try to use them sparingly. Also, you can use shift registers and avoid having to use all the global variables.  The global variables could be where you are getting your strange results.

You did not include all of your vi's, so I cant see what is in all of your subvis to take a look at them and see if you have anything strange in there.

Can you explain what wierd behavior are you getting??
Kenny

0 Kudos
Message 2 of 13
(3,505 Views)

One "weird thing" will be the "Current now" will show the value when this code starts because there is now data flow dictating when that value will be read.

As a general rule, LV will evaluate values that have no data dependacies before anything else.

Simply putting all of the code at the bottom in a seq frame will fix that issue.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 13
(3,496 Views)

I think Kenny is definitely correct.  A state machine will really help with the code.  However, the specific reason why your data is strange is what Ben hinted at.  You are putting a scalar (single value) in for X and an array of scalars in for Y.  You should build X as an array like you do with Y.  See the attached screenshot for an example of what I am talking about.

 

Good luck!! 

Daniel Eaton
National Instruments
Systems Engineering
Embedded and Industrial Control
0 Kudos
Message 4 of 13
(3,488 Views)
Admittedly I am something of a contrarian, but I don't see what a state machine would do for this code - it has no states! It sets something up and reads a response and repeats the process. You don't need a state machine for this code - or a sequence. All you need is some error handling. Right now the code has no way of telling you that there is anything wrong because it has no way of reporting errors. Hence, because you haven't made any provisions for errors you have to insert added logic to force what would happen naturally with the proper structure.

Sequence structures certainly have their place: In the same dust bin that we dumped GOTO statements - which logically is all sequence structures are. Sequence statements with more than one frame have no valid purpose in a dataflow language. Period. Dropping bad habits like sequence structures will make you a better programmer.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 13
(3,476 Views)
hi,

without the hassle of youself coming up with the examples would it be possible to suggest a better way to implement the above logic? i have no programming background and thus only had that amount of mastery over labview, often over-relying on the high-level VI's even.

It was mentioned that the sequence would not be needed? I hope you could shed more light into this matter.

Many thanks in advance,

Regards
0 Kudos
Message 6 of 13
(3,467 Views)

Basically, there are a few options for your code.  You could remove the sequence structure and program you application using dataflow alone.  This is what mikeporter is suggesting (I believe).  You could use error clusters going from VI to VI in the order you want to execute.  This will force LabVIEW to execute each VI in the desired order.  This is an example of dataflow and it removes the need for a sequence structure.  This will be the easiest way to implement your code.  If you code could grow and eventually have a lot of different cases that you need to switch (at will) between then a state machine is the way to go.  LabVIEW has a template for this and there are many good articles on NI.com that talk more about how to do this.  As for the actual logic of what you are doing, it seems fine.  Implementing dataflow will just clean up your code and be a better practice.  Also, reading the desired number of samples all at once may be a better practice as well, if your Read VDC can do that.

Daniel Eaton
National Instruments
Systems Engineering
Embedded and Industrial Control
0 Kudos
Message 7 of 13
(3,444 Views)
Can you post all your code including the subVIs. If so I'll be glad to take a shot at reworking it for you...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 13
(3,443 Views)

Hi,

 

thanks for offering. if i may impose on you; the files are attached. For any other stuff it should be instrument interfaces...

 

Regards,

0 Kudos
Message 9 of 13
(3,425 Views)
What did you use to create the ZIP file? WinZip can't open it...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 10 of 13
(3,423 Views)