Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 11 months ago.
LPC1768 Sampling rate and LabVIEW System
Hello, I want to make a DAQ board using a LPC1768.
In Labview system, I made DAQ program for logging data.
LPC1768's datasheet said 200KHz Maximum sampling rate in 13MHz.
but I couldn't get data High frequency samples.
I used diversity code in ARM Forum. but I can't solve this problem.
Please see this figures.
Fig 1. is 10Hz Sine wave from Function generator. It is good.
Fig 2 is 100Hz Sine wave, I get good data.
Fig 3 is 1KHz Sine wave, but it was distorted! you can see this picture, samples of a period is 7-8 points. when Nyquist's theory, general signal sampling ratex2, but sine wave need almost x10.
Why LPC1768 can't make sample 200KHz?
I used library FastAnalogIn : http://developer.mbed.org/users/Sissors/code/FastAnalogIn/ ADC_Test : http://developer.mbed.org/users/simonb/code/ADC_test/ ADC_fast_sample_and_send : http://developer.mbed.org/users/gno/code/ADC_fast_sample_and_send/
But I can't get accuracy data and fast samples..... This result that I set baud rate 921600 or 460800. but i don't think main problem is not baud rate. How can i change this source?
I just want to the fastest ADC single channel, don't need signal filter(because labview will filter),
Here is my code.
- include <FastAnalogIn.h>
- include <mbed.h>
AnalogIn ain0(p20);
Serial pc(USBTX,USBRX); Tx, Rx Pin
int main()
{
pc.baud(460800);
while(1)
{
pc.printf("%f\n",ain0.read()*3.3);
}
}
Last Fig is my labview(2014) code.
I hope to get some tip.
Jeongdae (iNES)
1 Answer
9 years, 11 months ago.
You might try buffering some samples before sending them to the pc:
#include <FastAnalogIn.h> #include <mbed.h> AnalogIn ain0(p20); Serial pc(USBTX,USBRX); // define the maximum number of samples #define BUFFERSIZE 256 int main() { pc.baud(460800); float buffer[BUFFERSIZE]; int t=0; while(1) { // get samples in buffer for (t=0; t<BUFFERSIZE; t++) { buffer[t]=ain0.read(); } // now send them to the PC for (t=0; t<BUFFERSIZE; t++) { pc.printf("%f\n",buffer[t]*3.3); } } }