Repository navigation
Example Experiments
The following section shows example implementations for using the FreiStat Python framework either as a standalone software, or as a backend. In both cases the software is used with serial communication via USB between FreiStat and framework, implementing cyclic voltammetry
To operate the FreiStat software in Standalone mode, the mode argument must be set like depicted below (or not defined since mode= FREISTAT_STANDALONE is the default value).
from FreiStat.Methods.run_cyclic_voltammetry import Run_CV
run_CV = Run_CV(commnicationMode= FREISTAT_SERIAL ,
mode= FREISTAT_STANDALONE
)
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
)In standalone mode the framework opens matplotlib windows plotting the measurement results in real time (exception: LowPerformanceMode= True). Furthermore, the measurement results are outputted to the standard terminal. After the experiment is completed, the data is stored as .csv-file under the location saved in the return value strExportPath.
In backend mode the framework does not do anything regarding visualization of the data after calling the start method. This is done to allow, that the visualization is started in the main process.
from FreiStat.Methods.run_cyclic_voltammetry import Run_CV
run_CV = Run_CV(commnicationMode= FREISTAT_SERIAL,
mode= FREISTAT_BACKEND
)
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
)After setting up the method, the API of the facade run_CV can be accessed.
Important: The references to the classes returned by the API must be saved to prevent garbage collection
# Underlying plotter class
plotter = run_CV.get_plotter()
# Process which handles data transmission and storage
process = run_CV.get_process()
# Live plot figure
fig = plotter.get_figure()
# List of static plots displaying the different methods inside a sequence (Only when using the sequence mode)
listFigures = plotter.get_listfigures()
# Data queue used for data exchange between main process (visualization) and process for data transmission and storage
dataQueue = run_CV.get_dataQueue()Beside the API for getting access to certain parts of the framework, the software can accept references to certain Tkinter elements to guide data output.
plotter.set_listBox(TextTerminal)
plotter.set_progressBar(ProgressBar)After setting up the previous stated parts of the software, the visualization can be started. As in the example for the standalone mode the software behaves differently depending on the LowPerformanceMode. In the example of operating the framework as backend, the respective functions T_Animate (equals LowPerformanceMode= False) and T_Print (equals LowPerformanceMode= True) can be accessed directly.
For T_Print the latency defines in which time interval the data is printed to tune further the performance.
if (LowPerformanceMode == False):
plotter.T_Animate(dataQueue)
animate = plotter.get_animate()
else :
plotter.T_Print(latency, dataQueue)
animate = plotter.get_animate()The following section shows an example of implementing a sequence of three electrochemical methods (CA -> CV -> CA).
from Python.FreiStat.Methods.run_sequence import Run_Sequence
sequence = Run_Sequence(EnableOptimizer= False)
sequence.add_CA(Potential_Steps= [-0.1, 0.05, 1],
Pulse_Lengths=[0.3, 0.5, 0.4],
Sampling_Rate= 0.02,
Cycle= 20,
CurrentRange= 15e-6,
MainsFilter = True,
Sinc2_Oversampling = 667,
Sinc3_Oversampling = 2)
sequence.add_CV(StartVoltage= 0.5,
FirstVertex= -0.62,
SecondVertex= 1.05,
Stepsize= 0.001,
Scanrate= 0.2,
Cycle= 10,
CurrentRange= 45e-6,
FixedWEPotential= True,
MainsFilter = True,
Sinc2_Oversampling = 667,
Sinc3_Oversampling = 2)
sequence.add_CA(Potential_Steps= [-0.4, 1],
Pulse_Lengths=[0.2, 0.2],
Sampling_Rate= 0.02,
Cycle= 1,
CurrentRange= 15e-6,
MainsFilter = True,
Sinc2_Oversampling = 667,
Sinc3_Oversampling = 2)
strExportpath = sequence.start(SequenceCycles= 3, LowPerformanceMode= False)The FreiStat framework will create two folders (Persistent_Data_Objects and Measurements) in the same location as the executing Python file. These folders are then used to store Persistent Data Objects and Measurement results respectively.
The folder structure is thereby identical for both folders:
- Persistent_Data_Objects\YY_MM_DD\HH_MM_SS\
- Measurements\YY_MM_DD\HH_MM_SS\
During the experiment, the measurement results are saved as Persistent_Data_Objects in the respective folder. This allows for a recovery of the data using the Data Recovery tool if the experiment is terminated.
After the experiment is done, the start-function of the facade class returns a string (strExportpath) containing the path to the location of the stored .csv-file results. In this folder, the measurement results, as well as the measurement settings are saved as .csv-files.
The data recovery allows for converting Persistent Data Objects into .csv-files. This can be useful to recover data from experiments which got terminated or didn't finish properly.
Recovery_Data().start_Recovery("PATH_TO_FOLDER\\Persistent_Data_Objects\\YY_MM_DD\\HH_MM_SS")