ISISComputingGroup / IBEX

Top level repository for IBEX stories
4 stars 2 forks source link

3D magnet: eliminate quad-state booleans #4827

Open Tom-Willemsen opened 4 years ago

Tom-Willemsen commented 4 years ago

As a scientist and developer using the 3D cryomag on zoom, I would like to be able to change the status of the switch heaters reliably.

This driver is an LvDCOM driver, but it appears that at some point the converter has become confused and generated multiple strings for the same item(s). See https://github.com/ISISComputingGroup/EPICS-Magnet3D/blob/698116ffd43389b413226bb998e3b37902829fcc/magnet3DApp/protocol/controls.txt#L931 for an example

<STRINGS>
    <STRING>OFF</STRING>
    <STRING>ON</STRING>
    <STRING>OFF</STRING>
    <STRING>ON</STRING>
</STRINGS>

@FreddieAkeroyd and I had a look at this and suspect that this was causing some support calls on zoom related to not being able to change the state of the switch heater intermittently. On examining the underlying labview code, it appears that the relevant code is a simple boolean, so presumably cannot be in 4 states.

Acceptance criteria:

DiegoAlbaVenero commented 4 years ago

A further update from Diego Alba Venero (Zoom instrument scientist). Over the next user experiment there was an issue setting the field again. In this case, it was needed to press the "ramp" button several times before it worked. My guess is that the switch heater was not ready in a predictable time, and therefore pressing the "ramp" didn't have any effect. I can't confirm this. The users circunvented the issue using an additional while loop setting the switch heaters on/off. The used script (that got them running but far from ideal) is copied below. I only copy one coil for saving space

def pleasesetfield3D(x=0,y=0,z=0):

X component

currx=get_pv("IN:ZOOM:SCIMAG3D_01:MAG:X:FIELD")
print currx
if abs(x-currx) > 0.001:
    set_pv("IN:ZOOM:SCIMAG3D_01:PSU:X:SP",currx)
    #print('setting the current')
    time.sleep(2)
    set_pv("IN:ZOOM:SCIMAG3D_01:PSU:RAMP:CMD",1)
    #print('pressing the ramp button')
    time.sleep(2)
    psux=get_pv("IN:ZOOM:SCIMAG3D_01:PSU:X")
    while(abs(currx-psux)>0.001):
        print('firste while loop')
        print('currx/psux = '+str(currx)+'/'+str(psux))
        time.sleep(5)
        psux=get_pv("IN:ZOOM:SCIMAG3D_01:PSU:X")
    time.sleep(3)    
    set_pv("IN:ZOOM:SCIMAG3D_01:PSH:X:SP",1) # This is a naughty boy
    #print('out of the while loop')
    time.sleep(2)
    #print('resetting the field')
    set_pv("IN:ZOOM:SCIMAG3D_01:PSU:X:SP",x)
    #print('PSU_X_to_'+str(x))
   # time.sleep(2)
    #print('pressing again the ramp button')
    #set_pv("IN:ZOOM:SCIMAG3D_01:PSU:RAMP:CMD",1) # This one fails
    #time.sleep(5)
   # set_pv("IN:ZOOM:SCIMAG3D_01:PSU:RAMP:CMD",1) # This one works
   #- it's not so simple :(
    time.sleep(2)
    psux=get_pv("IN:ZOOM:SCIMAG3D_01:PSU:X")
    counter = 0
    while(abs(x-psux)>0.001):
        set_pv("IN:ZOOM:SCIMAG3D_01:PSU:RAMP:CMD",1)
        time.sleep(15)
        counter+=1
        print('mashed go ' + str(counter)+ ' times')
        psux=get_pv("IN:ZOOM:SCIMAG3D_01:PSU:X")
    time.sleep(15)
    #print('finish!')
    set_pv("IN:ZOOM:SCIMAG3D_01:PSH:X:SP",0) # Another Naughty Boy
    set_pv("IN:ZOOM:SCIMAG3D_01:PSU:X:SP",0.0)
    time.sleep(15)
    counter = 0
    while(psux > 0.001):
        set_pv("IN:ZOOM:SCIMAG3D_01:PSU:RAMP:CMD",1)
        time.sleep(15)
        psux = get_pv("IN:ZOOM:SCIMAG3D_01:PSU:X")
        time.sleep(3)
        counter+=1
        print('mashed calme '+str(counter) + ' times')
# Y component
curry=get_pv("IN:ZOOM:SCIMAG3D_01:MAG:Y:FIELD")