Tachometer

This module provides a set of functionalities for managing the Tachometer system, including initialization, RPM calculations, RPM averaging, and configuration management to ensure accurate representation of engine RPM.

Configuration Parameters

All API functions have the first argument as the module ID.

Configuration

Name

Description

Range

enable

Enables Tachometer functionality.

0 (disabled) or 1 (enabled)

rpm_range

The RPM range for the tachometer.

Minimum to Maximum RPM (e.g., 0 to 8000)

bar_count

The number of bars for RPM display.

1 to 16

rpm_thresholds

RPM thresholds for bar activation.

Array of thresholds (configurable values).

average_period

The number of data points used for calculating average RPM.

1 to 100

APIs

The Tachometer module provides the following APIs to initialize, process, and update the tachometer data:

API Functions

Function

Description

rs_am_tachometer_init

Initializes the tachometer system with default configuration values.

rs_am_tachometer_process

Processes the tachometer system by calculating the RPM and updating bar states.

Error Codes

Each API for the tachometer module returns success or failure codes. For detailed information on the error codes, please refer to the following section:

Tachometer Module Header Details

The header file for tachometer modules, rs_am_tachometer.h, defines the required structures and APIs for initialization and processing.

Typedefs

typedef struct tag_rs_tacho_config rs_tacho_config_t

Includes.

Tachometer runtime data structure

typedef struct tag_rs_tacho_runtime rs_tacho_runtime_t

Tachometer configuration data structure.

typedef struct tag_rs_tacho_output rs_tacho_output_t

Tachometer output data structure.

typedef struct tag_rs_am_tachometer rs_am_tachometer_t

Contains information about tachometer.

Functions

rs_ret_val_t rs_am_tachometer_init(rs_am_tachometer_t *ptr_tachometer)

Initializes the tachometer module with default configuration.

Sets up initial configuration values for the tachometer, including bar thresholds and hysteresis for RPM transitions.

Parameters:

ptr_tachometer[in] Pointer to the Tachometer structure to initialize.

Returns:

Returns success after initialization.

rs_ret_val_t rs_am_tachometer_process(rs_am_tachometer_t *ptr_tachometer)

Main processing function for the tachometer module.

Calculates average RPM, updates bar levels, and processes dispatcher events.

Parameters:

ptr_tachometer[in] Pointer to the Tachometer structure for processing.

Returns:

Returns success after processing the tachometer data.

struct tag_rs_tacho_config
#include <rs_am_tachometer.h>

Includes.

Tachometer runtime data structure

Public Members

uint8_t enable_module

Enable/Disable tachometer module.

uint16_t max_tacho_val

Maximum tachometer value.

uint16_t tacho_hysteresis

Hysteresis value only for tachometer off.

uint8_t max_bar_count

Maximum bar count for tachometer display.

uint16_t tacho_bar_threshold

Values for bars that should be turned on and off.

uint16_t tacho_idle_bar_threshold

idle Value for bars that should be turned on and off

uint16_t tacho_red_bar_threshold

Max or over RPM Values for bars that should be turned on and off.

struct tag_rs_tacho_runtime
#include <rs_am_tachometer.h>

Tachometer configuration data structure.

Public Members

uint16_t raw_tacho_val

Raw tachometer value.

uint16_t display_tacho_val

Displayable tachometer value.

uint8_t current_tacho_bar

Current active tachometer bar.

struct tag_rs_tacho_output
#include <rs_am_tachometer.h>

Tachometer output data structure.

Public Members

uint16_t prev_display_rpm

Previous RPM value displayed.

uint16_t display_rpm_bars

Current RPM value to display.

uint8_t filtered_rpm

Filtered RPM value for smoother operation.

uint8_t angular_speed

Angular speed of tachometer.

uint8_t tacho_state

to indicate tachometer Faults

struct tag_rs_am_tachometer
#include <rs_am_tachometer.h>

Contains information about tachometer.

Public Members

rs_tacho_config_t config

Configuration for tachometer.

rs_tacho_runtime_t runtime

Runtime state of the tachometer.

rs_tacho_output_t output

Output values of the tachometer.