Jump to main content

##

# 3.3.23.3 mcRefI_ReferenceControl

## C

    /* Floating point reference control */
    void mcRefI_ReferenceControl(  tmcRef_Parameters_s * const pParameters,
                                                        const float32_t command, float32_t * const pOut )

    /* Fixed point reference control */
    void mcRefI_ReferenceControl(  tmcRef_Parameters_s * const pParameters,
                                                        const int16_t command, int16_t * const pOut )

## Summary

This function performs the reference control.

## Description

This function controls the reference speed input, allowing for smooth acceleration or deceleration to achieve a target command value. It adjusts the reference based on specified parameters and clamps it within defined limits. The diagram below illustrates the reference control process.

## Precondition

The reference control module must be initialized and enabled.

## Parameters

Param | Description
--- | ---
pParameters | A pointer to the reference control module parameter structure
command | The target command value to which the reference should be adjusted. Please refer the generated header for the exact data type.
pOut | A pointer to a variable where the resulting reference value will be stored. Please refer the generated header for the exact data type.

## Returns

None

## Example

    // Define the Reference control module data structure
    tmcRef_Parameters_s params;

    // Define the parameters for floating point reference control
    float32_t commandRef = 10.0f;
    float32_t nRef;

    // Define the parameters for fixed point reference control
    int16_t commandRef =10;
    int16_t nRef;

    /** Reference control  */
    mcRefI_ReferenceControl(&params, commandRef, &nRef);

## Remarks

Refer the generated header file for the exact function signature.