# devices.nanotec:NanotecPD4


Nanotec PD4 stepper motor with integrated controller.


Usage

``` python
devices.nanotec:NanotecPD4(
    interface,
    steps_per_deg=1,
    zero_offset=-150,
    steps_lower_limit=-150,
    steps_upper_limit=-21900,
    pos_mode="abs",
    status_enable=False,
    **kwargs,
)
```


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize the Nanotec PD4 controller. |
| [getCurrentRecordParams()](#getCurrentRecordParams) | Readout the current record write parameter set in dictionary. |
| [getErrorStatus()](#getErrorStatus) | Read if the motor has a position error. |
| [getLastReferenceTime()](#getLastReferenceTime) | Get the time of the last reference run in local time. |
| [getMovingStatus()](#getMovingStatus) | Read if the motor is still moving. |
| [getPosDeg()](#getPosDeg) | Get current position in degrees. |
| [getPosMode()](#getPosMode) | Get active positioning mode. |
| [getRotDir()](#getRotDir) | Get the rotation direction. |
| [id()](#id) | Get the device identifier. |
| [move()](#move) | Halbach function to move the motor. |
| [moveClip()](#moveClip) | Move the motor with position clipping. |
| [moveClipWait()](#moveClipWait) | Move the motor with position clipping and wait for completion. |
| [moveWait()](#moveWait) | Halbach function to move the motor and wait for completion. |
| [readInitSpeed()](#readInitSpeed) | Read the current minimum step frequency. |
| [readMoves()](#readMoves) | Read the current position in steps. |
| [referenceRun()](#referenceRun) | Perform a reference run and set positioning mode to absolute. |
| [resetMoves()](#resetMoves) | Reset the position of the motor to 0. |
| [resetPosError()](#resetPosError) | Reset the position error. |
| [setPosMode()](#setPosMode) | Set the positioning mode to either relative or absolute. |
| [setPosition()](#setPosition) | Set the position to a given number of steps. |
| [setRotDir()](#setRotDir) | Set the rotation direction based on the sign of direction. |
| [setRotDirBin()](#setRotDirBin) | Set the rotation direction using binary values. |
| [startRecord()](#startRecord) | Start the active record / start the motor. |
| [stopRecord()](#stopRecord) | Stop the motor. |

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


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


Initialize the Nanotec PD4 controller.


Usage

``` python
__init__(
    interface,
    steps_per_deg=1,
    zero_offset=-150,
    steps_lower_limit=-150,
    steps_upper_limit=-21900,
    pos_mode="abs",
    status_enable=False,
    **kwargs,
)
```


#### Parameters


`interface: str`  
Communication interface identifier

`steps_per_deg: int = ``1`  
Steps per degree of rotation, by default 1

`zero_offset: int = ``-150`  
Internal zero offset in steps, by default -150

`steps_lower_limit: int = ``-150`  
Lower limit in steps, defined as the smallest distance to the reference point, by default -150

`steps_upper_limit: int = ``-21900`  
Upper limit in steps, defined as the greatest distance to the reference point, by default -21900

`pos_mode: str = ``"abs"`  
Initial positioning mode, either "abs" or "rel", by default "abs"

`status_enable: bool = ``False`  
Enable status responses, by default False

`**kwargs`  
Additional arguments passed to VisaDevice


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


### getCurrentRecordParams()


Readout the current record write parameter set in dictionary.


Usage

``` python
getCurrentRecordParams(param)
```


#### Parameters


`param: str`  
Parameter to retrieve, options include:

- p: Position mode
- s: Travel distance
- u: Initial step frequency
- o: Maximum step frequency
- n: Second maximum step frequency
- b: Acceleration and braking ramp
- d: Direction of rotation
- t: Reversal in direction of rotation for repeat records
- w: Repetitions
- P: Pause between repetitions and continuation records
- N: Record number of continuation record


#### Returns


`int`  
Value of the requested parameter


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


### getErrorStatus()


Read if the motor has a position error.


Usage

``` python
getErrorStatus()
```


#### Returns


`bool`  
True if there is a position error, False otherwise


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


### getLastReferenceTime()


Get the time of the last reference run in local time.


Usage

``` python
getLastReferenceTime()
```


#### Returns


`str`  
Time of run formatted as "YYYY-MM-DD hh:mm:ss"


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


### getMovingStatus()


Read if the motor is still moving.


Usage

``` python
getMovingStatus()
```


#### Returns


`bool`  
True if the motor is moving, False otherwise


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


### getPosDeg()


Get current position in degrees.


Usage

``` python
getPosDeg()
```


#### Returns


`float`  
Current position in degrees


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


### getPosMode()


Get active positioning mode.


Usage

``` python
getPosMode()
```


#### Returns


`str`  
Positioning mode ("rel", "abs", or "error")


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


### getRotDir()


Get the rotation direction.


Usage

``` python
getRotDir()
```


#### Returns


`int`  
Rotation direction (0: Left, 1: Right)


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


### id()


Get the device identifier.


Usage

``` python
id()
```


#### Returns


`str`  
Device identifier string


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


### move()


Halbach function to move the motor.


Usage

``` python
move(
    moves,
    position,
    speed,
)
```


Moves the motor by a given amount of steps (rel) or to a given position (abs) depending on the current positioning mode. In relative positioning mode, moves has to be a positive integer.


#### Parameters


`moves: int`  
Number of steps to move or target position (positive in rel pos mode)

`position: int`  
Current position

`speed: float`  
Movement speed


#### Returns


`None`  


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


### moveClip()


Move the motor with position clipping.


Usage

``` python
moveClip(
    pos,
    unit,
)
```


Move the motor by a given distance (rel) or to a given position (abs) in the specified unit, depending on active positioning mode. Suitable for absolute and relative movement as well as degrees (if calibrated) or steps.


#### Parameters


`pos: float`  
Position or distance to move

`unit: str`  
Unit of position ("deg" or "steps")


#### Returns


`None`  


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


### moveClipWait()


Move the motor with position clipping and wait for completion.


Usage

``` python
moveClipWait(
    posDeg,
    unit,
)
```


Move the motor by a given distance (rel) or to a given position (abs) in the specified unit, depending on active positioning mode. Wait for move to finish. Suitable for absolute and relative movement as well as degrees (if calibrated) or steps.


#### Parameters


`posDeg: float`  
Position or distance to move

`unit: str`  
Unit of position ("deg" or "steps")


#### Returns


`None`  


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


### moveWait()


Halbach function to move the motor and wait for completion.


Usage

``` python
moveWait(
    moves,
    position,
    speed,
)
```


#### Parameters


`moves: int`  
Number of steps to move or target position

`position: int`  
Current position

`speed: float`  
Movement speed


#### Returns


`None`  


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


### readInitSpeed()


Read the current minimum step frequency.


Usage

``` python
readInitSpeed()
```


#### Returns


`int`  
Minimum step frequency in steps/s


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


### readMoves()


Read the current position in steps.


Usage

``` python
readMoves()
```


#### Returns


`int`  
Current position in steps


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


### referenceRun()


Perform a reference run and set positioning mode to absolute.


Usage

``` python
referenceRun(wait=600000.0)
```


Recommended to use when the position of the magnet isn't defined.


#### Parameters


`wait: float = ``600000.0`  
Timeout value for the reference run in milliseconds, by default 600e3


#### Returns


`None`  


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


### resetMoves()


Reset the position of the motor to 0.


Usage

``` python
resetMoves()
```


#### Returns


`None`  


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


### resetPosError()


Reset the position error.


Usage

``` python
resetPosError()
```


Useful when running into limits.


#### Returns


`None`  


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


### setPosMode()


Set the positioning mode to either relative or absolute.


Usage

``` python
setPosMode(mode)
```


#### Parameters


`mode: str`  
Positioning mode ("rel" or "abs")


#### Returns


`None`  


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


### setPosition()


Set the position to a given number of steps.


Usage

``` python
setPosition(moves)
```


#### Parameters


`moves: int`  
Number of steps to set as the position


#### Returns


`None`  


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


### setRotDir()


Set the rotation direction based on the sign of direction.


Usage

``` python
setRotDir(direction)
```


#### Parameters


`direction: int`  
Direction value (-1 -\> 0 -\> Left; 1 -\> 1 -\> Right)


#### Returns


`None`  


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


### setRotDirBin()


Set the rotation direction using binary values.


Usage

``` python
setRotDirBin(direction)
```


#### Parameters


`direction: int`  
Direction value (0 -\> Left; 1 -\> Right)


#### Returns


`None`  


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


### startRecord()


Start the active record / start the motor.


Usage

``` python
startRecord()
```


#### Returns


`None`  


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


### stopRecord()


Stop the motor.


Usage

``` python
stopRecord()
```


#### Returns


`None`
