From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time stamp woes

Solved!
Go to solution

Attached is a code I am building to generate and acquire waveform signals and then write them to a text file with appropriate time stamps. As it stands, I have only linked up the writing portion to the acquired signals (I plan to write generated signals next); however, my time stamps are not being written alongside my voltages, as I was expecting them to. I have had some trouble with this (probably because I am an absolute novice at this), but would appreciate some expert knowledge in this area. Can anyone help me out? The code and a text file from a dummy test are attached. Thanks!

Download All
0 Kudos
Message 1 of 11
(3,237 Views)

Your pink shift register is not wired on the left side. You have created a plain tunnel over it by accident..

 

Here's how it loooks if I move the tunnel downwards.

 

 

(I have not looked at the rest of your code, so there could be other issues. For example you should definitely use "build array" instead of "insert into array". Plain autoindexing would work too, but you should rework it into a state machine where saving is just a state that does not need a program stop.)

Message 2 of 11
(3,230 Views)

Thank you. Indeed, I had a tunnel hiding in there, which I fixed. However, that wasn't really the main problem I was having with this program. Now I have inserted a function to Get Waveform Components (for purposes of having a bundled data type with time stamps); however, it seems the data wire leaving my DAQmx Read function is of the wrong type to wire directly to the Get Waveform Components function. Any help resolving this issue would be great. Attached is an updated version of the program.

0 Kudos
Message 3 of 11
(3,143 Views)

The wire leaving the DAQmx read is a 1-D array of waveforms.  (Turn on context help Ctrl-H and hover over the wire so you can see the datatype and find out why it wont' connect.)  This makes sense because your are reading N samples N channels.

 

Get Waveform components expects a waveform.  You you need to use Index Array to get out one of the waveforms from the array of waveforms.

0 Kudos
Message 4 of 11
(3,127 Views)

You don't have a waveform, but an array of waveforms. Just wrap an autoindexing FOR loop around the "get waveform components" and (inside this loop) rebundle each to get an array of bundled data, one for each channel, at the right loop boundary.

 

 

0 Kudos
Message 5 of 11
(3,126 Views)

Thank you. I used the Index Waveform Array function and that seemed to do the trick. Since I've got this thread going already, I have a few more questions.

 

My end goal is to write voltages in one column and corresponding time stamps in an adjacent column.  What I get when I run a dummy test (writing 1000 samples of an 8000 Hz, 1V square wave signal, sampling at 16000 Hz) is attached as a text file. I see three columns - one for the time stamp, check, one for the supposed input voltage, check, (though not sure why all the values are the same here?) and one more for I have no idea what. It's just a column full of zeroes.

 

Any insight on what the third column might be and why my voltage readings are flat in the second column? I would hazard a guess and say it is a sampling rate issue, though I can't pinpont what it is.

 

On another unrelated note, in an earlier version of this program, I was using shift registers, though I don't know if I need to be doing that now that I have a different code architecture.

Download All
0 Kudos
Message 6 of 11
(3,084 Views)

Well the third column is Knob Input.  I do not know what you intended with that knob.


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 11
(3,078 Views)

As a follow-up to my last post, I figured out that the third column is the time step, dt. The fact that it calculates 0.00 for every sample reading, tells me something is amiss in my code. I have tried running the code with an analog trigger setting on the input side, but that didn't make a difference. I still get the same output file (see attachment in previous post). It seems to me that the text file is being filled up (written) before the input side even sees the output side signal, but my debugging procedure (highlight execution) does not necessarily agree with this hypothesis. Any advice at all would be a great help. Thanks in advance!

0 Kudos
Message 8 of 11
(3,039 Views)

Thank you. I removed the knob (as this must have been an artifact from the example I grabbed that portion of the code from) and wired the actual time step, dt, value so that it is written in the third column of the output file. Attached in my current code and a screenshot from the GUI settings for a dummy test. The results of the dummy test are also attached as a text file. Now I guess my problem is the fact that all of my acquired voltages are the same value, which is incorrect, given the settings in my GUI.

Download All
0 Kudos
Message 9 of 11
(3,036 Views)
Solution
Accepted by topic author UARK

Hi UARK,

 

I just ran your VI with a simulated device, and was able to read in appropriate data (it wasn't all constant).  Try opening up a Test Panel in NI MAX to view the data that your device is reading in, and check whether this data is constant.  If so, this is an issue with your hardware rather than your LabVIEW program.  That being said, this issue is pretty different from your original post, and I would suggest creating a new forum post for it altogether so that more people see it.

 

Thanks,

 

Myriam D.

Applications Engineer

National Instruments

0 Kudos
Message 10 of 11
(2,991 Views)