LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I make elapsed time agree with real time in my waveform graph?

I am taking measurements of a system via USB and plotting (For example) Laser current versus elapsed time.

 

I have set the x-axis for 10 seconds (say), but it takes about 2 minutes to plot the graph. How can I make the elapsed time in the graph correspond to real time?

0 Kudos
Message 1 of 9
(5,012 Views)

Show us your VI?

 

Waveform graphs take an array of data, or a waveform of data and plot it at once.  If it is a waveform, it includes a dT (delta Time) value in it.  If it is just an array, then you'll have to define the dT for the X-axis within the graph properties.  Assuming that the data is 1 second apart.

 

Attach your VI.  But first run it so data shows up on the graphs.  Go to Edit > Make Current Values Default.  Then save and attach.

0 Kudos
Message 2 of 9
(4,995 Views)

Sorry - It is a waveform chart not a graph...

 

It is continuously updated as it is run to show measured laser current, but I cannot make the elapsed time agree with real time?

 

The VI will not run without the hardware since it talks to a microcontroller (Which takes the measurements).

0 Kudos
Message 3 of 9
(4,986 Views)

Here is the VI for reference... But note - It does not run properly or produce plots without the hardware being present.

0 Kudos
Message 4 of 9
(4,981 Views)

I don't see what determines the loop rate. Are you sure all the code and instrument communication can keep up with it? Your charts assume a 10ms update rate, but since they are hidden in different cases of a case structure, who knows how often they receive data?.

 

A lot of your code is quite questionable, for example the use of "insert into array" instead of "built array". Formula node outputs on the left, and such.

0 Kudos
Message 5 of 9
(4,958 Views)

@altenbach wrote:

 

 

A lot of your code is quite questionable, for example the use of "insert into array" instead of "built array". Formula node outputs on the left, and such.


Yeah, that is some strange array manipulation in a way I've never seen before.  The VI has a lot of comments to explain what is going on  (Good), but the comments are often wrong (BAD).  It says "Initialize a 1 element "Array" to build Vectors from", but is actually building a 0 element array because of the 0 constant wired into the array length.   ?????Smiley SurprisedSmiley Frustrated

0 Kudos
Message 6 of 9
(4,952 Views)

I don't think you have fully understood the code, but I'm not surprised.... It runs very fast and my microcontroller keeps up just fine. Each iteration of the main loop sends one hex command (Plus 2 data bytes) to the micro via USB... and receives one hex response (Plus 2 data bytes) from the micro via USB. There are 21 commands to cycle through here before the process repeats over and over. (The loop index is used as a pointer to select the current command and data bytes from the arrays).

 

The micro echoes each hex command back over the USB (Like a handshake) and attaches 2 bytes of measured data. There are correspondingly 21 different response "cases" to process, and so the charts ARE updated systematically and regularly on each loop iteration. The echoed command itself is used to decide which "response case" to select, based on its index in the original command vector.

 

The "1 element array comment" is misleading. It is - as you say a "0 element array" or a "Null array" which is necessary to build the vectors properly using the "Insert into array" function.

 

The formula node does not care that outputs are on the left hand side. This merely simplified the routing of wires in the VI

 

The loop can be controlled by inserting a delay of say 4ms, and adjusting the update rate of the charts to (21x4ms = 84ms), but I still don't get agreement of "real time" in the plots. It is close but not exact.

0 Kudos
Message 7 of 9
(4,919 Views)

@pjleeflyer1 wrote:

I don't think you have fully understood the code, but I'm not surprised....

 

Your use of a flat sequence structure shows you do not understand basic LabVIEW programming.

 

This program should be a simple state machine architecture. 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 9
(4,916 Views)

@pjleeflyer1 wrote:

 

The "1 element array comment" is misleading. It is - as you say a "0 element array" or a "Null array" which is necessary to build the vectors properly using the "Insert into array" function.

 

But the problem is you don't need the Insert into Array function.  Insert Array is a function that rarely needs to be used.  I find if a novice LabVIEW programmer is using it, 99% of the time, they are misusing and should be using Build Array.  It doesn't make sense to create an Empty array and Insert into it.  Just use Build Array.  What you are doing is considered a Rube Goldberg. Take a look at the image below and see how much cleaner it is.  It eliminates 1 function and 3 constants everywhere you used it.  No need to initialize a 0 element array (2 constants there) and "insert" into the front of nothing (another constant there for the "insertion" point.)

 

 

The formula node does not care that outputs are on the left hand side. This merely simplified the routing of wires in the VI

 

Correct.  The Formula node doesn't care about the outputs being on the left.  But the programmer looking at your code does.  It looks like an input just like the 3 inputs above it.  You say it "simplified" the wiring.  But actually made it more confusing because you now have wires that are effectively running backwards.  It makes it very difficult for someone to follow your code and know where the source of the data is, and where the "sinks" of the data are.

 


 

0 Kudos
Message 9 of 9
(4,911 Views)