low sampling rate with adc

Thread Starter

tux21

Joined Apr 10, 2010
21
i cheched with matlab, the usb to serial conv. i use is giving correct baud rate of 57600 when i transmit simply ascii value '2' from uC to pc
 

Thread Starter

tux21

Joined Apr 10, 2010
21
i cheched with matlab, the usb to serial conv. i use is giving correct baud rate of 57600 when i transmit simply ascii value '2' from uC to pc
 

Thread Starter

tux21

Joined Apr 10, 2010
21
i think i could finally get something. i connected the ALE pin i.e 30th pin of 8051 as clock to adc0808. Its suppose to give 1/6th of 11.0592MHz ie.like 1.8432 Mhz. But adc max clock is specified as 1.28Mhz :-?. Also i have connected pin 31 to Vcc.

First i tested pain single character sending to matlab from uc and found to time it took to fill a large InputBufferSize and concluded that it was more than 5000 samples which is close to the theoretical 57600/10=5760. So my usb-> serial was okay.

Then i minimized all the delays in the adc operations. used timer instead of loop delays. It turns out adc0808 is not that slow. It will do adc faster than the uart can send samples to pc. No special delays were required between setting ALE,SC,OE,ADDRESS etc. But the high clock was a must. I have also not used any timer and serial interrupts. Just get adc value in accumilator, put in SBUF and monitor TI flag.
This method gives me around 4500 samples/sec. the 4 q flip flop method in mazidi will not work as the input from crystal is insufficient to drive the Flipflops.

Also keep sufficent InputBufferSize in matlab serial around 50MB. This is not good for audio signals, but for ECG,EEG,EMG etc it will do.
Attached picture of 800 Hz sine. Multiply the circles in a period with
time period 2ms to get sampling rate.

i'll come with if more trouble comes.

ps. also adding 800Hz sine , spline interpolated to triple sampling rate in matlab
 

Attachments

Last edited:

Thread Starter

tux21

Joined Apr 10, 2010
21
Done!
now i am at 115200 baudrate using 11.0592 crystal and timer2. getting around 7200 samples/sec. i think adc is the limiter this time

fig without interpolation
 

Attachments

Last edited:

t06afre

Joined May 11, 2009
5,934
I was just wondering. Do the circle dots denote values? If that is the case I would recheck my system. Because in your recording you have values varying only a few bits +/-. What is your AD converter range and what do use as input signal then testing
 
Last edited:

Thread Starter

tux21

Joined Apr 10, 2010
21
circle is the marker in matlab plot function. denotes the points where samples are available. in the picture 2 posts above you can see its 256 levels between 0-5V for the 8bit adc. input signal is from laptop speaker out possibly max upto 3V. Sine wave generated with soundcard scope program

"Because in your recording you have values varying only a few bits +/-.." what does that mean?
 

t06afre

Joined May 11, 2009
5,934
circle is the marker in matlab plot function. denotes the points where samples are available. in the picture 2 posts above you can see its 256 levels between 0-5V for the 8bit adc. input signal is from laptop speaker out possibly max upto 3V. Sine wave generated with soundcard scope program

"Because in your recording you have values varying only a few bits +/-.." what does that mean?
A bit in your case is the same as the value of 1 LSB from your ADC. If your ADC is configured to measure 0-5 volt each bit will have a value equal 5(volt)/(2^8) or approx 19.5 mV pr bit. So your signal shows quite small fluctuations
 
Last edited:

Thread Starter

tux21

Joined Apr 10, 2010
21
Great!

now i am able to get out around 11,200 samples/sec from the ADC+uC combination. Earlier i used to do adc then wait for TI to set and clear it i.e wait for frame to be transmitted.

JNB TI,$ ;WAIT FOR SERIAL TRANSMISSION
CLR TI

But now i can omit the above wait for Tx to happen and directly go to obtaining the next adc value to be Tx
The trick i found is to initialize serial Transmission in the beginning itself just once with

MOV SBUF,#'0' ;INITIALIZE Tx

before starting anything else. Once this is done adc and uart transmissions can be done without any delays between them ;->

Note that i am using 1.8Mhz as my clock for adc0808 from ALE pin

"So your signal shows quite small fluctuations "
isn't that good?
 

Thread Starter

tux21

Joined Apr 10, 2010
21
well that trick doesn't work. it got higher because of overlap of adc and uart Tx times
 
Last edited:

retched

Joined Dec 5, 2009
5,207
ok. And what are you using to keep the ADC and uart from overlapping? They should be operating on the same clock. You may just be sampleing the same value over and over due to the differences being so close.. As t06afre said.
 

t06afre

Joined May 11, 2009
5,934
Tux
Can you make a new plot of your signal. But this time make scale on the Y axises visible, so we can see the variation in the signals clearly. And also tell us which amplitude your test signal has
 

Thread Starter

tux21

Joined Apr 10, 2010
21
amplitude is abot 3v max i think , from audio out of laptop. see post 23 for image with scale.
@retched uart comes after adc in asm program of 8051. so samples are at distinct times
 
Top