# devices.oxford:IPS120_switchheater


IPS120 driver with switch heater control for persistent mode.


Usage

``` python
devices.oxford:IPS120_switchheater(
    interface,
    isobus_addr=None,
    legacy=True,
    fieldlimits=(0, 1),
    max_rate=0.5,
    switch_wait_time=5,
    **kwargs,
)
```


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize the IPS120 switch heater driver. |
| [getMagnetStatus()](#getMagnetStatus) | Get the operational state of the magnet. |
| [getMagneticField()](#getMagneticField) | Get the current magnetic field value. |
| [getMagneticFieldRate()](#getMagneticFieldRate) | Get the magnetic field ramp rate. |
| [getPersistentField()](#getPersistentField) | Get the persistent field value trapped in the magnet. |
| [getSwitchHeater()](#getSwitchHeater) | Get the state of the switch heater. |
| [getVersion()](#getVersion) | Get the controller firmware version. |
| [getVoltage()](#getVoltage) | Get the power supply output voltage. |
| [setMagnetStatus()](#setMagnetStatus) | Set operational state of the magnet. |
| [setMagneticField()](#setMagneticField) | Set the magnetic field to the specified value. |
| [setMagneticFieldNonPersistent()](#setMagneticFieldNonPersistent) | Set the field in non-persistent mode (with switch heater on). |
| [setMagneticFieldPersistent()](#setMagneticFieldPersistent) | Set the field and switch to persistent mode. |
| [setMagneticFieldRate()](#setMagneticFieldRate) | Set magnetic field ramp rate. |
| [setSwitchHeater()](#setSwitchHeater) | Control the switch heater state. |

------------------------------------------------------------------------


### \_\_init\_\_()


Initialize the IPS120 switch heater driver.


Usage

``` python
__init__(
    interface,
    isobus_addr=None,
    legacy=True,
    fieldlimits=(0, 1),
    max_rate=0.5,
    switch_wait_time=5,
    **kwargs,
)
```


#### Parameters


`interface: str`  
VISA resource name or device path

`isobus_addr: int = None`  
ISOBUS address for the device

`legacy: bool = ``True`  
If True, use legacy mode without floating point commands

`fieldlimits: tuple = (0, 1)`  
Min and max field limits in Tesla (default: (0, 1))

`max_rate: float = ``0.5`  
Maximum allowed field ramp rate in T/min (default: 0.5)

`switch_wait_time: float = ``5`  
Wait time in seconds after switching heater state (default: 5)

`**kwargs: dict`  
Additional arguments passed to the IsobusDevice constructor


------------------------------------------------------------------------


### getMagnetStatus()


Get the operational state of the magnet.


Usage

``` python
getMagnetStatus()
```


#### Returns


`int | None`  
State of the magnet: 0 - HOLD 1 - RTOS (Ramp to setpoint) 2 - RTOZ (Ramp to zero) 3 - CLMP (Clamped, when current is 0) 4 - Warming up 8 - Fault None if status could not be read


------------------------------------------------------------------------


### getMagneticField()


Get the current magnetic field value.


Usage

``` python
getMagneticField(setp=False)
```


#### Parameters


`setp: bool = ``False`  
If True, also returns the setpoint value


#### Returns


`float or tuple`  
Current field value in Tesla, or a tuple of (current, setpoint) if setp=True


------------------------------------------------------------------------


### getMagneticFieldRate()


Get the magnetic field ramp rate.


Usage

``` python
getMagneticFieldRate(setp=False)
```


#### Parameters


`setp: bool = ``False`  
If True, also returns the setpoint rate


#### Returns


`float or tuple`  
Current ramp rate in T/min, or (current, setpoint) if setp=True


------------------------------------------------------------------------


### getPersistentField()


Get the persistent field value trapped in the magnet.


Usage

``` python
getPersistentField()
```


#### Returns


`float or None`  
Persistent field value in Tesla, or None if switch heater is on


#### Notes

Only returns a valid value if switch heater is off.

------------------------------------------------------------------------


### getSwitchHeater()


Get the state of the switch heater.


Usage

``` python
getSwitchHeater()
```


#### Returns


`int | None`  
Switch heater state: 0 - Off with no field in the magnet 1 - On 2 - Off with persistent field inside 5 - Heater fault 8 - No switch fitted None if status could not be read


------------------------------------------------------------------------


### getVersion()


Get the controller firmware version.


Usage

``` python
getVersion()
```


#### Returns


`str`  
Firmware version string


------------------------------------------------------------------------


### getVoltage()


Get the power supply output voltage.


Usage

``` python
getVoltage()
```


#### Returns


`float`  
Output voltage in Volts


------------------------------------------------------------------------


### setMagnetStatus()


Set operational state of the magnet.


Usage

``` python
setMagnetStatus(state)
```


#### Parameters


`state: int`  
Operational state code: 0 - HOLD 1 - RTOS (Ramp to setpoint) 2 - RTOZ (Ramp to zero) 3 - CLMP (Clamped, when current is 0) - disallowed


------------------------------------------------------------------------


### setMagneticField()


Set the magnetic field to the specified value.


Usage

``` python
setMagneticField(xval)
```


#### Parameters


`xval: float`  
Magnetic field value in Tesla


#### Notes

Automatically checks that the value is within the configured field limits.

------------------------------------------------------------------------


### setMagneticFieldNonPersistent()


Set the field in non-persistent mode (with switch heater on).


Usage

``` python
setMagneticFieldNonPersistent(
    field,
    block=False,
)
```


#### Parameters


`field: float`  
Target field value in Tesla

`block: bool = ``False`  
If True, blocks until field has reached target value


------------------------------------------------------------------------


### setMagneticFieldPersistent()


Set the field and switch to persistent mode.


Usage

``` python
setMagneticFieldPersistent(field)
```


#### Parameters


`field: float`  
Target field value in Tesla


#### Notes

Sets the field, turns off the switch heater, and then ramps the power supply to zero while keeping the field trapped in the magnet.

------------------------------------------------------------------------


### setMagneticFieldRate()


Set magnetic field ramp rate.


Usage

``` python
setMagneticFieldRate(rate)
```


#### Parameters


`rate: float`  
Field ramp rate in T/min (between 0 and max_rate)


------------------------------------------------------------------------


### setSwitchHeater()


Control the switch heater state.


Usage

``` python
setSwitchHeater(output)
```


#### Parameters


`output: bool`  
True to turn on the switch heater, False to turn it off


#### Notes

The switch heater is used to control persistent mode operation. When on, the magnet follows the power supply current. When off, the field is trapped in the magnet.
