encoder(), IK220

Encoder() talks to the IK220 PCI card of Heidenhain.

* = encoder( hhe9, position)
* = encoder( hhe9)                    position
* = encoder( hhe9, StaPort)           status register
* = encoder( hhe9, CancelRef)         cancel ref. sequence
* = encoder( hhe9, DoRef)             start reference sequence
* = encoder( hhe9, Init)              init encoder 
* = encoder( hhe9, offset, ival)      set offset [counts]
* = encoder( hhe9, conversion, xval)  set conversion factor
* = encoder( hhe9, offset)            get offset
* = encoder( hhe9, conversion)        get conversion

* = encoder( hhe9, p1)                0 increment
                                      1 EnDat   
                                      2 SSI         

* = encoder( hhe9, p2)                0 11 muApp      
                                      1 1Vpp          

* = encoder( hhe9, p3)                0 linear axis
                                      1 rotational axis

* = encoder( hhe9, p4)                0 positive 
                                      1 negative

The position is calculated by: pos = (encoder - offset)/conversion

A start sequence:

* = encoder( hhe9, p2, 0)   sets the card to current mode
* = encoder( hhe9, init)
* = hex(encoder( hhe9, staport)) -> 0x20   
* = encoder( hhe9)

A reference sequence:

 
!
! move near the reference mark
!
move mot1 0      
* = encoder( hhe9, init)
* = hex(encoder( hhe9, staport)) -> 0x20
* = encoder( hhe9, doref)
* = hex(encoder( hhe9, staport)) -> 0x4060
!
! move over the reference mark
!
move mot1 1  
* = hex(encoder( hhe9, staport)) -> 0xffffc024
* = encoder( hhe9, position)     -> some value

An encoder is calibrated in the following way (assume the encoder reads the monochromator rotation axis):