Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Two Sets of Temperature Control for Fly Stage and Generic Setup in Bluesky #170

Closed
qzhang234 opened this issue Jun 18, 2020 · 29 comments
Closed
Assignees
Labels
maintenance something needs to be changed

Comments

@qzhang234
Copy link
Collaborator

The temperature readout PV currently defined in Bluesky points to the one used in generic setup (See screenshot attached). However with Rigaku we commonly use fly stage, whose temperature readout PV is different (See screenshot attached). Anyway to add it in Bluesky so that it can be switched between the two?

Screen Shot 2020-06-17 at 11 47 21 PM

Screen Shot 2020-06-18 at 10 29 45 AM

@prjemian
Copy link
Collaborator

Looking through the instrument configuration:

snow% git grep -i lakeshore | grep -v archive
devices/__init__.py:from .lakeshore import *
devices/lakeshore.py:Lakeshore temperature controllers
devices/lakeshore.py:__all__ = "lakeshore T_A T_SET".split()
devices/lakeshore.py:        self.controller_name = f"Lakeshore 336 Controller Loop {loop_number}"
devices/lakeshore.py:    support for Lakeshore 336 temperature controller
devices/lakeshore.py:lakeshore = LS336Device("8idi:LS336:TC4:", name="lakeshore", labels=["heater", "Lakeshore"])
devices/lakeshore.py:T_A = lakeshore.loop1.temperature
devices/lakeshore.py:T_SET = lakeshore.loop1.target
plans/alignments.py:from ..devices import actuator_flux, att, default_counter, pind4, lakeshore, samplestage
plans/alignments.py:    yield from bp.rel_scan([pind4,lakeshore],samplestage.x,pos_start,pos_stop,num_pts)
plans/alignments.py:    yield from bp.rel_scan([pind4,lakeshore],samplestage.z,pos_start,pos_stop,num_pts)
staff/QZ/align.py:from instrument.devices import pind4, lakeshore, samplestage
staff/QZ/align.py:    yield from bp.rel_scan([pind4,lakeshore],samplestage.x,pos_start,pos_stop,num_pts)
staff/QZ/align.py:    yield from bp.rel_scan([pind4,lakeshore],samplestage.z,pos_start,pos_stop,num_pts)

@prjemian
Copy link
Collaborator

To choose which Lakeshore readout, set both T_A and T_SET. Here is the default:

T_A = lakeshore.loop1.temperature
T_SET = lakeshore.loop1.target

To pick the other one:

T_A = lakeshore.loop3.temperature
T_SET = lakeshore.loop3.target

If this gets to be a routine activity, we can create a utility function to make this change:

def selectLakeshoreReadout(readout=1):
    global T_A , T_SET
    if readout not in (1, 2, 3, 4):
        raise ValueError(f"readout must be integer between 1 & 4, received {readout}")
    obj = [lakeshore.loop1, lakeshore.loop2, lakeshore.loop3, lakeshore.loop4][readout-1]
    T_A = obj.temperature
    T_SET = obj.target

@prjemian
Copy link
Collaborator

close this if your question is answered

@qzhang234
Copy link
Collaborator Author

Let me give it a try after dinner, if it works I'll close it

@qzhang234
Copy link
Collaborator Author

@prjemian I changed lakeshore.py per your suggestion (See screenshot), and when I restarted Bluesky the T_A value readout has matched the one on input C (See screenshot). However, when I set T_SET using RE(bps.mv(T_SET, 32)), nothing seem to have changed on the EPICS side and I also noticed that the EPICS set temperature for input C is -273.15 C.

I'm now confused about the source of the problem. @sureshnaps Could you comment on that as well?

Thanks,

Screen Shot 2020-06-18 at 11 30 51 PM

Screen Shot 2020-06-18 at 11 40 19 PM

Screen Shot 2020-06-18 at 11 40 38 PM

@qzhang234
Copy link
Collaborator Author

@prjemian @sureshnaps @ericmdufresne This problem with controlling the temperature on fly stage using Bluesky is actually more complicated than I thought: The readback is still 8idi:LS336:TC4:IN3, but the setpoint is actually 8idi:pid1.VAL instead of 8idi:LS336:TC4:OUT3:SP, so it violated the class definition of LS336Device in lakeshore.py.

We could either change our EPICS definition, or come up with a new class definition for temperature control on the fly stage. Which one is better?

Screen Shot 2020-06-20 at 5 57 27 PM

Screen Shot 2020-06-20 at 5 58 53 PM

@sureshnaps
Copy link
Collaborator

sureshnaps commented Jun 21, 2020 via email

@prjemian
Copy link
Collaborator

prjemian commented Jun 21, 2020 via email

@qzhang234
Copy link
Collaborator Author

