After extensive stress tests and after months of use in production, I’m happy to announce MultiTrans, an implementation of a multi channel transceiver. Find MultiTrans in the Arduino library manager or in the GitHub repo feklee/multitrans.
New in version 1.2 is binary communication, i.e. sending and receiving messages that may include the null character.
I’m happy to answer any questions!
Features:
-
Transceiver: Transmit and receive simultaneously via a single pin. (No clock line needed.)
-
Multi channel: Multiple pins can transceive simultaneously.
-
Collision detection: One pin can start sending without worrying if the other side is sending as well. Collisions are automatically detected and circumvented. No information is lost.
-
Maximum uni-directional data rates on an Arduino Uno / Pro Mini:
-
Communication with one peer: 12 kbit/s
-
Communication with four peers: 3 kbit/s
Bi-directional data rates are a little less than half of the above rates in each direction.
Limitations: -
Buffers:
-
The buffer on the transmitting end can contain 256 bits at the most. For each character, 21 bits are necessary. This equates to 12 characters.
-
The buffer on the receiving end can only contain up to 255 pin change events.
-
Flushing the buffer on the receiving end takes some time.
The system is thus best used for short bursts of data with sufficient idle time in between. -
No built-in error checking. You may want to implement your own error checking, to take care of:
-
If you have a flaky connection between the Arduinos, for example due to bad electrical contacts, then bits may get lost.
-
Theoretically, i.e. if timing is perfectly right, the collision detection built into MultiTrans may fail resulting in bit loss.
-
It only works with AVR based Arduinos. In fact, code so far has only been tested with the Arduino Pro Mini and the Arduino Uno.
-
Timers are occupied:
-
8-bit Timer/Counter2 (TC2), for transmitting
-
16-bit Timer/Counter1 (TC1), for receiving
Examples:
-
Simple: bi directional communication between two Arduinos
-
Triangle: Arduinos communicating in a triangle
-
Stress test (advanced): testing maximum and minimum data rates with five Arduinos all communicating simultaneously