Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ats9870 dev branch #66

Closed
wants to merge 51 commits into from
Closed

Ats9870 dev branch #66

wants to merge 51 commits into from

Conversation

damazter
Copy link
Contributor

This is version 0.1 of the Alazar driver. It has been tested in so far that we know that it works, but a more complete test set should be included in later versions. In summary, this driver works, but this is not the final version. However people can already start using it, so I think it therefore should be pulled into the master branch of qcodes such that the code is available for everyone.

There are some todo items left in the code which also will get resolved in later versions.

…he code and structure is written.

More functions would be nice and several todo items are important before actual implementation
…tors to validate that the value is in the values of the dictionary. The driver now calls the validate function of the parameter class to enforce this validation.

Solved the problem with sample rates

changed the default of some parameters

implemented trivial dictionaries.

Driver still largely untested
@AdriaanRol
Copy link
Contributor

Awesome! 👍

from qcodes.instrument.parameter import Parameter
from qcodes.utils import validators

# TODO (C) logging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are (C), (W) etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

M o S C o W prioritizes the todo items and stand for respectively:
Must be done, Should be done, Could be done and Would be nice if done.

It is not perfect, but it helps picking out the most important stuff to work on

@damazter
Copy link
Contributor Author

damazter commented Apr 6, 2016

I posted two comments already (see above), but I also see some very good suggestions (I like the abbreviation of setting parameters) so I see there is a little work to be done. I'll report back.

self.parameters['sample_rate']._get_byte(),
self.parameters['clock_edge']._get_byte(),
self.parameters['decimation']._get_byte())
self._result_handler(error_code=return_code, error_source="AlazarSetCaptureClock")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pattern:

return_code = self._ATS9870_dll.Alazarxxxxx(self._handle, ...)
self._result_handler(error_code=return_code, error_source='Alazarxxxxx')

gets a little tedious. What about something like this instead of _result_handler:

def call_dll(self, func_name, *args):
    func = getattr(self._ATS9870_dll, func_name)
    return_code = func(self._handle, *args)

    if error_code != self._success:
        # TODO (C) log error

        # include the args (the beginning anyway) so you don't need the special case
        # of one or more args in the error_source, and you get more info to debug with
        argrepr = repr(args)
        if len(argrepr) > 100:
            argrepr = argrepr[:96] + '...)'

        # put error_code in a class attribute so we're not constantly re-evaluating the dict
        if error_code not in self._error_codes:
            raise KeyError('unknown error {} from function {} with args: {}'.format(
                error_code, func_name, argrepr))
        raise Exception('error {}: {} from function {} with args: {}'.format(
            error_code, self._error_codes[error_code], func_name, argrepr))

I could even imagine including a kwarg updates=['clock_source', 'sample_rate', 'clock_edge', 'decimation'] that would create the _set_updated() calls that also consistently trail this pattern.

Also, it's maybe a matter of style, but I wouldn't call the unknown error a KeyError because the error itself isn't that the key is missing, that's just the reason you don't have more info to give the user about it. I'd probably call them both RuntimeError

@AdriaanRol
Copy link
Contributor

@damazter , about a week ago you showed me an example of using the driver with an "acquisition controller". I want to adopt this paradigm when using the ATS and replace our higher level meta-instruments with these "acquisition controllers" (and convince @cdickel and @elrama- that it's a good idea :) ) .

I think it is a rather powerful paradigm but I find it hard to reproduce the example from memory; did you hand the controller to the ATS or the other way round? and what are the commands you execute to start an acquisition?

I guess besides the docs/examples the acquisition controller docstring itself is a good place for this

@cdickel
Copy link

cdickel commented Apr 9, 2016

I guess that is a good idea but I think the settings of both time domain and frequency domain measurements should be stored somewhere permanently such that one can switch quickly between the two. That was the reason for building the abstraction layer.


From: Adriaan [[email protected]]
Sent: Saturday, April 09, 2016 12:01
To: qdev-dk/Qcodes
Cc: Christian Dickel
Subject: Re: [qdev-dk/Qcodes] Ats9870 dev branch (#66)

@damazterhttps://github.com/damazter , about a week ago you showed me an example of using the driver with an "acquisition controller". I want to adopt this paradigm when using the ATS and replace our higher level meta-instruments with these "acquisition controllers" (and convince @cdickelhttps://github.com/cdickel and @elrama-https://github.com/elrama- that it's a good idea :) ) .

I think it is a rather powerful paradigm but I find it hard to reproduce the example from memory; did you hand the controller to the ATS or the other way round? and what are the commands you execute to start an acquisition?

I guess besides the docs/examples the acquisition controller docstring itself is a good place for this


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com/qdev-dk-archive/pull/66#issuecomment-207761217

The extra kwarg added in this pull request breaks qcodes unless the
base instrument class is updated as well to accomodate for this
extra kwarg
@damazter
Copy link
Contributor Author

The continuation of the development of this branch is contingent on pullrequest #303
the current state of this pullrequest shows the usecase for the propblem solved in #303

damazter and others added 7 commits August 15, 2016 16:35
fixed them to comply with the ATS-SDK programmer's guide
included many more numbers into the idn of the alazar cards
…erence

Suggest/add instrumentserver reference
add [parameter]._save_val to the _set method of the
alazarparameter to obtain proper snapshots of the
alazarparameters
The ats example notebook now works and is a bit more to the point.
Comments will be added later
fix comments and it now works with loops
wrote more comments for the acquisition controller.
acquisitioncontroller now accepts name instead of id as a reference
for the alazar instrument. removed a useless statement passing the alazar reference around
@damazter
Copy link
Contributor Author

@alexcjohnson @giulioungaretti
@elrama- @nataliejpg @nulinspiratie @AdriaanRol

I believe this is it,
the driver is now in a working state and all remaining things that remain to be done are not essential to the workings of this driver (for the ATS9870 at least)
I am ready to dance
(I think the failing test has nothing to do with this pull request)

@AdriaanRol
Copy link
Contributor

I would vote to dance ASAP so that there is a stable version in the master on which @elrama- @nataliejpg and @nulinspiratie can base their acquisition controllers and drivers for other types.

I am in no position to judge the PR though, what I understand of it is beautiful and well thought out but I'll leave this to @giulioungaretti

@nulinspiratie
Copy link
Contributor

Awesome to hear! I will add the pr for four channels soon. Is it now also
able to work in a loop?

On Aug 16, 2016 10:32 PM, "damazter" [email protected] wrote:

@alexcjohnson https://github.com/alexcjohnson @giulioungaretti
https://github.com/giulioungaretti
@elrama- https://github.com/elrama- @nataliejpg
https://github.com/nataliejpg @nulinspiratie
https://github.com/nulinspiratie @AdriaanRol
https://github.com/AdriaanRol

I believe this is it,
the driver is now in a working state and all remaining things that remain
to be done are not essential to the workings of this driver (for the
ATS9870 at least)
I am ready to dance
(I think the failing test has nothing to do with this pull request)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
qdev-dk-archive#66 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGgLHSyY9xibljJwi0ABAGnW_TFpwsOqks5qga3zgaJpZM4H8pQT
.

@damazter
Copy link
Contributor Author

Awesome to hear! I will add the pr for four channels soon. Is it now also
able to work in a loop?

I made an example of a working loop-acquisition in the example notebook (docs/examples/Qcodes example ATS_ONWORK.ipynb)

@nataliejpg
Copy link
Contributor

@damazter: this looks great, especially <3 the added comments and example notebook. I was wondering why it is that the part where you add the "acquisition" parameter to the acquisition controller (and also of course the 'do_acquisition' function) in the DFT_acquisition_controller isn't part of the base AcquisitionController in ATS.py? Is there some reason why that wouldn't work because to me it seems like a more natural place for them to be?

@damazter
Copy link
Contributor Author

@nataliejpg
The idea is that some people will have very different needs of their acquisitioncontroller. The current example DFT only takes the amplitude of signal A as a parameter in the acquisition. Other experiments will want to gather I and Q in a single parameter. Or even a list of I's and Q's. This means that it is not possible to define the acquisition parameter in the driver itself, but it must be defined in some user defined piece of code, which is the acquisitioncontroller implementations.

Secondly, the do_acquisition function adds the kwargs to the acquire function of the ATS driver. The way you would like to do this also hugely differs from experiment to experiment. For a example controller, it's fine to specify everything explicitely, but for a more integrated setup, some automation in these variables might be nice. Again, these kind of automations are too specific to put in the general driver, so the acquisitioncontroller implementations looked like a nice spot to put them to me.

Let me know if you agree. I am very open to hear ideas for improvements, but this is the best that I could come up with.

@nataliejpg
Copy link
Contributor

@damazter oh yes I see, I didnt think about the different forms the "acquisition" parameter would need to have, probably in many cases it will need to be a 'hard' parameter and that will have to be user defined also. I think that part might be one of the more important parts of the acquisition controller to document though seeing as it is becoming less clear as to what is calling what between the alazar card and the acquisition controller. My understanding is that previously you would write a controller which was then used when you called the alazar aquitre function and sorted out the data handling/processing part but on the face of it you would only really interact with the alazar in your notebook (or wherever you run qcodes) and ask it directly to carry out the aquire funtion and it would return the processed data. Now if you want to pull some data you get the "acquisition" parameter of your acquisition_controller which causes the alazar's aquire funtion to be carried out which in turn uses the acquisition controller for its data handling/processing. Does that sound right? I think it's an extra layer with the aim of enabling use of a qcodes paramer. The fact that the qcodes parameter is a parameter of the aqcuisition controller is what adds this extra part. That's not to say that I disagree because I am really keen on having the user only ever need to change the acquisition controller based on what they want to acquire but I do think that this structure needs some explaining in comments/docs as it's no longer really obvious what's going on just from looking at the acquisition controller which would be the ideal. Sorry this got so long. Also this is so far just speculation from reading the code, I'll try actually using it next week and maybe have more useful feedback.

@damazter
Copy link
Contributor Author

@nataliejpg

Now if you want to pull some data you get the "acquisition" parameter of your acquisition_controller which causes the alazar's aquire funtion to be carried out which in turn uses the acquisition controller for its data handling/processing. Does that sound right?

This is exactly right

I think it's an extra layer with the aim of enabling use of a qcodes paramer.

yes

The fact that the qcodes parameter is a parameter of the aqcuisition controller is what adds this extra part.

I don't follow this sentence :(

but I do think that this structure needs some explaining in comments/docs as it's no longer really obvious what's going on just from looking at the acquisition controller which would be the ideal

More docs would be better, but I am not entirely sure what kind of doc-structure would fit this

If allocated_buffers > buffers_per_acquisition, more results would be returned than acquired
which is not wanted. This condition is now explicitely checked.
@damazter
Copy link
Contributor Author

damazter commented Sep 5, 2016

@nulinspiratie
I build in a check against allocated_buffers > buffers_per_acquisition
So this should fix your issue

@AdriaanRol
Copy link
Contributor

@alexcjohnson @giulioungaretti any updates on this? It seems to me it is awaiting feedback before it can 💃

@damazter
Copy link
Contributor Author

superseded by #338

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants