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.

AWR1642: how to calculate vitalsign output frame rate from 50 msec to 20 msec

Part Number: AWR1642

I had increased the frame rate by changing the frame periodicity in the "frameCfg" command from 50 to 20(msec).

the IIR filter coefficients are based on this 20 frames per second rate

Accordingly I would like to calculate and update those coefficients.

I am not sure how to change the following values. Can you guide me how to calculate and change it accordingly?

FYI) when I just changed frameCfg 50 to 20 in command and run in EVM, frame numbers are skipped. 

cf)

/*! @brief Second-order IIR-Filter contains 6 coefficeints per stage */
#define IIR_FILTER_COEFS_SECOND_ORDER 6

/*! @brief Number of Delay Elements in Second-order IIR-Filter */
#define NUM_DELAY_ELEMENTS_IIR_FILTER 3

/*! @brief Size should at least equal to "Coefficeints per stage * Number of stages + 2" */
#define BREATHING_WFM_IIR_FILTER_TAPS_LENGTH (IIR_FILTER_COEFS_SECOND_ORDER * IIR_FILTER_BREATH_NUM_STAGES) + 2

/*! @brief Size should be equal to Coefficeints per stage * Number of stages + 2 */
#define HEART_WFM_IIR_FILTER_TAPS_LENGTH (IIR_FILTER_COEFS_SECOND_ORDER * IIR_FILTER_HEART_NUM_STAGES) + 2

Thanks in advance,

BR,

