low sampling rate with adc

Thread Starter

tux21

Joined Apr 10, 2010
21
i have to get around upto 900 Hz signal in MATLAB for which i use adc0808 with 8051 AT89S52

i use uC pin to generate clock of about 230kHz for adc. when i use 4 D flipflops to divide 11.0592MHz clock of uC by 16 and give it to adc it doesn't work(given like this in Mazidi book)

Now, i am able to get enough sampling rate for sine waves upto 50Hz but above that i get distorted conversion most likely due to undersampling as in figure attached . I have configured the uC to continuously operate the adc and send values to pc via serial port.

baud rate is set at highest possible 57600. matlab collects these binary values and stores in its serial port inputbuffer (1 MB) from where i read them to plot.

My problem is i am not able to get sufficent sampling rate for signals above 50Hz when i test with a sine wave generator.

The sampling rate is not controlled by me.
Plz help. I attach the assembly code with comments as well
 

Attachments

retched

Joined Dec 5, 2009
5,207
Sorry, I dont own MATLAB. What are you sampling? And have you scoped your clock to see if it is really what you expect?
 

Thread Starter

tux21

Joined Apr 10, 2010
21
i have to sample EMG signal i.e electromyogram. so i used sine wave at 900Hz as test for max frequency input.


i expect adc clock to be of 230khz considering the timer used to generate delay in 8051.
 

bertus

Joined Apr 5, 2008
22,995
Hello,

When I look at the datasheet of the ADC0808 the clockspeed must be between 10 kHz and 1280 kHz.

Greetings,
Bertus
 

retched

Joined Dec 5, 2009
5,207
Just checking back.. Bertus is correct. Your 900hz signal is far too slow to use with this ADC. This also appears to be better suited for TTL than audio encoding.
 

Thread Starter

tux21

Joined Apr 10, 2010
21
yes i am providing clock through P2.7 of AT89S52 with 460Hz.

@ retched

i am not using the 900Hz signal for audio encoding. i just wanna digitize it. But the sampling seems to be too slow.

Also dividing the 11.0592 Mz clock of uC by 16 for adc clock doesn't work.
 

retched

Joined Dec 5, 2009
5,207
Your clock has to be FASTER than 10,000 hz if you are giving it 460 hz, that is probably why your samples are being taken WAY too slow.

Do you have a frequency counter? to see if the divide by 16 is working properly?
 

Thread Starter

tux21

Joined Apr 10, 2010
21
config bits of adc , yes

its properly working for low frequency signals upto 50Hz
is there any delay requirements after setting address, output enable etc?
 

retched

Joined Dec 5, 2009
5,207
Sometimes there are. You should try to put a 20mS delay after the select and before the first samples are taken. I would also check for application notes involving this ADC. As for the signal you are sampling, is it loud enough to be picked up by the ADC? You may need an amp to boost the signal so it is within the specs that the ADC can read.
 

Thread Starter

tux21

Joined Apr 10, 2010
21
i am sure the signals are sufficient in amplitude , i checked with pc souncard scope.

could you give link or explain a bit about the 20 ms delay you are talking about. i never thought of that. its obviously for first few samples right?
 

retched

Joined Dec 5, 2009
5,207
here are some quotes from around the forum:

You should wait for the go_done bit to be set by mcu before to take the reading.

Read the data sheet to see the timing involved. In the meanwhile place a delay before the restarting the new ADC reading and you will see an improvement.
Rich (BB code):
double ADConvert1(void)
{
        double chairvolt=0;
        CHS0 = 1;              // Use channel AN1
        CHS1 = 0;
        ADON = 1;              // Turn A/D on
        __delay_us(20);        // delay 30 usec to settle A/D acquisition
        ADGO = 1;              // Start conversion
        while ( ADGO );        // wait for ADGO to go off signalling end of conversion
        chairvolt = (ADRESH*4)+(ADRESL/64);    //Caulating value of N
        return chairvolt;        // Display result
}
 

t06afre

Joined May 11, 2009
5,934
Hi Tux21
How do you control your samplerate, and what do you use as samplerate? Also then you transfer your data to Matlab, do you use raw binary format or some other format?
 

Thread Starter

tux21

Joined Apr 10, 2010
21
hi,
actually i don't control at all. in 8051 program i call function for adc which returns value in accu. this value is immediately sent via uart to matlab and uC waits till transmission has occured. then again gets the new adc value and so on.

what controls the sampling rate is adc conversion and uart transmission time
 

t06afre

Joined May 11, 2009
5,934
You are using serial communication and that will limit the samplerate. If you use 1 start bit 8 data bits and 1 stop bit. You will need 10 bit in each data transfer. If you use 57600 bit pr second, you can theoretically transfer 5760 samples pr second. I guess the real number will be lower. But I guess you can use a samplerate equal to 4KHz without problem. The samplerate should be precise controlled used onboard timers and interrupt programming
 
Top