开发者

calculating frequency for signal in c# .net

I am developing an application for an oscilloscope in c# .NET, I am drawing different kinds of waves (sine, square etc..) with the help of zedgraph control. I get values from oscilloscope and stored in a buffer of size 1024(byte array) and have to calculate parameters like time period, Frequency, rise time, 开发者_开发百科fall time etc at run time. for this purpose i have to extract only a single cycle of whole signal.one more problem is that values are not always rise or fall continuously mean values are stored in buffer like this[0,0,0,1,1,2,3,4,5,5,6,6,6,5,5,4,3,2,1,1,0,0,0..........]. signals are continuously receive from machine. it is not sure that waves are always oscillating around zero. Thanks Regards Nilesh


You can estimate the frequency a number a of ways. Probably the easiest, if you have a math lib, is to compute the FFT and take the lowest frequency.

Alternatively you can check the zero crossings(around the mean value). The faster it oscillates about 0 the higher its frequency. Similarly the extrema tell you a lot about the frequency(think of a sinusoid whose extrema and zeroes alternate and are evenly spaced).

There is also a transform called the period transform but I don't remember it too much. I saw it in a book about music for finding the tempo of a song.

http://www.cs.berkeley.edu/~vazirani/s09quantum/notes/lecture4.pdf

Another way might be to use the auto-correlation and when it is large it means the function is in "sync" with itself(assuming it doesn't change shape to fast). and it should be easy to calculate the distance between these the maximums.


You could find out the time period between a crest and a trough, which will give you half the wavelength for that particular wave.

calculating frequency for signal in c# .net

For graph 1, the first trough is 2, the first crest is 12. Find out the time taking between these points, and you have half the wavelength.

For graph two, the same principle applies, you can calculate the wavelength (and thus the period) for each section of the graph

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