Discussion:
plot and save digital waveform
(too old to reply)
JaredW
2008-01-02 16:40:06 UTC
Permalink
Q1: There is not a concept of a Digital Chart yet in LabVIEW. However, you can get around this by using a shift register in your while loop, and append the previous waveform with the new waveform, and then plot the new waveform. There is a VI in the Digital Waveform palette for concatanating two waveforms called "Append Digital Samples.vi". This VI only takes a single DWDT, not a 1D Array of DWDTs, so you will need to put it in a for loop that indexes through each element of your 1D arrays. See attached screenshot.
Q2: The dynamic datatype in LabVIEW only supports the various types of Analog Waveforms, not digital waveforms. Also, the only LabVIEW graph that supports digital waveforms at this time is the Digital Waveform Graph. You can get around the histogram issue by following the suggestions made in the Q1 answer.
Q3: I agree that the file read/write functions are confusing with regard to which datatypes they support. Unfortunatly, digital waveforms are not supports by the file I/O VIs you are trying to use (even though the icon has a digital signal on it :smileymad: ). To save the data to a spreadsheet ascii file, you will have to convert the data to a spreadsheet string, and then save that string to file using the standard LabVIEW File I/O VIs. There is not an intuitive way to convert DWDT to ASCII, but there is a simple method to do it. First off, a DWDT is really just a 2d array of 0's and 1's. So fist you should convert your DWDT into a 2D array of U8, where each element represents a signal sample for one signal. Once you have the 2D array of 0's and 1's, you can use a control from the string palette called "convert to spreadsheet string", and pass it the 2D array. I've quickly created an example you can look at to get a reference for how to do this. Your situation is a little harder since you are using a 1D array of DWDTs, so I had to add a for loop that indexes each element (I also asssumed that each element of the 1D array only contains one signal).
Good luck,Jared
 
 Message Edited by JaredW on 01-02-2008 10:22 AM


combineDWDTSamples.JPG:
Loading Image...


