LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting Waveform Graph X-axis for 24 hours

I'm sure this is simple for anyone with more LabVIEW knowhow than me (which is probably most of you!)

 

I need to track production output over a 24 hour period. I have a vi that updates the result graph once per hour. My problem is the x-axis needs to run from 6am to 6am. I can see how I use an offset to create a 6 am start, but if I set it to cover 24 hours the graph wants to display hour 30 as the x-axis max. 

 

Can anyone share a tip for how to get the x axis to go from 06:00 to 23:00 and than on to 0:00 and 06:00? (Appending a picture of the loop I'm using for testing.)

another_novice_0-1662043423497.png

 

 

0 Kudos
Message 1 of 7
(2,152 Views)

An intriguing problem you posed -- how to design a Waveform Graph that has the following Properties:

  1. The X Axis is labeled in "Time Units" as "HH:MM" (presumably relative to the day that the data were acquired), with the appropriate ?AM/PM" suffix..
  2. The X-Axis is 24 hours in leng so that the right-most Label matches the left-most (e.g. both are, say, 6:00 AM).
  3. The dacreta being plotted span no more than 24 Hours.
  4. You have a specified "Time Start/Stop" for the Graph (e.g. "6:00 AM").

I don't use Graphs much (my data works better with Charts), and I don't remember (and am too lazy to look up) how to specify the width of a Graph.  But I created a Waveform Graph and "by inspection", found that it contained 1000 points, so I'm going to take this as "fixed", for the time being.

 

Here's what I did, and my reasoning:

  1. Dropped a Waveform Graph on a blank VI.  Inspection shows the number of points on the Graph is 1000.
  2. You want the X Axis to plot "Actual Time" values, not "Relative Time" (so if the first point is 6:00 AM, the last point won't be 30:00 AM, but 6 AM).
  3. I'm assuming that the first data point is at 6 AM, possibly because that's the value of t0 on a Wave:%M%form being plotted.
  4. Go to the Display Format property of the Graph.  You need "Absolute Time" (since you want "actual", not "relative", time).  Choose HH:MM, with AM/PM and set Date as "Unused".
  5. You need a "Custom Time Format", so check "Advanced Editing Mode".  In the Format String, remove the part that shows the Date (on a second line).  The Format should be %<%I:%M %p>T which means 12-hour Hour, colon, Minute, space, AM/PM in Absolute Time format.
  6. Go look at your Graph.  You should now see time starting as some "number of hours" (mine shows 7 P.M., because I'm on the Eastern part of the US)(extra points for figuring out why 7 PM), and ends just after 7:16 PM.
  7. So we got the Time Labels right, but it only shows 16+ minutes, or a few more than 960 seconds.  I made a "Leap of Faith" that the default number of points in the Graph was 1000, and said (to myself) "If there are 86,400 seconds in a day, I bet if I choose an offset of 864, I'll get a 24-hour plot".  Try it and see for yourself.
  8. So now, all you have to do is fix the Offset.  I'm going to leave that as an "Exercise for the Reader"  (Hmm, I should probably generate some "Fake Data" and try to plot it, using one of the Waveform functions that can generate, say, a Sinusoid having 1000 points, a frequency of 5 cycles/day, and a period of 24 hours).

One of the things I really like about LabVIEW is how much fun it is to put together a (self-)teaching example, where you make up "known data" and then try to analyze (or plot) it to learn about analysis (or plotting).

 

Try out what I just described (and did for myself to be sure it would work).

 

Bob Schor

0 Kudos
Message 2 of 7
(2,139 Views)

Excellent info Bob, thank you very much. I'd never looked at those time settings before so thank you for showing me how to reach and use them. 

 

I'll tinker around a bit and when I get my routine running I'll be back to mark your answer as 'Accepted'. Or ask more questions. 😉

0 Kudos
Message 3 of 7
(2,126 Views)

Well, I'm a little embarrassed.  I just wrote a little VI to generate a 5-cycle-a-day waveform for 24 hours, 1000 points, and when I wired it into my "constructed" Waveform Graph (oh -- it's a Graph, dummy, you are not familiar with Graphs, just Charts, maybe that's the mistake), it gave me a 5-cycle sinusoid, as expected, but but X axis was not showing Time (it did show seconds, however ...).

 

Back to the drawing board.

 

Bob "Close, but No Cigar" Schor

0 Kudos
Message 4 of 7
(2,120 Views)

Arrrggghhh!  It was really easy to drop a Graph and get the X (time) labels to be 7:00 PM, 9:00 PM, 11:00 PM, 1:00 AM, ... 7:00 pm, and I hinted at why it stopped and started at 7 PM (you really don't want to know), but the "easy fix" I envisioned to let you set the starting and stopping time, and the easy of plotting Graph data showed how simple-minded my "clever" approach really was.

 

Graphs and Charts are really old (meaning not very "flexible" due to 30+ years of "history" and "compatibility"), and (accordingly) have somewhat limited "flexibility" in making the kind to "nice-looking" visual images that you are interested in seeing.

 

That does not mean that it can't be done, but (at least from my feeble attempts to do it "simply") it may take a bit of extra work to make "attractive".

 

I'd suggest several approaches:

  • Check out the LabVIEW Tools Network -- I'll bet there's a Plotting Package that works with LabVIEW that has the Bells and Whistles you desire.
  • "Roll your own".  Create a String Indicator that you lay down on top of the X Axis label and populate it (with appropriate spacing) with the text that you want (6:00 AM, etc.).  Have it "cover up" the existing X labels.  [I've done something similar for "run-time-populated Data Tables", writing the data as a 2D Array of Floats, and a "header" a 1D Array of Strings].
  • ???  Maybe someone else on the Forum has learned how to get more out of Graphs ...

Bob Schor

 

0 Kudos
Message 5 of 7
(2,103 Views)

Bob,

Thanks for the suggestion to check the Idea Exchange. I found a discussion there that seems like it should help: https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Simple-chart-with-time-as-X-Axis/idi-p/1252436#commen...

 

 

0 Kudos
Message 6 of 7
(2,070 Views)

@another_novice wrote:

I'm sure this is simple for anyone with more LabVIEW knowhow than me (which is probably most of you!)

 

I need to track production output over a 24 hour period. I have a vi that updates the result graph once per hour. My problem is the x-axis needs to run from 6am to 6am. I can see how I use an offset to create a 6 am start, but if I set it to cover 24 hours the graph wants to display hour 30 as the x-axis max. 

 

Can anyone share a tip for how to get the x axis to go from 06:00 to 23:00 and than on to 0:00 and 06:00? (Appending a picture of the loop I'm using for testing.)

another_novice_0-1662043423497.png

 

 


Here is what I did for tracking daily solar production:

 

I set my X- axis properties like this:

Z0-4Capture.PNG

Z0-3Capture.PNG

86400 is the number of seconds in one day

 

When I launch my program and every night at Midnight I clear the graphs and set their X axis min and max to 12:00AM to 12:00AM with the attached ZeroHour vi.

 

Z0-2Capture.PNGZ0-1Capture.PNG

I also set the X axis increment to 1 hour (3600 seconds)

 

========================
=== Engineer Ambiguously ===
========================
Message 7 of 7
(2,060 Views)