Skip to content

Add convenience functions to encoder module for computing theta and omega #167

@npetersen2

Description

@npetersen2

The encoder driver drv/encoder.c should be extended to support computing theta and omega values. These values are based on the number of pulses per revolution of the connected encoder.

The desired functions are simply for convenience; they store no state and are rather simple, but are common actions which anyone who uses an encoder will have to do. If we have these, then the user application does not have to worry about the particular encoder pulses per rev. Instead, they just configure the driver at boot and then it keeps track of it.

// Compute the current speed in mechanical rad/s
//
// This function will subtract the previous position from the current position and divide by delta time.
// Finally, it will use the steps per rev to get the answer in a standardized mechanical rad/s
double encoder_calc_speed(double dt, uint32_t pos_prev);

// Compute the current position in mechanical rad/s
//
// This function simply uses the steps per rev to get the answer in a standardized mechanical radians
double encoder_get_theta(void);


// Compute resolution in mechanical rads
//
// This function returns the resolution of the encoder output in mechanical radians
double encoder_get_theta_resolution(void);

Metadata

Metadata

Assignees

No one assigned

    Labels

    driverInvolves the drivers which interface between C firmware and hardware.dspInvolves the DSP C code.help wantedAnyone can jump in and assist on this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions