Showing posts with label LabVIEW. Show all posts
Showing posts with label LabVIEW. Show all posts

Tuesday, July 6, 2010

LabVIEW: Windowing Program

Hello everyone,
Sorry for the delay. Last week and yesterday I spent most of my time fiddling around with LabVIEW. Currently I have a program that takes two inputs waveforms (reference and sample THz signals), plots them in time, allows for the selection of 1 region of interest for each, then apodizes those sections, and through the use of an FFT, finally plots their phases and magnitudes versus frequency.The front panel starts off with separate reference and sample time plots. Cursors 0 and 1 allow the user to select the ROIs. The effect of different apodization functions (aka smoothing and window functions) on the ref and sample sections can be observed in the graphs below. To the left of these graphs there is a ‘Windows’ drop down menu with an accompanying number slide bar. And below all of this are the phase and magnitude versus frequency plots of the apodized waveforms. There is a stop button on the front panel because, as will be shown in the block diagram, the functions being performed are in a while loop. This allows for the run to be continuous, thus allowing for uninterrupted observation of the changes the user makes in the front panel.
Much of the block diagram is reminiscent of my first program, which was explained in full detail in a previous blog post. The new VIs include:
  • Extract Portion of Signal - This extracts the ROI defined by the cursors, replots it on the original graph where it is highlighted, and feeds the waveform data into the windows 2 subVI.
  • Windows 2 – This subVI I customized (with Bianca’s guidance) to allow the user to select different apodization windows and input parameter values when needed. This was done by creating a case structure containing cases for every window function. The user can select which window function he or she would like to use through the drop down menu on the front panel. The menu item selected has a numerical value attached to it that informs the case structure which case to perform. The waveform is then reconstructed with the new apodized amplitude values. *I will explain what such functions do, the motivation for why they are applied, and discuss which ones are/aren’t advantageous for the particular THz data I’m working with. Expect this in the next blog entry.*
  • Align and Resample - This VI looks at both the apodized reference and sampled waveforms and makes the following changes: resamples both using the lower dt of the two, and makes the waveforms equal length by appending a zero amplitude tail at the end of the shorter waveform. *This is important when it comes to sampling in the frequency domain and parameter extraction, which will also be explained soon.*
  • FFT – The temporal waveforms undergo a Fast Fourier Transform with the use of this VI. The THz radiation signals can be plotted as phase vs frequency and magnitude vs frequency graphs.
  • While Loop- All of these VIs are contained in a while loop. The user can now note immediate changes to the graphs as he or she changes ROIs, window functions, or window parameters.

Wednesday, June 9, 2010

1st LabVIEW Program: Time Sample, 1 .txt file, 1 ROI

Hello everybody,

So I have completed my first LabVIEW program as you can read from the title. Sorry it took so long for me to post this. I had a lot of help from online tutorials and Bianca. I really hope not to bother her so much for the next couple of ones but I'm still learning the ropes. Programming has been pretty fun; I feel like I can see myself getting it more every time I open up the program. Hopefully I don't hit a wall. I'm gonna have to progress into more complicated programs (all before my trial versions of the software end, 19 days remaining). It's going to expand into multiple regions of interest (ROI), mathematical operations and transforms, and possibly multiple data sources. But let's not count any chickens. I got a lot of reading to do as well so I will have to find a way to balance my time wisely. My focus is going to be on THz-Time Domain Sprectroscopy (TDS), which includes Time Domain Trans/Reflection Spec (TDTS and TDRS).

Anyway, here's what my program looks like. I plan to explain the diagram and front panel in detail so now would be the time to stop reading. Just kidding.. But seriously.
Image of single text file and single region of interest time sampling program.

I suggest to open the image in a new window beside this blog post so it's easiest to follow along.


The Front Panel
As I have mentioned before, the front panel is what the user will see when they open up the LabVIEW program. At the top left the user is asked to input a data file, which in this case is strictly a 2 column .txt file spreadsheet. Once selected the user can click Run (arrow button right below the file menu) and the data points in the spreadsheet generate a waveform on the plot. There are also two cursors, Start and End, on the plot. These cursors can be moved around freely but snap their coordinates to the data points they intersect on the waveform. The cursor legend below the file input indicates the name, color, and coordinates of the cursors. Note green, Start, cursor ahead of red, End, cursor. Once the cursors enclose a desired region of interest the user can click Run again and the data table below the plot will produce max and min information such as amplitude, time on the plot, and index.

Block Diagram
All the work behind creating a user friendly interface can be found here. The block diagram starts with the File Path VI which allows you to open a .txt file. Once entered, it's read by the Read From Spreadsheet VI (block with glasses) and spat out as a 2D array (orange line). The transpose port at the bottom of this block is set to true because the text file data points are arranged in one time column and one amplitude column, and LabVIEW likes to work with rows of data types. The 2D array information is sorted out by the Index Array function. With this VI you can select 1D sub-arrays and individual elements. Elements t1 and and t0 are selected and then subtracted to get dt. Then element Y0 (first amplitude point) is subtracted from the Y array in order to baseline the amplitude data values. So now dt and Y are fed into the Build Waveform VI and can output a Waveform Graph. On this plot two cursors are added and assigned Property Nodes. A Cursor List VI (which is in the form of a cluster) containing information for Start and End cursors hat used. The information is then sorted out using an Index Array again (with Start indexed as 0 and End as 1). The output of the VI is still in cluster form but using the Unbundle by Name VI the X, time , position of each cursor can be singled out. The reason why this is done is because tstart and tend define your region of interest and are used to reproduce the selected waveform section with the help of the Get Wave Subset VI. The Statistic Express VI then gives you the values, times, and indexes of the max and min amplitude points. Indexes (unlike time and amplitude) are reset at the start of the cursor so, for example, the index of the max is relative to the cursor instead of the original plot. We want index relative to the original plot so just like before when the cursor 'Position X' was unbundled by name, we do the same for Index of the Start cursors and add it to the index of the max and min. This way we get Indexmax as indexed in the original plot not the sub waveform. All of the data components become Dynamic Data after the Statistic VI so they are converted into scalar form through a conversion VI and bundled by name. This way I can add a neat array indicator with labels. Et voila!

Tuesday, June 1, 2010

'Getting Started with LabVIEW'

Bianca and I went over essentially what she wants me to do. There is no THz setup to experiment with for now, but plenty of data to process and convert into a more clear and tangible form. And that is what I will be accomplishing during my stay here.

Like I described in my previous post, the THz setup signals ultimately take an electrical form like voltage or current before they reach a computer. Each collected data point is assigned a voltage amplitude and time for example. These points can be manipulated to reveal a whole lot of Time Domain Spectroscopy (TDS) information. But first getting the time sampling into a waveform can be very useful and better all around if you want to progress into spectroscopic evaluation. And all this can be done through LabView.

LabVIEW is a software package that enables its users to work with 'virtual instruments'. With this software you drag, drop, and define function and control blocks the way you would type and arrange code for a MatLab mfile in order to execute a program. Not only are these blocks time saving and easier to visualize, they also include many signal processing functions.
LabView Front Panel and Block Diagram screen shot (I recommend clicking on it to enlarge the figure)

Two major windows you can work with are the block diagram window and front panel. The front panel (gray background) serves as the interface for the user. Here data is displayed and saved. The block diagram (white background) is where all the dirty work happens. Blocks can be added and arranged as needed, and display desired features on the front panel.

The plan is to create a front panel that is easy to navigate and allows the user to look at time sampling files (simultaneously if desired) of either .txt, NASA software, or .picotd files. The output will be in graphical form that can be inspected by the user. Data from the selected sections of the graph, which I'll call Regions of Interest, will be displayed by a table. There are certain things to note when working with these different file types:
  • .txt : Have no headers to work with. Data appears in two columns (1: time, 2: Amp). Time increment, Δt, between measurements is determined by [t_2 - t_1].
  • Nasa : Are text files but with one column of data (Amp). Must know time sampling window (80 ps or 320 ps) and total data points. Δt is equal to [sampling window time/total # of data points].
  • .picotd : Contain two columns of data like .txt, but contain headers that are ~185 characters long. A special block that skips over characters must be added to the diagram. Δt can be found following the same procedure for .txt files.
The user will be prompted to specify the file type and then LabVIEW will know what path to direct towards.Front panel scheme for a single .txt file

For now I am starting small and will develop a simple program with one .txt data file. From there I will develop programs for NASA and .picotd files.


Here's to programming!