McDermott-Group / servers

Public repo that stores LabRAD servers and other non-measurement related code
0 stars 2 forks source link

Current VNA server questions. #90

Closed roboguy222 closed 7 years ago

roboguy222 commented 7 years ago

What is the point of the ReadRawGPIBDeviceWrapper class?

roboguy222 commented 7 years ago

Also, these VNA servers have settings get_trace(), get_s2p(), and get_s_parameters(). Do we need/want all of these?

amopremcak commented 7 years ago

At most two but ideally just one, are there any non-trivial differences between the methods? That is, could you use one of these methods to rewrite the other two?

patzinak commented 7 years ago

The wrapper just adds the read_raw() method to the gpib.py in LabRAD package instead of tweaking it as we are used to do. To my knowledge the GPIB server from the UCSB server repository hadn't got corresponding setting till very-very recently but I don't think we have updated ours.

roboguy222 commented 7 years ago

Why do we use this only for one of the servers and not the others?

It also seems like it is calling itself. Maybe I am just reading this wrong, but I am quite confused by the function.

patzinak commented 7 years ago

Guilhem had arguments in support of all three methods. get_trace() is supposed to get a trace from the screen, while the other two to configure the device and get either all or a subset of the S-parameters. Some code duplication could be removed, however, it seems it is reasonable to preserve at least two out of three methods.

patzinak commented 7 years ago

Are you talking about the wrapper or the settings? I'm incapable of using a laptop now to easily browse the repo. If you are talking about the wrapper, than this is because the other server does not need it, or it is used mistakenly in the first one. If you are talking about the settings, the oldest VNA does not allow full S-parameters scans: either reflection or transmission.

Could you please split the issue into two or rename it if the wrapper thing is not an issue anymore?

On Nov 21, 2016 16:00, "Chris Wilen" notifications@github.com wrote:

Why do we use this only for one of the servers and not the others?

It also seems like it is calling itself. Maybe I am just reading this wrong, but I am quite confused by the function.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/McDermott-Group/servers/issues/90#issuecomment-262081278, or mute the thread https://github.com/notifications/unsubscribe-auth/AMaYkMjqb_Jye_Y-FfWj_9jQ71fJYai8ks5rAhSUgaJpZM4K31cK .

roboguy222 commented 7 years ago

ok I am at least getting rid of the get_s2p() setting at least. It just returns the same as the others, but in a weird format, as far as I'm concerned.

patzinak commented 7 years ago

It might be faster if you need all the S-parameters, not sure.

On Nov 21, 2016 17:56, "Chris Wilen" notifications@github.com wrote:

ok I am at least getting rid of the get_s2p() setting at least. It just returns the same as the others, but in a weird format, as far as I'm concerned.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/McDermott-Group/servers/issues/90#issuecomment-262105924, or mute the thread https://github.com/notifications/unsubscribe-auth/AMaYkO58aDtcpQyU9Z54PQJm2ObKEV2Eks5rAi-6gaJpZM4K31cK .

roboguy222 commented 7 years ago

I am tempted to do the following: measurement_setup() with an argument that is a list of the Sxy's you want to use. get_trace() then records this data and sends it back, in the order of the list in ^. display_format() allows you to adjust what you see vs. what is sent back (log mag, Re/Im, etc). Does this sound reasonable?

patzinak commented 7 years ago

This seems better. Are you fixing the returned format to dB, deg or are you going to allow selecting it? How are you going to pass the frequencies? Have an extra method get_frequencies() or get them as the first colon of the returned data? Think about these issues in context of other devices like conventional oscilloscopes, sampling scopes and spectra analyzers. You always have to set the frequencies/times, and return at least a 1D dataset.

On Nov 21, 2016 18:34, "Chris Wilen" notifications@github.com wrote:

I am tempted to do the following: measurement_setup() with an argument that is a list of the Sxy's you want to use. get_trace() then records this data and sends it back, in the order of the list in ^. display_format() allows you to adjust what you see vs. what is sent back (log mag, Re/Im, etc). Does this sound reasonable?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/McDermott-Group/servers/issues/90#issuecomment-262112183, or mute the thread https://github.com/notifications/unsubscribe-auth/AMaYkGysnDWXCE98DDkT1zQgvdLvRzS_ks5rAjiZgaJpZM4K31cK .

roboguy222 commented 7 years ago

The user can select the returned format. I am not passing frequencies for these, what do you mean?

patzinak commented 7 years ago

I meant not passing but returning. If you use name display_format it should only mean changing units on display. You should then implement data_format or combine them in a single method.

On Nov 21, 2016 20:02, "Chris Wilen" notifications@github.com wrote:

The user can select the returned format. I am not passing frequencies for these, what do you mean?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/McDermott-Group/servers/issues/90#issuecomment-262126409, or mute the thread https://github.com/notifications/unsubscribe-auth/AMaYkNAcihDHw1c-vUmzEKtoogr4FHWMks5rAk1OgaJpZM4K31cK .

roboguy222 commented 7 years ago

It looks like it will be harder than I thought to just traces that are not visible (hard to return I,Q when viewing Mag/Phase). Any ideas for how to deal with this? Are we ok with having the only options either both mag/phase or both I/Q?

