Inertia Sensor Network

PaulS:

  Serial.println(AcceX(ChipSelPin1));

becomes

int val = AcceX(ChipSelPin1);

Serial.write(hightByte(val));
Serial.write(lowByte(val));




You'll need some kind of separator between the pairs of bytes, so that if one gets lost, the receiver can know that and recover.

Or, you need some kind of separator between groups of bytes, and discard the whole group if the separator occurs again to soon, in the input stream.

Since you have no byte values that would not be part of the data stream, you have a couple of choices. One would be to split each byte into two nibbles, and send the 4 nibbles. Then, the separator can be any value over 127.

The other would be to send a series of (say 4) separator bytes (all the same value). That series of bytes is unlikely to appear in your data. That series of bytes could be 0s or 255s.

May I just use space (that is, Serial.write(040)) to be the seperator?
In such case, would it happen that my data from the sensor to be the same as some special ascii code, such as new line or carriage return?

The receiving side will be Processing running from my computer.

PeterH:

yan5619:
Could it be that I am polling my sensors fast enough, but Serial.print() made it slow?

That's a good question. Why don't you remove the print statements and just call the Acce*() functions without printing the results, and see what effect that has on the speed?

Thank you very much. I've tried it, and yes, Serial.print is exactly why it is that slow =)