Encoder
Component Type: Input
Status: Implemented
Overview
Dawn provides two quadrature encoder IO classes:
encoder (
CIOEncoder): Provides basic position tracking.encoder_index (
CIOEncoderIndex): Provides position tracking along with index position and index count information.
These components interface with the underlying OS quadrature encoder driver to provide rotation or linear position data to the framework.
Implementation
Both encoder classes use the DTYPE_INT32 data type for position values.
They interact with the OS through the porting layer (dawn/include/dawn/porting/encoder.hxx).
CIOEncoderreturns a singleint32_tvalue representing the current position.CIOEncoderIndexreturns a vector of threeint32_tvalues: 1. Current position 2. Last index position 3. Index event counter
Both classes support the CMD_RESET trigger to reset the hardware encoder
count.
Configuration
Kconfig
CONFIG_DAWN_IO_ENCODER: Enables the basic encoder IO class.CONFIG_DAWN_IO_ENCODER_INDEX: Enables the index-aware encoder IO class.
YAML
Example configuration for a basic encoder:
ios:
- id: rot_enc
type: encoder
dtype: int32
config:
devno: 0
posmax: 1024
Example configuration for an encoder with index support:
ios:
- id: spindle_enc
type: encoder_index
dtype: int32
config:
devno: 1
posmax: 4096
Supported config fields:
devno: Driver device number (e.g.,0for/dev/qenc0).posmax: (Optional) Maximum position value before wrap-around.