Simple signal processing in C #

I take a sample of the real world sensor and I need to display its filtered value. The signal is sampled at a speed of 10 Hz and during this period it can rise to 80% of the maximum range.

I used to use Root Mean Square as a filter and just applied it to the last five values ​​that I registered. For this application, this will not be good, because I do not store constant values. In other words, I need to consider the time in my filter ...

I read in the DSP Guide , but I did not get much from this. Is there a tutorial that is specifically reserved for programmers, not Mathcad engineers? Are there some simple code snippets that could help?

Update. After several tests of the spreadsheet, I decided to register all samples and applied the Butterworth filter .

+3
source share
4 answers

You always need to save some values ​​(but not necessarily all input values). The output current of the filter depends on the number of input values ​​and, possibly, some past output values.

The easiest filter is the first pass of the Butterworth lower pass filter. This would only require storing one output file value. The output signal (current) of the filter y (n) is equal to:

y (n) = x (n) - a1 * y (n-1)

x (n) - , y (n-1) - . a1 . 5 ( ), , , . , , !

( , #):

double a1 = 0.57; //0.57 is just an example value.
double lastY = 0.0;
while (true)
{
    double x = <get an input value>;

    double y = x - a1 * lastY;

    <Use y somehow>

    lastY = y;
}

(a ).

. ; y x.

+6

DSP "" (.. "" ) . (FFT). , ( " " ) " ", "", 0 (10 ). , , (10 ) 0-2 , 2-4 , 4-6 , 6-8 8-10 .

"" , , , . , , , , 6 ( , 6 ). 6-8 8-10 0, .

, "", , . , , , . - , , , , .

( , FFT, ), . , , . , , " ", .

+5

, , # Reactive LINQ - . (II.) - Reactive LINQ.

As a way to get events, so that you can do your processing without saving all the values, it will just do the processing when you get the next event.

To consider time, you can simply use a negative exponent to reduce the impact of past measurements.

+2
source

Yes, for complex real-time systems that sample multiple data streams, there may be a problem in data processing (computing and storing data) and data consistency.

-1
source

Source: https://habr.com/ru/post/1716393/


All Articles