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

lakeshore support not waiting to reach temperature #118

Closed
prjemian opened this issue Dec 6, 2019 · 11 comments · Fixed by #135
Closed

lakeshore support not waiting to reach temperature #118

prjemian opened this issue Dec 6, 2019 · 11 comments · Fixed by #135
Assignees
Labels
bug Something isn't working

Comments

@prjemian
Copy link
Collaborator

prjemian commented Dec 6, 2019

When scanning the lakeshore.loop1 object through a list of temperatures, we observed that the lakeshore.loop1.wait_until_settled() method was not waiting.

@prjemian prjemian added the bug Something isn't working label Dec 6, 2019
@prjemian prjemian self-assigned this Dec 6, 2019
@prjemian
Copy link
Collaborator Author

prjemian commented Dec 6, 2019

The default support looks for lakeshore.loop1.signal as the measure of current temperature. The correct PV to watch (8idi:LS336:TC4:IN1) is signal lakeshore.loop1.temperature.

prjemian pushed a commit that referenced this issue Dec 6, 2019
@prjemian
Copy link
Collaborator Author

prjemian commented Dec 6, 2019

Changing the settled() property did not solve the problem.

@prjemian
Copy link
Collaborator Author

prjemian commented Dec 6, 2019

Implemented local workaround as quick solution in user's directory:

def lakeshore_wait(controller, delay_s=5):
    yield from bps.null()       # must yield something, this does nothing
    t0 = time.time()
    logger.info(f"waiting to reach target temperature {controller.target.value:.2f}")

    while abs(controller.temperature.get() - controller.target.get()) > controller.tolerance.get():
        logger.info(f"T={controller.temperature.value:.2f}, waiting {delay_s}s")
        yield from bps.sleep(delay_s)

    logger.info(f"reached target temperature in {time.time()-t0:.2f}s, T={controller.temperature.value:.2f}")

@prjemian
Copy link
Collaborator Author

prjemian commented Dec 6, 2019

TODO: Factor these changes into the Device for this object. Look at 10-devices.py

@prjemian
Copy link
Collaborator Author

prjemian commented Feb 3, 2020

note: We have learned that ophyd is designed specifically to not use EPICS CA monitors. Instead, to get the immediate value of any EpicsSignal, use the .get() method. The .value property gets the value from the python cache which may not be the most recent value in the EPICS IOC.

@prjemian
Copy link
Collaborator Author

prjemian commented Feb 3, 2020

clarification: in #118 (comment), signal is the readback value of the controller set point (confirms the controller knows the temperature we want the controller to maintain) while temperature is the value from the temperature sensor (the readback).

@prjemian
Copy link
Collaborator Author

prjemian commented Feb 3, 2020

Compare our Lakeshore support with similar from NSLS-II/CSX: https://github.com/NSLS-II-CSX/xf23id1_profiles/blob/master/profile_collection/startup/csx1/devices/lakeshore.py

Looks as if our EPICS database is different, thus different device-specific PVs, on top of the different PV name scheme used at NSLS-II.

@prjemian
Copy link
Collaborator Author

prjemian commented Feb 3, 2020

With changeset 64abd0b , this code is ready for testing.

@prjemian
Copy link
Collaborator Author

prjemian commented Feb 4, 2020

Tried a simple test:

In [6]: RE(lakeshore.loop1.wait_until_settled())                                                                                                                                              
Waiting 0.0s to reach 25.002, now 25.002
Waiting 5.0s to reach 25.002, now 25.002
Waiting 10.0s to reach 25.002, now 25.002
Waiting 15.0s to reach 25.002, now 25.002
Waiting 20.0s to reach 25.002, now 25.002
Waiting 25.0s to reach 25.002, now 25.002
Waiting 30.0s to reach 25.002, now 25.002
Waiting 35.0s to reach 25.002, now 25.002
^CA 'deferred pause' has been requested. The RunEngine will pause at the next checkpoint. To pause immediately, hit Ctrl+C again in the next 10 seconds.
Deferred pause acknowledged. Continuing to checkpoint.
Waiting 40.0s to reach 25.002, now 25.002

Lakeshore is not connected. More diagnostics:

In [9]: lakeshore.loop1.settled??                                                                                                                                                             
Type:        property
String form: <property object at 0x7f2dd4622778>
Source:     
# lakeshore.loop1.settled.fget
@property
def settled(self):
    """Is temperature close enough to target?"""
    diff = abs(self.temperature.get() - self.target.get())
    return diff <= self.tolerance.get()

In [10]: lakeshore.loop1.temperature.get()                                                                                                                                                    
Out[10]: -273.15

In [11]: lakeshore.loop1.target.get()                                                                                                                                                         
Out[11]: 25.0

So, when lakeshore is not connected, the EPICS support reports a temperature of -273.15. We should trap for that and raise an appropriate exception.

@prjemian
Copy link
Collaborator Author

prjemian commented Feb 4, 2020

Testing the support now:

In [13]: lakeshore.loop1.tolerance.put(1)                                                                                                                                                     

