Sine wave sampling rate and communication with Matlab

Hi all,

I would like to monitor two 50Hz sine waves. One of my biggest problem is that the sampling rate is not too high (the maximum i could make was about 110samples/period @ 50Hz). I tried to adjust the prescale factor to 4 bits, but its not really punctual, so i use 32-bit prescaling. I also want to draw the waves in matlab which collects the infos from the arduino via a serial port. If I'm right, the maximum baudrate a Uno can handle is 2Mbaud so with these settings i should get a lot more than ~100 samples. (The samples are integers from 0 to 1023)

I have a DDS function generator which makes a sine wave and i wanted to simulate another sign (square) with a switchbutton and measure its frequency with the pulsein function and print it to the lcd display too but in this case sampling rate decreases about 2-3samples/period. It looks like to me that some communication protocoll is not fast enough for all those things.

My question is that can i increase/min. duble the sampling rate while i have two sine signs both at 50 Hz, print the frequency and phase shifts (two square waves from those sines) to the lcd and send the sine waves' datas to matlab to draw them?

Thank you for the answers in advance!

Maybe it helps if you show your code so people can advise where to improve? The Arduino analogRead documentation states that you can do roughly 10 kSamples per second; the Atmel datasheet for the 328 states a maximum of around 80 kSamples per second.

Which board do you use?

Seeing that you're new here, post code using code tags.
[code] your code here [/code] will result in

 your code here