-
Notifications
You must be signed in to change notification settings - Fork 0
Communication protocol
In the spirit of openness, the Octave code uses a documented protocol for communicating with the Arduino. This page serves to be the specification draft for that protocol and as such isn't final. This also means that if the Octave code doesn't match this document, the Octave code is broken. The same goes for the Arduino code.
The transport is implemented using serial communication as a basis. The default settings are 9600 8N1, which is also the default setting for the Arduino Serial library, although the protocol permits other speeds (but currently only 8-bit, no pairity and 1 stop bit).
Let's start with a sample packet from the Arduino:
N0001P0511\r\n (where \r is CR and \n is LF)
This is what the different characters mean:
N This is the header for the negative ADC value.
0001 This is the raw data from the ADC itself.
P This is the header for the positive ADC value.
0511 This is the raw data from the ADC itself.
\r\n This serves as the footer of the packet.
- The headers
NandPare mandatory, but other headers can follow if, for instance, multiple cells are to be tested at once. The meaning of - If no data is available for the negative ADC, its entire data field has to be filled with 0 when the MOSFET is on and equal to the positive data field when the MOSFET is turned off
- The positive data field has to represent the ADC of the first cell and thus has to provide a valid data field.
Due to the nature of the project, there isn't much to do for the Arduino besides relaying ADC readouts and controlling the MOSFET. The latter part is why bi-directional communication is required.
Sample packet:
+
+ Either a + (plus) or - (minus) indicating the requested state of the MOSFET.
- A plus represents that power is requested to be turned on from the battery to be tested
- A minus represents that power is requested to be turned off from the battery to be tested
- Note that it is merely a requested action; the Arduino must try to satisfy the request but it is not required to succeed
- The Arduino has no obligation to explicitly report back whether or not the operation was successful, the responsibility to detect an error falls on the Octave code