DWDT Array to String2.JPG:
http://forums.ni.com/attachments/ni/70/7967/3/DWDT Array to String2.JPG
bachman
2008-01-02 21:10:07 UTC
Permalink
Thanks for your reply.I've tried to do as your pictures shows without luck :(   My DAQass read four digital inputs and my labview version is 8.0 where some icons doesn't look similar to your version or I cant find them without names.First problem is with the shift register. I get a dimension issue. Please see first attachment.The second problem is that I don't find the "0101|Data" that you use. I've tried with "empty digital data" but that doesn't seem correct and it only has one connection pin. Same about the rest of the icons.. it's hard to find them here :( . can you please give me the name of the icons you use so I can try to search for them?Q4: Is it possible to have a timescale in the digital waveform graph that simply starts from 0us and just counts... if us doesn't exist ms would work too. Currect is with date, or a long time format with 12:22:22,123   but I would only like more like a stopwatch that only counts in millis or micro starting from 0.Q5: Four digital inputs are read atm. I would like the writeout to be columns. First column should be the stopwatch starting at 0. And the second, third etc.. column should be state of the input.exampletime | di 1 | di 2 | di3 | di40         0      0      0      01         1      0      0      02         1      1      0      03         0      1      1      04         0      0      1      15         0      0      0      1and so on.. thanks /Bachman


shiftreg1.JPG:
Loading Image...


savetofile1.JPG:
Loading Image...
JaredW
2008-01-02 23:40:09 UTC
Permalink
Hey, I found a forum post pretty quickly on how to add headers to a spreadsheet string. This would be a good read for you.
<a href="http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=10512&amp;query.id=95854#M10512" target="_blank">http://forums.ni.com/ni/board/message?board.id=170&amp;message.id=10512&amp;query.id=95854#M10512</a>
JaredW
2008-01-02 23:40:09 UTC
Permalink
You are very close. I marked up your first screenshot showing where your errors are. You are not initializing the shift register with the correct datatype, you must use a 1D array of DWDTs, so the shift register has the same datatype as what you are using inside your while loop. That will get you running again.
Second, the 1010/data icon you mentioned is the "Get Waveform Component" unbundler. Looking at your other screenshot, it looks like you found it to get the "Y" data from the DWDT. Now just use it again to retrieve the data from the "Y" component. The unbundler is polymorphic and will adapt to the type of data wired into it (and the icon will change:smileyhappy: ).
The reason you are using the undundle functions is to get the root data from the waveform. A Digital Waveform is really a combination of a Digital Table (Y), a Timestamp (To), and a time interval (dT). A Digital Table (Y), is made up&nbsp;of a 2D array of U8s (data), and a 1D array of U32s (transitions). The 2D Data array has the 1's and 0's of the waveform. The first dimension of the array is the samples, the second is the signals.
Now onto the timestamp question. The DAQ VI is likely adding a timestamp to your waveform, and the graph is showing that value to you. If you right click on the graph and check the "ignore time stamp" item, the waveform will always start with 0, and count up by dT.
For the last item, you will already have the data in a spreadsheet formated string, so you will just need to add the row/column headers. Start by reading the LV help in regards to all of the functions and VIs in the strings palette. You will just have to do some tedious string manipulations to get the row/column header names added.
&nbsp;
&nbsp;Message Edited by JaredW on 01-02-2008 05:21 PM


shiftreg1.jpg:
Loading Image...
bachman
2008-01-03 13:40:08 UTC
Permalink
I've tried to do the initialize of the shift register. But I don't sort it out :( I'm unsure how to do it and at the moment it looks like I've messed my "empty digital waveform" so I cannot connect anything to it at all anymore. How do I reset it to the defaults? My wires doesn't have that diagonal icon I can see on your. I've attached a screen of my environment, but I can't find the icons that you've been using without knowing their name. For some reason my lines (the dual blue ones) doesn't look like yours. you have a single blue line. I've tried to create a numeric control and connect it outside the for loop. But I don't get anything even near your picture screenshot :(I would be grateful if you could give me a hand on my attached workspace or attach yours. I have really made a genuine try to build an environment similar to yours to save my data. But I've failed.thanks alot /Bachman


savetofile2.JPG:
Loading Image...


measure with time.vi:
http://forums.ni.com/attachments/ni/70/7979/2/measure with time.vi
JaredW
2008-01-03 16:40:08 UTC
Permalink
You are newer to LabVIEW than I had originally assumed. I want to just get you the VI but I don't have LabVIEW 8 or DAQ, so the screenshots&nbsp;were my best attempt at helping you out quickly. Since that is not working I'm in the process of getting LV 8 and DAQ.
In the meantime, let's talk through some of your issues. First the shift register initialization. Rather than you trying to redraw my screenshot, let's think through what you are trying to do. This will be a good LabVIEW exercise for you&nbsp;:smileyhappy: . The shift register needs to be initialized with an empty 1D array of Digital Waveforms. There are a number of ways you can do this. There are build array functions in the array's palette, there are constants that can be created on the block diagram, there are Front Panel controls that can be wired to the shift register, etc. In my screenshot I chose to create a front panel control that was a 1D array of Waveforms. I then wired that control to the shift register. I did that because I didn't realize the "empty waveform" VI that you are using existed in LabVIEW 8 ( I thought that was a LV 8.2 feature). I recommend you continue to use the Empty Waveform VI to create a single waveform, but you still need to create a 1D array of waveforms. In conjunction with the Empty Waveform VI, there are two different&nbsp;methods to do this using one of two different&nbsp;VIs from the array palette. Here begins your first lesson, can you find one of the 2 methods for building or&nbsp;initializing an array from a single data type value?
Now into your for loop. You are passing your 1D array of Digital Waveforms into the for loop. The For Loop is automatically indexing one element at a time from that array for you, and the For Loop will loop one time for each element in your array. This happens because when an array is passed into a For Loop, you can right click on that node and choose whether it is auto-indexed or just passed straight through. Now inside the for loop, you are getting the 2D array of digital values component from a single waveform. The first index of this 2D array is all of the samples for a signal channel, the 2nd index is all of the channels.Now you only want the samples for the first channel from the 2D array. That information is contained at the first index of the first dimension of the 2D array. Therefore you will want to index out a subarray from the 2D array. There is really only one array VI in the array palette for doing this. Can you find which on it is? In your screenshot I'm looking at your VI, you have chosen the incorrect one.
Reply back as soon as you've tried these two things. By then I should have found a LV 8 and DAQ installation. Message Edited by JaredW on 01-03-2008 10:14 AM
bachman
2008-01-03 19:40:08 UTC
Permalink
Hi, I've tried made the exercises ... I hope I got both correct. Please see attachment. Btw, I've also attached my measurement that at least works (even if I've not :( succeed saving the data on file, what we are working on right now) as a second file, bild1.jpg. What I actually want to do later when I got the logging to file working is to analyse when the state changes occur. The jitter in between the three channels. For example. Does a state change take longer time between the first/second to high the second time than the first time? I will try to get a histogram or similar in labview (or matlab?) that decribes the variance between the three channels. Buf first I must have the data logged to a spreadsheet or textfile that is possible to import.Had any luck searching for labview8?/Bachman


exercise.JPG:
Loading Image...


bild1.JPG:
Loading Image...
JaredW
2008-01-03 20:40:13 UTC
Permalink
Ok, having your version of LV helps. The experience of using Digital Waveforms has been much improved since LV 8.0.
&nbsp;
I have worked up a VI that tries to mimic what you were trying to do. Hopefully this helps you understand how to work with digital waveforms a little better.
&nbsp;
In order to do the jitter analysis, there is a VI in the digital palette called "search for digital pattern.vi". You can use this VI to search for a 0,1 pattern to find the timestamp of a rising edge. Then you can search for the 1,0 pattern, which would give you the timestamp for the falling edge. Then you can do the math on the two timestamps for your analysis.
&nbsp;
-Jared


measure with time.vi:
http://forums.ni.com/attachments/ni/70/7982/1/measure with time.vi
bachman
2008-01-04 01:10:09 UTC
Permalink
Jared, I'm very grateful for all your help! I've started to get things going. I do writeout strings to file also. Please see attachments. There's still one major thing missing and it's a time column :( I would like it like:time (us) | di1 | di2 | di31&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 1&nbsp;&nbsp; &nbsp;&nbsp; 0&nbsp;&nbsp; &nbsp;&nbsp; 02&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 0&nbsp;&nbsp; &nbsp;&nbsp; 1&nbsp;&nbsp; &nbsp;&nbsp; 0..&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; ..&nbsp;&nbsp; &nbsp;&nbsp; ..&nbsp;&nbsp; &nbsp;&nbsp; ....&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; ..&nbsp;&nbsp; &nbsp;&nbsp; ..&nbsp;&nbsp; &nbsp;&nbsp; ..I to sample at rise and fall for all three DIs. And it is those instants that I see the states for in the spreadsheet/textfile. A timestamp in the first column with good resolution would be great. Do you have any suggestions on how to solve that?I've yet not started to look at they Jitter analysis. My idea was to first get the timestamp included in the text file and then probabily continue the analysis in Matlab or similar tool where native peep can give support when needed.thanks /Bachman


bild2.JPG:
Loading Image...


minfil.txt:
http://forums.ni.com/attachments/ni/70/7988/2/minfil.txt
JaredW
2008-01-04 15:10:07 UTC
Permalink
The easiest way to add timestamps would be to add it to the 2D array before it is sent to the "Array to Spreadsheet String.vi". You simply just have to append to the first index of the 2D array your 1D array of timestamps. Since your 2D array is actually U8 values, I would recommend converting it to DBLs before appending the timestamp array to it. This way you have better resolution for the timestamps.
Before I just do this for you, I want to give you a shot at it :) . Hint #1, to convert a 2D array of U8s to another type, use one of the conversion VIs from the numeric palette. Hint #2, you have already learned how to add data to an array from early posts.
Don't stay stuck for too long. Reply as soon as you have something either working or semi-working. Be sure to attach your VIs to the reply as well if they are not working.
&nbsp;
bachman
2008-01-04 20:40:11 UTC
Permalink
I've tried to add a time (duration since start in ms) to an array and then add the array to the 2d array. Unfortunetely I don't get it working :( no timestamp is added in first column showing the time at the instant :( I'll attach my workspace and a snapshot.thanks alot /Bachman


minfil5.txt:
http://forums.ni.com/attachments/ni/70/8006/1/minfil5.txt


test41.vi:
http://forums.ni.com/attachments/ni/70/8006/2/test41.vi


insert_timestamp.jpg:
Loading Image...
JaredW
2008-01-04 21:40:09 UTC
Permalink
The way you are creating your timestamp array is not even close to what you described to me that you wanted. So let us start there. You did get the combining array part correct :smileyhappy: .
It is incorrect to use theTick Count VI to create a timestamp array. The Tick Count VI will return to you the computers clock time in seconds at the point when it is executed. It is in no way representative of your data's timestamps. You are also only getting 3 tick counts in your VI, one for each of the 3 signals. I don't think this is what you wanted. Have you discovered probes yet. It is a debugging feature of LabVIEW that lets you see the data on a wire during execution. Right Click on any wire and select Probe. This will be useful in helping you find out where you are making programming mistakes. If you know what data you want on a wire, and it is not there, you then know that whatever logic put data on that wire must be wrong.
I assumed that you wanted a timestamp that reflects when each sample occured relative to some start time (probably zero seconds). You will need to create this array of timestamps by using the period of your acquisition sample rate, and buiding up an array of&nbsp;values [0, dT, dT x 2, dT x 3, dT&nbsp;x 4, etc]. The 1D array needs to be the same size as the number of total samples in your collected waveform. As difficult as that sounds, it is very easy to program this in LabVIEW. You can do this with a for loop that runs the same number of times as your waveform's sample count. Inside this loop, multiply the index (blue box in bottom left) by the dT (period) of your acquisition rate. Pass the result out of your for loop, and you will have your 1D timestamp array (be sure auto-indexing is turned on for the output). If you know the period by heart, you can just use a numeric constant. If you don't know it, then you can also get the dT component from one of your Digital Waveforms.
You've almost got it. You'll be a labVIEW expert in no time :smileywink:
&nbsp;
&nbsp;

Continue reading on narkive:
Search results for 'plot and save digital waveform' (Questions and Answers)
3
replies
How do I create a Sine Wave in Visual Basic 10?
started 2011-04-13 09:38:14 UTC
programming & design
Loading...