Difference between revisions of "DNA Melting: Using the LockIn DNAMelter GUI"

From Course Wiki
Jump to: navigation, search
(Created page with "Category:20.309 Category:DNA Melting Lab {{Template:20.309}} == Description: == The Matlab DNA Lock-In GUI is called <code>DNALockIn.m</code> and is located in the <cod...")
 
Line 5: Line 5:
 
== Description: ==
 
== Description: ==
  
The Matlab DNA Lock-In GUI is called <code>DNALockIn.m</code> and is located in the <code>CourseMaterials/Labs/DNAMelting</code>. You may make a copy in your directory of choice, double click that copy to open the code in Matlab, then run the code via the Run button.
+
The LockIn DNA Melter GUI is located on the lab computer desktop. The LockIn version is similar to the Basic version; however the LockIn version provides for driving the LED, temperature control, and digital filtering.
  
DNALockIn is very similar to DNAMelter; however DNALockIn also provides for driving the LED and temperature control.
+
On the left side of the window, the LockIn GUI has panels for setting the LED carrier frequency and amplitude, for temperature control (min and max temperature as well as ramp times), for temperature control PID parameters, temperature sensor parameters, setting the lock-in phase, and choosing filter frequencies and bandwidth.
  
On the left side of the window, DNALockIn has panels for setting the LED carrier frequency and amplitude, for temperature control (min and max temperature as well as ramp times), for temperature control PID parameters, temperature sensor parameters, and setting the lock-in phase.
+
[[Image:GUILockInCarrierDetail.png|100 px|left]]
 
+
[[Image:DNALockInCarrierDetail.png|100 px|left]]
+
 
'''Carrier:''' Set the '''frequency''', '''amplitude''', and '''offset''' of the carrier waveform. Offset should always be greater than amplitude to keep the LED drive linear.  '''Rsense''' is the scaling resistor for setting the LED current.  Use the '''LED''' button to turn the LED drive on and off.
 
'''Carrier:''' Set the '''frequency''', '''amplitude''', and '''offset''' of the carrier waveform. Offset should always be greater than amplitude to keep the LED drive linear.  '''Rsense''' is the scaling resistor for setting the LED current.  Use the '''LED''' button to turn the LED drive on and off.
  
  
  
[[Image:DNALockInTemperatureDetail.png|100 px|left]]
+
[[Image:GUILockInTemperatureDetail.png|100 px|left]]
 
'''Temperature:''' The temperature control algorithm implements a temperature ramp from '''minT''' to '''maxT''' ('''Heat time'''), a hold at '''maxT''' ('''Hold time'''), then a ramp from '''maxT''' down to '''minT''' ('''Cool time'''), and finally a hold at minT until temperature control is disabled.   
 
'''Temperature:''' The temperature control algorithm implements a temperature ramp from '''minT''' to '''maxT''' ('''Heat time'''), a hold at '''maxT''' ('''Hold time'''), then a ramp from '''maxT''' down to '''minT''' ('''Cool time'''), and finally a hold at minT until temperature control is disabled.   
  
Line 23: Line 21:
 
Use the '''Reset''' button before starting a new temperature control cycle (after a previous test, an aborted test, or after using Go to min T).
 
Use the '''Reset''' button before starting a new temperature control cycle (after a previous test, an aborted test, or after using Go to min T).
  
[[Image:DNALockInPIDDetail.png|100 px|left]]
+
[[Image:GUILockInPIDDetail.png|100 px|left]]
 
'''PID Gains:''' The program controls the temperature by turning the TEC on and off several times a second. The duty cycle (fraction of time the TEC is on) is determined by a PID algorithm:
 
'''PID Gains:''' The program controls the temperature by turning the TEC on and off several times a second. The duty cycle (fraction of time the TEC is on) is determined by a PID algorithm:
 
::::: <math> {\rm DutyCycle} = P T_{\rm err} + I \int T_{\rm err} dt + D \frac{d}{dt} T_{\rm err} </math>
 
::::: <math> {\rm DutyCycle} = P T_{\rm err} + I \int T_{\rm err} dt + D \frac{d}{dt} T_{\rm err} </math>
Line 29: Line 27:
  
  
[[Image:DNAMelterSensorDetail.png|100 px|left]]
+
[[Image:GUISensorDetail.png|100 px|left]]
 
'''Temperature sensor:''' It is important to set the '''Vref''' and '''Rpullup''' parameters each time DNALockIn is run, so that the temperature is computed accurately. (Remember you are attempting to determine the melting ''temperature'' of a DNA sample.) Vref is the actual voltage supplied either by the reference or +15V supply, and Rpullup is the "pull-up" resistor in the temperature circuit. Rt0 is the sensor resistance at 0 C (1000 ohms) and alphaT is the sensor temperature coefficient (3.85 ohm/degree).  Rt0 and alphaT should not be changed unless a different type of temperature sensor is used.
 
'''Temperature sensor:''' It is important to set the '''Vref''' and '''Rpullup''' parameters each time DNALockIn is run, so that the temperature is computed accurately. (Remember you are attempting to determine the melting ''temperature'' of a DNA sample.) Vref is the actual voltage supplied either by the reference or +15V supply, and Rpullup is the "pull-up" resistor in the temperature circuit. Rt0 is the sensor resistance at 0 C (1000 ohms) and alphaT is the sensor temperature coefficient (3.85 ohm/degree).  Rt0 and alphaT should not be changed unless a different type of temperature sensor is used.
 
   
 
   
  
[[Image:DNALockInPhaseDetail.png|100 px|left]]
+
[[Image:GUILockInPhaseDetail.png|100 px|left]]
'''Phase:''' Before starting a run, with a fluorescent sample in place and LED on, use the '''Phase''' slider to adjust the lock-in phase to maximize the fluorescence signal (upper-right graph).
+
'''Phase:''' Before starting a run, with a fluorescent sample in place and LED on, use the '''Phase''' dial to adjust the lock-in phase to maximize the fluorescence signal (upper-right graph).
 
   
 
   
 +
[[Image:GUILockInFilterDetail.png|100 px|left]]
  
DNALockIn graphs the fluorescence voltage signal as well as temperature data in multiple plots.  DNALockIn acquires the temperature and fluorescence signals at 200 kHz every 0.1 seconds (20000 data points).  Select signals and their associated spectra are displayed in the two left-hand graphs.  Florescence voltage and temperature (averaged over the 20000 points every 0.1 seconds) versus time are plotted in the upper right-hand graph.  Florescence voltage versus temperature is plotted in the lower right-hand graph.
+
The LockIn GUI graphs the fluorescence voltage signal as well as temperature data in multiple plots.  DNALockIn acquires the temperature and fluorescence signals at 200 kHz every 0.1 seconds (20000 data points).  Select signals and their associated spectra are displayed in the two left-hand graphs.  Florescence voltage and temperature (averaged over the 20000 points every 0.1 seconds) versus time are plotted in the upper right-hand graph.  Florescence voltage versus temperature is plotted in the lower right-hand graph.
  
Before starting a run, use the '''Clear Data''' button to clear out data accumulated from setting up or a previous run.
+
Before starting a run, use the '''Clear''' button to clear out data accumulated from setting up or a previous run.
  
At the end of a run, use the '''Save Data''' button to save to a file. The data will be tab-delimited and can be read into Matlab with the <code>load</code> command.  DNALockIn also continuously saves data to the file "DNALockInRunningData.txt".  Before restarting MATLAB and/or DNALockIn, copy this file to another name to save the data.
+
At the end of a run, use the '''Save''' button to save to a file. The data will be tab-delimited and can be read into Matlab with the <code>load</code> command.   
  
Troubleshooting: If Matlab gives you a data acquisition error, for example, "<code>NO DATA ACQUISITION DEVICE FOUND!</code>", open the Measurement and Automation Explorer ("MAX"), open the Devices and Interfaces drop-down on the left side, and make sure there is only one "NI USB-6xxx" entry and that it is called "Dev1." If it is not, or there is more than one device listed, physically disconnect the USB cable from your DAQ, then delete all "NI USB-6xxx" entries, then reconnect your DAQ, then verify that one entry reappears and that it is called "Dev1." Try to run the DNAMelter program again, and/or close it, re-open it, and run it again. If this does not work, consult a TA or Instructor.
+
Troubleshooting: If there is a data acquisition error, for example, "<code>Data acquisition cannot start!</code>", it may be the DAQ device is not working. Try physically disconnecting the USB cable from the DAQ box and then reconnecting it. The X-series devices (blue and silver boxes) have on/off switches: make sure it is on or toggle the power off and on. If that fails, open the Measurement and Automation Explorer ("MAX"), open the Devices and Interfaces drop-down on the left side, and make sure there is only one "NI USB-6xxx" entry and that it is called "Dev1." Try to run the DNAMelter program again, and/or close it, re-open it, and run it again. If this does not work, consult an Instructor.  
  
 
== Options: ==
 
== Options: ==
  
DNALockIn may be run in the Matlab command window or in another script as
+
Clicking on the icon in the upper-left corner or pressing Alt-space will bring up the system menu. The system menu contains options for showing the about box, and for saving/loading the current configuration.
: <code>DNALockIn</code>
+
 
or with optional Matlab-style 'Name', Value pairs which can be used to pre-set parameters in the GUI
+
: <code>DNALockIn('Name',Value,...)</code>
+
  
 
The following options may be set:
 
The following options may be set:
Line 120: Line 117:
 
|}
 
|}
  
Example:
 
: <code>DNALockIn('Rpu',14860,'Vref',14.96)</code>
 
Starts the GUI with Rpullup set to 14860 and Vref set to 14.96.
 
 
'CalculateTemperatureFcn' may be used to specify an external function to calculate temperature if a special temperature sensor or circuit is substituted for the standard setup.  The function takes two arguments, a struct and a voltage, and returns the calculated temperature.  The struct contains the standard parameters as well as any others specified in the command line.  The standard temperature function is equivalent to
 
: <code> @(params,V) (params.Rpu*V/(params.Vref - V) - params.Rt0)/params.alphaT </code>
 
 
== Filters: ==
 
The band pass filter is set by the user-supplied 'BandPassFilterFcn'. This function takes 2 arguments, the carrier frequency and the data acquisition rate, and returns a filter kernel for use by the Matlab <code>filter</code> function. The Matlab  <code>fir1</code> function may be used to generate a suitable kernel, for example,
 
: <code> DNALockIn( 'BandPassFilterFcn', @(F,R) fir1(256,[(F-500)/(R/2) (F+500)/(R/2)]) ) </code>
 
generates an order-256 bandpass filter with a 1000 Hz window centered on the carrier frequency. (Note that R/2 is the Nyquist frequency = one-half the sample rate.) BandPassFilterFcn is called when DNALockIn starts and any time the carrier frequency is changed. The default is to use a band pass filter of 1 (all pass filter), a filter with no effect.
 
  
'DownSampleFilterFcn' sets the down sample filter. This function takes 2 arguments, the down-sample frequency and the data acquisition rate, and returns a filter kernel, which should be a low-pass filter. DownSampleFilterFcn is called only once when DNALockIn starts.  The default is a low-pass filter with cutoff at the down-sample frequency:
 
: <code> @(F,R) fir1(256,F/(R/2)) </code>
 
  
'LowPassFilterFcn' sets the low pass filter. This function takes 1 argument, the down-sample frequency and returns a filter kernel, which should be a low-pass filter.  LowPassFilterFcn is called only once when DNALockIn starts.  For example,
 
: <code> DNALockIn( 'LowPassFilterFcn', @(F) fir1(256,1/(F/2)) ) </code>
 
generates an order-256 low-pass filter with a cutoff of 1 Hz.  The default is an all-pass filter of 1.
 
  
 
{{Template:20.309 bottom}}
 
{{Template:20.309 bottom}}

Revision as of 20:21, 20 March 2014

20.309: Biological Instrumentation and Measurement

ImageBar 774.jpg


Description:

The LockIn DNA Melter GUI is located on the lab computer desktop. The LockIn version is similar to the Basic version; however the LockIn version provides for driving the LED, temperature control, and digital filtering.

On the left side of the window, the LockIn GUI has panels for setting the LED carrier frequency and amplitude, for temperature control (min and max temperature as well as ramp times), for temperature control PID parameters, temperature sensor parameters, setting the lock-in phase, and choosing filter frequencies and bandwidth.

GUILockInCarrierDetail.png

Carrier: Set the frequency, amplitude, and offset of the carrier waveform. Offset should always be greater than amplitude to keep the LED drive linear. Rsense is the scaling resistor for setting the LED current. Use the LED button to turn the LED drive on and off.


GUILockInTemperatureDetail.png

Temperature: The temperature control algorithm implements a temperature ramp from minT to maxT (Heat time), a hold at maxT (Hold time), then a ramp from maxT down to minT (Cool time), and finally a hold at minT until temperature control is disabled.

The Start button initiates a temperature control cycle. ("Start" will change to "Stop" when temperature control is active; if you stop a cycle, you have the option to resume at the last temperature.) Use the Go to min T button to force the temperature to minT. Use the Fan button to turn on the fan manually (usually the fan is only on after the Hold time when ramping down the temperature).

Use the Reset button before starting a new temperature control cycle (after a previous test, an aborted test, or after using Go to min T).

GUILockInPIDDetail.png

PID Gains: The program controls the temperature by turning the TEC on and off several times a second. The duty cycle (fraction of time the TEC is on) is determined by a PID algorithm:

$ {\rm DutyCycle} = P T_{\rm err} + I \int T_{\rm err} dt + D \frac{d}{dt} T_{\rm err} $

where $ T_{\rm err} $ is the difference between the desired and measured temperature. The P, I, and D parameters are the proportional, integral, and derivative gains, respectively. If the PID gains are changed, the Restore button can be used to set them back to their default values.


GUISensorDetail.png

Temperature sensor: It is important to set the Vref and Rpullup parameters each time DNALockIn is run, so that the temperature is computed accurately. (Remember you are attempting to determine the melting temperature of a DNA sample.) Vref is the actual voltage supplied either by the reference or +15V supply, and Rpullup is the "pull-up" resistor in the temperature circuit. Rt0 is the sensor resistance at 0 C (1000 ohms) and alphaT is the sensor temperature coefficient (3.85 ohm/degree). Rt0 and alphaT should not be changed unless a different type of temperature sensor is used.


GUILockInPhaseDetail.png

Phase: Before starting a run, with a fluorescent sample in place and LED on, use the Phase dial to adjust the lock-in phase to maximize the fluorescence signal (upper-right graph).

GUILockInFilterDetail.png

The LockIn GUI graphs the fluorescence voltage signal as well as temperature data in multiple plots. DNALockIn acquires the temperature and fluorescence signals at 200 kHz every 0.1 seconds (20000 data points). Select signals and their associated spectra are displayed in the two left-hand graphs. Florescence voltage and temperature (averaged over the 20000 points every 0.1 seconds) versus time are plotted in the upper right-hand graph. Florescence voltage versus temperature is plotted in the lower right-hand graph.

Before starting a run, use the Clear button to clear out data accumulated from setting up or a previous run.

At the end of a run, use the Save button to save to a file. The data will be tab-delimited and can be read into Matlab with the load command.

Troubleshooting: If there is a data acquisition error, for example, "Data acquisition cannot start!", it may be the DAQ device is not working. Try physically disconnecting the USB cable from the DAQ box and then reconnecting it. The X-series devices (blue and silver boxes) have on/off switches: make sure it is on or toggle the power off and on. If that fails, open the Measurement and Automation Explorer ("MAX"), open the Devices and Interfaces drop-down on the left side, and make sure there is only one "NI USB-6xxx" entry and that it is called "Dev1." Try to run the DNAMelter program again, and/or close it, re-open it, and run it again. If this does not work, consult an Instructor.

Options:

Clicking on the icon in the upper-left corner or pressing Alt-space will bring up the system menu. The system menu contains options for showing the about box, and for saving/loading the current configuration.


The following options may be set:

Option name Description Default
'rate' Data acquisition rate 200000 Hz
'duration' Data acquisition time 0.1 seconds
'Vref' Temperature circuit reference voltage 15 V
'Rpu' Temperature circuit pullup 15000 ohms
'Rt0' Temperature sensor R at T=0 1000 ohms
'alphaT' Temperature sensor coefficient 3.850 ohms/degree
'CalculateTemperatureFcn' User function to calculate temperature (see below)
'taskbarHeight' Height of Windows taskbar for sizing window 40 pixels
'LEDoffV' Drive voltage to force LED off -0.025 V
'frequency' LED drive frequency 8000 Hz
'amplitude' LED drive amplitude 0.010 A
'offset' LED drive offset 0.012 A
'Rsense' LED current scaling resistor 100 ohms
'Tmin' Start temperature 25 C
'Tmax' End temperature 95 C
'tHeat' heat ramp time 900 seconds
'tCool' cool ramp time 900 seconds
'tHold' hold time 120 seconds
'Pgain' Proportional gain 0.5
'Igain' Integral gain 0.02
'Dgain' Derivative gain 0.75
'Ilimit' PID integral limit 1
'controltime' Temperature control update time 1 second
'fan' Set to 1 to force fan always on 0
'BandPassFilterFcn' User function to set BandPassFilter See Filters
'BandPassFilter' Band pass filter kernel 1
'DownSampleRate' Intermediate down sample frequency 1000 Hz
'DownSampleFilterFcn' User function to set DownSampleFilter See Filters
'DownSampleFilter' Down-sampling filter See Filters
'LowPassFilterFcn' User function to set LowPassFilter See Filters
'LowPassFilter' Low pass filter kernel 1