by yonghui » Fri Dec 12, 2014 11:30 pm
if you really need real time transfer of data between arduino and matlab at very very high rate then mayb arduino is not so suitable because of the speed.
for your COM speed of 115200bps which this will mean that the COM speed is 11520 byte per seconds. but u will need to consider the time taken by arduino to write to transmit buffer of serial COM. so the actual rate of transfer will need to take consider of copying data for the converted samples sending out to computer, computer buffers and matlab retrieve it. if your taking the 10bits resolution for the analog signals, means u will need 2 bytes transfer per sample. this will again slower down your data rate.
i still recommendes that you buffer up enough data in arduino, then transfer the whole data packets to computer for processing. and this can make the data rate stable, and not so much fluctuating because of COM communication.
i guess most oscilloscope is doing this way too.
for example: if you are doing FFT of a signal and the signal is 100HZ. so if my requirements is the signal need to be sample at 10 times of the signal frequency, i will sample it at 1Ksps, with the help of timer interrupt set to 1Khz, i will jump to interrupt and read adc every interrupt and save to buffer. if my requirement is 100 samples. i will stop timer interrupt and sampling after 100 samples complete, and by this time i will send whole 100 samples to matlab for processing. then after that i will repeat the process again and again by turning on timer interrupt and sending to matlab after 100samples. with this my sampling rate is fixed with timer interrupt and wont be affected by lagging of COM communication at computer side.
thanks®ards,
yh