SEARCH
TOOLBOX
LANGUAGES
modified on 18 September 2014 at 14:45 ••• 10,681 views

05-05 DataConversion

From Manuals

Jump to: navigation, search

This example reads an Analog to Digital Converter (ADC) and outputs it to a Digital to Analog Converter(DAC).

The signals used for this example are listed below:

Signals Used and Connector Locations for Example 05-05
Signal LPC4330 PIN NAME BAM210E BAM210 BAM200E BAM200 Used for
A0 P7_4 J8-1 J8-1 S4-3 S4-3 Function Generator
DAC0 P4_4 J8-6 J8-6 S3-5 S3-5 Oscilloscope

The following schematic can be used to build the circuit with a BAM210E or BAM210.

BAM210
Schematic for example 05-05
/*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(DAC0);      //defines analog output on Pin DAC0
AnalogIn Ain(A0);        //defines analog input on Pin A0 
DigitalOut test(p21);
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
   }
}

DAC0 (CH2) and the Function Generator (CH1) was captured on the oscilloscope in the image below.

The following image shows the built circuit on a BAM210E.