low sampling rate with adc

Discussion in 'Embedded Systems and Microcontrollers' started by tux21, Apr 10, 2010.

  1. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    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
     
  2. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    any suggestions?
     
  3. retched

    AAC Fanatic!

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

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    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.
     
  5. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    Can this adc deal with audio signals.Can anyone test it?
    plz tell me i have to complete urgently
     
  6. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    This information should be available in the ADCs datasheet. I do not have one to test.
     
  7. bertus

    Administrator

    Apr 5, 2008
    15,649
    2,348
    Hello,

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

    Greetings,
    Bertus
     
  8. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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.
     
  9. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    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.
     
  10. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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?
     
  11. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    sorry its 400 khz and not Hz

    i am generating it using timer0 interrupt to toggle pin of uC
     
  12. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    You set your config bits properly?
     
  13. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    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?
     
  14. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    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.
     
  15. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    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?
     
  16. retched

    AAC Fanatic!

    Dec 5, 2009
    5,201
    312
    here are some quotes from around the forum:

    Code ( (Unknown Language)):
    1. double ADConvert1(void)
    2. {
    3.         double chairvolt=0;
    4.         CHS0 = 1;              // Use channel AN1
    5.         CHS1 = 0;
    6.         ADON = 1;              // Turn A/D on
    7.         __delay_us(20);        // delay 30 usec to settle A/D acquisition
    8.         ADGO = 1;              // Start conversion
    9.         while ( ADGO );        // wait for ADGO to go off signalling end of conversion
    10.         chairvolt = (ADRESH*4)+(ADRESL/64);    //Caulating value of N
    11.         return chairvolt;        // Display result
    12. }
     
    tux21 likes this.
  17. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    i will check with the delays
    thanks
     
  18. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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?
     
  19. tux21

    Thread Starter New Member

    Apr 10, 2010
    21
    0
    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
     
  20. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
     
Loading...