This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EVM430-FR6047: uss

Part Number: EVM430-FR6047


hi there.

in the project MSP430FR6043EVM_USS_Water_Demo, point me to which variable/variables is/are read to obtain the ADC capture. both here, and continuous capture.

thanks,

  • Hi,

    I do not get your point. Do you mean obtain the ADC capture by saving the ADC capture data into a .csv file? Then you can click the "Save capture" button. 

    Best regards,

    Cash Hao

  •  Hi Cash,

    I need help finding the location in the project software where the ADC capture and Continuous capture are sent to the GUI of the USS.

    thanks,

  • Hi,

    You should find in the function HMI_PostMeasurement_Update(). There is one function called CommandHandler_transmitCaptures() which sends the ADC capture data to the GUI.

    Best regards,

    Cash Hao

  • hi Cash, and thanks for the information.

    kindly point me to the C code/functions which read/upate, the following USS parameters in the GUI

    thanks.

  • Hi,

    It is in HMI_updateUSSParameters() function.

    Best regards,

    Cash Hao

  • hi Cash,

    in order to calibrate the ADC signal to my preference using the information you gave me above, do i need to do the calibration after calling these functions:

    code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
    code = USS_runAlgorithms(&gUssSWConfig,&algResults);

    or can i do my calibration before calling these functions.

    thanks,

  • HI,

    For my understanding, what you are trying to do is Start low power ultrasonic capture -> calibrate ADC signal -> run algorithms to get the results based on the calibrated ADC signal.

    Best regards,

    Cash Hao

  • hi Cash,

    here is the code of what i want to accomplish.

    int main(void)
    {
    #if (APPLICATION_ENABLE_CHANNEL_SWAP == true)
        uint16_t appSwapInterval = APPLICATION_CHANNEL_SWAP_INTERVAL;
    #endif
    
    #if (APPLICATION_ENABLE_ABSTOF_DTOF_OFFSET_CALIBRATION == true)
        USS_dTof_absTof_offset_results abstoFDtofTestResults;
        USS_dTof_absTof_offset_test_config abstoFDtofTestConfig =
        {
             .numOfTestIterations        = APPLICATION_ABSTOF_DTOF_OFFSET_UPDATE_INTERVAL,
             .isUseLPMCapture            = APPLICATION_ABSTOF_DTOF_OFFSET_LPM_CAPTURE,
             .isCalculateUpsAbsTofOffset = APPLICATION_ABSTOF_DTOF_OFFSET_CALC_UPS_ABSTOF,
             .isCalculateDnsAbsTofOffset = APPLICATION_ABSTOF_DTOF_OFFSET_CALC_DNS_ABSTOF,
             .isCalculateDToFOffset      = APPLICATION_ABSTOF_DTOF_OFFSET_CALC_DTOF,
        };
    #endif
    
        volatile USS_message_code code;
        USS_Algorithms_Results algResults;
        USS_calibration_hspll_results testResults;
        int i;
    
    
    
        // Register PLL unlock event
        USS_registerHSPLLInterruptCallback(USS_HSPLL_Interrupt_PLLUNLOCK,
                                           &handlePllUnlockEvent);
    
        code = USS_configureUltrasonicMeasurement(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);
    
    #if((USS_ALG_ABS_TOF_COMPUTATION_MODE == USS_ALG_ABS_TOF_COMPUTATION_MODE_LOBE_WIDE) || \
        (USS_ALG_ABS_TOF_COMPUTATION_MODE == USS_ALG_ABS_TOF_COMPUTATION_MODE_HILBERT_WIDE))
        // Reference binary pattern are only needed by
        // USS_Alg_AbsToF_Calculation_Option_lobeWide and
        // USS_Alg_AbsToF_Calculation_Option_hilbertWide AbsToF computation options
        if((USS_Alg_AbsToF_Calculation_Option_lobeWide ==
                gUssSWConfig.algorithmsConfig->absToFOption)
           || (USS_Alg_AbsToF_Calculation_Option_hilbertWide ==
                   gUssSWConfig.algorithmsConfig->absToFOption))
        {
    #if defined(__MSP430_HAS_SAPH_A__)
            if(USS_measurement_pulse_generation_mode_multi_tone ==
                    gUssSWConfig.measurementConfig->pulseConfig->pulseGenMode)
            {
                code = USS_generateMultiToneBinaryPattern(&gUssSWConfig);
                checkCode(code, USS_message_code_no_error);
            }
    #endif
            if(USS_measurement_pulse_generation_mode_multi_tone !=
                    gUssSWConfig.measurementConfig->pulseConfig->pulseGenMode)
            {
                code = USS_generateMonoDualToneBinaryPattern(&gUssSWConfig);
                checkCode(code, USS_message_code_no_error);
            }
        }
    
    #if (APPLICATION_ENABLE_BINARY_PATTERN_SIZE_SCALING == true)
        gUssSWConfig.algorithmsConfig->binaryPatternLength =
                (gUssSWConfig.captureConfig->sampleSize / APPLICATION_BINARY_PATTERN_SCALE_FACTOR);
    #endif
    
    #endif
    
    
        // Application must ensure no application level interrupts occur while
        // verifying HSPLL Frequency
        disableApplicationInterrupts();
    
        code = USS_verifyHSPLLFrequency(&gUssSWConfig, &testResults);
        checkCode(code, USS_message_code_no_error);
    
        // Application can re-enable interrupts after HSPLL verification
        enableApplicationInterrupts();
    
        gUssSWConfig.algorithmsConfig->clockRelativeError = _IQ27div((int32_t)(testResults.actualTestCount -
                testResults.expectedResult),testResults.expectedResult);
    
        code = USS_initAlgorithms(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);
    
    #if (APPLICATION_ENABLE_SIGNAL_GAIN_CALIBRATION == true)
        code = USS_calibrateSignalGain(&gUssSWConfig);
        checkCode(code, USS_message_code_Signal_Gain_Calibration_successful);
    #endif
    
    #if (APPLICATION_ENABLE_ABSTOF_DTOF_OFFSET_CALIBRATION == true)
        code = USS_calculateOffsets(&gUssSWConfig, &abstoFDtofTestResults,
                                    &abstoFDtofTestConfig);
        checkCode(code, USS_message_code_no_error);
    
        code = USS_updateAdditionalCaptureDelay(&gUssSWConfig,
              ((abstoFDtofTestResults.upsAbsToFOffset + abstoFDtofTestResults.dnsAbsToFOffset) /2.0f) -
              APPLICATION_ABSTOF_REFERENCE);
        checkCode(code, USS_message_code_no_error);
    
        code = USS_updateDtoFOffset(&gUssSWConfig, (-1.0f *abstoFDtofTestResults.dToFOffset));
        checkCode(code, USS_message_code_no_error);
    
    #endif
    
        while(!calibrateUSSParameters()) ; //do until system is calibrated
    
        // Set the background timer period to 1 second
        USS_configAppTimerPeriod(&gUssSWConfig, gUssSWConfig.systemConfig->measurementPeriod);
    
    
        while(1)
        {
            code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
            checkCode(code, USS_message_code_no_error);
    
            code = USS_runAlgorithms(&gUssSWConfig,&algResults);
            checkCode(code, USS_message_code_valid_results);
    
    #if (APPLICATION_ENABLE_CHANNEL_SWAP == true)
            if(appSwapInterval == 0)
            {
                code = USS_swapCaptureChannels(&gUssSWConfig);
                code = USS_swapAlgorithmsCaptureBuffers(&gUssSWConfig);
    
                appSwapInterval = APPLICATION_CHANNEL_SWAP_INTERVAL;
            }else{
                appSwapInterval--;
            }
    #endif
    
            prepareTransmission(algResults.volumeFlowRate);
    
            #if APPLICATION_ENABLE_UART_DEBUG
                for(i=0;i<messageLength;i++){
                    uartTxHexByte(messageBuffer[i]);
                    uartTxByte(' ');
                }
                uartTxByte('\n');
                uartTxByte('\r');
                uartTxUSSResult(APPLICATION_UART_ABSTOF_UPS_DELIM,&algResults.totalTOF_UPS);
                uartTxUSSResult(APPLICATION_UART_ABSTOF_DNS_DELIM,&algResults.totalTOF_DNS);
                uartTxUSSResult(APPLICATION_UART_DTOF_DELIM,&algResults.deltaTOF);
                uartTxUSSResult(APPLICATION_UART_VFR_DELIM,&algResults.volumeFlowRate);
                uartTxByte('\n');
                uartTxByte('\r');
            #endif
            // Wait for timer to elapse
            USS_waitForAppTimerElapse(&gUssSWConfig,USS_low_power_mode_option_low_power_mode_3);
        }
    }
    

    note line 103, here is where i want to set the USS parameters. 

    note here is calibrate routine

    static uint8_t calibrateUSSParameters(void){ //USS_SW_Library_configuration *config
        uint16_t updnsCaptureSize = gUssSWConfig.captureConfig->sampleSize;
        uint8_t* pUPSCap = (uint8_t*)(USS_getUPSPtr(&gUssSWConfig));
        uint8_t* pDNSCap = (uint8_t*)(USS_getDNSPtr(&gUssSWConfig));
        volatile USS_message_code code;
    
        // Perform a low power measurement, going to LPM3 in between UPS and DNS
        code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);
        
      //  read pUPSCap and pDNSCap to determin best USS parameters  
        
      // set USS parameters based on Algorithm 
        
      //  update the USS
    
        return 0;
    
    }
    
    

    your comments are very much appreciated. 

    thank you so much for your help

    Ephraim

  • hi Cash, 

    i just recieved a message from you through the system, however it is exactly the same as your last message, i am confused.

    in my last message, i want a confirmation that the location where i am inserting my code (line 103, note original TI code). is correct.

    Here is code that captures the upstream and downstream data, and for now just prints. Am i doing the capture correctly?

    static uint8_t calibrateUSSParameters(void){ //USS_SW_Library_configuration *config
        uint16_t updnsCaptureSize = gUssSWConfig.captureConfig->sampleSize;
        uint8_t* pUPSCap = (uint8_t*)(USS_getUPSPtr(&gUssSWConfig));
        uint8_t* pDNSCap = (uint8_t*)(USS_getDNSPtr(&gUssSWConfig));
        volatile USS_message_code code;
    
    
        // Perform a low power measurement, going to LPM3 in between UPS and DNS
        code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);
    
      //  determine the best USS parameters based on the up/down stream for best USS parameters
        printBytes(pUPSCap, updnsCaptureSize);
        printBytes(pDNSCap, updnsCaptureSize);
    
      // set USS parameters based on Aquasmart Algorithm
        gUssSWConfig.captureConfig->gainRange = (USS_Capture_Gain_Range )50; //USS_GAIN_RANGE;
        gUssSWConfig.measurementConfig->startADCsamplingCount = 350; //(uint16_t)USS_ADC_SAMP_COUNT;
        gUssSWConfig.measurementConfig->startPPGCount = 125;  //USS_START_CAPTURE_SEC;
        gUssSWConfig.measurementConfig->turnOnADCCount = 250; //(uint_least16_t) USS_TURN_ON_ADC_COUNT;
        gUssSWConfig.algorithmsConfig->negSearchRange = 100; //USS_ALG_ABS_TOF_NEG_SEARCH_RANGE;
        gUssSWConfig.algorithmsConfig->ratioOfTrackLobeToPeak = 10.72; //USS_ALG_RATIO_OF_TRACK_LOBE
    
      //  update the USS
    
        return 0;
    
    }
    

  • Hi,

    Never mind, I thought you have resolved your issue in the last post. 

    So, I saw you try to update the gain range, startADCamplingCount, startPPGCount and trunOnADCCount after capture the signal. What are you trying to do here? These parameters will not have an impact on running the algorithm. 

    For the parameter negSearchRange and ratioOfTrackLobeToPeak these two parameter do affect running the algorithm. But why do you need to change it here?

    Are you working on a multi channel water meter project? 

    Best regards,

    Cash Hao

  • hi Cash,

    The focus of my assignment is to allow during runtime before using the algResults.volumeFlowRate value, to tune the calibration with the parameter /advanced parameters as in the USS GUI and update the USSLib.

    Regarding the actual parameters and values, i leave for later, note- that i am not knowledgeable in the meaning and use of these parameters, these will be delt with later.

    to summarize my immediate requests, using the given template project: FR6043_USSSWLib_template

    1. where in the main is best suited to call the function calibrateUSSParameters(). now i am calling it from the main before the while(1) loop. Is this ok?

    2. in the calibrateUSSParameters() i capture a ADC signal as follows: 
    code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
    checkCode(code, USS_message_code_no_error);

    will this capture the signal and store the UP/DOWN signal and size in these variables? 

    uint16_t updnsCaptureSize = gUssSWConfig.captureConfig->sampleSize;
    uint8_t* pUPSCap = (uint8_t*)(USS_getUPSPtr(&gUssSWConfig));
    uint8_t* pDNSCap = (uint8_t*)(USS_getDNSPtr(&gUssSWConfig));

    now i will call a series of functions where each function calibrates a parameter. i am assuming that the global structure gUssSWConfig can be used inside these functions to change the default values. so, i do not need to pass the structure in into the function.

    finally, i will update USSLib using the same functions as found in the HMI_updateUSSParameters()

    here is the code of the function:

    static uint8_t calibrateUSSParameters(void){ //USS_SW_Library_configuration *config
        uint16_t updnsCaptureSize = gUssSWConfig.captureConfig->sampleSize;
        uint8_t* pUPSCap = (uint8_t*)(USS_getUPSPtr(&gUssSWConfig));
        uint8_t* pDNSCap = (uint8_t*)(USS_getDNSPtr(&gUssSWConfig));
        volatile USS_message_code code;
    
    
        // Perform a low power measurement, going to LPM3 in between UPS and DNS
        code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);
    
        calibrateGainRang(pUPSCap,pDNSCap,updnsCaptureSize);                   //(USS_Capture_Gain_Range )50; //USS_GAIN_RANGE;
        calibrateStartADCsamplingCount(pUPSCap,pDNSCap,updnsCaptureSize);      //(uint16_t)USS_ADC_SAMP_COUNT;
        calibrateStartPPGCount(pUPSCap,pDNSCap,updnsCaptureSize);              //USS_START_CAPTURE_SEC;
        calibrateTurnOnADCCount(pUPSCap,pDNSCap,updnsCaptureSize);             //(uint_least16_t) USS_TURN_ON_ADC_COUNT;
        calibrateNegSearchRang(pUPSCap,pDNSCap,updnsCaptureSize);              //USS_ALG_ABS_TOF_NEG_SEARCH_RANGE;
        calibrateRatioOfTrackLobeToPeak(pUPSCap,pDNSCap,updnsCaptureSize);     //USS_ALG_RATIO_OF_TRACK_LOBE
    
      //  update the USSLib
        _update_USSmeterConfig();
        _update_USSpllConfiguration();
        _update_USSmeasurementConfig();
        _update_USScaptureConfig();
        _update_USSalgorithmsConfig();
        _update_USSsleepDuration();
    
        return 0;
    
    }
     

     thank you so much for your support

    Ephraim

  • hi Cash,

    this is a continuation of the last email. hope for no confusion.

    looking at the code of the update functions you directed me too.:

    update_USSmeterConfig();
    _update_USSpllConfiguration();
    _update_USSmeasurementConfig();
    _update_USScaptureConfig();
    _update_USSalgorithmsConfig();
    _update_USSsleepDuration();

    it appears they mostly update USS GUI. this is not what i want to do. 

    i want to update the USSLib with new parameters and restart the algorithm.

    i see the global structure gUssSWConfig gives me access to all the parameters i want to modify.

    after modification is there a routine the restarts the algorithm or should i just wait for the software to enter the endless loop, and there the algorithm will start with the new values. 

        while(1)
        {
            code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
            checkCode(code, USS_message_code_no_error);
    
            code = USS_runAlgorithms(&gUssSWConfig,&algResults);
            checkCode(code, USS_message_code_valid_results);

    please confirm.

    thank you so much for your assistance.

    Ephraim

  • Hi,

    I kind of understanding what you are trying to do here. 

    You want to change the parameters/advanced parameters during runtime in the software. Is it correct?

    To achieve that, you can change the parameters in gUssSWConfig first and then call USS_initAlgorithms() function. This function will update your parameters. You can update your parameters and call this function after the SW has finished one measurement which is after the runAlgorithms function and before the next ADC captures. 

    Best regards,

    Cash Hao

  • hi Cash,

    yes, this is exactly my task.

    kindly confirm my logic,

    i call my routine calibrateUSSLibParameters() before the endless loop

        // Set the background timer period to 1 second
        USS_configAppTimerPeriod(&gUssSWConfig, gUssSWConfig.systemConfig->measurementPeriod);
    
        calibrateUSSLibParameters();
        
        while(1)
        {
            code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
            checkCode(code, USS_message_code_no_error);
    
            code = USS_runAlgorithms(&gUssSWConfig,&algResults);
            checkCode(code, USS_message_code_valid_results);
    

    in my function calibrateUSSLibParameters() 

    static void calibrateUSSLibParameters(void){ //USS_SW_Library_configuration *config
        uint16_t updnsCaptureSize = gUssSWConfig.captureConfig->sampleSize;
        uint8_t* pUPSCap = (uint8_t*)(USS_getUPSPtr(&gUssSWConfig));
        uint8_t* pDNSCap = (uint8_t*)(USS_getDNSPtr(&gUssSWConfig));
        volatile USS_message_code code;
    
        
        // Perform a low power measurement, going to LPM3 in between UPS and DNS
        code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);
    
        code = USS_runAlgorithms(&gUssSWConfig,&algResults);
        checkCode(code, USS_message_code_valid_results);
    
        
        //show data before update
        printBytes(pUPSCap, updnsCaptureSize);
        printBytes(pDNSCap, updnsCaptureSize);
    
        calibrateGainRang(pUPSCap,pDNSCap,updnsCaptureSize);                   //(USS_Capture_Gain_Range )50; //USS_GAIN_RANGE;
        calibrateStartADCsamplingCount(pUPSCap,pDNSCap,updnsCaptureSize);      //(uint16_t)USS_ADC_SAMP_COUNT;
        calibrateStartPPGCount(pUPSCap,pDNSCap,updnsCaptureSize);              //USS_START_CAPTURE_SEC;
        calibrateTurnOnADCCount(pUPSCap,pDNSCap,updnsCaptureSize);             //(uint_least16_t) USS_TURN_ON_ADC_COUNT;
        calibrateNegSearchRang(pUPSCap,pDNSCap,updnsCaptureSize);              //USS_ALG_ABS_TOF_NEG_SEARCH_RANGE;
        calibrateRatioOfTrackLobeToPeak(pUPSCap,pDNSCap,updnsCaptureSize);     //USS_ALG_RATIO_OF_TRACK_LOBE
    
        //show data after update
        printBytes(pUPSCap, updnsCaptureSize);
        printBytes(pDNSCap, updnsCaptureSize);
        
        //update the USS Lib with new parameters
        code = USS_initAlgorithms(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);
    }
    

    here i call the two routines to get one measurement.

      // Perform a low power measurement, going to LPM3 in between UPS and DNS
        code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);
    
        code = USS_runAlgorithms(&gUssSWConfig,&algResults);
        checkCode(code, USS_message_code_valid_results);

    and after setting my values in gUssSWConfig. i call the init function.

       //update the USS Lib with new parameters
        code = USS_initAlgorithms(&gUssSWConfig);
        checkCode(code, USS_message_code_no_error);

    thank you so much for your guidence.

    Ephraim

  • Hi,

    That looks good to me. 

    If you want to change the parameters in during the runtime. You might put calibrateUSSLibParameters() in the while loop. Like below one.

    while(1)

    {

    calibrateUSSLibParameters() ;

    code = USS_startLowPowerUltrasonicCapture(&gUssSWConfig);
    checkCode(code, USS_message_code_no_error);

    code = USS_runAlgorithms(&gUssSWConfig,&algResults);
    checkCode(code, USS_message_code_valid_results);

    }

    Best regards,

    Cash Hao

  • hi Cash,

    thank you so much for your assistance.

    you may close this case.

    Ephraim

**Attention** This is a public forum