Go Down

Topic: ARDUINO CODE PROBLEM! (Read 5 times) previous topic - next topic


Can't the PC see into my arduino

No, all the PC sees is the end of a length of wire with some ones and zeroes on it.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


Can you tell me what i need to change then please? How can i make my pc see the readings from my arduino? All i want to do is see the multiple signals on my arduino displayed on a graph  :.


There are a number of ways you could fix your code. You could send some specific value as a start or end of packet marker. The matlab program would wait for the start or end marker to appear ignoring anything that was not the start or end marker, then reading everything until the next start or end marker.

For example:
"|",L0, H0, L1, H1, L2, H2, ..., L6, H6, "|", L0, ...

The problem with this approach is that whatever value you use as start or end of packet marker may represent a valid low or high byte.

You could send the values as text, with start and end markers and delimiters.
"<287, 1000, 14, 299, 127, 943, 883><286, 876, ..."

The disadvantage to this approach is that converting the values to text takes time, and parsing the data on the receiving end takes time, too. The amount of data sent increases, too.

The advantage is that the start and end markers and delimiters are clearly separate values. The PC can probably parse and convert the values in next to no time, and the increase in data sent is typically about 100%. Sending the integer value 12 as two bytes takes two bytes. Sending it as a character string takes two bytes, so no increase. Sending the integer value 1023 as two bytes takes 2 bytes. Sending it as a character string takes 4 bytes, so a 100% increase. Since most values will be in the 10 to 999 range, there will be, on average, 3 characters per value (plus a delimiter) vs. 2 bytes, for an average of 4 bytes per value.

Clearly, though, the PC can then figure out how many values are in each packet.


Hrmm, ive never used or even heard of start or end markers before! then again i have very little experience with arduino and matlab so im not surprised this is new to me..
Do u have an example, or if possible can you show me with the code i provided earlier a way of how to use these markers? I could really do with some help please


Go Up