Syncronized Serial communication with Arduino

Greetings everyone,
I have been working on developing a custom serial 'protocol' for communicating data from a PC to an arduino; specifically for driving a 8x8 LED matrix from audio levels (among other things)

Now I had planned to send 8 bytes at a time, 1 byte for each row or column, with values from 0 to 255... But I have run into some problems:

  1. How to signal 'start' or 'end' of a packet of 8 bytes so that the display isn't refreshing with half of one frame and half of another seeing as though each byte needs to range from 0 to 255... and all useful ASCII characters fall within that range.
    I was thinking of possibly using multiple-byte start/end codes as well as explicitly counting the read bytes once a start byte(s) is read.

  2. since the clock speed of the arduino is quite a bit faster than a 9600 baud rate (Side question: any drawbacks/caveats with higher serial baud rates?), how to make sure that either a) the full 8 bytes is available (delay? .. seems too much of a hack) or b) make sure it waits for an available byte and keeps reading bytes until a start/end code is reached and/or it reads 8 bytes explicitly.

Basically I want to make sure the frames sent as 8-byte packets (might be more than 8 bytes with some other overhead info I might want to put in) are correctly displayed.

Any comments or suggestions would be greatly appreciated!
Thanks in advance,

  • John

Seconded.

I have the same problem with serial communications. What's the proper way of forming a data packet? I've resorted to using ASCII characters to send numbers i.e. sending a string '1234/n' and converting them into integers afterwards so I can use '/n' as packet terminator. But clearly that's not efficient. What is the proper way do do this?

Cheers
-Z-

One way this is done is to frame the data. This is often done use DLE STX bytes to signal the start of transmission and DLE ETX to signal the end. Within the data, a value pair of DLE STX or DLE ETX gets escaped (preceded) with another DLE, which is then stripped out at the receiving end.

STX has a value of 0x02, ETX a value of 0x03 and DLE is 0x10.

The following is the best description I could find online:

http://www.cc.gatech.edu/classes/AY2005/cs4251_fall/class14.ppt#669,2,Character-Oriented Framing

Mike

One way this is done is to frame the data. This is often done use DLE STX bytes to signal the start of transmission and DLE ETX to signal the end. Within the data, a value pair of DLE STX or DLE ETX gets escaped (preceded) with another DLE, which is then stripped out at the receiving end.

STX has a value of 0x02, ETX a value of 0x03 and DLE is 0x10.

The following is the best description I could find online:

http://www.cc.gatech.edu/classes/AY2005/cs4251_fall/class14.ppt#669,2,Character-Oriented Framing

Mike

Hey, thanks. That seems to be quite a smart way of doing it. I've been looking for something like that online, but wasn't sure what keyword to search for... ::slight_smile:

Cheers,
-Z-