Repository navigation
Telegram Exchange
The FreiStat software on the microcontroller communicates by using JSON-telegrams. The exchange of telegrams is thereby bidirectional and can be separated into the following types of telegrams:
Command telegrams are used to configurate the FreiStat software on the microcontroller by an external software.
Depending on the chosen "Command Type" the telegram is interpreted differently by the microcontroller.
- "ExT" : Experiment type
- "ExP" : Experiment parameters
- "ExC" : Control Command
- "ExS" : Experiment sequence
The sequence of transmitted telegrams follows a defined order. In a first step, the experiment type transmitted. This telegram is acknowledged by the microcontroller. The microcontroller expects then a telegram containing the matching experiment parameters for the chosen electrochemical method.
This telegram is acknowledged again by the microcontroller. After this a last telegram with a start command is required. This is also acknowledged by the microcontroller, which then starts executing the experiment.
To stop the experiment a telegram containing a stop command must be send to the microcontroller. The controller acknowledges this telegram and sends back a control command containing a stop command.
The first telegram which must to be send contains the experiment type. In the current version, the FreiStat supports 6 different electrochemical methods, which are listed below. Each of these methods use a unique set of experiment parameters, which is explained on their respective wiki page.
- "CA" : Chronoamperometry
- "LSV" : Linear Sweep Voltammetry
- "CV" : Cyclic Voltammetry
- "NPV" : Normal Pulse Voltammetry
- "DPV" : Differential Pulse Voltammetry
- "SWV" : Square Wave Voltammetry
The base structure of the experiment type telegram is depicted below.
{"Telegram Identifier": 1,"Command Type": "Experiment Type"}-
Telegram Identifieris always"C"for telegrams containing the experiment type -
Command Typeis always"ExT", which abbreviates Experiment Type -
Experiment Typeindicates the microcontroller which experiment should be executed
The following JSON-telegram shows the example for cyclic voltammetry.
{"C":1,"ExT": "CV"}After the telegram with the experiment type was send, the required experiment parameters for the chosen method must be transmitted. As explained above, each method requires different parameters, which are explained on the wiki page of the respective method.
Thereby not all experiment parameters need to be send. If parameters are omitted, the internally defined default values are used. Furthermore, the order of experiment parameters can be chosen arbitrarily.
The base structure of the experiment parameter telegram is depicted below.
{"Telegram Identifier": 2,"Command Type": {"Parameter 1":"Value", "Parameter 2":"Value"}}-
Telegram Identifieris always"C"for telegrams containing the experiment parameters -
Command Typeis always"ExP", which abbreviates Experiment Parameters -
{...}contains all the experiment parameters stored as indexed values
The following JSON-telegram shows the example for cyclic voltammetry.
{"C":2,"ExP":{"pSP":500.4395,"pLP":-620.0,"pUP":1050.0,"pSZ":2.0,"pSR":200.0,"pC":1,"pLRS":11,"pFWP":1,"pMF":0,"pOS2":1,"pOS3":2}}The last telegram required to start an experiment is a control command with the "start" keyword. This telegram can be send at an arbitrary time after the first two telegrams have been send. Same applies for the telegram, which contains the "stop" keyword, that terminates the running experiment.
- "Start" : Start experiment
- "Stop" : Stop experiment
The following JSON-telegram shows the example for an start telegram.
{"Telegram Identifier": 3,"Command Type": "Operating Command"}-
Telegram Identifieris always"C"for telegrams containing control commands -
Command Typeis always"ExC", which abbreviates Experiment Control -
Operating Commandcontains one of the defined keywords
{"C":3,"ExC": "Start"}In contrast to the previously explained sequence of telegrams to start 1 electrochemical method, the sequence mode can be used to execute a list of electrochemical methods. The working principle behind this is as follows. The telegram, which enables the sequence mode is send to the microcontroller. This is then followed up by an telegram containing the experiment parameters for the sequence. Then packages of experiment type and experiment parameter telegrams are send to the controller for every method, which should be executed. After this, the telegram to disable the sequence mode is send. Lastly, the normal start telegram gets transmitted to start the sequence.
- "SE" : Sequence mode enabled
- "SD" : Sequence mode disabled
{"Telegram Identifier": 4,"Command Type": "Operating Commands"}-
Telegram Identifieris always"C"for telegrams containing sequence mode control commands -
Command Typeis always"ExC", which abbreviates Experiment Sequence -
Operating Commandcontains one of the defined keywords
The following JSON-telegram shows the example for starting the sequence mode on the microcontroller.
{"C":4,"ExS": "SE"}Acknowledge telegrams are the response of the microcontroller to received telegrams. The telegrams are thereby very short and only contain a number, which is equivalent to the previously received "Telegram Identifier" value.
- 1 : Experiment Type
- 2 : Experiment Parameters
- 3 : Control command
- 4 : Control sequence mode
{"Telegram Identifier": "Value"}-
Telegram Identifieris always"A"for telegrams acknowledge telegrams -
Valueis equivalent to the previously received"Telegram Identifier"value.
The following JSON-telegram shows the example for acknowledging a "Experiment Type" telegram.
{"A":1}Data telegrams are send from the microcontroller to the python framework in certain time intervals. These depend on the chosen electrochemical method and the experiment parameters. Regardless of the method, the data telegram is always structured in the same way.
- "R" : Cycle
- "M" : Measurement values
- "D" : Datapoint to identify measurement
- "V" : Measured voltage value (in mV)
- "C" : Measured current value (in μA)
- "T" : Time stamp since microcontroller was started (in ms)
{"R": "Cycle number","M":{"D":"Datapoint","V":"Voltage value","C":"Current value","T":"Time stamp"}}The following JSON-telegram shows the example for measurement point 180 during the first cycle.
{"R":1,"M":{"D":180,"V":889.40173,"C":8.88046,"T":14451}}