필터 지우기
필터 지우기

serial communication data shifted

조회 수: 6 (최근 30일)
isra
isra 2017년 1월 26일
댓글: isra 2017년 1월 26일
Hello I'm trying to read analog inputs from arduino and send them to matlab, My problem is that sometimes the data is shifted. I'm erading several analog inputs. When I plot the second input's data, I sometimes get the data from input 1, then I find input 2's data in the plot of input 3. There seem to be a synchronization issue, how can I fix it?

답변 (1개)

Walter Roberson
Walter Roberson 2017년 1월 26일
I suggest you debug this by sending the sensor number and the current sample count along with the sensor reading. This will allow you to see whether the data is all being transmitted but sometimes out of order, or if the problem is that entire chunks of data are being missed.
  댓글 수: 2
isra
isra 2017년 1월 26일
Yes I did this, I made Arduino print out the number of the pin before printing it's data (i.e printe "1" then A0's output each in a line). Then in matlab, it will read the first raw then according to it's value (1,2,,4) it will save the next reading in the corresponding vector. This seems to be the only way around it, I still have to realtime plot it so I'll have to see if it will work with it or not. Thanks
isra
isra 2017년 1월 26일
I've tried plotting the data, I have a problem with it, it seems to display the readings for a certain time only (700 samples) then after that I get random lines. Do you have any idea as to why this happens? I'm supplying my board with a continuous sine wave.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Arduino Hardware에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by