My supervisor suggested that we use python for remote control of equipment. This is primarily a reference for future Deepika, but I hope will also be helpful for some other engineer.
1. Download python and run its msi to download python in Windows.
2. Install pip: python get-pip.py
3. Install visa: pip install pyvisa
On Mac: I downloaded pyvisa https://pypi.python.org/pypi/PyVISA and ran python setup.py install from terminal.
import visa will work as is. But one will need to add path to file to be imported before you can import files.
If the instrument is connected through Ethernet: try this
Restart the instrument to go to its Windows menu. Run ipconfig /all to get the Ethernet adapter Local Area Connection address --> ip_address.
import visa
rm = visa.ResourceManager()
scope = rm.get_instrument("USB::hex::hex::hex::INSTR")
print scope.ask('*IDN?')
scope.write('measurement:source ch1')
scope.write('measurement:type frequency')
print scope.ask('measurement:immed:value?')
scope.ask('ch2:scale?')
scope.ask('horizontal:scale?')
#change voltage scale
scope.write('ch2:scale 1.0000')
#change time scale
scope.write('horizontal:scale 1.0000E-9')
#stop
scope.write('acquire:state off')
#run
scope.write('acquire:state on')
References:
1. Video from Tektronix to get started
2. There is a minor error in the previous reference. This is how to fix it: fix
3. Programming manual
4. Useful example, and example2
5. You can use rm.list_resources() to get the identifier of the instrument. For other devices that I am connecting to, I used object_handle = rm.open_resource(identifier). PyVisa will handle GPIB, RS232, USB and sockets. Tutorial
6. Note that list_resources() will not give any information about instruments connected via LAN. You need to know the IP address of the instruments to start the communication. Use scope = rm.get_instrument("TCPIP::ip_addr::INSTR")
7. On one particular windows machine, the command prompt did not recognize pip as a command even after I installed pip. echo %PATH% showed no signs of pip. You can update path variable, or use doskey/ alias.
doskey pip=C:\Python<insert_version_here>\scripts\pip
Now the command prompt found pip, understood the install option but kept looping around help menu. I downloaded pyvisa.tar.gz, used 7 zip to extract and ran python setup.py install to install pyvisa.
8. You can use ipconfig/all to get your ip address. Then ping self. Use arp -a to find other devices on the network.
1. Download python and run its msi to download python in Windows.
2. Install pip: python get-pip.py
3. Install visa: pip install pyvisa
On Mac: I downloaded pyvisa https://pypi.python.org/pypi/PyVISA and ran python setup.py install from terminal.
import visa will work as is. But one will need to add path to file to be imported before you can import files.
import sys
sys.path.insert(0, '/path/to/directory')
4. Download Tekvisa and install its .exeIf the instrument is connected through Ethernet: try this
Restart the instrument to go to its Windows menu. Run ipconfig /all to get the Ethernet adapter Local Area Connection address --> ip_address.
import visa
rm = visa.ResourceManager()
scope = rm.get_instrument("USB::hex::hex::hex::INSTR")
print scope.ask('*IDN?')
scope.write('measurement:source ch1')
scope.write('measurement:type frequency')
print scope.ask('measurement:immed:value?')
scope.ask('ch2:scale?')
scope.ask('horizontal:scale?')
#change voltage scale
scope.write('ch2:scale 1.0000')
#change time scale
scope.write('horizontal:scale 1.0000E-9')
#stop
scope.write('acquire:state off')
#run
scope.write('acquire:state on')
References:
1. Video from Tektronix to get started
2. There is a minor error in the previous reference. This is how to fix it: fix
3. Programming manual
4. Useful example, and example2
5. You can use rm.list_resources() to get the identifier of the instrument. For other devices that I am connecting to, I used object_handle = rm.open_resource(identifier). PyVisa will handle GPIB, RS232, USB and sockets. Tutorial
6. Note that list_resources() will not give any information about instruments connected via LAN. You need to know the IP address of the instruments to start the communication. Use scope = rm.get_instrument("TCPIP::ip_addr::INSTR")
7. On one particular windows machine, the command prompt did not recognize pip as a command even after I installed pip. echo %PATH% showed no signs of pip. You can update path variable, or use doskey/ alias.
doskey pip=C:\Python<insert_version_here>\scripts\pip
Now the command prompt found pip, understood the install option but kept looping around help menu. I downloaded pyvisa.tar.gz, used 7 zip to extract and ran python setup.py install to install pyvisa.
8. You can use ipconfig/all to get your ip address. Then ping self. Use arp -a to find other devices on the network.
No comments:
Post a Comment