serial communication data shifted

1 次查看(过去 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