kisub

  • Kisub,

    You will need to update the IIR coefficients in this section of code found in the "dss_data_path.c" source file.

    //////////////  Parameters :  IIR-Cascade Bandpass Filter  //////////////////////////////////////
    
        // 0.1 Hz to 0.5 Hz Bandpass Filter coefficients
         float pFilterCoefsBreath[IIR_FILTER_BREATH_NUM_STAGES * IIR_FILTER_COEFS_SECOND_ORDER] = {
                                                1.0000, 0, -1.0000, 1.0000, -1.9632, 0.9644,
                                                1.0000, 0, -1.0000, 1.0000, -1.8501, 0.8681 };
         float pScaleValsBreath[IIR_FILTER_BREATH_NUM_STAGES + 1] = {0.0602, 0.0602, 1.0000};
         memcpy(obj->pFilterCoefsBreath, pFilterCoefsBreath, sizeof(pFilterCoefsBreath));
         memcpy(obj->pScaleValsBreath, pScaleValsBreath, sizeof(pScaleValsBreath));
    
        // Heart Beat Rate    0.8 - 4.0 Hz
        float pFilterCoefsHeart_4Hz[IIR_FILTER_HEART_NUM_STAGES * IIR_FILTER_COEFS_SECOND_ORDER] = {
                                                   1.0000, 0, -1.0000, 1.0000, -0.5306, 0.5888,
                                                   1.0000, 0, -1.0000, 1.0000, -1.8069, 0.8689,
                                                   1.0000, 0, -1.0000, 1.0000, -1.4991, 0.5887,
                                                   1.0000, 0, -1.0000, 1.0000, -0.6654, 0.2099 };
        float pScaleValsHeart_4Hz[IIR_FILTER_HEART_NUM_STAGES + 1] = {0.4188, 0.4188, 0.3611, 0.3611, 1.0000};
        memcpy(obj->pFilterCoefsHeart_4Hz, pFilterCoefsHeart_4Hz, sizeof(pFilterCoefsHeart_4Hz));
        memcpy(obj->pScaleValsHeart_4Hz, pScaleValsHeart_4Hz, sizeof(pScaleValsHeart_4Hz));

    Regards,
    Kyle

  • Can you show me an example how you can reach for 50Hz sample?

    H(z) = B(z)/A(z) = (b0+b1*z^-1+b2*z^-2)/(1+a1*z^-1+a2*z^-2)

    To make it easier, As I said earlier, Can you share formula that TI had used ?

    pFilterCoefsBreath[IIR_FILTER_BREATH_NUM_STAGES * IIR_FILTER_COEFS_SECOND_ORDER] = {
                                                1.0000, 0, -1.0000, 1.0000, -1.9632, 0.9644,
                                                1.0000, 0, -1.0000, 1.0000, -1.8501, 0.8681 };
    In the above, first 5 values are in the code b0,b1,b2,a0,a1, What are the rest of them?

    I used two calculators, one from TI and the other from websites.

    The followings are what I am doing with trial and errors ---------------------------------------------------------------------------------------------------------

    It sounds like 2nd order Z-transform bandwidth filter.

    It is not clear to me the following each value.


    Why did you use IIR filter instead of FIR filter even though phase variance is so important in vitalsign measurement?
    I understand that IIR is cheaper than FIR filter in terms of cost.

    It looks like biquad iir filter. So, I can use the following TI calculator accordingly.
    www.ti.com/.../COEFFICIENT-CALC
    In my case what can be right choice for 50Hz sample rate?
    There are Type but no bandwidth filter.
    What should be Sampling frequency(Fs), Fc, Gain, BW[Hz], Q, S, O ?

    or

    Based upon arachnoid.com/.../
    In my case, Filter type = Bandpass, Center Frequnecy = 0.3 (0.1~0.5), Sample Rate Hz= 20, 
    Q=0.707 ???
    Gain DB = 1 ???
    I am not sure which Q, Gain DB I need to set.

    Reference) 

    First of all the first twelve arrays.

    Usually for 2nd order 

    based upon filter_IIR_BiquadCascade function,

    b0 = pFilterCoefs[ indexTemp ];
    b1 = pFilterCoefs[ indexTemp + 1];
    b2 = pFilterCoefs[ indexTemp + 2];
    a1 = pFilterCoefs[ indexTemp + 4];
    a2 = pFilterCoefs[ indexTemp + 5];

    float pFilterCoefsBreath[IIR_FILTER_BREATH_NUM_STAGES * IIR_FILTER_COEFS_SECOND_ORDER] = {
                                                1.0000, 0, -1.0000, 1.0000, -1.9632, 0.9644,
                                                1.0000, 0, -1.0000, 1.0000, -1.8501, 0.8681 };
         float pScaleValsBreath[IIR_FILTER_BREATH_NUM_STAGES + 1] = {0.0602, 0.0602, 1.0000};

  • For the bandpass filter, to separate the breathing and heart-rate waveform we are using an “IIR Bi-quad cascade filter”.

    For determining the filter coefficients we are using the Matlab function fdesign.bandpass() that requires the DSP System Toolbox in Matlab. The Matlab code for this is

    h = fdesign.bandpass('n,f3db1,f3db2', dataObjParams.N_filterOrder_breath, ... 
    dataObjParams.freqLowCutoffBreathing_Hz, ...
    dataObjParams.freqHighCutoffBreathing_Hz, ...
    dataObjParams.samplingFreq);
    Hd = design(h, 'butter','SystemObject', true);
    IIR_Params.sosBreath = Hd.SOSMatrix;
    IIR_Params.scaleValuesBreath = Hd.ScaleValues;


    On the device the coefficients are defined in MmwDemo_dataPathConfigBuffers() in the file dss_data_path.c
    IIR_Params.sosBreath values obtained from Matlab go to pFilterCoefsBreath
    IIR_Params.scaleValuesBreath go to pScaleValsBreath

    float pFilterCoefsBreath[IIR_FILTER_BREATH_NUM_STAGES * IIR_FILTER_COEFS_SECOND_ORDER] = {
    1.0000, 0, -1.0000, 1.0000, -1.9632, 0.9644,
    1.0000, 0, -1.0000, 1.0000, -1.8501, 0.8681 };
    float pScaleValsBreath[IIR_FILTER_BREATH_NUM_STAGES + 1] = {0.0602, 0.0602, 1.0000};
    memcpy(obj->pFilterCoefsBreath, pFilterCoefsBreath, sizeof(pFilterCoefsBreath));
    memcpy(obj->pScaleValsBreath, pScaleValsBreath, sizeof(pScaleValsBreath));


    Apart from that these values would also need to be changed in MmwDemo_dataPathInitVitalSigns()

    // Vital-signs peak search frequencies may be different from the Band-pass filter cut-off frequencies
    obj->breath_startFreq_Hz = 0.1; // Breathing-Rate peak search Start-Frequency
    obj->breath_endFreq_Hz = 0.6; // Breathing-Rate peak search End-Frequency

    Regards,
    Kyle

  • from your matlab code, what I can know is

    1. low/high Cutoff method is used

    2. still my question is the number of coefficients. Why does it have 12 instead of having 10?

    For Single Biquad filter stage, y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a2 * y[n-2]

    We just need b0,b1,b2, a1,a2 and 2nd order's ones.

    Question 1) 6 stages X number of order(2) = 12 ----> WHY is no.stage 6 instead of 5?

    float pFilterCoefsBreath[IIR_FILTER_BREATH_NUM_STAGES * IIR_FILTER_COEFS_SECOND_ORDER] = {
    1.0000, 0, -1.0000, 1.0000, -1.9632, 0.9644,
    1.0000, 0, -1.0000, 1.0000, -1.8501, 0.8681 };
    There are twelve elements in array. My quess is {a00, a01, a02, b01, b02, b03 , a10, a11, a12, b11, b12, b13} . I assume that Demo uses Direct form I.

    Question 2) Do TI use direct form I type or II type?

    Qeustion3) What is Q value, Sample Rate Hz, and target gain(dB) in vital sign Demo? -10DB? -3DB? 

    Question4) What is central frequency in this bypass filter? For breathing , 0.1~ 0.5 Hz, so is it 0.3Hz?

    Thanks in advance,

    kisub 

  • This is a gentle reminder for your answer.

    Can you answer it? It has been 3 weeks till now.

    BR

    kisub Jung

  • HI sorry for the delay

    Q1 & 2) The structure of the Filter is Direct Form-II , Serially cascaded Biquad Filter. Block diagram is in the thread  https://e2e.ti.com/support/sensors/f/1023/t/857972

    Please use matlab tools to determine Q value

    Q3 & 4) The coefficients generated in the sample code are for a low cutoff Freq = 0.1 Hz, High cutoff Freq 0.5 Hz, sample rate 20 Hz.

    Thank you

    Cesar

  • There are missing answers so I am reminding you again.
    #1.
    •Qeustion3) What is Q value, Sample Rate Hz, and target gain(dB) in vital sign Demo? -10DB? -3DB? 
    From Question 3, What is target gain(dB) in vital sign Demo?
    #2.
    •Question4) What is central frequency in this bypass filter? For breathing , 0.1~ 0.5 Hz, so is it 0.3Hz?
    What is central frequency in this bypass filter? 
     
    #3.
    From Earlier question) We had tried to use TI calculator for Q value. It looks like biquad iir filter. 
    www.ti.com/.../COEFFICIENT-CALC
    In my case what can be right choice for 50Hz sample rate?
    There are Type but no bandwidth filter.
    What should be Sampling frequency(Fs), Fc, Gain, BW[Hz], Q, S, O ?
    Your earlier suggestion was to use matlab while TI has already provides calculator for IIR filter direct form II.
    What is the reason?
    Usually it is supposed to be found with tool from https://arachnoid.com/BiQuadDesigner/ And those parameters should be provided in my opinion.
    Can you provide it to me?
    Thanks for your answer in advance,
    BR 
    kisub Jung