MSP430UltrasonicLibrary  02_30_00_03
Functions
Algorithm_api

Functions

USS_message_code USS_initAlgorithms (USS_SW_Library_configuration *config)
 The following API initializes USS_Algorithms_Handle based on user USS_Algorithms_User_Configuration, USS_System_Configuration, USS_Meter_Configuration and USS_Measurement_Configuration structs. Currently this API does not perform any parameter checks. More...
 
USS_message_code USS_runAlgorithmsFixedPoint (USS_SW_Library_configuration *config, USS_Algorithms_Results_fixed_point *results)
 The following API calculates Absolute ToF Upstream, Absolute ToF Downstream, Delta ToF, Volume Flow Rate using fixed point math. //!

IMPORTANT: It is recommend to use this version of the API to reduce power consumption numbers. More...
 
USS_message_code USS_runAlgorithms (USS_SW_Library_configuration *config, USS_Algorithms_Results *results)
 The following API calculates Absolute ToF Upstream, Absolute ToF Downstream, Delta ToF, Volume Flow Rate.

Note1: USS_initAlgorithms must be called prior to calling this function. The API expects to have a Up stream (UPS) and Down stream (DNS) of size "sampleSize" in contiguous LEA memory where the first capture is assumed to be UPS capture and the second capture is assumed to be DNS capture. Therefore, UPS and DNS capture depends on the type of capture the user select via sequenceSelection member in USS_Measurement_Configuration structure For example: if sequenceSelection == USS_CAPTURE_SEQUENCE_SELECTION_CH0_CH1 then USS CH0 is assumed to be UPS capture and CH1 is assumed to be DNS capture and vice versa for USS_measurement_capture_sequence_ch1_ch0 If API return message code USS_message_code_valid_results, then algorithms result are valid. More...
 
USS_message_code USS_calibrateVolumeFlowRate (USS_SW_Library_configuration *config, USS_Algorithms_Results_fixed_point *results)
 The following API calibrates Volume Flow Rate using fixed point math. More...
 
USS_message_code USS_calibrateVFRFlow (USS_SW_Library_configuration *config, USS_Algorithms_Results_fixed_point *results)
 The following API calibrates Volume Flow Rate using flow (only). More...
 
USS_message_code USS_calibrateVFRFlowTemperature (USS_SW_Library_configuration *config, USS_Algorithms_Results_fixed_point *results)
 The following API calibrates Volume Flow Rate using flow and temperature. More...
 
USS_message_code USS_scaleVolumeFlowRate (USS_SW_Library_configuration *config, USS_Algorithms_Results *results)
 The following API scales Volume Flow Rate by the additional scale factor. More...
 
USS_message_code USS_computeTemperature (USS_SW_Library_configuration *config, USS_Algorithms_Results_fixed_point *results)
 The following API computes temperature using UPS and DNS AbsToF. More...
 
USS_message_code USS_setTemperature (float temperature, USS_Algorithms_Results_fixed_point *results)
 The following API updates the fixed point temperature. More...
 
USS_message_code USS_generateMonoDualToneBinaryPattern (USS_SW_Library_configuration *config)
 The following API is used to generate the binary pattern used by USS_Alg_AbsToF_Calculation_Option_lobeWide and USS_Alg_AbsToF_Calculation_Option_hilbertWide computation options. Use this when AbsTof computation option is set to USS_Alg_AbsToF_Calculation_Option_lobeWide or USS_Alg_AbsToF_Calculation_Option_hilbertWide and pulse generation is single or dual mode. More...
 
USS_message_code USS_generateMultiToneBinaryPattern (USS_SW_Library_configuration *config)
 The following API is used to generate the binary pattern used by USS_Alg_AbsToF_Calculation_Option_lobeWide and USS_Alg_AbsToF_Calculation_Option_hilbertWide computation options. Use this when AbsTof computation option is set to USS_Alg_AbsToF_Calculation_Option_lobeWide or USS_Alg_AbsToF_Calculation_Option_hilbertWide and pulse generation is multi tone mode. More...
 
