In this document
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 IF2 Tile so it can access the ports to your SOMANET Drive module.
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.
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_watchdogNote
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.
Include the REM 14 Service header rem_14_service.h in your app.
Instantiate the ports for the REM 14.
REM 14 needs a
SPIPorts
structure containing two clock blocks and 4 1-bit ports for SPI.
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 ``tile_usec`. And fill up the REM 14 specific parameters.
#include <CoreC2X.bsp> //Board Support file for SOMANET Core C2X device
#include <Drive1000-rev-c4.bsp> //Board Support file for SOMANET Drive module
//(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_DRIVE_SPI_PORTS;
int main(void)
{
par
{
on tile[IF2_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.tile_usec = IF2_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.tile_usec);
}
}
return 0;
}
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)
REM_14_ABIResolution
¶Type for ABI resolution.
Enum Values:
REM_14_Noise
¶Type for Noise setting.
Enum Values:
REM_14_DynAngleComp
¶Type for Dynamic Angle Error Compensation.
Enum Values:
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:
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).
dyn_angle_error_comp
¶Disable Dynamic Angle Error Compensation.
hysteresis
¶Hysteresis for 11 Bit ABI Resolution.
abi_resolution_settings
¶Resolution of ABI (0 = 11 bits, 1 = 10 bits)
PositionFeedbackConfig
¶Configuration structure of the position feedback service.
Structure Members:
sensor_type
¶Select the sensor type.
sensor_function
¶Select which data to write to shared memory.
polarity
¶Encoder polarity.
tile_usec
¶Number of clock ticks in a microsecond >
pole_pairs
¶Number of pole pairs.
resolution
¶Number of ticks per turn.
offset
¶Offset (in ticks) added to the absolute multiturn position (count).
Does not affect the electrical angle
max_ticks
¶The multiturn position is reset to 0 when reached.
velocity_compute_period
¶Velocity compute period in microsecond.
Is also the polling period to write to the shared memory
biss_config
¶BiSS sensor configuration.
rem_16mt_config
¶REM 16MT sensor configuration.
rem_14_config
¶REM 14 configuration.
hall_config
¶Hall sensor configuration.
initRotarySensorInterface
(SPIPorts &spi_ports)¶Initialize SPI ports and clock blocks.
Parameters: |
|
---|
initRotarySensor
(SPIPorts &spi_ports, PositionFeedbackConfig &config)¶Initialize REM 14 sensor.
Parameters: |
|
---|---|
Returns: | status |
readZeroPosition
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the zero position (offset)
Parameters: |
|
---|---|
Returns: | zero position (offset) |
readNumberPolePairs
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the number of pole pairs.
Parameters: |
|
---|---|
Returns: | number of pole pairs |
readRedundancyReg
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the redundancy register.
Parameters: |
|
---|---|
Returns: | redundancy register |
readProgrammingReg
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the programming register.
Parameters: |
|
---|---|
Returns: | programming register |
readCORDICMagnitude
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the Cordic magnitude.
Parameters: |
|
---|---|
Returns: | Cordic magnitude |
readRotaryDiagnosticAndAutoGainControl
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the Diagnostic and AutoGain Control.
Parameters: |
|
---|---|
Returns: | Diagnostic and AutoGain Control |
readRotarySensorError
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the sensor error.
Parameters: |
|
---|---|
Returns: | sensor error |
readRotarySensorAngleWithoutCompensation
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the singleturn position without compensation.
the SPI ports structure
Parameters: |
|
---|---|
Returns: | singleturn position without compensation |
Returns: | status |
readRotarySensorAngleWithCompensation
(SPIPorts &spi_ports, UsecType tile_usec)¶Read the singleturn position with compensation.
Parameters: |
|
---|---|
Returns: | singleturn position with compensation |
Returns: | status |
writeSettings
(SPIPorts &spi_ports, UsecType tile_usec, unsigned short address, unsigned short data)¶Write the setting register.
Parameters: |
|
---|---|
Returns: | status |