05-05 DataConversion
From Manuals
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:
| 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.
/*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.



