while (1) 
{  
    if (start_flag == 1) 
    { 
        // Count the number of data points present in signal buffer  
        for (i = sb_front; i != sb_rear; i = (i + 1) % SB_DATA_WINDOW) 
        {  
            count++;  
        }  

        if (count > 0) 
        { 
            // Get the first inserted data point (in FIFO order)  
            datapoint = sbuf_peek(); 

            // Calculates the neutral peak by passing the data point to the Peak Filter  
            neutral_datapoint = get_neutral_peaktopeak(datapoint); 

            // Uses the neutral point to subtract from the current data point 
            // Signal is rectified by taking absolute difference between the two points 
            // Moving Average filter is applied to the obtained peak values   

            result = get_moving_average(abs(datapoint - neutral_datapoint));  

            // Remove the first element (in FIFO order) since it has already been processed  
            sbuf_remove();  

            time_elapsed += 5.0;  

        }  
        count = 0;  
    }  
}