Experiment 16 -- Triangle wave data

This notebook assumes that you have already used the Exp16 Helper.nb notebook to acquire Square Wave data, and you understand how to set up a data point and acquire it using the procedure in that notebook.

This notebook is not saveable using ctrl+S or using Save from its File menu. You must use Save As... or shift+ctrl+S.

Saving the CurveFit data set!!

What follows is the command you get from the CurveFit main palette selection Data I/O : Save File.
Give the filename a .dat extension. It will generate a standard CurveFit data file.
Evaluate the following cell to save your CurveFit data set:

With[  {name = SystemDialogInput["FileSave", DataFileName]},
  If[ name =!= $Canceled, SaveFile[name]]
]

Erase the current CurveFit data set:

EraseData[] (* Use Undo[] to recover data *)

Frequency and Gain Values should have already been determined

Use the frequency already defined in the Exp16 Helper.nb notebook. Evaluate the following cell to display fo and the already defined values for the gain function g[ ]. Follow the procedure in Exp16 Helper.nb to check the gain values for the various input voltages (RMS) and update these values if necessary.

(* Frequency where gain is measured in Khz *)
fo (* kHz *)

Information[g]

Triangle Wave

Set up the Triangle waveform

Select the Ramp waveform. Select the Symmetry option. Set the value to 50%.

Start with Amplitude = 100 mV RMS. You will then use g[100.] for initial gain value.

Common Values used for the Triangle wave calculations

Coefficient values which are common to all terms in the Fourier Sine series for a Triangle Wave with unit amplitude.
Evaluate the following cell:

(* Coefficient value which is common to all terms in the Fourier Sine series for a Triangle Wave with unit amplitude. *)
Co =8./(Pi^2)
(* Factor to convert Triangle input waveform RMS to peak amplitude. *)
rms2peak = Sqrt[3.]

1 st Harmonic (Fundamental)

The harmonic number and the corresponding frequency for the signal generator. Evaluate:

h=1; (* Harmonic number *)
fset = fo/h  (* Set signal generator to this frequency *)

Edit Vin and Vout values and evaluate the cell:

Vin  =100. (* mV RMS: Triangle wave amplitude *)
Vout=278.381  (* mV RMS: Filter output voltage *)

Vcorrected =Vout Sqrt[2.] (h^2)/g[1.0 Vin] (* multiply by (h^2) for the Triangle *)
Vratio=Vcorrected/(rms2peak Vin)/Co

The final result ideally should equal 1. Evaluate the next cell to add the data point to CurveFit:

AddData[h,Vratio,"Triangle Wave Data"]
(* Use the Undo button on the Data Viewer window if it doesn't look right *)

3rd Harmonic

The harmonic number and the corresponding frequency for the signal generator. Evaluate:

h=3; (* Harmonic number *)
fset = fo/h  (* Set signal generator to this frequency *)

Edit Vin and Vout values and evaluate the cell:

Vin  =100. (* mV RMS: Triangle wave amplitude *)
Vout=30.67  (* mV RMS: Filter output voltage *)

Vcorrected =Vout Sqrt[2.] (h^2)/g[1.0 Vin] (* multiply by (h^2) for the triangle *)
Vratio=Vcorrected/(rms2peak Vin)/Co

Check that result seems reasonable and, if so, evaluate the next cell to add the data point to CurveFit:

AddData[h,Vratio,"Triangle Wave Data"]
(* Use the Undo button on the Data Viewer window if it doesn't look right *)

5th Harmonic

Ditto for this harmonic, except increase to 500 mV RMS for Vin.  g[ ]. Follow the procedure in Exp16 Helper.nb to measure and define the gain value g[500.] if necessary.

h=5; (* Harmonic number *)
fset = fo/h  (* Set signal generator to this frequency *)

New signal generator RMS voltage amplitude and the filter’s output AC RMS voltage measurement:

Vin  =500. (* mV RMS: Triangle wave amplitude *)
Vout=55.4  (* mV RMS: Filter output voltage *)

Vcorrected =Vout Sqrt[2.] (h^2)/g[1.0 Vin]
Vratio=Vcorrected/(rms2peak Vin)/Co

Evaluate the next cell to add the data point to CurveFit:

AddData[h,Vratio,"Triangle Wave Data"]
(* Use the Undo button on the Data Viewer window if it doesn't look right *)

nth Harmonic (copy, edit, and evaluate to add more Triangle wave harmonics)

Follow the procedure in Exp16 Helper.nb to measure and define additional gain values such as g[1000.] if necessary.

The harmonic number and the corresponding frequency for the signal generator:

h=7; (* Harmonic number example *)
fset = fo/h  (* Set signal generator to this frequency *)

New signal generator RMS voltage amplitude and the filter’s output AC RMS voltage measurement:

Vin  =1000. (* 1.0V RMS Triangle wave amplitude for this example *)
Vout=56.37  (* mV RMS: Corresponding Filter output voltage from Voltmeter app *)

Vcorrected =Vout Sqrt[2.] (h^2)/g[1.0 Vin]
Vratio=Vcorrected/(rms2peak Vin)/Co

Evaluate the next cell to add the data point to CurveFit:

AddData[h,Vratio,"Triangle Wave Data"]
(* Use the Undo button on the Data Viewer window if it doesn't look right *)

Fit the data:

Evaluate the following cells to have CurveFit fit your data points:

LinearDataPlot[ImageSize->400]

All data points ideally should have y = 1.0, so fitting to a constant is appropriate:

ConstantFit[]

Because our code sets the Y sigmas to the standard deviation, the reduced Chi-squared will be identically 1.0

LinearDifferencePlot[ImageSize->400]

Saving the CurveFit data set!!

What follows is the command you get from the CurveFit main palette selection Data I/O : Save File.
Give the filename a .dat extension (TriangleData.dat, perhaps?). It will generate a standard CurveFit data file.
Evaluate the following cell to save your CurveFit data set:

With[  {name = SystemDialogInput["FileSave", DataFileName]},
  If[ name =!= $Canceled, SaveFile[name]]
]