Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

plot and save digital waveform

Hi,
I'm a new labview user. I have problems plotting and writing digital to spreadsheet. My hardware is NI-USB-6251 and LW ver is 8, only digital inputs used.

Q1
First here is my workbench http://geting.se/viewimage.php?image=77262-measure1.JPG#
Is it possible to make continues plots? Right now it's just plotting 10 samples.. I would like it to plot constanstly as long as the state keep changing on the input chan. And the xaxis with time should just continue..

Q2
The Data output from the DAQ assistant is 1-D digital waveform. It seem to be hard to work with that 😞
Wherever I connect it complains that graphs want dynamic datatype. I've tried to convert to DDT, but that doesn't work. For instance I would like to plot a histogram which doesn't work.

Q3
Is it posible to save the data output of the DAQ assistant to a spreadsheet? I've tried to write to file using "Write to Measurement File", but then it complains that the source is 1D digital waveform and sink is DDT 😞

Some of the questions above might be trivial to a experienced user. But I've spent alot time to do this (basic?) measures already.
I assume that I will have to switch to analog even if it's ttl I'm measuring if I can't get this working.

grateful to help
/BK



0 Kudos
Message 1 of 13
(6,051 Views)

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 Smiley Mad ). 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
Download All
0 Kudos
Message 2 of 13
(6,024 Views)
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.

example
time | di 1 | di 2 | di3 | di4
0         0      0      0      0
1         1      0      0      0
2         1      1      0      0
3         0      1      1      0
4         0      0      1      1
5         0      0      0      1

and so on..

thanks /Bachman
Download All
0 Kudos
Message 3 of 13
(6,002 Views)

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 changeSmiley Happy ).

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 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.

 

 



Message Edited by JaredW on 01-02-2008 05:21 PM
0 Kudos
Message 4 of 13
(5,991 Views)

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.

http://forums.ni.com/ni/board/message?board.id=170&message.id=10512&query.id=95854#M10512

0 Kudos
Message 5 of 13
(5,988 Views)
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
Download All
0 Kudos
Message 6 of 13
(5,971 Views)

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 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 Smiley Happy . 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 methods to do this using one of two different VIs from the array palette. Here begins your first lesson, can you find one of the 2 methods for building or 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
0 Kudos
Message 7 of 13
(5,955 Views)
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
Download All
0 Kudos
Message 8 of 13
(5,943 Views)
Ok, having your version of LV helps. The experience of using Digital Waveforms has been much improved since LV 8.0.
 
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.
 
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.
 
-Jared
0 Kudos
Message 9 of 13
(5,935 Views)
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 | di3
1                 1      0      0
2                 0      1      0
..                  ..      ..      ..
..                  ..      ..      ..

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
Download All
0 Kudos
Message 10 of 13
(5,920 Views)