serial communication data shifted

1 visualizzazione (ultimi 30 giorni)
isra
isra il 26 Gen 2017
Commentato: isra il 26 Gen 2017
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?

Risposte (1)

Walter Roberson
Walter Roberson il 26 Gen 2017
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 Commenti
isra
isra il 26 Gen 2017
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 il 26 Gen 2017
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.

Accedi per commentare.

Categorie

Scopri di più su Arduino Hardware in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by