REM 14 Encoder Module

This module provides functions to read data coming from a REM 14 Encoder.

Those functions are used in Serial Encoder Module itself used by Position Feedback Module to create a service for reading a REM 14 encoder.

The functions should always run over an IFM Tile so it can access the ports to your SOMANET IFM device.

How to use

Important

We assume that you are using SOMANET Base and your app includes the required board support files for your SOMANET device.

See also

You might find useful the REM 14 Sensor Demo <app_test_rem_14, which illustrates the use of this module.

  1. First, add all the SOMANET Motor Control modules to your app Makefile.

    USED_MODULES = configuration_parameters module_adc module_encoder_rem_14 lib_bldc_torque_control module_board-support module_hall_sensor module_utils module_position_feedback module_pwm module_incremental_encoder module_biss_encoder module_encoder_rem_16mt module_serial_encoder module_shared_memory module_spi_master module_watchdog
    

    Note

    Not all modules will be required, but when using a library it is recommended to include always all the contained modules. This will help solving internal dependency issues.

  2. Include the REM 14 Service header rem_14_service.h in your app.

  3. Instantiate the ports for the REM 14.

    REM 14 needs a SPIPorts structure containing two clock blocks and 4 1-bit ports for SPI.

  4. Fill up the REM 14 configuration structure.

    The functions use the same configuration structure as the Position Feedback Module. You need to fill up all the generic sensor parameters especially ``ifm_usec`. And fill up the REM 14 specific parameters.

  5. At your IFM tile, You can use the functions to read REM 14 data.
    #include <CORE_C22-rev-a.bsp>   //Board Support file for SOMANET Core C22 device
    #include <IFM_DC100-rev-b.bsp>  //Board Support file for SOMANET IFM DC100 device
                                    //(select your board support files according to your device)
    
    // 2. Include the REM 14 Service header **rem_14_service.h** in your app.
    #include <rem_14_service.h>
    
    // 3.Instantiate the ports for the REM 14.
    SPIPorts spi_ports = SOMANET_IFM_SPI_PORTS;
    
    int main(void)
    {
        par
        {
            on tile[IFM_TILE]:
            {
                // 4. Fill up the REM 14 configuration structure.
                PositionFeedbackConfig position_feedback_config;
                position_feedback_config.polarity    = NORMAL_POLARITY;
                position_feedback_config.pole_pairs  = POLE_PAIRS;
                position_feedback_config.ifm_usec    = IFM_TILE_USEC;
                position_feedback_config.offset      = 0;
    
                position_feedback_config.rem_14_config.hysteresis     = REM_14_SENSOR_HYSTERESIS ;
                position_feedback_config.rem_14_config.noise_setting  = REM_14_SENSOR_NOISE;
                position_feedback_config.rem_14_config.dyn_angle_comp = REM_14_SENSOR_DAE;
                position_feedback_config.rem_14_config.abi_resolution = REM_14_SENSOR_ABI_RES;
    
                // 5. Use the functions to read REM 14 data.
                // initialize the sensor
                initRotarySensor(spi_ports, position_feedback_config);
    
                // read REM 14 data
                position = readRotarySensorAngleWithCompensation(spi_ports, position_feedback_config.ifm_usec);
            }
        }
    
        return 0;
    }
    

API

Definitions

DEFAULT_SPI_CLOCK_DIV

divisor for SPI clock frequency, (250/DIV)/2 MHz

REM_14_POLLING_TIME

Time between reads in micro seconds.

REM_14_EXECUTING_TIME

fraction of microsecond: 1 us / 2 = 0.5 us

REM_14_SAVING_TIME

fraction of microsecond: 1 us / 5 = 0.2 us

REM_14_WIDTH_INDEX_PULSE

Width of the index pulse I (0 = 3LSB, 1 = 1LSB).

REM_14_FACTORY_SETTINGS

Factory Settings, just reading, no writing.

REM_14_UVW_ABI

Defines the PWM Output (0 = ABI is operating, W is used as PWM; 1 = UVW is operating, I is used as PWM)

REM_14_DATA_SELECT

This bit defines which data can be read form address 16383dec (3FFFhex).

0->DAECANG 1->CORDICANG

REM_14_PWM_CONFIG

Enables PWM (setting of UVW_ABI Bit necessary)

Types

REM_14_ABIResolution

Type for ABI resolution.

Enum Values:

REM_14_ABI_RES_11BIT

ABI resolution 11 bit.

REM_14_ABI_RES_10BIT

ABI resolution 10 bit.

REM_14_Noise

Type for Noise setting.

Enum Values:

REM_14_NOISE_NORMAL

noise normal

REM_14_NOISE_REDUCED

noise reduced

REM_14_DynAngleComp

Type for Dynamic Angle Error Compensation.

Enum Values:

REM_14_DAE_ON

DAE compensation on.

REM_14_DAE_OFF

DAE compensation off.

REM_14_Hysteresis

Type for REM 14 Hysteresis.

Enum Values:

REM_14_HYS_11BIT_3LSB

Hysteresis for 11 Bit ABI Resolution: 3 LSB.

REM_14_HYS_11BIT_2LSB

Hysteresis for 11 Bit ABI Resolution: 2 LSB.

REM_14_HYS_11BIT_1LSB

Hysteresis for 11 Bit ABI Resolution: 1 LSB.

REM_14_HYS_11BIT_OFF

Hysteresis for 11 Bit ABI Resolution: no hysteresis.

REM_14_HYS_10BIT_3LSB

Hysteresis for 10 Bit ABI Resolution: 3 LSB.

REM_14_HYS_10BIT_2LSB

Hysteresis for 10 Bit ABI Resolution: 2 LSB.

REM_14_HYS_10BIT_1LSB

Hysteresis for 10 Bit ABI Resolution: 1 LSB.

REM_14_HYS_10BIT_OFF

Hysteresis for 10 Bit ABI Resolution: no hysteresis.

REM_14Config

Structure type to define the REM 14 sensor configuration.

Structure Members:

REM_14_Noise noise_settings

Noise setting.

In 3.3V operation, VDD and VREG must be tied together. In this configuration, normal noise performance (ONL) is available at reduced maximum temperature (125°C) by clearing NOISESET to 0. When NOISESET is set to 1, the full temperature range is available with reduced noise performance (ONH).

REM_14_DynAngleComp dyn_angle_error_comp

Disable Dynamic Angle Error Compensation.

REM_14_Hysteresis hysteresis

Hysteresis for 11 Bit ABI Resolution.

REM_14_ABIResolution abi_resolution_settings

Resolution of ABI (0 = 11 bits, 1 = 10 bits)

PositionFeedbackConfig

Configuration structure of the position feedback service.

Structure Members:

SensorType sensor_type

Select the sensor type.

SensorFunction sensor_function

Select which data to write to shared memory.

SensorPolarity polarity

Encoder polarity.

UsecType ifm_usec

Number of clock ticks in a microsecond >

int pole_pairs

Number of pole pairs.

int resolution

Number of ticks per turn.

int offset

Offset (in ticks) added to the absolute multiturn position (count).

Does not affect the electrical angle

int max_ticks

The multiturn position is reset to 0 when reached.

int velocity_compute_period

Velocity compute period in microsecond.

Is also the polling period to write to the shared memory

BISSConfig biss_config

BiSS sensor configuration.

REM_16MTConfig rem_16mt_config

REM 16MT sensor configuration.

REM_14Config rem_14_config

REM 14 configuration.

QEIConfig qei_config

QEI sensor configuration.

HallConfig hall_config

Hall sensor configuration.

GPIOType gpio_config

GPIO configuration.

SPIPorts

Structure for SPI ports and clock blocks.

Structure Members:

spi_master_class spi_class
port *movable slave_select

Functions

void initRotarySensorInterface(SPIPorts &spi_ports)

Initialize SPI ports and clock blocks.

Parameters:
  • spi_ports – the SPI ports structure
SensorError initRotarySensor(SPIPorts &spi_ports, PositionFeedbackConfig &config)

Initialize REM 14 sensor.

Parameters:
  • spi_ports – the SPI ports structure
  • config – position feedback config containing the REM 14 sensor config
Returns:

status

int readZeroPosition(SPIPorts &spi_ports, UsecType ifm_usec)

Read the zero position (offset)

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
Returns:

zero position (offset)

int readNumberPolePairs(SPIPorts &spi_ports, UsecType ifm_usec)

Read the number of pole pairs.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
Returns:

number of pole pairs

int readRedundancyReg(SPIPorts &spi_ports, UsecType ifm_usec)

Read the redundancy register.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
Returns:

redundancy register

int readProgrammingReg(SPIPorts &spi_ports, UsecType ifm_usec)

Read the programming register.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
Returns:

programming register

int readCORDICMagnitude(SPIPorts &spi_ports, UsecType ifm_usec)

Read the Cordic magnitude.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
Returns:

Cordic magnitude

int readRotaryDiagnosticAndAutoGainControl(SPIPorts &spi_ports, UsecType ifm_usec)

Read the Diagnostic and AutoGain Control.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
Returns:

Diagnostic and AutoGain Control

int readRotarySensorError(SPIPorts &spi_ports, UsecType ifm_usec)

Read the sensor error.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
Returns:

sensor error

{ unsigned int, unsigned int } r readRotarySensorAngleWithoutCompensation(SPIPorts &spi_ports, UsecType ifm_usec)

Read the singleturn position without compensation.

the SPI ports structure

Parameters:
  • ifm_usec – number of ticks in a microseconds
Returns:

singleturn position without compensation

Returns:

status

{ unsigned int, unsigned int } r readRotarySensorAngleWithCompensation(SPIPorts &spi_ports, UsecType ifm_usec)

Read the singleturn position with compensation.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
Returns:

singleturn position with compensation

Returns:

status

int writeSettings(SPIPorts &spi_ports, UsecType ifm_usec, unsigned short address, unsigned short data)

Write the setting register.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
  • address – the address of the register to write (settings1 or settings2)
  • data – the data to write
Returns:

status

int writeZeroPosition(SPIPorts &spi_ports, UsecType ifm_usec, unsigned short data)

Write the zero position (offset)

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
  • data – the data to write
Returns:

status

int writeNumberPolePairs(SPIPorts &spi_ports, UsecType ifm_usec, unsigned short data)

Write the number of pole pairs.

Parameters:
  • spi_ports – the SPI ports structure
  • ifm_usec – number of ticks in a microseconds
  • data – the data to write
Returns:

status