USS_message_code USS_updateABSTOFCalculationIteration (USS_SW_Library_configuration *config)
 The following API allows user to update the frequency at which the Absolute Time of Flight is calculated in the algorithms. The iteration value is set via the "absTOFIteration" parameter in the USS_Algorithm_User_Configuration structure. More...
 
USS_message_code USS_updateClockRelativeError (USS_SW_Library_configuration *config)
 The following API allows user to update clockRelativeError parameter during runtime. The clockRelativeError parameter is used to by USS_runAlgorithms and USS_runAlgorithmsFixedPoint APIs. The clockRelativeError parameter is used to correct the UPS and DNS AbsTOF calculations. Refere to clockRelativeError description for for guidance on how to estimate this parameter using USS_verifyHSPLLFrequency API. More...
 
USS_message_code USS_getResultsInFloat (USS_Algorithms_Results_fixed_point *pFixedResults, USS_Algorithms_Results *pFloatResults)
 The following API allows user to convert the fixed point Algorithm results to floating point representation. More...
 
USS_message_code USS_swapAlgorithmsCaptureBuffers (USS_SW_Library_configuration *config)
 This function allows user to swap capture buffers. It is highly recommended to call this function after calling USS_swapCaptureChannels. More...
 
bool USS_isAlgorithmChannelsSwapped (void)
 This function allows users to query current status Algorithm Capture buffers. More...
 
USS_message_code USS_updateAdditionalCaptureDelay (USS_SW_Library_configuration *config, float additionalCaptureDelay)
 This function allows users to update Additional Capture Delay with with minimal algorithm reconfiguration. More...
 
USS_message_code USS_updateDtoFOffset (USS_SW_Library_configuration *config, float dTofOffset)
 This function allows users to update Delta Time Of Flight Offset with with minimal algorithm reconfiguration. More...
 
USS_message_code USS_setAbsTOFStatus (USS_SW_Library_configuration *config, USS_absTOF_status_object *status)
 This function allows users to update the internal AbsTOF status. Including the state and index for the UPS / DNS channels. More...
 
USS_message_code USS_getAbsTOFStatus (USS_SW_Library_configuration *config, USS_absTOF_status_object *status)
 This function allows users to obtain the internal AbsTOF status. Including the state and index for the UPS / DNS channels. More...
 

Detailed Description

Function Documentation

§ USS_initAlgorithms()

USS_message_code USS_initAlgorithms ( USS_SW_Library_configuration config)

The following API initializes USS_Algorithms_Handle based on user USS_Algorithms_User_Configuration, USS_System_Configuration, USS_Meter_Configuration and USS_Measurement_Configuration structs. Currently this API does not perform any parameter checks.

Parameters
[in]configis a pointer to the USS SW Library user configuration
Returns
USS_message_code

§ USS_runAlgorithmsFixedPoint()

USS_message_code USS_runAlgorithmsFixedPoint ( USS_SW_Library_configuration config,
USS_Algorithms_Results_fixed_point results 
)

The following API calculates Absolute ToF Upstream, Absolute ToF Downstream, Delta ToF, Volume Flow Rate using fixed point math. //!

IMPORTANT: It is recommend to use this version of the API to reduce power consumption numbers.



Note1: USS_initAlgorithms must be called prior to calling this function.

The API expects to have a Up stream (UPS) and Down stream (DNS) of size "sampleSize" in contiguous LEA memory where the first capture is assumed to be UPS capture and the second capture is assumed to be DNS capture. Therefore, UPS and DNS capture depends on the type of capture the user select via sequenceSelection member in USS_Measurement_Configuration structure For example: if sequenceSelection == USS_CAPTURE_SEQUENCE_SELECTION_CH0_CH1 then USS CH0 is assumed to be UPS capture and CH1 is assumed to be DNS capture and vice versa for USS_measurement_capture_sequence_ch1_ch0 If API return message code USS_message_code_valid_results, then algorithms result are valid.

Parameters
[in]configis a pointer to the USS SW Library user configuration
[in]resultsis a pointer to the USS Algorithms Result structure
Returns
USS_message_code

Referenced by USS_runAlgorithms().

§ USS_runAlgorithms()