In [14]: lakeshore.loop1.target.get()                                                                                                                                                         
Out[14]: 25.0

In [15]: lakeshore.loop1.temperature.get()                                                                                                                                                    
Out[15]: 25.759

In [16]: lakeshore.loop1.target.put(28)                                                                                                                                                       

In [17]: RE(lakeshore.loop1.wait_until_settled())                                                                                                                                             
Waiting 0.0s to reach 28.002, now 25.642
Waiting 5.0s to reach 28.002, now 25.622
Waiting 10.0s to reach 28.002, now 25.612
Waiting 15.0s to reach 28.002, now 25.592
Waiting 20.0s to reach 28.002, now 25.572
Waiting 25.0s to reach 28.002, now 25.562
Waiting 30.0s to reach 28.002, now 25.562
Waiting 35.0s to reach 28.002, now 25.572
Waiting 40.0s to reach 28.002, now 25.602
Waiting 45.0s to reach 28.002, now 25.642
Waiting 50.0s to reach 28.002, now 25.682
Waiting 55.0s to reach 28.002, now 25.732
Waiting 60.0s to reach 28.002, now 25.782
Waiting 65.0s to reach 28.002, now 25.842
Waiting 70.0s to reach 28.002, now 25.912
Waiting 75.0s to reach 28.002, now 25.982
Waiting 80.0s to reach 28.002, now 26.052
Waiting 85.0s to reach 28.002, now 26.122
Waiting 90.0s to reach 28.002, now 26.202
Waiting 95.0s to reach 28.002, now 26.292
Waiting 100.0s to reach 28.002, now 26.372
Waiting 105.0s to reach 28.002, now 26.452
Waiting 110.0s to reach 28.002, now 26.542
Waiting 115.0s to reach 28.002, now 26.632
Waiting 120.0s to reach 28.002, now 26.712
Waiting 125.0s to reach 28.002, now 26.812
Waiting 130.0s to reach 28.002, now 26.892
Lakeshore 336 Controller Loop 1 signal: 25.012
Total time: 134.898s, settled:False
Out[17]: ()

In [18]: RE(lakeshore.loop1.wait_until_settled())                                                                                                                                             
Lakeshore 336 Controller Loop 1 signal: 25.012
Total time: 0.002s, settled:True
Out[18]: ()

Indicated success:False at end of wait. But it was settled within 1 degree!

sureshnaps pushed a commit that referenced this issue Feb 4, 2020
@prjemian
Copy link
Collaborator Author

prjemian commented Feb 4, 2020

retesting

In [1]: lakeshore.loop1.tolerance.put(1)                                                                                                                                                      

In [2]: lakeshore.loop1.target.get()                                                                                                                                                          
Out[2]: 25.0

In [3]: lakeshore.loop1.temperature.get()                                                                                                                                                     
Out[3]: 26.192

In [4]: lakeshore.loop1.target.put(28)                                                                                                                                                        

In [5]: RE(lakeshore.loop1.wait_until_settled())                                                                                                                                              
Waiting 0.0s to reach 28.002, now 0.002
Waiting 5.0s to reach 28.002, now 0.002
Waiting 10.0s to reach 28.002, now 26.092
Waiting 15.0s to reach 28.002, now 0.002
Waiting 20.0s to reach 28.002, now 26.042
Waiting 25.0s to reach 28.002, now 26.022
Waiting 30.0s to reach 28.002, now 26.012
Waiting 35.0s to reach 28.002, now 0.002
Waiting 40.0s to reach 28.002, now 0.002
Waiting 45.0s to reach 28.002, now 26.022
Waiting 50.0s to reach 28.002, now 26.032
Waiting 55.0s to reach 28.002, now 26.052
Waiting 60.0s to reach 28.002, now 26.082
Waiting 65.0s to reach 28.002, now 26.112
Waiting 70.0s to reach 28.002, now 26.152
Waiting 75.0s to reach 28.002, now 26.182
Waiting 80.0s to reach 28.002, now 0.002
Waiting 85.0s to reach 28.002, now 26.282
Waiting 90.0s to reach 28.002, now 0.002
Waiting 95.0s to reach 28.002, now 0.002
Waiting 100.0s to reach 28.002, now 26.432
Waiting 105.0s to reach 28.002, now 26.502
Waiting 110.0s to reach 28.002, now 26.562
Waiting 115.0s to reach 28.002, now 26.622
Waiting 120.0s to reach 28.002, now 26.682
Waiting 125.0s to reach 28.002, now 26.752
Waiting 130.0s to reach 28.002, now 26.822
Waiting 135.0s to reach 28.002, now 26.892
Waiting 140.0s to reach 28.002, now 26.952
Lakeshore 336 Controller Loop 1 signal: 25.022
Total time: 143.624s, settled:True
Out[5]: ()

In [6]:                                                                                                                                                                                       

The temperature reporting is weird. Oscillates between 0 and temperature readback. Not sure this is a problem to solve in bluesky, certainly not part of this issue. Declare success with waiting to reach temperature.

prjemian added a commit that referenced this issue Feb 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant