Here, we will cover how to operate a Squidstat in Manual Mode. The Squistat API provides a set of manual mode commands as functions, which allow the user to control the squidstat while an experiment is running. Which can be useful for for scenarios where the user needs to change parameters on the fly (i.e. in a GUI application). See the manual experiments tab in the Squidstat User Interface software for an example use case of this feature.
Manual Mode Commands
The following commands are provided by the AisInstrumentHandler to control the Squidstat.
This class contains the possible error codes returned to the user when working with the API....
Definition AisErrorCode.h:18
AisErrorCode setManualModeVoltageAutorange(uint8_t channel) const
enable voltage autoranging for the manual experiment.
AisErrorCode setManualModeOCP(uint8_t channel) const
set open-circuit potential mode.
AisErrorCode setManualModeCurrentRange(uint8_t channel, int currentRangeIndex) const
set the current range for the manual experiment. Once a range is set, autoranging capability is turne...
AisErrorCode setManualModeVoltageRange(uint8_t channel, int voltageRangeIndex) const
set the voltage range for the manual experiment. Once a range is set, autoranging capability is turne...
AisErrorCode setManualModeConstantVoltage(uint8_t channel, double value) const
set constant voltage for the manual experiment.
AisErrorCode setManualModeCurrentAutorange(uint8_t channel) const
enable current autoranging for the manual experiment.
AisErrorCode setManualModeSamplingInterval(uint8_t channel, double value) const
set an interval for sampling the data.
AisErrorCode setManualModeConstantCurrent(uint8_t channel, double value) const
set constant current for the manual experiment.
Start the Experiment
Before calling any of the above commands, the manual experiment must be started.
- C++
qDebug() << "Starting manual mode at open circuit potential";
AisErrorCode error = handler.startManualExperiment(CHANNEL);
qDebug() << error.message();
QCoreApplication::quit();
}
- Python
print("Starting manual mode at open circuit potential")
error = handler.startManualExperiment(CHANNEL)
if error.value() != AisErrorCode.Success:
print(error.message())
app.quit()
Now our experiment will run indefinitely, until AisInstrumentHandler::stopExperiment is called.
Manual Modes
The three main operational modes are OCP (Open Circuit Potential), Potentiostatic, and Galvanostatic, defined below:
- OCP: Measures the open circuit potential of the system.
- Potentiostatic: Maintains a constant potential while measuring current.
- Galvanostatic: Maintains a constant current while measuring potential.
Here is an example of how to set each at timed intervals after an experiment has started.
- C++
QTimer::singleShot(5000, [=, &handler]() {
qDebug() << "Switching to constant current at .1A";
AisErrorCode error = handler.setManualModeConstantCurrent(CHANNEL, .1);
qDebug() << error.message();
}
});
QTimer::singleShot(15000, [=, &handler]() {
qDebug() << "Switching to constant voltage at 1V";
AisErrorCode error = handler.setManualModeConstantVoltage(CHANNEL, 1);
qDebug() << error.message();
}
});
QTimer::singleShot(25000, [=, &handler]() {
qDebug() << "Switching to open circuit potential";
qDebug() << error.message();
}
});
- Python
def setConstantCurrent(channel):
print("Switching to constant current at .1A")
error = handler.setManualModeConstantCurrent(channel, .1)
if error.value() != AisErrorCode.Success:
print(error.message())
QTimer.singleShot(5000, lambda:setConstantCurrent(CHANNEL))
def setConstantVoltage(channel):
print("Switching to constant voltage at 1V")
error = handler.setManualModeConstantVoltage(channel, 1)
if error.value() != AisErrorCode.Success:
print(error.message())
QTimer.singleShot(15000, lambda:setConstantVoltage(CHANNEL))
def setOpenCircuit(channel):
print("Switching to open circuit potential")
error = handler.setManualModeOCP(channel)
if error.value() != AisErrorCode.Success:
print(error.message())
QTimer.singleShot(25000, lambda:setOpenCircuit(CHANNEL))
Note: As a reminder, it is always a good idea to check the error code returned by each command to ensure successful execution. See AisErrorCode for more information.
Stop the Experiment
Stopping the manual experiment uses the same command as stopping a normal experiment (AisInstrumentHandler::stopExperiment). In this case, we use a SingleShot timer (C++ | Python) to stop the experiment after 30 seconds.
- C++
QTimer::singleShot(30000, [=, &handler]() {
qDebug() << "Stopping experiment";
qDebug() << error.message();
}
});
- Python
def stopExperiment(channel):
print("Stopping experiment.")
error = handler.stopExperiment(channel)
if error.value() != AisErrorCode.Success:
print(error.message())
QTimer.singleShot(30000, lambda:stopExperiment(CHANNEL))
See the full example here