USS_message_code USS_runAlgorithms ( USS_SW_Library_configuration config,
USS_Algorithms_Results results 
)

The following API calculates Absolute ToF Upstream, Absolute ToF Downstream, Delta ToF, Volume Flow Rate.

Note1: USS_initAlgorithms must be called prior to calling this function. The API expects to have a Up stream (UPS) and Down stream (DNS) of size "sampleSize" in contiguous LEA memory where the first capture is assumed to be UPS capture and the second capture is assumed to be DNS capture. Therefore, UPS and DNS capture depends on the type of capture the user select via sequenceSelection member in USS_Measurement_Configuration structure For example: if sequenceSelection == USS_CAPTURE_SEQUENCE_SELECTION_CH0_CH1 then USS CH0 is assumed to be UPS capture and CH1 is assumed to be DNS capture and vice versa for USS_measurement_capture_sequence_ch1_ch0 If API return message code USS_message_code_valid_results, then algorithms result are valid.

Parameters
[in]configis a pointer to the USS SW Library user configuration
[in]resultsis a pointer to the USS Algorithms Result structure
Returns
USS_message_code

References _USS_SW_Library_configuration_::algorithmsConfig, _USS_Algorithms_User_Configuration_::temperatureCalcOption, USS_Alg_temperature_Calculation_Option_enabled, USS_calibrateVolumeFlowRate(), USS_computeTemperature(), USS_getResultsInFloat(), USS_runAlgorithmsFixedPoint(), USS_scaleVolumeFlowRate(), and USS_setTemperature().

Referenced by USS_calculateOffsets().

§ USS_calibrateVolumeFlowRate()

USS_message_code USS_calibrateVolumeFlowRate ( USS_SW_Library_configuration config,
USS_Algorithms_Results_fixed_point results 
)

The following API calibrates Volume Flow Rate using fixed point math.



Note1: USS_runAlgorithmsFixedPoint must be called prior to calling this function.

The API checks the volumeCalibrationOption member in the USS_Algorithms_User_Configuration structure. For example: If volumeCalibrationOption == USS_Alg_volume_flow_Calibration_Option_flow Then this API executes USS_calibrateVFRFlow If volumeCalibrationOption == USS_Alg_volume_flow_Calibration_Option_flow_temperature Then this API executes USS_calibrateVFRFlowTemperature If API return message code USS_message_code_valid_results, then algorithms result are valid.

Parameters
[in]configis a pointer to the USS SW Library user configuration
[in]resultsis a pointer to the USS Algorithms Result structure
Returns
USS_message_code

References _USS_SW_Library_configuration_::algorithmsConfig, USS_Alg_volume_flow_Calibration_Option_flow, USS_Alg_volume_flow_Calibration_Option_flow_temperature, USS_calibrateVFRFlow(), USS_calibrateVFRFlowTemperature(), USS_message_code_no_error, and _USS_Algorithms_User_Configuration_::volumeCalibrationOption.

Referenced by USS_runAlgorithms().

§ USS_calibrateVFRFlow()

USS_message_code USS_calibrateVFRFlow ( USS_SW_Library_configuration config,
USS_Algorithms_Results_fixed_point results 
)

The following API calibrates Volume Flow Rate using flow (only).



Note1: USS_runAlgorithmsFixedPoint must be called prior to calling this function.

The API checks the meter constant Look-Up-Table (LUT) using the measured volume flow rate. The calibrated volume flow rate is stored in the results->iq16VolumeFlowRate member, and the un calibrated result is stored in results->iq16VolumeFlowRateNoCalib member. For measured volume flow rate below the minimum VFR defined in the LUT, the minimum VFR corresponding meter constant will be used. If API return message code USS_message_code_valid_results, then algorithms result are valid.

Parameters
[in]configis a pointer to the USS SW Library user configuration
[in]resultsis a pointer to the USS Algorithms Result structure
Returns
USS_message_code