qzhang234 commented Jun 21, 2020

@prjemian Would you mind if I take a first stab at it? I'm free on Sunday anyways.

Also how do I back everything up? Copy ~/.ipython-bluesky or push to a branch?

@prjemian
Copy link
Collaborator

prjemian commented Jun 21, 2020 via email

@qzhang234
Copy link
Collaborator Author

Here's what I got:

talc% git add -A
talc% git commit -m "backup before adding temp ctrl for fly stage"
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
talc% git push origin master
Username for 'https://github.com': 

What username should I use?

@qzhang234 qzhang234 added the maintenance something needs to be changed label Jun 21, 2020
@prjemian
Copy link
Collaborator

prjemian commented Jun 21, 2020 via email

@qzhang234
Copy link
Collaborator Author

It worked! I'll try define the new class for temperature control of fly stage then.

If this works it would be the first python class I've ever defined.

@prjemian
Copy link
Collaborator

To make this work, we'll have to do something similar to the instrument.devices.lakeshore.LS336_LoopBase() but use the correct PVs for the signals: signal, target, temperature, ...

Long term, it might be useful to redesign this since it is extremely beam line specific. No other beam line uses this non-standard support for Lakeshore this way.

@prjemian
Copy link
Collaborator

Aha! Helps to talk it through... In our teleconference, it seems there is another screen, pid_control.ui, that is used to control the PID loop. This is important here. It shows the controls of an EPICS epid record which is a device we already have defined in our instrument package. instrument.devices.epid defines two of them: pid1 and pid2. The screen above shows the GUI for pid1.

Long story short:

from .epid import pid1, pid2
T_A = pid1.final_value 
T_SET = pid1.controlled_value

@prjemian
Copy link
Collaborator

... and, as we discovered, there were a couple problems with the setup of these epid devices to be changed. (BCDA-APS/apstools#324 and BCDA-APS/apstools#325)

We fixed them locally so that when the apstools package is updated, our adaptation to those changes will be minimal.

@prjemian
Copy link
Collaborator

Also leaving the previous definitions of T_A and T_SET in place (commented out) for reference and as alternatives in case they are needed.

@prjemian
Copy link
Collaborator

From the epid record documentation:

CVAL Value of controlled variable
VAL Setpoint value

The screen view above shows this correctly.

The epid object is named properly for the .CVAL field:

controlled_value = Component(EpicsSignalRO, ".CVAL")

@prjemian
Copy link
Collaborator

The difference in the name of controlled_value vs. current_value is semantics. Since the epid documentation uses the former term, we should use that here and remove the reference to current_value.

@prjemian
Copy link
Collaborator

The apstools package has been updated for the changes in the epid record support. A release candidate 1.2.6rc1 is available for update:

conda install -c aps-anl-tag 1.2.6rc1

With these changes, profile_bluesky/startup/instrument/devices/epid.py can be edited to remove the customization and invoke EpidRecord directly:

# class ModifiedEpidRecord(EpidRecord):
    # ... any custom content ...

pid1 = EpidRecord("8idi:pid1", name="pid1", labels=["pid",])
pid2 = EpidRecord("8idi:pid2", name="pid2", labels=["pid",])

@prjemian
Copy link
Collaborator

@qzhang234 Can you make these changes?

@qzhang234
Copy link
Collaborator Author

In 15 min. I'm writing an email to Suresh to ask him to create virtual sessions under 8idiuser on the workstations. Apparently Eric and I have different permission levels than Suresh

@prjemian
Copy link
Collaborator

If this works, then I will finalize the release of apstools 1.2.6. (provisional release notes: https://github.com/BCDA-APS/apstools/wiki/release-notes-1.2.6)

@prjemian
Copy link
Collaborator

use this install command:

conda install -c aps-anl-dev apstools=1.2.6rc1

@qzhang234
Copy link
Collaborator Author

I still can't use NX on talc so I'm doing this instead (quartz can't see outside network). Let me know if I'm doing this right

Screen Shot 2020-06-24 at 2 06 01 PM

@qzhang234
Copy link
Collaborator Author

@prjemian conda install complete. However I noticed that there is a mismatch between T_A and T_SET. I checked the PID parameters and they were the same as the ones used by our last user. Is there some additional command I need to use to turn on the power of the temperature control so that T_A will try to match T_SET?

Screen Shot 2020-06-24 at 2 09 19 PM

@sureshnaps
Copy link
Collaborator

sureshnaps commented Jun 24, 2020 via email

@prjemian
Copy link
Collaborator

prjemian commented Jun 24, 2020 via email

@sureshnaps
Copy link
Collaborator

sureshnaps commented Jun 25, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
maintenance something needs to be changed
Projects
None yet
Development

No branches or pull requests

4 participants