how can you recognize the first bit of a word with arduino?

i'm making two arduino comunicate via laser but i have a little problem... every time the conection gets interrumpt i have to reset both arduino's so that the reciever could recieve the information properly. I want to know if someone knows how to make that the reciever could detect the first bit of the message so that it could always recive the information without having to reset both arduinos.

seandogue8 years ago
You need to establish a communication link prior to sending data.

The first signals from the transmission side should simply be providing a wakeup notice to the receiver, not data.

Once the wakeup is accepted by the received and it has come out of sleep mode, it needs to acknowledge that to the transmitter side and let the transmitter know it's ready to receive data.

At that point standard comm protocols can be used to send the data stream. To the best of my knowledge, CRC is the standard method for ensuring valid data encapsulation.

In fact, AFAIK, the whole process is standardized in wireless and IRda communication specs.

Also, are you pushing the laser with the Arduino's serial ports ? They shouldn't lock up ! Write a timeout routine that allows the system to restart a bad transmission.
Then you need to look at your data modulation - you should look at a Manchester encoding scheme called an NRZ code, which ensures there is no DC in the transmission stream. Rules for "wireless" comms are different for wired comms.
I was wondering if perhaps the means of communication itself might be the problem.  Are you dumping the bit stream directly to the laser?  If so, I would think using some method of modulation (and demodulation on the other end) may be more reliable.

If the receiver is expecting a raw bit stream, then it may interpret a dropout caused by obstruction (such as dust) as data.  This would confuse the receiver and force you to reset it.

If you were to use FM to encode/decode the bit stream, this may make it more immune to such problems.  The transmitter would alternate between two frequencies, and the receiver would wait until the light pulsed at one frequency or another before accepting it as data.

This would require some modification to the code, but otherwise I think it would give your setup immunity to noise created by dropouts.  Granted, it may make it a bit slower transmission, but reliability always trumps speed.