<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_plain.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="Module.2004-02-26.4616">
  <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Lab 7: ADC, DAC, and Mixed Signals</name>
  <metadata xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
  <md:version xmlns:bib="http://bibtexml.sf.net/">1.6</md:version>
  <md:created xmlns:bib="http://bibtexml.sf.net/">2004/02/26 10:46:16 US/Central</md:created>
  <md:revised xmlns:bib="http://bibtexml.sf.net/">2006/03/29 23:35:33.931 US/Central</md:revised>
  <md:authorlist xmlns:bib="http://bibtexml.sf.net/">
      <md:author xmlns:bib="http://bibtexml.sf.net/" id="adrianv">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Adrian</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Valenzuela</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">adrianv@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist xmlns:bib="http://bibtexml.sf.net/">
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="deaniafe">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Deania</md:firstname>
      <md:othername xmlns:bib="http://bibtexml.sf.net/">M.</md:othername>
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Fernandez</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">deaniafe@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="adrianv">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Adrian</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Valenzuela</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">adrianv@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="seejaie">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">CJ</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Ganier</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">seejaie@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="jpfrantz">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Patrick</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Frantz</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">jpfrantz@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist xmlns:bib="http://bibtexml.sf.net/">
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">adc</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">dac</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">lab 7</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">mixed signals</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">msp430</md:keyword>
  </md:keywordlist>

  <md:abstract xmlns:bib="http://bibtexml.sf.net/">We will learn what is involved in Analog to Digital Conversion and conversely, Digital to Analog Conversion.</md:abstract>
</metadata>

<content xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">

<section xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="s1">
<name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">ADC, DAC, and Mixed Signals</name>
<exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="exercise4.1">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Quickies</name>
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="pro1">
	<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="l1" type="enumerated"><item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">The MSP430 has both a 10 and 12-bit ADC. The number of bits used by the ADC is known as its resolution.  You may learn more about sampling and Analog to Digital Converters from the <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" document="m12835">Introduction to Sampling</cnxn> module. How many possible values can be represented for each of the 10 and 12 bit cases?</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Extreme voltages, either too high or too low, cannot be measured correctly.  What is the range of analog voltages that can be accurately represented on <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" document="m12796">The MSP430F16x Lite Development Board</cnxn>?  You may want to check the <link xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" src="http://cnx.rice.edu/content/m12396/latest/usersguide.pdf">User's Guide</link> or experiment with the hardware.</item>
		<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">In the real world, signals are polluted by "noise" that alters the quality of the original signal.  Signal to Noise Ratio, SNR, is often used as a measure of the quality of a signal.  Before a signal is sampled through the ADC, it is helpful to condition the signal in order to improve its SNR.  What can be done to condition the signal?  Where would it be ideal to condition it and why?  (i.e. at the ADC, near the source, at the processor?) </item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">The Nyquist Theorem states that a signal must be sampled at least twice as fast as the highest frequency in order to be decoded without error. The minimum sampling frequency is therefore known as the Nyquist Sampling Rate. Typical, audio CDs are sampled at a rate of 44.1 kHz, and can be decoded to 65,536 unique voltage levels. What is the highest frequency that can be represented without error? How many bits per sample are used? What is the total data rate for a stereo CD?</item>


	</list>
</para>
</problem>
</exercise>

<exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="exercise4.2">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">ADC Setup</name>
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="pro2">
<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="l2" type="enumerated"><item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Figure out what the following codes is doing.  Set up the hardware so that it functions correctly, and comment each line of code.  What is the code's function?
<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" type="block"><![CDATA[
#include <msp430x16x.h>   

#define yellow 0x80
#define set_led(led, state) { 
  if (state) 
    P1OUT &= ~(led);
 else P1OUT |= (led); 
}

void main(void){
  P1DIR |= 0x80;
  set_led(yellow,0);
  WDTCTL = WDTPW+WDTHOLD;               
  P6SEL |= 0x04;                        
  ADC12CTL0 = ADC12ON+SHT0_2;          
  ADC12MCTL0 = SREF_0 + INCH_2 + EOS;   
  ADC12CTL1 = SHP;                      
  ADC12CTL0 |= ENC;                     
   
  while (1)  { 
    ADC12CTL0 |= ADC12SC;               
    while ((ADC12IFG & BIT0)==0);
    
    if (ADC12MEM0 >= 1620)
      set_led(yellow,1)
    else set_led(yellow,0)
    _NOP();                             
  }
}
]]>
</code>
<note xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" type="HINT">Most modern compilers intended for use with embedded processors, such as the <link xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" src="http://www.rowley.co.uk/">Rowley's CrossWorks for MSP430</link>, allow the user to check the status of the registers while the program is halted.  This is extremely helpful in debugging code.  For example, if the program is halted with a <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">NOP()</code> after a sample is taken from the ADC, the user may check the <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">ADC12MEMx</code> register to see the new value that has been stored.  If a value has changed since the last time the processor was halted, it will turn red.</note>
</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Create a version of the program that is interrupt driven and uses <term xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Repeat-single channel Conversion Mode</term>.  The original program uses a while-loop to poll the interrupt flag.  What is the sampling rate?</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Using <term xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Repeat-sequence-of-channels Conversion Mode</term>, write an interrupt driven program to sample analog input channels 1 and 2.  As before, toggle an LED for each channel as it passes the 1.5V threshold.  You should now have two separate analog voltages controlling two separate LEDs.</item>
</list>
</para>
</problem>
</exercise>

<exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="element-464">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">DAC Setup</name>
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="element-910">
<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="l1a" type="enumerated">
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Configure that <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">DAC12_1CTL</code> register so that DAC0 outputs a triangle wave.  This program should be interrupt driven, and any computation of the triangle wave should be in the ISR.  View the output on the oscilloscope and take a screenshot.</item>
</list>
</para></problem>
</exercise><exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="exercise4.3">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Stereo to Mono Mixer</name>
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="pro3">
<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="prob3" type="enumerated">
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Combine the last two problems to create a stereo to mono mixer.  The program should sample ADC0 and ADC1, add the two signals together, and output the result from DAC1.  It is possible to write the contents of <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">ADC12MEMx</code> directly to <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">DAC12_xDAT</code>. You should also scale down each of the input signals so that you don't saturate the output. Only use a single interrupt.  Take a screenshot with a) your stereo input signals (make sure that they are different) and b) your mono result. Could you process an audio CD like the one described in <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" target="exercise4.1">Problem 1.4</cnxn>?  Explain.</item>
</list>
</para>
</problem>
</exercise>

</section>

  </content>
  
</document>