roboguy222 commented 7 years ago

The display_format function as it exists now has nothing to do with units or frequencies? It just means mag/phase or I/Q.

patzinak commented 7 years ago

I suggest that we should lock the display and data units for now, have only one setting responsible for this. The next step would be to allow turning the display on and off while taking data. I remember that the manual recommends doing this to speed up the measurements.

roboguy222 commented 7 years ago

Ok, and we prefer IQ? We can try converting between them to whatever the user wants once the data comes out?

patzinak commented 7 years ago

I think we prefer dB and deg. The reason why it is IQ now is because it was simply the mode that the things we set when I was debugging the server last time and I didn't really cared what is on the screen but many people later told me that they wan to see S-parameters in logarithmic scale, i.e. in dB.

patzinak commented 7 years ago

The question of mag/phase vs IQ is somewhat related to units (dB/deg vs unitless quantities) however one can plot the magnitude in linear scale and not use any units. I don't think we often use such options.

roboguy222 commented 7 years ago

Any idea how much turning the display off speeds up the measurements? This should be relatively easy to do I think.

patzinak commented 7 years ago

No, I never tested this.

On Nov 22, 2016 12:59 PM, "Chris Wilen" notifications@github.com wrote:

Any idea how much turning the display off speeds up the measurements? This should be relatively easy to do I think.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/McDermott-Group/servers/issues/90#issuecomment-262332259, or mute the thread https://github.com/notifications/unsubscribe-auth/AMaYkGHUx52riWQmEQRpKFkYuWw4MtyNks5rAzuBgaJpZM4K31cK .

roboguy222 commented 7 years ago

I am trying to get the VNA to return data in a binary string instead of ascii (which is allowed in the manual by the VNA), but getting the following error. Any idea how to get around this? It seems weird that they would support this feature if GPIB doesn't.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\labrad\client.py", line 67, in __call__
    return f.result() if wait else f
  File "C:\Python27\lib\site-packages\concurrent\futures\_base.py", line 405, in
 result
    return self.__get_result()
  File "C:\Python27\lib\site-packages\concurrent\futures\_base.py", line 357, in
 __get_result
    raise type(self._exception), self._exception, self._traceback
labrad.types.Error: (0) [GPIB VNA] Remote Traceback (most recent call last):
Failure: labrad.types.Error: (0) [mcd-adr1 GPIB Bus] Remote Traceback (most rece
nt call last):
  File "C:\Python27\lib\site-packages\labrad\server.py", line 232, in request_ha
ndler
    result = yield setting.handleRequest(self, c.data, flat_data)
  File "C:\Python27\lib\site-packages\labrad\decorators.py", line 181, in handle
Request
    return self.func(server, c, data)
  File "gpib_server.py", line 242, in query
    resp = self.getDevice(c).query(data)
  File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 40
7, in query
    return self.read()
  File "C:\Python27\lib\site-packages\pyvisa\resources\messagebased.py", line 33
2, in read
    message = self.read_raw().decode(enco)
exceptions.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
4: ordinal not in range(128)
 [payload=None]
 [payload=None]
roboguy222 commented 7 years ago

I see what you mean by trouble with units, Ivan. Do you know how to return an arbitrary number of arrays of varying units (dB, deg)? I can't figure out what unit string to give as the return type. I can do something like '(v[dB],v[deg],v[dB],v[deg],...)' but the number of arrays needs to be specified...

patzinak commented 7 years ago

Replying to the last question, you can try *(*v[dB], *v[deg]) but this has to be tested.

roboguy222 commented 7 years ago

I can try that, but that means they need to be in an array of pairs, instead of just a list. This makes it difficult to record traces set up by a user. A single trace, for example.

patzinak commented 7 years ago

As for the UnicodeDecodeError, looks like the VNA sends 2-byte unicode string that the GPIB server or the GPIB LabRAD module is trying to convert to 1-byte string. You have to use a codec that converts 2-byte character into two separated bytes when it is actually read by the GPIB-handling code and then convert these bytes back into the unicode characters when the string is handled to the server.

patzinak commented 7 years ago

Maybe you can try to use UTF-8 like it is described here.

roboguy222 commented 7 years ago

Yeah but I think the error comes out of pyvisa, which I don't have control over :(.

patzinak commented 7 years ago

Why do you think so? You should check whether you see the error if you directly communicate with the VNA bypassing the LabRAD infrastructure.

roboguy222 commented 7 years ago

The new VNA server is more or less ready to go now. I have not yet tested the really old VNA, and only done preliminary tests on the N5230A, but maybe you can look at the format of how to use it now. I still can't figure out how to enter a return type string, so for now the returned data is unitless.

TLDR: there is probably more we want to change, but a first draft is done if you want to start integrating it into measurement code.

patzinak commented 7 years ago

@roboguy222

A couple things to be improved:

Documentation for the get_trace() setting is confusing: "LOGMAG", "PHASE", "REIM" seem have nothing to do with "IQ" and "MP".

Data for a single trace return as a 2D array. If several traces are taken, would it be a 3D array?

Units should be attached to the values when "MP" format is being used.

Specifications for triggerType are not given in the measurement_setup() doc-string.

patzinak commented 7 years ago

All this has been mostly fixed.