Templates & Examples
When creating a new custom experiment, you can leverage the pre-built templates provided in the Custom Experiment Builder to get started quickly. These carefully designed templates help you understand how to use the blocks effectively and serve as a foundation that can be easily modified to meet your specific experimental requirements.
Each template is also conveniently available as an example in the toolbox, as shown below:
The examples in the Methods category represent Zahner Lab experiments that have been built using visual blocks.
The examples below are explained in general terms. Comprehensive documentation that explains everything in detail is available for each block in the documentation or via the block context menu. The relevant documentation pages that go beyond connecting blocks are linked.
Cyclic Voltammetry
This example demonstrates how to create a cyclic voltammetry (CV) experiment using the Custom Experiment Builder, equivalent to the CV available in the standard GUI.
Set variable start_value to 500 mV
Set variable end_value to 1500 mV
Set variable OCV to the result of an open circuit voltage determination
Switch on at OCV in potentiostatic mode
Ramp from OCV to start_value at a rate of 100 mV/s
Perform a polarization at start_value
Measure a cyclic voltammetry with start_value and end_value, 2 cycles and vertex values of 500 mV and -500 mV.
Measure a polarization at end_value
Switch off
Potentiostatic EIS
This example demonstrates how to create a potentiostatic EIS experiment using the Custom Experiment Builder, equivalent to the Potentiostatic EIS available in the standard GUI.
Set variable start_value to 500 mV
Set variable OCV to the result of an open circuit voltage determination
Switch on at OCV
Ramp from OCV to start_value at a rate of 100 mV/s
Measure a potentiostatic EIS at start_value with a 100 mV amplitude
Switch off
Chronoamperometry
This example demonstrates how to create a chronoamperometry experiment using the Custom Experiment Builder, equivalent to the chronoamperometry available in the standard GUI.
Set variable start_value to 500 mV
Set variable OCV to the result of an open circuit voltage determination
Switch on at OCV
Ramp from OCV to start_value at a rate of 100 mV/s
Set a stability condition of 1 mA/s or at least 3 seconds
Measure a polarization at start_value for a maximum of 5 seconds
Switch off
CC-CV
This example demonstrates how to use stop conditions to create a combined constant current - constant voltage (CC-CV) charging experiment.
Set variable charging_voltage to 4.13 V
Set a stop condition for the range between 3.5 V and charging_voltage, to stop if the voltage goes outside this range
Switch on in galvanostatic mode
Measure a galvanostatic polarization at 1 A until the stop condition is met or 1800 s have passed
Switch off and afterwards switch on in potentiostatic mode
Set an additional stop condition for current below 50 mA
Measure a potentiostatic polarization at charging_voltage until a stop condition is met or 1800 s have passed
Switch off
Naming and Combination
This is a complex example that demonstrates how to combine multiple measurement primitives into a single dataset using dynamic naming.
Set start_value to OCV
Initialize a variable last_bias with start_value
Switch on at start_value
Create a for-each loop with the loop parameter bias that will iterate over the list [500m, 1.0, 1.5]
Create a dynamic dataset name for the ramp and settling polarization to the next bias voltage with the name “ramp_and_settling_to_bias_{bias}”
Measure ramp from last_bias to bias at 100 mV/s
Measure potentiostatic polarization at bias for 10 s
Measure cyclic voltammetry starting and ending at bias, with vertex values of +/- 500 mV from bias. The dataset name is “cv_at_bias_{bias}”
Set last_bias to bias for the next iteration
Iterate over all bias values in the list, then switch off
Error Handling
Error handling can be a difficult concept to grasp at first. The following three examples show the most common situations and demonstrate step by step how the error handling blocks work in practice.
Script Error
A script error occurs when there is a logical mistake in your experiment. For example, trying to perform an operation on the wrong type of value.
In this example, a number is used where a list is expected, which triggers a "SCRIPT" error.
Inside the do section, the variable
iis set to the number1.Next, the experiment tries to set the first item of
ito500m, butiis a number, not a list. This is not a valid operation, so an error occurs.Because the error happened inside do, execution immediately stops there. Any blocks below this point in the do section are skipped.
The program jumps to the on error section. Here, a message box is displayed that combines the text
"An error has occurred, which has been caught."with the error type and the error message.The finally checkbox is not enabled, so no cleanup actions run.
The resulting message box looks like this:
The type is "SCRIPT" and the message explains that a property cannot be created on a number, confirming that the error was caused by treating a number as a list.
Device Error
A device error occurs when the IM7 reports a problem. For example, when the requested operating conditions cannot be achieved.
In this example, a "DEVICE" error is triggered because the potentiostat cannot deliver the requested current through the connected test object.
Inside the do section, the experiment tries to switch on the potentiostat
MAINin galvanostatic mode with a bias of1 A.However, a 100 MΩ resistor is connected as the test object. To push 1 A through 100 MΩ, the potentiostat would need to output 100 MV, which is far beyond its capabilities. The IM7 detects this and reports a device error. Execution in do stops immediately and the polarization block is not executed.
The program jumps to the on error section, which displays a message box showing the error type (
"DEVICE") and the error message with details from the IM7.The finally checkbox is enabled, so the finally section runs after on error has finished. Here it switches off the potentiostat
MAIN. In this particular case, the potentiostat never actually turned on (because the switch-on itself failed), so the switch-off has no practical effect. However, using finally for cleanup is still good practice. In other situations, the error might occur after the potentiostat has already been switched on.
The resulting message box looks like this:
The type is "DEVICE" and the message contains the details reported by the IM7 about why the potentiostat could not be switched on.
The finally section is especially useful for device cleanup. In this example, it makes sure the potentiostat is always switched off, even if an error occurs. This prevents the device from being left in an active state after a failed experiment.
Manual Stop
This example shows how to use the Do On Manual Stop block to react when the user presses the stop button during a running experiment.
The Do On Manual Stop block is placed at the top. It defines what should happen if the user clicks the stop button in the Zahner Lab:
Play a beep at 440 Hz for 0.5 seconds.
Display a message box with the text
"Manual Break".
Below that, an Open Circuit Voltage Scan runs for 10 seconds at a sample rate of 50 readings per second.
If the user presses the stop button while the scan is running, the scan is interrupted and the actions defined in the Do On Manual Stop block are executed. The beep sounds and the message box appears.
The resulting message box looks like this: