python-3.xinstrumentationvisaoscilloscopepyvisa

Python code to read/write label of oscilloscope


I have written a small Python code to read back the label of a particular channel on my Tektroniks oscilloscope. The following code works well and gives the expected result.

import visa
rm=visa.ResourceManager()
Tek_Scope= rm.open_resource('USB0::0x0699::0x0409::C010314::INSTR')

Tek_Scope.write("CH2:LABEL?")
Readback= Tek_Scope.read()
print(Readback)

However, when I try to change the label of the same channel, the label name does not change. I do not get any error either. It seems I am missing any syntax to communicate and write to the instrument? In the following code, I am trying to rename my Ch1 label to VDD

Tek_Scope.write('CH1:LABEL %s' %'VDD' )

Please advise if someone has idea about this.


Solution

  • It appears that you have to quote string parameters to VISA commands:

    Tek_Scope.write('CH1:LABEL "%s"' % 'VDD')