计算 c# .net 中信号的频率

发布于 2024-10-13 07:45:46 字数 295 浏览 8 评论 0原文

我正在 c# .NET 中开发示波器应用程序,我正在 zedgraph 控件的帮助下绘制不同类型的波(正弦波、方波等)。 我从示波器获取值并将其存储在大小为 1024(字节数组)的缓冲区中,并且必须在运行时计算时间段、频率、上升时间、下降时间等参数。 为此,我必须仅提取整个信号的单个周期。还有一个问题是值并不总是连续上升或下降平均值存储在缓冲区中,如下所示[0,0,0,1,1,2,3 ,4,5,5,6,6,6,5,5,4,3,2,1,1,0,0,0........................]。连续接收来自机器的信号。 不确定波总是在零附近振荡。 谢谢 问候 尼勒什

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只涨不跌 2024-10-20 07:45:46

您可以通过多种方式估计频率。如果您有数学库,最简单的方法可能是计算 FFT 并采用最低频率。

或者,您可以检查过零(围绕平均值)。它在 0 附近振荡越快,其频率就越高。类似地,极值告诉您很多有关频率的信息(想象一个极值和零值交替且均匀分布的正弦曲线)。

还有一种变换称为周期变换,但我不太记得了。我在一本关于音乐的书中看到了它,用于找到歌曲的节奏。

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

另一种方法可能是使用自相关,当它很大时,意味着该函数与自身“同步”(假设它不会快速改变形状)。并且应该很容易计算这些最大值之间的距离。

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.

长安忆 2024-10-20 07:45:46

您可以找出波峰和波谷之间的时间周期,这将为您提供该特定波的一半波长。

alt text

对于图 1,第一个波谷是 2,第一个波峰是 12。找出这些点之间花费的时间,你就有一半的波长。

对于图二,同样的原理适用,您可以计算图每个部分的波长(以及周期)

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

alt text

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文