1

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.

Sinha
  • 431
  • 1
  • 5
  • 12
  • Sorry for the confusion. I have Python 3. I removed the tag for Phtyon 2 just now. – Sinha Aug 16 '18 at 18:32
  • can you post the write function or a minimal example demonstrating your problem? – darrahts Aug 16 '18 at 18:42
  • The write() is a part of the PYVISA library i am using (I guess). Just now, I modified my code in my original issue description to reflect this. I have also added a PyVisa label now. – Sinha Aug 16 '18 at 19:07

1 Answers1

2

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

Tek_Scope.write('CH1:LABEL "%s"' % 'VDD')
jasonharper
  • 9,450
  • 2
  • 18
  • 42
  • Yes this works now. Although I am wondering that when I tried the following command for some other test involving writing an float (than a string), I was able to do so without need for " " around %f **Instrument.write(" SOURCE:VOLTAGE:LEVEL:IMMEDIATE:AMPLITUDE %f " % VDD_input)** – Sinha Aug 16 '18 at 19:13
  • 2
    Well, that's a number - there's no ambiguity as to where the parameter ends, unlike a string that might contain spaces. – jasonharper Aug 16 '18 at 19:15
  • Thanks a lot for your help! – Sinha Aug 16 '18 at 19:21