vhha1972 Posted August 27, 2012 Report Share Posted August 27, 2012 Hi All, As I am new to Labview, I am asking another (possibly!) simple/naive question! I know how to get latest y-value while running a VI. However, I do not know how to get the associated time stamp (x-value) with the y-value. I need both the x & y values during the execution of my program to do some other things. Please see attached code. I used the Index Array Function. But it only gave me y-value. No time stamp! Cheers, Saif EX_A.vi Quote Link to comment
asbo Posted August 27, 2012 Report Share Posted August 27, 2012 1) Double-click the Convert from Dynamic Data node. 2) In the configuration dialog, select Single waveform from the data type listbox. 3) Wire a Get Waveform Components to the output of the Convert node. You now have access to the Y array, as you did before, but now you can also retrieve the t0 and dt. These can be used to calculate the timestamp of any arbitrary index of the dataset. Quote Link to comment
vhha1972 Posted August 28, 2012 Author Report Share Posted August 28, 2012 Hi Asbo, Thanks so much for your response! I tried to do what you suggested (attached). Now I have (at least) two problems: 1. My y-value is no more a scalar? Can I use it as is or I need to convert it into scalar. When I connect an indicator to it, I get i, j, k, etc. If i keep this to zero, I should be OK? 2. The 't0' is just PC time. How do I use this to get t = 0, 1, 2, 3 sec etc.? Any help would be much appreciated. Thanks a lot! Saif EX_A.vi Quote Link to comment
asbo Posted August 28, 2012 Report Share Posted August 28, 2012 The Y is an array because it's all of the Y points in a waveform. Use the Index Array node like you did before to get a specific element. You asked for a timestamp, not an index. If you're looking to get the maximum index, get the size of the Y array and then subtract one (based indices are zero-based). In the last VI, you weren't getting the latest Y value, you were getting the first Y value in the latest block of data. Quote Link to comment
vhha1972 Posted August 29, 2012 Author Report Share Posted August 29, 2012 Hi Asbo, Thanks so much. I tried your code. The last y-value is OK (updating). But last x-value is stuck at 999 (not moving). Please see attached. Saif EX_B.vi Quote Link to comment
vhha1972 Posted August 29, 2012 Author Report Share Posted August 29, 2012 For example, when I write data to a lvm file from two channels, I get one time column and two y-value columns. Please see attached image of lvm file. I want access to the latest elements of this file while I am running my program in Labview. Cheers, Saif Quote Link to comment
vhha1972 Posted August 29, 2012 Author Report Share Posted August 29, 2012 Hi All, I will try to explain my problem a bit more... When I run my VI, my pressure pump starts running, and pressure in the system starts to increase. I want to calculate pressure (P) over time (t) ratio (P/t) at the instant the rising pressure crosses 80mmHg. The attached VI does something close. Only thing is that I want the FIRST P/t value when this condition is met and want to use it further. So, I want that first P/t to be stored somewhere temporarily while the program is still running. Based on the first instant of P/t when the pressure crosses 80mmHg, I want to run a motorized leakage valve for a time period proportional to P/t. So, I have 2 problems: (1) How to hold/latch the P/t value associated with the instant when rising pressure crosses 80mmHg. (2) How to send voltage signal to motorized valve only for a fixed duration (range ~ 1-2 seconds), based on the detected P/t ratio. Thanks! VI Attached. EX_C.vi Quote Link to comment
vhha1972 Posted August 29, 2012 Author Report Share Posted August 29, 2012 This is how my pressure versus time graph looks like... Quote Link to comment
asbo Posted August 29, 2012 Report Share Posted August 29, 2012 The waveform you get from your DAQ is not continuous, it looks like you're just requesting 1000 samples each iteration. You'll need to use a shift register to maintain a rolling count and add that value in with your latest array size. Quote Link to comment
Saverio Posted September 4, 2012 Report Share Posted September 4, 2012 This is also another cross-post from NI: http://forums.ni.com/t5/LabVIEW/How-to-get-time-stamp/td-p/2136340 At some point along the way it seems the question changed. I lost track jumping back and forth. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.