References _USS_SW_Library_configuration_::algorithmsConfig, _USS_Algorithms_User_Configuration_::calibObject, _USS_Algorithms_User_Configuration_::flowCalibObject, _USS_Algorithms_Flow_Meter_Constant_::iq16Offset, _USS_Algorithms_Flow_Meter_Constant_::iq16Slope, _USS_Algorithms_Results_fixed_point_::iq16VolumeFlowRate, _USS_Algorithms_Results_fixed_point_::iq16VolumeFlowRateNoCalib, _USS_Alg_volume_Flow_Calib_Object_::numOfRanges, _USS_Alg_volume_Flow_Calib_Object_::pMeterConfiguration, USS_findMeterConstantRange(), and USS_message_code_valid_results.

Referenced by USS_calibrateVolumeFlowRate().

§ USS_calibrateVFRFlowTemperature()

USS_message_code USS_calibrateVFRFlowTemperature ( USS_SW_Library_configuration config,
USS_Algorithms_Results_fixed_point results 
)

The following API calibrates Volume Flow Rate using flow and temperature.



Note1: USS_runAlgorithmsFixedPoint must be called prior to calling this function.

The API uses the measured volume flow rate and temperature to find the corresponding quadrilateral. The calibration algorithm has 2 states, a search and track state. The first iteration it will run a full search of the quadrilateral using column (flow) first, then search via row (temperature). If a quadrilateral is found the next iteration of the algorithm will be in track mode, searching the previously found quadrilateral. If the flow, temperature pt is outside, then it will search the surrounding quadrilaterals. If the search is unsuccesfull, it will go back to search mode. The calibrated volume flow rate is stored in the results->iq16VolumeFlowRate member, and the un calibrated result is stored in results->iq16VolumeFlowRateNoCalib member. For measured volume flow rate, temperature outside of the defined quadrilaterals, the closest qudrilateral meter constants will be used for calibration. If API return message code USS_message_code_valid_results, then algorithms result are valid.

Parameters
[in]configis a pointer to the USS SW Library user configuration
[in]resultsis a pointer to the USS Algorithms Result structure
Returns
USS_message_code

References _USS_SW_Library_configuration_::algorithmsConfig, _USS_Algorithms_User_Configuration_::calibObject, _USS_Alg_volume_Flow_Temperature_Calib_Object_::colNum, _USS_Algorithms_User_Configuration_::flowTempCalibObject, _USS_Alg_volume_Flow_Temperature_Calib_Object_::rowNum, _USS_Alg_volume_Flow_Temperature_Calib_Object_::searchQuadCount, _USS_Alg_volume_Flow_Temperature_Calib_Object_::state, USS_Alg_volume_flow_Calibration_state_search, USS_Alg_volume_flow_Calibration_state_track, USS_calculateVolumeFlowRate(), USS_initialSearchQuad(), USS_isPtInside(), USS_message_code_Calibration_VFR_pt_inside_quadrilateral, USS_message_code_valid_results, and USS_searchNeighborQuad().

Referenced by USS_calibrateVolumeFlowRate().

§ USS_scaleVolumeFlowRate()

USS_message_code USS_scaleVolumeFlowRate ( USS_SW_Library_configuration config,
USS_Algorithms_Results results 
)

The following API scales Volume Flow Rate by the additional scale factor.



Note1: USS_getResultsInFloat must be called prior to calling this function.

The API multiplies results->volumeFlowRate by meterConfig->volumeAddlScaleFactor. The API is only needed when the additional scale factor is larger than 1.0f. It checks the volumeCalibrationOption member in the USS_Algorithms_User_Configuration structure. For example: If volumeCalibrationOption != USS_Alg_volume_flow_Calibration_Option_disabled Then it also scales results->volumeFlowRateNoCalib member by volumeAddlScaleFactor. If volumeCalibrationOption == USS_Alg_volume_flow_Calibration_Option_disabled Then results->volumeFlowRateNoCalib = results->volumeFlowRate. If API return message code USS_message_code_valid_results, then algorithms result are valid.

Parameters
[in]configis a pointer to the USS SW Library user configuration
[in]resultsis a pointer to the USS Algorithms Result structure
Returns
USS_message_code

References _USS_SW_Library_configuration_::algorithmsConfig, _USS_SW_Library_configuration_::meterConfig, USS_Alg_volume_flow_Calibration_Option_disabled, USS_message_code_no_error, _USS_Meter_Configuration_::volumeAddlScaleFactor, _USS_Algorithms_User_Configuration_::volumeCalibrationOption, _USS_Algorithms_Results_::volumeFlowRate, and _USS_Algorithms_Results_::volumeFlowRateNoCalib.

Referenced by USS_runAlgorithms().

§ USS_computeTemperature()

USS_message_code USS_computeTemperature ( USS_SW_Library_configuration config,
USS_Algorithms_Results_fixed_point results 
)

The following API computes temperature using UPS and DNS AbsToF.



Note1: USS_runAlgorithmsFixedPoint must be called prior to calling this function.

The API calculates the sound velocity (c) using UPS and DNS based on the formula: c = (L/2)*( (1/UPS) + (1/DNS)) = (L/2)*( (UPS+DNS)/(UPS*DNS) ) Then it converts the velocity to temperature using the temperature Look-Up-Table (LUT). When the velocity calculated is outside of the LUT range. If velocity is below the lowest velocity in the LUT, then the lowest 2 LUT values will be used to calculate temperature If velocity is above the highest velocity in the LUT, then the highest 2 LUT values will be used to calculate temperature

Parameters
[in]configis a pointer to the USS SW Library user configuration
[in]resultsis a pointer to the USS Algorithms Result structure
Returns
USS_message_code

References _USS_SW_Library_configuration_::algorithmsConfig, _USS_Algorithms_Results_fixed_point_::iq16Temperature, _USS_Alg_temperature_Calculation_Object_::pTempLUT, _USS_Algorithms_User_Configuration_::tempCalcObject, _USS_Alg_temperature_Calculation_Object_::tempLUTLength, USS_calculateVelocity(), USS_findTemperature(), USS_message_code_algorithm_error_temperature_object, and USS_message_code_no_error.

Referenced by USS_runAlgorithms().

§ USS_setTemperature()

USS_message_code USS_setTemperature ( float  temperature,
USS_Algorithms_Results_fixed_point results 
)

The following API updates the fixed point temperature.



Note1: USS_runAlgorithmsFixedPoint must be called prior to calling this function.

The API converts the temperature parameter to IQ16 format, the result is stored in results->iq16Temperature. This API must be used if volumeCalibrationOption == USS_Alg_volume_flow_Calibration_Option_flow_temperature and temperatureCalcOption == USS_Alg_temperature_Calculation_Option_disabled; for applications where the temperature is calculated using an external sensor.

Parameters
[in]temperatureis the new temperature value
[in]resultsis a pointer to the USS Algorithms Result structure
Returns
USS_message_code

References _USS_Algorithms_Results_fixed_point_::iq16Temperature, and USS_message_code_no_error.

Referenced by USS_runAlgorithms().

§ USS_generateMonoDualToneBinaryPattern()

USS_message_code USS_generateMonoDualToneBinaryPattern ( USS_SW_Library_configuration config)

The following API is used to generate the binary pattern used by USS_Alg_AbsToF_Calculation_Option_lobeWide and USS_Alg_AbsToF_Calculation_Option_hilbertWide computation options. Use this when AbsTof computation option is set to USS_Alg_AbsToF_Calculation_Option_lobeWide or USS_Alg_AbsToF_Calculation_Option_hilbertWide and pulse generation is single or dual mode.

Parameters
[in]configis a pointer to the USS SW Library user configuration
Returns
USS_message_code

§ USS_generateMultiToneBinaryPattern()

USS_message_code USS_generateMultiToneBinaryPattern ( USS_SW_Library_configuration config)

The following API is used to generate the binary pattern used by USS_Alg_AbsToF_Calculation_Option_lobeWide and USS_Alg_AbsToF_Calculation_Option_hilbertWide computation options. Use this when AbsTof computation option is set to USS_Alg_AbsToF_Calculation_Option_lobeWide or USS_Alg_AbsToF_Calculation_Option_hilbertWide and pulse generation is multi tone mode.

Parameters
[in]configis a pointer to the USS SW Library user configuration
Returns
USS_message_code

§ USS_updateABSTOFCalculationIteration()

USS_message_code USS_updateABSTOFCalculationIteration ( USS_SW_Library_configuration config)

The following API allows user to update the frequency at which the Absolute Time of Flight is calculated in the algorithms. The iteration value is set via the "absTOFIteration" parameter in the USS_Algorithm_User_Configuration structure.



Increasing the value for "absTOFIteration" reduces the average consumption of the application.



Note1: Calling this API will cause that USS_runAlgorithmsFixedPoint or USS_runAlgorithm API computes the Absolute Time of Flight next time they are called.



Note2: USS_initAlgorithms must be called prior to calling this function.

Parameters
[in]configis a pointer to the USS SW Library user configuration
Returns
USS_message_code

§ USS_updateClockRelativeError()

USS_message_code USS_updateClockRelativeError ( USS_SW_Library_configuration config)

The following API allows user to update clockRelativeError parameter during runtime. The clockRelativeError parameter is used to by USS_runAlgorithms and USS_runAlgorithmsFixedPoint APIs. The clockRelativeError parameter is used to correct the UPS and DNS AbsTOF calculations. Refere to clockRelativeError description for for guidance on how to estimate this parameter using USS_verifyHSPLLFrequency API.



Note1: USS_initAlgorithms must be called prior to calling this function.

Parameters
[in]configis a pointer to the USS SW Library user configuration
Returns
USS_message_code

§ USS_getResultsInFloat()

USS_message_code USS_getResultsInFloat ( USS_Algorithms_Results_fixed_point pFixedResults,
USS_Algorithms_Results pFloatResults 
)

The following API allows user to convert the fixed point Algorithm results to floating point representation.

Parameters
[in]pFixedResultsis a pointer to fixed point algorithm result structure
[in]pFloatResultsis a pointer to a floating point algorithm result structure. The converted results are returned in this structure
Returns
USS_message_code

Referenced by USS_runAlgorithms().

§ USS_swapAlgorithmsCaptureBuffers()

USS_message_code USS_swapAlgorithmsCaptureBuffers ( USS_SW_Library_configuration config)

This function allows user to swap capture buffers. It is highly recommended to call this function after calling USS_swapCaptureChannels.

Parameters
[in]configis a pointer to the USS SW Library user configuration.
Returns
USS_message_code

§ USS_isAlgorithmChannelsSwapped()

bool USS_isAlgorithmChannelsSwapped ( void  )

This function allows users to query current status Algorithm Capture buffers.

Returns
true Capture buffers are swapped false Capture buffers are NOT swapped

§ USS_updateAdditionalCaptureDelay()

USS_message_code USS_updateAdditionalCaptureDelay ( USS_SW_Library_configuration config,
float  additionalCaptureDelay 
)

This function allows users to update Additional Capture Delay with with minimal algorithm reconfiguration.

Parameters
[in]configis a pointer to the USS SW Library user configuration.
[in]additionalCaptureDelaynew additional capture delay
Returns
USS_message_code

§ USS_updateDtoFOffset()

USS_message_code USS_updateDtoFOffset ( USS_SW_Library_configuration config,
float  dTofOffset 
)

This function allows users to update Delta Time Of Flight Offset with with minimal algorithm reconfiguration.

Parameters
[in]configis a pointer to the USS SW Library user configuration.
[in]dTofOffsetnew dtof Offset
Returns
USS_message_code

§ USS_setAbsTOFStatus()

USS_message_code USS_setAbsTOFStatus ( USS_SW_Library_configuration config,
USS_absTOF_status_object status 
)

This function allows users to update the internal AbsTOF status. Including the state and index for the UPS / DNS channels.

Parameters
[in]configis a pointer to the USS SW Library user configuration.
[in]statusis a pointer to the USS absTOF status object
Returns
USS_message_code

§ USS_getAbsTOFStatus()

USS_message_code USS_getAbsTOFStatus ( USS_SW_Library_configuration config,
USS_absTOF_status_object status 
)

This function allows users to obtain the internal AbsTOF status. Including the state and index for the UPS / DNS channels.

Parameters
[in]configis a pointer to the USS SW Library user configuration.
[in]statusis a pointer to the USS absTOF status object
Returns
USS_message_code
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale