LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate digital waveform form a read from spreadsheet.vi

Hi, I'm very new to LabView and am having some problems in completing what I believed would be a very simple task.

I am using the Read from Spreadsheet.vi to read in an Ascii tab delimited file that I created in Matlab (the file is simple a vector of 1's and 0's that represent a binary stream) All that I want to do is take the output from this and generate a digital waveform corresponding to the 1's and 0's in the array but I cannot find a way of doing this.....

Help much appreciated,
Thanks.
0 Kudos
Message 1 of 9
(4,704 Views)

You should be able to just run your data straight  in to the digital write function as long as you select the correct port width of your hardware.

If you want to do it with a digital waveform it's a bit trickier, the digital waveform data type is a surprisingly complex animal.
There might be a better way to do it, but this is what I've had to do in the past...
The "build digital data" function needs a 2D array in, so convert your 1D array into a 2D.
Then the digital data can be input into a Build Digital Waveform.
Then the digital waveform can be output with the write digital waveform.



Message Edited by Troy K on 03-23-2008 11:37 AM
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Download All
0 Kudos
Message 2 of 9
(4,694 Views)

I've made a few assumptions in my 1st reply...

1. That you've read your data in as an integer array and...
2. That you only want to output 1 line of digital data (as opposed to a whole ports worth) and...
3. That the following vi doesn't do what you want it to...

In the 'Programming' >> 'Waveform' >> 'Digital Waveform' >> 'Digital Conversion' palette there is a 'Spreadsheet String to Digital.vi'

This would be the easiest way to do it (you may have to manipulate your string a bit depending on how you want your output to work).

So instead of using the 'Read from Spreadsheet.vi', you could use the 'Read from Text File.vi' and feed the string into the 'Spreadsheet String to Digital.vi' as shown above.



Message Edited by Troy K on 03-23-2008 12:20 PM
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 3 of 9
(4,688 Views)

Thanks Troy K, I think one of my main problems was I was still using LabView 7.1 (I have since installed a newer version)
The Spreadsheet String to Digital.vi seems to do what I wanted... however I have run into another problem to do with writing the data to the digital output...

I'm using DAQmx write (Digital Wfm 1Chan NSamp) in order to output my data but this seems to ignore the timing of the input waveform.
In the The Spreadsheet String to Digital.vi I have set the sample rate to 1 and when I output this waveform to a digital graph I see the 1's and 0's spaced out by a second each. However, when I look at the output from my DAQmx write it seems to be doing it as fast as possible and not following the waveform correctly as a result. I expected the DAQmx write.vi to output the data with the same timing as the input waveform, what am I doing wrong?

Thanks.

 

0 Kudos
Message 4 of 9
(4,649 Views)
Yeah, the write function ignores the timing in the waveform and relies on the rate specified elsewhere.

When you set up the DAQmx task (in MAX or programmatically) you need to specify the rate in samples/second.

This sounds pretty straight forward but can actually be a bit tricky depending on the rate you want and the hardware you are using.

Give it a go. If it works, great, if not, then we can start looking at how to accomplish what you need to do for your hardware (why explain a complex method you may never need?).
If simply setting the rate produces an error or the wrong results, include what hardware you are using in your next reply.
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 5 of 9
(4,629 Views)
Ok, I put in a DAQmx Timing vi between before my DAQmx Write, however I havn't had much luck...

I can't remember the exact wording of the error as I am not in the lab, but whatever I tried with this vi was telling me I had selected an invalid sample type and I should be using On Demand... I couldn't see an option for this in that vi though.
Makes me think that perhaps my hardware (USB-6008) doesn't support timing with this vi?

Again thanks for the help.
0 Kudos
Message 6 of 9
(4,619 Views)
OK, the bad news is that the USB 6008 can't do hardware clocked output (digital or analog).

The only way to time your output changes is with software.
(You are at the mercy of Windows processes for software timing and USB so if you do it this way don't expect a lot of accuracy).
If you only want to clock the data out at 1Hz it may be OK.

You will just need to write 1 bit at a time in a loop with a 'wait millisecond multiple' to control the timing. (Or buy some fancier hardware)


Message Edited by Troy K on 03-26-2008 11:22 AM
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 7 of 9
(4,612 Views)
Ok, I've managed to get a digital signal out by using a while loop and the read from spreadsheet vi (see below), however I now have another little problem with regard to this vi.



I have attached the EOF? output to the conditional terminal of the while loop so that when the end of file is reached the loop should stop... but it doesn't as EOF never becomes true and the while loop just buffers my text file with additional 0's

I guess I need to put an EOF character at the end of my input text file (which is just a single row of tab delimited 0's and 1's) but I haven't been able to find out what this is or how to do it!
I've come across some old labview documentation saying EOF characters are platform specific and that it is CRLF in windows, but I couldn't get this to work...

I'm saving my text file in notepad at present using the default ANSI encoding at present

Thanks (it's almost working :))

Message Edited by Phoenix82 on 03-26-2008 07:40 PM
0 Kudos
Message 8 of 9
(4,589 Views)
Maybe use a for loop instead of a while loop. It will automatically index the values, then stop at the end.
The value of EOF wont change inside the while loop, it is determined before the while loop can even start.

I would recommend doing some training to learn a few of these concepts to make your future programs easier to write.
If you can get your hands on some of the LabVIEW Basics training manuals that would be a good start.
It will help clarify how a lot of the different functions behave.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 9 of 9
(4,579 Views)