#chose a mode with the instrument will run, check the manual to see all modes.
defconfigMode(self,mode):
ifmode<0andmode>16:
print("INVALID INPUT")
else:
self.__s.send("CONF:HW:MODE "+str(mode)+"\n")
self.checkErrors()
self.validMode()
#check if the mode is valid for the current hardware
defvalidMode(self):
self.__s.send("CONF:HW:MODE:VAL")
print(self.receiveString())
#Command configures if [SOURCe:]<Function> commands are immediately or phase-angle controlled Query returns the synchronous operating mode
definstrumentSync(self,value):
ifvalue==0orvalue==1:
self.__s.send("CONF:INST:SYNC "+str(value)+"\n")
else:
print("INVALID INPUT")
#The 9400 will contain one (1), two (2), or three (3) logical instruments depending on the CONFigure:HW:MODE selected. Unless otherwise noted in a specific command, Any command or queries with an INSTRUMENT scope will be processed by the last instrument selected by either an INSTrument:NSELect or an INSTrument:SELect.
definstrumentNselect(self,value):
ifvalue<1orvalue>3:
print("INVALID INPUT")
else:
self.__s.send("INST:NSEL "+str(value)+"\n")
self.checkErrors()
#Command selects an instrument by its alias name created with INSTrument:DEFine[:NAME]. Query returns the current selected logical instrument alias name.
#check this command, maybe something wrong
definstrumentSelect(self):
self.__s.send("INST:SEL")
self.checkErrors()
#Command assigns an alias name allowing selection of the instrument using INSTrument:SELect <name> Query returns the alias name assigned to a specific output channel.
definstrumentDefName(self,name,num):
self.instrumentNselect(num)
self.__s.send("INST:DEF:"+str(name)+"\n")
self.checkErrors()
#Command disassociates an <identifier> alias from the logical instrument number.
#After the command executes, the default identifier is re-associated with the instrument number.
#The default identifier cannot be deleted.
definstDelName(self,name):
self.__s.send("INST:DEL:"+str(name)+"\n")
self.checkErrors()
#Query returns the <identifier> alias for the requested instrument number.
#If no instrument number is provided, the <identifier> of the selected instrument is returned.
definstrumentName(self,num):
ifnum<1ornum>3:
print("INVALID INPUT")
else:
self.__s.send("INST:NAME "+str(num)+"\n")
self.checkErrors()
#Function that receives messages back and transform it in a string
defreceiveString(self):
msg=self.__s.recv(1024)
...
...
@@ -37,42 +90,43 @@ class NHR9400:
#Function to see if exist any error in the carry
defcheckErrors(self):
self.__s.send("SYST:ERR?\n")
self.__s.timeout(5)
returnself.receive()
# Controle do relé de saída do hardware (LIGAR OU DESLIGAR)
# 0 OFF - Instrumento desabilitado
# 1 ON - Instrumento habilitado
defenableOutput(self,value):
ifvalue==0orvalue==1:
self.__s.send("SOUR:OUTP:ON "+value+"\n")
self.__s.send("SOUR:OUTP:ON "+str(value)+"\n")
else:
print("INVALID INPUT")
################################# Setters and Getters ################################################
#set limit voltage of all phases
defsetVoltage(self,voltage):
self.__s.send("SOUR:VOLT "+voltage+"\n")
self.__s.send("SOUR:VOLT "+str(voltage)+"\n")
#Functions that sets the limits voltage on one phase (A, B or C)