简体   繁体   English

在C#.net中计算信号的频率

[英]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. 我正在用c#.NET开发示波器的应用程序,我借助zedgraph控件绘制了各种波形(正弦波,方波等)。 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. 我从示波器获取值并将其存储在大小为1024(字节数组)的缓冲区中,并且必须在运行时计算诸如时间段,频率,上升时间,下降时间等参数。 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..........]. 为此,我只需要提取整个信号的单个周期。另一个问题是值并不总是连续地上升或下降,平均值存储在缓冲区中是这样的[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. 如果您有数学能力,最简单的方法可能是计算FFT并采用最低频率。

Alternatively you can check the zero crossings(around the mean value). 或者,您可以检查零交叉点(均值附近)。 The faster it oscillates about 0 the higher its frequency. 它大约在0左右振荡,频率越高。 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 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. 您可以找出波峰与波谷之间的时间段,这将为您提供该特定波的一半波长。

替代文字

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. 对于图1,第一个波谷为2,第一个波峰为12。找出这些点之间的时间,则波长为一半。

For graph two, the same principle applies, you can calculate the wavelength (and thus the period) for each section of the graph 对于图二,应用相同的原理,您可以计算图的每个部分的波长(从而计算周期)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM