Rob Toulson / Mbed 2 deprecated PE_05-05_DataConversion

Dependencies:   mbed

main.cpp

Committer:
robt
Date:
2012-10-15
Revision:
0:84f45646bc00

File content as of revision 0:84f45646bc00:

/*Program Example 5.5: Inputs signal through ADC, and outputs to DAC. 
View DAC output on oscilloscope. To demonstrate Nyquist, connect variable 
frequency signal generator to ADC input. Allows measurement of conversion 
times, and explores Nyquist limit.
                                                                            */
#include "mbed.h"
AnalogOut Aout(p18);      //defines analog output on Pin 18
AnalogIn Ain(p20);        //defines analog input on Pin 20
DigitalOut test(p5);
float ADCdata;

int main() {
  while(1) {
    ADCdata=Ain;   //starts A-D conversion, and assigns analog value to ADCdata
    test=1;        //switch test output, as time marker
    test=0;
    Aout=ADCdata;  // transfers stored value to DAC, and forces a D-A conversion 
    test=1;        //a double pulse, to mark the end of conversion 
    test=0;     
    test=1;
    test=0;             
    //wait(0.001);    //optional wait state, to explore different cycle times
   }
}