Stepping motors with encoders are introduced to Online by:
define/dev=stepper/mod=omsmaxv/base=0x01000000/vec=0x0/chan=0/encoder=1 mot1
Online provides the following functions to operate the encoders:
SET_MOTOR_CONVERSION_ENCODER(id) smce() GET_MOTOR_ENCODER_RAW(id) gmeraw() SET_MOTOR_HOME_POSITION(id) smhp() GET_MOTOR_UNIT_POSITION_ENCODER(id) gmupe() GET_MOTOR_CONVERSION_ENCODER(id) gmce() GET_MOTOR_HOME_POSITION(id) gmhp() GET_MOTOR_FLAG_ENCODER(id) gmfe() GET_MOTOR_FLAG_ENCODER_CD(id) gmfecd() encoder conversion defined GET_MOTOR_FLAG_ENCODER_HD(id) gmfehd() encoder home position defined GET_MOTOR_FLAG_ENCODER_HOMED(id) gmfeh() encoder homed defined move/home id
This is a typical sequence:
set_motor_unit_backlash( mot65) = 0.1 smce(mot65) = -2000 smhp(mot65) = 50 move/home mot65 * = gmupe(mot65)
The function get_motor_unit_position_encoder() works only after a motor has been homed. If this is not possible, the function get_motor_encoder_raw() provides a relative measurement. A virtual counter that uses the raw encoder reading may look like this:
if( $method =~ /reset/i) { return 1; } if( $method =~ /read/i) { return Spectra::get_motor_encoder_raw( "mot25")/Spectra::get_motor_conversion_encoder( "mot25"); }