Instrument Control Lib
Framework to control Oscilloscopes, SMUs, Function Generators and DC Powersupplies via Ethernet.
KEI2600.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include "Device.h"
9 #include "types/SMU.h"
10 
11 namespace PIL {
12  class Logging;
13 }
14 
18 class KEI2600 : public SMU {
19 public:
20  explicit KEI2600(std::string ipAddress, int timeoutInMs, PIL::Logging *logger, SEND_METHOD mode = DIRECT_SEND);
21  [[maybe_unused]] explicit KEI2600(std::string ipAddress, int timeoutInMs, SEND_METHOD mode);
22 
23  virtual ~KEI2600() = default;
24 
25  PIL_ERROR_CODE measure(UNIT unit, SMU_CHANNEL channel, double *value, bool checkErrorBuffer) override;
26  double measurePy(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer);
27 
28  PIL_ERROR_CODE turnOn(SMU_CHANNEL channel, bool checkErrorBuffer) override;
29  PIL_ERROR_CODE turnOff(SMU_CHANNEL channel, bool checkErrorBuffer) override;
30 
31  PIL_ERROR_CODE setLevel(UNIT unit, SMU_CHANNEL channel, double level, bool checkErrorBuffer) override;
32  PIL_ERROR_CODE setLimit(UNIT unit, SMU_CHANNEL channel, double limit, bool checkErrorBuffer) override;
33 
34  PIL_ERROR_CODE enableMeasureAutoRange(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer);
35  PIL_ERROR_CODE disableMeasureAutoRange(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer);
36 
37  PIL_ERROR_CODE enableSourceAutoRange(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer);
38  PIL_ERROR_CODE disableSourceAutoRange(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer);
39 
40  PIL_ERROR_CODE enableMeasureAnalogFilter(SMU_CHANNEL channel, bool checkErrorBuffer);
41  PIL_ERROR_CODE disableMeasureAnalogFilter(SMU_CHANNEL channel, bool checkErrorBuffer);
42 
43  PIL_ERROR_CODE setMeasureRange(UNIT unit, SMU_CHANNEL channel, double range, bool checkErrorBuffer);
44  PIL_ERROR_CODE setSourceRange(UNIT unit, SMU_CHANNEL channel, double range, bool checkErrorBuffer);
45 
46  PIL_ERROR_CODE setSenseMode(SMU_CHANNEL channel, SMU_SENSE senseArg, bool checkErrorBuffer);
47  PIL_ERROR_CODE setMeasurePLC(SMU_CHANNEL channel, double value, bool checkErrorBuffer);
48  PIL_ERROR_CODE setMeasureLowRange(UNIT unit, SMU_CHANNEL channel, double value, bool checkErrorBuffer);
49  PIL_ERROR_CODE setMeasureAutoZero(SMU_CHANNEL channel, AUTOZERO autoZero, bool checkErrorBuffer);
50  PIL_ERROR_CODE setMeasureCount(SMU_CHANNEL channel, int nrOfMeasurements, bool checkErrorBuffer);
51  PIL_ERROR_CODE setSourceFunction(SMU_CHANNEL channel, SRC_FUNC srcFunc, bool checkErrorBuffer);
52  PIL_ERROR_CODE setSourceOffMode(SMU_CHANNEL channel, SRC_OFF_MODE srcOffMode, bool checkErrorBuffer);
53  PIL_ERROR_CODE setSourceSettling(SMU_CHANNEL channel, SRC_SETTLING srcSettling, bool checkErrorBuffer);
54  PIL_ERROR_CODE enableSourceSink(SMU_CHANNEL channel, bool checkErrorBuffer);
55  PIL_ERROR_CODE disableSourceSink(SMU_CHANNEL channel, bool checkErrorBuffer);
56  PIL_ERROR_CODE displayMeasureFunction(SMU_CHANNEL channel, SMU_DISPLAY displayMeasureFunc, bool checkErrorBuffer);
57 
58  PIL_ERROR_CODE enableBeep(bool checkErrorBuffer = true);
59  PIL_ERROR_CODE disableBeep(bool checkErrorBuffer);
60  PIL_ERROR_CODE beep(float timeInSeconds, int frequency, bool checkErrorBuffer);
61 
62  std::string getLastError();
63  PIL_ERROR_CODE clearErrorBuffer();
64  PIL_ERROR_CODE getErrorBufferStatus();
65 
66  PIL_ERROR_CODE performLinearVoltageSweep(SMU_CHANNEL channel, double startVoltage, double stopVoltage,
67  int increaseRate, double current, bool checkErrorBuffer);
68 
69  PIL_ERROR_CODE sendScript(const std::string &scriptName, const std::string &script, bool checkErrorBuffer);
70  PIL_ERROR_CODE sendVectorScript(const std::string &scriptName, const std::vector<std::string>& script,
71  bool checkErrorBuffer);
72  PIL_ERROR_CODE executeScript(const std::string &scriptName, bool checkErrorBuffer);
73  PIL_ERROR_CODE sendAndExecuteScript(const std::string &scriptName, const std::string &script,
74  bool checkErrorBuffer);
75  PIL_ERROR_CODE sendAndExecuteVectorScript(const std::string &scriptName, const std::vector<std::string>& script,
76  bool checkErrorBuffer);
77  PIL_ERROR_CODE executeBufferedScript(bool checkErrorBuffer);
78 
79  PIL_ERROR_CODE readBuffer(const std::string &bufferName, std::vector<double> *result, bool checkErrorBuffer);
80  std::vector<double> readBufferPy(const std::string &bufferName, bool checkErrorBuffer);
81  PIL_ERROR_CODE getBufferSize(const std::string &bufferName, int *value, bool checkErrorBuffer);
82  PIL_ERROR_CODE clearBuffer(const std::string &bufferName, bool checkErrorBuffer);
83  void clearBufferedScript();
84 
85  std::string CHANNEL_A_BUFFER = "A_M_BUFFER";
86  std::string CHANNEL_B_BUFFER = "B_M_BUFFER";
87 
88 private:
89  PIL_ERROR_CODE handleErrorCode(PIL_ERROR_CODE errorCode, bool checkErrorBuffer);
90 
91  PIL_ERROR_CODE toggleMeasureAnalogFilter(SMU_CHANNEL channel, bool enable);
92  PIL_ERROR_CODE toggleMeasureAutoRange(SMU_CHANNEL channel, UNIT unit, bool enable);
93  PIL_ERROR_CODE toggleSourceAutoRange(UNIT unit, SMU_CHANNEL channel, bool enable);
94  PIL_ERROR_CODE toggleBeep(bool enable);
95  PIL_ERROR_CODE toggleChannel(SMU_CHANNEL channel, bool enable);
96  PIL_ERROR_CODE toggleSourceSink(SMU_CHANNEL channel, bool enable);
97 
98  std::string getMeasurementStorage(SMU_CHANNEL channel);
99  PIL_ERROR_CODE readPartOfBuffer(int startIdx, int endIdx, const std::string &bufferName, char *printBuffer,
100  std::vector<double> *result, bool checkErrorBuffer);
101  PIL_ERROR_CODE appendToBuffer(int startIdx, int endIdx, const std::string &bufferName, char *printBuffer,
102  std::vector<double> *result, bool checkErrorBuffer);
103 
104  static std::string createPayload(const std::string &value);
105  static void createPayloadBatch(int offset, int numberOfLines, std::vector<std::string> values,
106  std::vector<std::string> *result);
107 
108  static std::string getChannelStringFromEnum(SMU_CHANNEL channel);
109  static std::string getStringFromAutoZeroEnum(AUTOZERO autoZero);
110  static std::string getStringFromSrcFuncEnum(SRC_FUNC srcFunc);
111  static std::string getStringFromOffModeEnum(SRC_OFF_MODE offMode);
112  static std::string getStringFromSettleEnum(SRC_SETTLING srcSettling);
113  static std::string getStringFromMeasureDisplayFunction(SMU_DISPLAY displayMeasureFunc);
114  static std::string getStringFromSenseValue(SMU_SENSE sense);
115  static std::string getLetterFromUnit(UNIT unit);
116  static std::string getMeasurementBufferName(SMU_CHANNEL channel);
117 
118  int m_BufferEntriesA = 1;
119  int m_BufferEntriesB = 1;
120  std::vector<std::string> defaultBufferedScript{CHANNEL_A_BUFFER + " = smua.makebuffer(%A_M_BUFFER_SIZE%)",
121  CHANNEL_B_BUFFER + " = smub.makebuffer(%B_M_BUFFER_SIZE%)",
122  CHANNEL_A_BUFFER + ".appendmode = 1",
123  CHANNEL_B_BUFFER + ".appendmode = 1"};
124 };
SEND_METHOD
Definition: Device.h:33
@ DIRECT_SEND
Definition: Device.h:34
This class implements the basic functionality of Keithley 2600 series SMU's.
Definition: KEI2600.h:18
PIL_ERROR_CODE executeBufferedScript(bool checkErrorBuffer)
Executes the buffered script.
Definition: KEI2600.cpp:1004
PIL_ERROR_CODE getErrorBufferStatus()
Request amount of elements in error queue. If queue is empty return PIL_NO_ERROR otherwise return PIL...
Definition: KEI2600.cpp:807
PIL_ERROR_CODE sendVectorScript(const std::string &scriptName, const std::vector< std::string > &script, bool checkErrorBuffer)
Sends the given script to the SMU. The scripts does not get executed.
Definition: KEI2600.cpp:906
virtual ~KEI2600()=default
PIL_ERROR_CODE readBuffer(const std::string &bufferName, std::vector< double > *result, bool checkErrorBuffer)
Reads the complete buffer with the given name.
Definition: KEI2600.cpp:1068
PIL_ERROR_CODE setMeasurePLC(SMU_CHANNEL channel, double value, bool checkErrorBuffer)
Sets the integration apeture for measurements.
Definition: KEI2600.cpp:540
PIL_ERROR_CODE setMeasureLowRange(UNIT unit, SMU_CHANNEL channel, double value, bool checkErrorBuffer)
Sets the lowest measurement range that is used when the instrument is autoranging.
Definition: KEI2600.cpp:566
PIL_ERROR_CODE enableMeasureAnalogFilter(SMU_CHANNEL channel, bool checkErrorBuffer)
Enables the analog filter mode for a certain channel. This engages an approximately 1 Hz analog filte...
Definition: KEI2600.cpp:372
PIL_ERROR_CODE disableSourceAutoRange(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer)
Disables source auto-range mode.
Definition: KEI2600.cpp:318
PIL_ERROR_CODE enableSourceSink(SMU_CHANNEL channel, bool checkErrorBuffer)
Turns on the source sink mode. This reduces the source limit inaccuracy that occurs when operating in...
Definition: KEI2600.cpp:414
PIL_ERROR_CODE beep(float timeInSeconds, int frequency, bool checkErrorBuffer)
Send a beeping sound with a specific duration and frequency to the SMU.
Definition: KEI2600.cpp:761
PIL_ERROR_CODE turnOn(SMU_CHANNEL channel, bool checkErrorBuffer) override
Turns on a specific channel of the KEI2600-SMU.
Definition: KEI2600.cpp:131
PIL_ERROR_CODE setSourceRange(UNIT unit, SMU_CHANNEL channel, double range, bool checkErrorBuffer)
Assigning a value to this attribute sets the SMU to a fixed range large enough to source the assigned...
Definition: KEI2600.cpp:489
PIL_ERROR_CODE clearBuffer(const std::string &bufferName, bool checkErrorBuffer)
Clears the buffer with the given name.
Definition: KEI2600.cpp:1026
PIL_ERROR_CODE clearErrorBuffer()
Clear the error buffer.
Definition: KEI2600.cpp:794
PIL_ERROR_CODE sendAndExecuteVectorScript(const std::string &scriptName, const std::vector< std::string > &script, bool checkErrorBuffer)
Sends and executes the given script.
Definition: KEI2600.cpp:988
PIL_ERROR_CODE setSourceOffMode(SMU_CHANNEL channel, SRC_OFF_MODE srcOffMode, bool checkErrorBuffer)
Sets the source output-off mode.
Definition: KEI2600.cpp:660
PIL_ERROR_CODE executeScript(const std::string &scriptName, bool checkErrorBuffer)
Executes the script with the given name on the smu.
Definition: KEI2600.cpp:959
PIL_ERROR_CODE getBufferSize(const std::string &bufferName, int *value, bool checkErrorBuffer)
Retrieves the size of the buffer with the given name.
Definition: KEI2600.cpp:1140
PIL_ERROR_CODE measure(UNIT unit, SMU_CHANNEL channel, double *value, bool checkErrorBuffer) override
This function measures a certain unit on a specific channel. This function can be used to measure vol...
Definition: KEI2600.cpp:51
std::vector< double > readBufferPy(const std::string &bufferName, bool checkErrorBuffer)
Reads the complete buffer with the given name. Instead of returning the received error code,...
Definition: KEI2600.cpp:1104
PIL_ERROR_CODE displayMeasureFunction(SMU_CHANNEL channel, SMU_DISPLAY displayMeasureFunc, bool checkErrorBuffer)
Specify the type of measurement currently displayed.
Definition: KEI2600.cpp:703
void clearBufferedScript()
Definition: KEI2600.cpp:1159
PIL_ERROR_CODE setSourceFunction(SMU_CHANNEL channel, SRC_FUNC srcFunc, bool checkErrorBuffer)
Set the source function which can bei either voltage or current.
Definition: KEI2600.cpp:640
KEI2600(std::string ipAddress, int timeoutInMs, PIL::Logging *logger, SEND_METHOD mode=DIRECT_SEND)
Constructor initializes the ip address and timeout. Disables the logger.
Definition: KEI2600.cpp:25
std::string getLastError()
Return last error in error-queue.
Definition: KEI2600.cpp:770
PIL_ERROR_CODE performLinearVoltageSweep(SMU_CHANNEL channel, double startVoltage, double stopVoltage, int increaseRate, double current, bool checkErrorBuffer)
Perform a linear voltage sweep on the SMU. Increases the voltage at the given rate until the stop vol...
Definition: KEI2600.cpp:839
PIL_ERROR_CODE enableBeep(bool checkErrorBuffer=true)
Enable beeper on the SMU. This command is mandatory to play beeping sounds afterwards.
Definition: KEI2600.cpp:723
PIL_ERROR_CODE setSenseMode(SMU_CHANNEL channel, SMU_SENSE senseArg, bool checkErrorBuffer)
Sets the sense mode of a specific channel. LOCAL, REMOTE or CALA is supported. When selecting LOCAL,...
Definition: KEI2600.cpp:520
PIL_ERROR_CODE setSourceSettling(SMU_CHANNEL channel, SRC_SETTLING srcSettling, bool checkErrorBuffer)
Set the source settling mode. (See SRC_SETTLING enum for more information)
Definition: KEI2600.cpp:681
PIL_ERROR_CODE disableSourceSink(SMU_CHANNEL channel, bool checkErrorBuffer)
Turns off the source sink mode.
Definition: KEI2600.cpp:424
PIL_ERROR_CODE disableMeasureAutoRange(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer)
Sets the SMU in fixed range measurement mode for a certain unit, e.g. voltage or current.
Definition: KEI2600.cpp:261
PIL_ERROR_CODE setMeasureRange(UNIT unit, SMU_CHANNEL channel, double range, bool checkErrorBuffer)
Sets the measure range (positive full-scale value of the measurement range of that SMU)....
Definition: KEI2600.cpp:458
PIL_ERROR_CODE enableMeasureAutoRange(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer)
Sets the SMU in auto-range mode for a certain unit, e.g. voltage or current.
Definition: KEI2600.cpp:250
PIL_ERROR_CODE setMeasureCount(SMU_CHANNEL channel, int nrOfMeasurements, bool checkErrorBuffer)
Sets the number of measurements made when a measurement is requested.
Definition: KEI2600.cpp:621
PIL_ERROR_CODE setLimit(UNIT unit, SMU_CHANNEL channel, double limit, bool checkErrorBuffer) override
Sets the limit of a certain channel of a certain unit. Allowed are power voltage and current....
Definition: KEI2600.cpp:215
PIL_ERROR_CODE disableMeasureAnalogFilter(SMU_CHANNEL channel, bool checkErrorBuffer)
Disables the analog filter mode of a certain channel.
Definition: KEI2600.cpp:382
PIL_ERROR_CODE disableBeep(bool checkErrorBuffer)
Disable beeper on the SMU. This command is mandatory to play beeping sounds afterwards.
Definition: KEI2600.cpp:732
PIL_ERROR_CODE sendAndExecuteScript(const std::string &scriptName, const std::string &script, bool checkErrorBuffer)
Sends and executes the given script.
Definition: KEI2600.cpp:978
PIL_ERROR_CODE sendScript(const std::string &scriptName, const std::string &script, bool checkErrorBuffer)
Sends the given script to the SMU. The scripts does not get executed.
Definition: KEI2600.cpp:896
double measurePy(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer)
Measurement method identical to KEI2600::measure, but in this method, the value is directly returned ...
Definition: KEI2600.cpp:100
std::string CHANNEL_A_BUFFER
Definition: KEI2600.h:85
PIL_ERROR_CODE enableSourceAutoRange(UNIT unit, SMU_CHANNEL channel, bool checkErrorBuffer)
Enables source auto-range mode. The SMU immediately changes range to the range most appropriate for t...
Definition: KEI2600.cpp:307
PIL_ERROR_CODE turnOff(SMU_CHANNEL channel, bool checkErrorBuffer) override
Turns off a specific channel of the KEI2600-SMU.
Definition: KEI2600.cpp:141
PIL_ERROR_CODE setMeasureAutoZero(SMU_CHANNEL channel, AUTOZERO autoZero, bool checkErrorBuffer)
Enables or disableds automatic updates to the internal reference measurements (autozero) of the instr...
Definition: KEI2600.cpp:600
std::string CHANNEL_B_BUFFER
Definition: KEI2600.h:86
PIL_ERROR_CODE setLevel(UNIT unit, SMU_CHANNEL channel, double level, bool checkErrorBuffer) override
Sets the level of a certain channel and of a certain unit. It can set the voltage or current on Chann...
Definition: KEI2600.cpp:180
Dummy class to allow assignment to SMU class.
Definition: SMU.h:12
SRC_OFF_MODE
Definition: SMU.h:55
UNIT
Unit which should be changed or measured.
Definition: SMU.h:31
SRC_FUNC
Definition: SMU.h:48
SRC_SETTLING
Definition: SMU.h:64
SMU_CHANNEL
Used to select which channel of the SMU should be used to measure or supplied.
Definition: SMU.h:20
SMU_DISPLAY
Definition: SMU.h:79
AUTOZERO
Definition: SMU.h:39
SMU_SENSE
Definition: SMU.h:90
This class contains a implementation of a command line interface. It supports various functions like ...
Definition: CommandLineInterface.h:16