Skip to content

Communication

Mark Jasper edited this page Feb 8, 2022 · 1 revision

The FreiStat supports three different ways of communication:

To define the correct mode of operation, the instantiation of the electrochemical method class needs to be done correctly.
The configurations for the different modes are thereby shown on the example of cyclic voltammetry.

The code snippet below shows an example implementation that is used as reference throughout this chapter. In the following chapter only, the relevant changes are shown.

from FreiStat.Methods.run_cyclic_voltammetry import Run_CV

run_CV = Run_CV(logger= Logger,
                commnicationMode= CommunicationMode,
                wlanSetting= WlanSetting,
                mode= Mode
                )

strExportPath = run_CV.start(StartVoltage= 0.5,
                             FirstVertex= 1.05,
                             SecondVertex= -0.62,
                             Stepsize= 0.002,
                             Scanrate= 0.1,
                             Cycle= 10,
                             CurrentRange= 45e-6,
                             FixedWEPotential= True,
                             MainsFilter= True,
                             Sinc2_Oversampling= 222,
                             Sinc3_Oversampling= 2,
                             EnableOptimizer= True,
                             LowPerformanceMode= False
                             )

FreiStat-USB

The serial USB mode is the standard mode defined for the FreiStat. If the FreiStat software is freshly installed, these settings should already be in place.

Setting Microcontroller

In the microcontroller software the settings are done in the constants.cpp (src/data_storage/constants.cpp). Ensure that both flags, for WiFi mode and Standalone mode are disabled.

/******************************************************************************
 * General definitions : Modes of operation
 *
 *      Constant                Value                     Meaning
 *****************************************************************************/
//#define FREISTAT_STANDALONE     true        // Flag indicating if the FreiStat is used in standalone mode
#define FREISTAT_STANDALONE     false
//#define WiFiEnabled             true        // Flag indicating if WiFi communication is enabled
#define WiFiEnabled             false

Setting Python Framework

In the Python framework, only the function call needs to be adjusted. As shown below, this is done by setting the communication mode to FREISTAT_SERIAL.

from FreiStat.Methods.run_cyclic_voltammetry import Run_CV

run_CV = Run_CV(commnicationMode= FREISTAT_SERIAL,
                ...
                )
...

FreiStat-WiFi

The WiFi mode allows for wireless communication between the FreiStat and the Python framework. In this communication the framework operates as server, while the FreiStat is used as client. This is done to allow multiple FreiStat to connect to the framework on different ports.

Setting: Microcontroller

In the microcontroller software the settings are done in the constants.cpp (src/data_storage/constants.cpp). Ensure that only the flag for WiFi mode is enabled.

/******************************************************************************
 * General definitions : Modes of operation
 *
 *      Constant                Value                     Meaning
 *****************************************************************************/
//#define FREISTAT_STANDALONE     true        // Flag indicating if the FreiStat is used in standalone mode
#define FREISTAT_STANDALONE     false
#define WiFiEnabled             true        // Flag indicating if WiFi communication is enabled
//#define WiFiEnabled             false

Furthermore the following segment must be configured.

/******************************************************************************
 * General definitions : WiFi config
 *
 *      Constant                Value                     Meaning
 *****************************************************************************/
#define WiFiSSID                "SSID"      // Name of the SSID which should be connected to
#define WiFiPASSWORD            "PASSWORD"  // Password of the SSID
#define WiFiIPOCTET_1           192         // 1 octet of the IP address
#define WiFiIPOCTET_2           168         // 2 octet of the IP address
#define WiFiIPOCTET_3           0           // 3 octet of the IP address
#define WiFiIPOCTET_4           101         // 4 octet of the IP address
#define WiFiLOCALPORT           20001       // Own port used for sending data
#define WiFiSERVERPORT          20000       // Server port data is send to

The WiFiOCTETs are thereby defining the IP address of the server (Device running the Python framework). Same applies for the WiFiSERVERPORT.

Setting: Python Framework

In the Python framework, only the function call needs to be adjusted. As shown below, this is done by setting the communication mode to FREISTAT_WLAN and configurating the wlanSetting.

from FreiStat.Methods.run_cyclic_voltammetry import Run_CV

run_CV = Run_CV(commnicationMode= FREISTAT_WLAN,
                wlanSetting = ["192.168.0.101", 
                               20000,
                               "192.168.0.201",
                               20001],
                ...
                )
...

FreiStat-Standalone

Note: The standalone mode has still some missing features, which makes it more of an experimental mode.

Setting Microcontroller

In the microcontroller software the settings are done in the constants.cpp (src/data_storage/constants.cpp). Ensure that only the flag for Standalone mode is enabled.

/******************************************************************************
 * General definitions : Modes of operation
 *
 *      Constant                Value                     Meaning
 *****************************************************************************/
#define FREISTAT_STANDALONE     true        // Flag indicating if the FreiStat is used in standalone mode
//#define FREISTAT_STANDALONE     false
//#define WiFiEnabled             true        // Flag indicating if WiFi communication is enabled
#define WiFiEnabled             false

After flashing the microcontroller, the display should light up and show the different electrochemical methods. Note that the experiments are conducted using the defined default values. These values can also be adjusted in the constants.cpp

Clone this wiki locally