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

Ikon-M not configuring shutter #28

Closed
mkoennecke opened this issue Dec 3, 2019 · 10 comments
Closed

Ikon-M not configuring shutter #28

mkoennecke opened this issue Dec 3, 2019 · 10 comments

Comments

@mkoennecke
Copy link

I am trying to use the Andor Ikon-M USB camera with area detector ADAndor. I tried debugging this problem and placed a breakpoint in AndorCCD::setupShutter(). I found that the shutter mode value was 0 and not the 2 I configured it to be. I then configured the driver into trace mode and in the trace I found lines like this:

2019/11/19 09:51:39.618 asynPortDriver:getIntegerParam: port=ANDOR error getting parameter 81 SHUTTER_MODE, in list 0, value u\

The trace also contains other, similar, lines for other parameters. I now assume that this the root cause of my problem. I did not modify anything in the drivers parameter handling. What can this be?

I attach the full trace:
andortrace.log

@MarkRivers
Copy link
Member

I am trying to use the Andor Ikon-M USB camera with area detector ADAndor. I tried debugging this problem and placed a breakpoint in AndorCCD::setupShutter(). I found that the shutter mode value was 0 and not the 2 I configured it to be. I then configured the driver into trace mode and in the trace I found lines like this:

2019/11/19 09:51:39.618 asynPortDriver:getIntegerParam: port=ANDOR error getting parameter 81 SHUTTER_MODE, in list 0, value u\

The trace also contains other, similar, lines for other parameters. I now assume that this the root cause of my problem. I did not modify anything in the drivers parameter handling. What can this be?

Those trace lines are warnings that, for example, getIntegerParam is being called for a parameter that has never been set. That may or may not actually be a problem, depending on whether the value read is actually being used.

When you say

the shutter mode value was 0 and not the 2 I configured it to be.

how did you configure it to be 2?

You should display the record with dbpr:

dbpr SQ:BOA:andor:cam1:ShutterMode 10

What does it show? Please post the complete output of that command.

Also post the output of the command

asynReport 1 ANDOR

@mkoennecke
Copy link
Author

I configured the ShutterMode with a caput command. Which gave no error and gave me the desired Detector Output as a result on caget.

Find attached a log of the two commands you asked for. They are in the wrong order though...
andor2.txt

@MarkRivers
Copy link
Member

The ADAndor driver uses 2 PVs to control the shutter operation.

The first PV is defined in the the ADDriver base class, and is called ShutterMode. It provides 3 choices, defined in ADBase.template:

record(mbbo, "$(P)$(R)ShutterMode")
{
    field(PINI, "YES")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))SHUTTER_MODE")
    field(ZRST, "None")
    field(ZRVL, "0")
    field(ONST, "EPICS PV")
    field(ONVL, "1")
    field(TWST, "Detector output")
    field(TWVL, "2")
    field(VAL,  "0")
    info(autosaveFields, "VAL")
}

You have set this to 2, which is correct if you want the detector to control the shutter.

The second PV is defined in andorCCD.template and is called AndorShutterMode. It provides 5 choices:

record(mbbo, "$(P)$(R)AndorShutterMode")
{
    field(PINI, "1")
    field(DTYP, "asynInt32")
    field(OUT,  "@asyn($(PORT),$(ADDR),$(TIMEOUT))ANDOR_SHUTTER_MODE")
    field(ZRST, "Fully Auto")
    field(ZRVL, "0")
    field(ONST, "Always Open")
    field(ONVL, "1")
    field(TWST, "Always Closed")
    field(TWVL, "2")
    field(THST, "Open for FVB")
    field(THVL, "4")
    field(FRST, "Open for Any")
    field(FRVL, "5")
}

It appears that you have set both of these correctly. asynReport shows:

Parameter 81 type=asynInt32, name=SHUTTER_MODE, value=2, status=0
Parameter 93 type=asynInt32, name=ANDOR_SHUTTER_MODE, value=0, status=0

So you have selected "Detector output" for ShutterMode and "Fully Auto" for AndorShutterMode".

I found that the shutter mode value was 0 and not the 2 I configured it to be.

I don't understand that statement. dbpr and asynReport both show that the value is 2 and not 0. What observation led you to think it was 0 and not 2?

Note that lines like this:

2019/11/19 09:51:39.618 asynPortDriver:getIntegerParam: port=ANDOR error getting parameter 81 SHUTTER_MODE, in list 0, value undefined

are normal because the order of PINI records in EPICS is somewhat undefined. So the value of ShutterMode may be initially undefined when the ADAndor::setupShutter() method is called. However, as each of the records processes it will be called again, until finally it is called with all records initialized and the operation should be as defined.

Please explain the actual problem you are observing, and what you changed in the driver to fix whatever problem you were observing.

@mkoennecke
Copy link
Author

The shutter settings are as they should be: ShutterMode 2 for Detector Output, AndorShutterMode 0 for fully auto.

I started off with me getting only getting background images when collecting data with the andor. More exactly images with ~300 counts with few hot pixels which were not very hot either.

I played around with various things until at some level of frustration I enabled the tracing thing. From the trace I learned that SetShutter() in setupShutter() was never called. I then proceeded to place a breakpoint at the start of setupShutter(). From this I learned that ShutterMode was 0. This made the test in the beginning of setupShutter() trigger and leave without ever calling SetShutter(). I observer that setupShutter() was sometimes called with the correct value but not reliably. The fix I then made was to call SetShutter() from the startAcquisition() method which I could observe to be frequently called from the trace. This fixed my problem but this seems not to be the right way forward.

@MarkRivers
Copy link
Member

Please change this line in setupShutter

  getIntegerParam(ADShutterMode, &adShutterMode);

to this:

  status = getIntegerParam(ADShutterMode, &adShutterMode);
printf("%s::%s command=%d, status=%d, adShutterMode=%d\n", 
driverName, functionName, command, status, adShutterMode);

adShutterMode should be 0 until it is set to 2 either via caput() (or equivalent from a GUI) or from autosave. Are you running autosave?

You seem to be reporting that it sometimes 2 but then goes back to 0? This debugging should show if that is ever happening.

@mkoennecke
Copy link
Author

I tried that. Find the output attached.

Yes, I am using autosave

Please note that I switched to AndorShutterMode 7, Bulb in the meantime. This is working as expected for me.
andor3.txt

@MarkRivers
Copy link
Member

It looks to me like you have indeed found a bug. The problem is that setupShutter() should be called whenever ADShutterMode is changed, but it is not. It will thus only work correctly if AndorShutterMode is changed after ADShutterMode, because then setupShutter will be called after the correct value of ADShutterMode is set.

Please try changing this code in writeInt32()

    else if ((function == AndorShutterMode) ||
             (function == AndorShutterExTTL)) {
      status = setupShutter(-1);
    }

to this:

    else if ((function == ADShutterMode) ||
             (function == AndorShutterMode) ||
             (function == AndorShutterExTTL)) {
      status = setupShutter(-1);
    }

@mkoennecke
Copy link
Author

Thanks, this helped. I proceeded to another problem in that SetShutter() did not like the Bulb mode much. But I attribute this to our special andor library version not being implemented properly. This is no longer an AD problem.

@MarkRivers
Copy link
Member

I have committed the above fix to the master branch.

Note that in order to use the master branch of ADAndor you will currently need to also use the master branch of ADCore, because it adds a new CCDMultiTrack class that ADAndor now uses. You will also need to use asyn R4-37 because ADCore R3-8 and later require that.

@MarkRivers
Copy link
Member

I am closing this issue because I believe that 591bbca fixes it.

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

No branches or pull requests

2 participants