EPC SCPI Operation Change
It is possible to operate the external potentiostats via EPC and Thales or via USB and Python without Thales, this operation is also called SCPI operation because of the used protocol.
For multichannel operation, the Zennium is secured with Python lock
objects so that when multiple channels with multiple threads try to access the Zennium at the same time, it is ensured that no race conditions occur.
This requires a basic understanding of multithreading and thread synchronization.
In the examples, the sequence and the switch are correctly synchronized.
The two functions acquireSharedZennium()
and releaseSharedZennium()
call the aquire and release methods of the Python lock object, which is used for synchronization.
By default, the potentiostat is switched off when the operating mode is changed, since voltage and current are not monitored during the change. But it is possible to leave the potentiostat switched on during the changeover, for example to measure EIS directly after polarization in SCPI.
Please note the Risk Assessment Document for these applications.
When switching between EPC and SCPI, manual attention must be paid to range exceeding. This is especially important for the voltage channels. For example, the XPOT2 has a range of +- 4 V in index 0 in Thales EPC mode and +- 5 V in SCPI mode.
In the following the steps are explained which are necessary for this operating mode. In the GitHub example you can see the detailed practical use.
Steps before operation
In the following the steps are listed which are necessary for this operation. This can be seen in detail in the GitHub example.
Connect the external potentiostat (XPOT2, PP2x2, EL1002) with USB to the computer. At the same time, connect the device to a Zennium using the EPC cable.
Switch on all devices.
Allow the equipment to warm up for at least 30 minutes.
Select and calibrate the EPC-device in Thales (with Remote2).
Switching the EPC-device to SCPI mode via Remote2 command.
Performing the offset calibration with Python/SCPI.
The device setup is prepared for alternating operation between Thales and Python/SCPI control.
Switch from SCPI to EPC
The following two steps are necessary for this operating mode change:
Acquire the Zennium that all devices share with the method
acquireSharedZennium()
. This method returns the value of the Python lock object. True if aquiring was successful. Passing the parameter blocking = False can be used to be able to do something else as long as the Zennium is not available.Switch the device from SCPI to EPC with the method
switchToEPC()
. If the parameter keepPotentiostatState = True is passed, then the potentiostat is not switched off when the operating mode is changed.
Switch from EPC to SCPI
This switch is easier because the Zennium can be released and switched to USB in one step, since USB allows all devices to be controlled in parallel at once, unlike EPC.
Only the method switchToSCPIAndReleaseSharedZennium()
must be called.
The Zennium is then released for other devices and the SCPI object is valid again.
Depending on the computer the change takes a few seconds.
Control classes
- class EpcScpiHandler(sharedZennium: ThalesRemoteScriptWrapper, epcPotentiostatId: int, serialNumber: int)
Class for the control objects.
This class manages the object composed of a cennium and the external potentiostat. The object contains an instance of a
SCPIDevice
and the shared commonThalesRemoteScriptWrapper
object.The SCPI object is invalid when the device is in EPC mode. The device must be manually switched from EPC to SCPI before the SCPI object can be used again.
- Parameters
sharedZennium (
ThalesRemoteScriptWrapper
) – Zennium object.epcChannel – Number of the EPC channel to which the device is connected via EPC cable. If a Rmux card is plugged in then the numbers have an offset.
serialNumber – Serial number of the external potentiostat.
Check if the zennium is available.
The method checks if the threading.lock for synchronizing access to the Zennium is available.
- Returns
True if the zennium is not locked and available.
Check if the Zennium is available.
Wrapper for the aquire method of the Python lock object. The parameters and return values are simply passed through.
- Parameters
blocking – When invoked with the blocking argument set to True (the default), block until the lock is unlocked, then set it to locked and return True.
timeout – When invoked with the floating-point timeout argument set to a positive value, block for at most the number of seconds specified by timeout and as long as the lock cannot be acquired. A timeout argument of -1 specifies an unbounded wait. It is forbidden to specify a timeout when blocking is false.
- Returns
The return value is True if the lock is acquired successfully, False if not (for example if the timeout expired).
Release the Zennium object.
Wrapper for the aquire method of the Python lock object.
Release a lock. This can be called from any thread, not only the thread which has acquired the lock. When the lock is locked, reset it to unlocked, and return. If any other threads are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed.
When invoked on an unlocked lock, a RuntimeError is raised.
- connectSCPIDevice() None
Establish connection to the potentiostat.
This method establishes the connection to the potentiostat (PP2x2, XPOT2 and EL1002) and passes it to the internal data structure. When invoked on an unlocked lock, a RuntimeError is raised.
Switch from EPC to SCPI mode of the potentiostat and release the Zennium.
The switch from EPC to SCPI must be made from the EPC operation, both control options can only release control but cannot take control away from each other.
After the control is released, the Zennium is released.
- Parameters
keepPotentiostatState – If this parameter is True, the potentiostat is not switched off when switching from EPC to SCPI.
- switchToSCPI(keepPotentiostatState: bool = False) None
Switch from EPC to SCPI mode.
It is recommended to use
switchToSCPIAndReleaseSharedZennium
instead of this function.Before calling this method, the Zennium must have been released, since these methods call aquire and release themselves. If the Zennium was locked before this function will block.
- Parameters
keepPotentiostatState – If this parameter is True, the potentiostat is not switched off when switching from EPC to SCPI.
- switchToEPC(keepPotentiostatState: bool = False) None
Switch from SCPI to EPC mode.
Before calling this method the Zennium must be locked with aquire.
This method is used to switch from SCPI to EPC operation. After this method is called, the scpiInterface object is destroyed because the USB connection is closed.
This method automatically selects the correct EPC channel.
- Parameters
keepPotentiostatState – If this parameter is True, the potentiostat is not switched off when switching from SCPI to EPC.
- close()
Close the SCPI connection.
The function is not required in epc mode.
- class EpcScpiHandlerFactory(shared_zennium_target='127.0.0.1')
Class for creating the control objects.
This class initializes the connection to the zennium. The
createEpcScpiHandler()
method can then be used to create a control object for the corresponding device.- Parameters
shared_zennium_target – IP address at which the Zennium can be reached. Default is “localhost”.
Returns the zennium object.
Returns the Zennium object, which contains the Remote2 commands as methods.
- Returns
Object with the Remote2 wrapper.
- getZenniumConnection() ThalesRemoteConnection
Returns the zennium connection object.
Returns the object that manages the connection to the zennium.
- Returns
Object with the connection to the zennium.
- createEpcScpiHandler(epcChannel: int, serialNumber: int) EpcScpiHandler
Returns the zennium connection object.
This method initializes the external potentiostats and creates the objects.
The objects are in SCPI mode after calling this function. For compatibility, the devices always start in EPC mode when connected to EPC, then they must be switched to SCPI standalone mode via Remote2. It is only possible to switch to SCPI mode via Remote2.
- Parameters
epcChannel – Number of the EPC channel to which the device is connected via EPC cable. If a Rmux card is plugged in then the numbers have an offset.
serialNumber – Serial number of the external potentiostat.
- Returns
Object with the external potentiostat.
- closeAll() None
Close connections to all devices.
This command closes all connections to the external potentiostats and to the Zennium.