WinTDR wavefile import macro version 1.0
TDR trace reflection coefficient computation macro 1.0

Introduction

These two Excel 97 macros were written for use with data acquired from WinTDR '98.  

Use of these macros is at the user's own risk!!!  I am NOT responsible if your data is ruined by use of these macros for whatever reason (you should back you data up somewhere prior to use).  

These macros are written in Visual Basic for Applications and I have included the source code should you desire to modify the code for your own personal reasons (do so at your own risk!).

Usage in Excel 97:  

1. Open "WinTDR macros.xls" and enable the macros.
2. Go to the "Tools/Macro/Macros..." menu or press "ALT+F8".
3. Click on the macro you want to run:
	a. 'wintdr macros.xls'!WinTDRtraceImport
b. 'wintdr macros.xls'!ComputeRC	

Overview

WinTDR waveform import macro version 1.0 ('wintdr macros.xls'!WinTDRtraceImport)

	This macro reads in sequential screens of TDR data (as in if you wanted to piece together a waveform with a D/D of 0.1 m for 10 meters, which is comprised of 10 screens of WinTDR data or 10 Excel worksheets) and orders them such that in the end you have one long waveform.  It can process up to 84 waveforms.

	Ideally you should have collected your data using having checked the "Wave 2nd Line" and unchecked the "Wrap wave" in the "Preferences/Wave File Format" menu.  Please note that you should examine your data prior to importation- very often you may have unwanted traces saved in a previous format than the data that you collected.  You should delete extraneous data as the macro identifies that data type that is in the file and then assumes that all subsequent data are identical.  
	IMPORTANT!  All worksheets/screens must have the same number of waveform data sets. 

	The macro assumes the following:
1. The first screen of the trace is the rightmost worksheet, and the leftmost the last.
2. The active cell in all worksheets is cell "A1".
3. The data has at least 2 lines and header data of 6 cells.

	Please note that 1 line data are not importable as they can have more than 256 data points and Excel has a limit of 256 cells per row.

	The macro does the following:
1. It checks and sees if the data exist in two or three rows.
2. It counts the quantity of data.
3. If necessary it converts 2 to 3 line data, that is that it adds a row and if necessary separates header data such as dates, times, etc. from trace data.
4. It then transposes all data to columns.
5. If necessary the waves are then "unwrapped", that is to say that they are made into strips of 251 data points.
6. The strips are then copied sequentially from each "TDR window" to the end of the trace.

TDR trace reflection coefficient computation macro 1.0 ('wintdr macros.xls'!ComputeRC)

	This macro goes through a waveform and computes the reflection coefficient for the entire waveform.  Upon running the macro you will notice that a dialog box opens.  As I have been very lazy you must know how many waveforms you need to process, how many data points are in them, how many columns the data are in and if you want the macro to add a new column for the reflection coefficient data.  You should check the "add column" box if your data does not contain empty columns to the right of your data as it computes the reflection coefficient in the column next to the original data and will therefore overwrite the data in it.
	The macro assumes that you start it in the first datapoint of the first waveform that you wish to import.  Note that the dialog box will not close until you click on "Cancel/Close".  The macro computes reflection coefficient using the following equation:
	RC = (vdp - vline)/ (vdp + vline)
	Where RC is the reflection coefficient, vdp the value at a given data point, and vline the average value of the first six data points in the waveform and is assumed to be the 50 ohm coaxial cable impedance. 

Notes on Usage of the macros:

1. These macros run very inefficiently such that the faster the computer the better.  Yes, I am aware that they are not the pinnacle of Microsoft Office Visual Basic programming.  I made numerous efforts to make them more efficient but failed as:
a. Excel 97 does not appear to allow for relative referencing of areas in macros, i.e., that I cannot use a mathematical equation to define an area and am therefore doomed to using For loops to do everything.
b. Dammit Jim I'm a geologist not a computer programmer!
2. When running these macros- DON'T DO ANYTHING ELSE ON THE COMPUTER!!!  I discovered that the macros do not work properly (i.e. ruin the data, etc.) when I did other things on the computer such as chat on ICQ, etc.  In fact, keep that in mind for any macro you run.
3. I will try and update these macros soon so that they are more "intelligent" or user friendly.

If you have any comments/ suggestions/ etc. let me know.  You can do so via email to serbin@mail.bgu.ac.il

Please note that Microsoft, Excel 97, Microsoft Office, and Visual Basic for Applications are trademarks of the Microsoft Corporation (or so I believe, if I missed anything anywhere or made a mistake please don't sue me).
