Open ScotchWhiskey opened 2 years ago
Images if of use
Just to add, someone used a hyper terminal and could talk to the device. So I now have the idn. But I still cannot execute through python. Their hyper terminal is from hilgraeve and has to be paid for it seems. So I cannot use it. So any suggestions as to what the problem is? I can connect to the device but not send commands or receive information from the device.
I do not have a C-compiler on my desktop, could this be an issue?
A C compiler is not required. And I would suggest you use the ivi backend (no argument to ResourceManager) over the py backend since you have a working VISA installation it seems.
Looking at your device manual you should use either ;
or \r
as write_termination and ;
as read termination. Using the TCPIP interface would also eliminate possible issues with a bad configuration of the serial link. finally you can use inst2.read_bytes(1)
to read a single byte at a time which can allow to figure out if the instrument is responding and what is the actual term char.
Hope this helps
Thankyou. Is the fact that I do not have a backend for PyUSB an issue? I am struggling to understand how to actually set it up as I have not done something like it before. I tried using ; and it did not work. But I will give the TCIP a go whn I can.
Your instrument is providing a serial emulation over usb as a consequence you do not need to care about pyusb. By the return value of pyserial.write is simply the number of character that was sent. You need to read to see any response from your device.
The TCIP didn't work either. We cannot ping the IP address of the laser, we get 'request timed out'.
With IVI backend we get an empty list.
We tried a different computer and the same.
However I think the problem is I was running
#import visa
import serial
import numpy as np
#rm = visa.ResourceManager() #checks devices that are
rm = visa.ResourceManager('@py') #to take the python backend
#rm = visa.ResourceManager('@sim')
print(rm.list_resources())
inst1 = rm.list_resources()
folowed by the import serial part. S0 it is working now i.e. I can get the idn. Trying to figure out how to send commands now as getting err 101's when trying to to eg set the wavelength using 'Wav 1550;'. If you have any tips for this let me know please. And thankyou for your help!
Pyvisa automatically adds the write termination for you so try removing the trailing ;
Instrument details
Output of
pyvisa-info
Version: 1.12.0 (bundled with PyVISA)
1: C:\Windows\system32\visa32.dll:
py: Version: 0.5.3 ASRL INSTR: Available via PySerial (3.5) USB INSTR: PyUSB does not seem to be properly installed. Please refer to PyUSB documentation and install a suitable backend like libusb 0.1, libusb 1.0, libusbx, libusb-win32 or OpenUSB. No backend available USB RAW: PyUSB does not seem to be properly installed. Please refer to PyUSB documentation and install a suitable backend like libusb 0.1, libusb 1.0, libusbx, libusb-win32 or OpenUSB. No backend available TCPIP INSTR: Available TCPIP SOCKET: Available GPIB INSTR: Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of funcionality. No module named 'gpib' sim: Version: 0.5.1 Spec version: 1.1
Hi,
I am trying to connect a Cobright DX4 laser to my computer to control it from my computer. However I am unable to do so. I have tried using both rm.openresource() and through pyserial. However neither seem to work.
However when I query the ID:
I get a timeout error:
VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
I have also tried to connect using pyserial.
ser.isOpen()
True
Now when I try to send a command eg
ser.write(str.encode('*IDN?'))
is the output. I am unsure as to what the issue. Ihave tried other commands and get numbers also eg 8, 16. I cannot decode having encoded. I coonected a thorlab power meter and this was recognised. Any help is appreciated!