用户工具

站点工具


knowledge:electronic:2019032101

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
knowledge:electronic:2019032101 [2023/07/07 04:22] – [Frequency analysis with FHT] obknowledge:electronic:2019032101 [2023/07/07 05:32] (当前版本) – [Summary] ob
行 225: 行 225:
  
 首先,该算法接受N个实数,并得到N/2个复数。然后我们可以将数据传递给另一个函数,计算复数的幅度,得到N/2个频率区间。最终,我们得到N/2个频率区间,每个区间覆盖sampling_rate/N Hz的频率范围。最后一个区间的最大值将为sampling_rate/2。这与信号处理理论,特别是混叠和奈奎斯特定律有关。在实践中,如果你想避免任何奇怪的效果,比如更高频率的“折叠”到较低频率上,你需要确保使用的采样率是期望声音信号中最高频率的两倍。否则,你的采样速度不够快。你也不应该过度采样,因为这会导致低ADC精度,并浪费在信号中不存在的FHT频率区间。我发现基于我的麦克风范围和典型人类听力范围,20KHz的值是一个不错的上限频率。因此,以38.4KHz(分频器=32)进行采样似乎是最佳选择。 首先,该算法接受N个实数,并得到N/2个复数。然后我们可以将数据传递给另一个函数,计算复数的幅度,得到N/2个频率区间。最终,我们得到N/2个频率区间,每个区间覆盖sampling_rate/N Hz的频率范围。最后一个区间的最大值将为sampling_rate/2。这与信号处理理论,特别是混叠和奈奎斯特定律有关。在实践中,如果你想避免任何奇怪的效果,比如更高频率的“折叠”到较低频率上,你需要确保使用的采样率是期望声音信号中最高频率的两倍。否则,你的采样速度不够快。你也不应该过度采样,因为这会导致低ADC精度,并浪费在信号中不存在的FHT频率区间。我发现基于我的麦克风范围和典型人类听力范围,20KHz的值是一个不错的上限频率。因此,以38.4KHz(分频器=32)进行采样似乎是最佳选择。
-So for N=256 and sampling_rate=38.4Khz we get 128 150hz bins with the first been holding the magnitude value of 0-150hz and the last bin holding the magnitude value of 19050-19200hz. We can now focus on specific bins that interest us, send the values of all the bins over serial connection, store the values, display them in some way, etc. 
 因此对于N=256和采样率为38.4KHz,我们得到128个150Hz的频率区间,其中第一个区间保存了0-150Hz的幅度值,最后一个区间保存了19050-19200Hz的幅度值。现在我们可以专注于我们感兴趣的特定频率区间,通过串行连接发送所有频率区间的值,存储这些值,以某种方式显示它们等等。 因此对于N=256和采样率为38.4KHz,我们得到128个150Hz的频率区间,其中第一个区间保存了0-150Hz的幅度值,最后一个区间保存了19050-19200Hz的幅度值。现在我们可以专注于我们感兴趣的特定频率区间,通过串行连接发送所有频率区间的值,存储这些值,以某种方式显示它们等等。
-One of the fun ways to use the data, especially when troubleshooting and developing is to visualize with an analyser. Load the following FHT example code to the Arduino or adapt it to your needs. It gets the samples, runs FHT on the data and sends it in binary form over serial. Your Arduino should be connected to a computer running Processing development environment. In Processing, load the “FHT 128 channel analyser” project. I had to make a change to the project to make it compatible with Processing 3.0 . To do so, move the call to “size” function from within the “setup” function to a new function called “settings”. 
 使用数据的有趣方法之一是使用分析器进行可视化,尤其是在故障排除和开发时。将以下 FHT 示例代码加载到 Arduino 或根据您的需要进行调整。它获取样本,对数据运行 FHT,并通过串行以二进制形式发送。您的 Arduino 应连接到运行 Processing 开发环境的计算机。在处理中,加载“FHT 128 通道分析器”项目。我必须对项目进行更改以使其与Processing 3.0 兼容。为此,将对“size”函数的调用从“setup”函数中移至名为“settings”的新函数。 使用数据的有趣方法之一是使用分析器进行可视化,尤其是在故障排除和开发时。将以下 FHT 示例代码加载到 Arduino 或根据您的需要进行调整。它获取样本,对数据运行 FHT,并通过串行以二进制形式发送。您的 Arduino 应连接到运行 Processing 开发环境的计算机。在处理中,加载“FHT 128 通道分析器”项目。我必须对项目进行更改以使其与Processing 3.0 兼容。为此,将对“size”函数的调用从“setup”函数中移至名为“settings”的新函数。
- 
  
 {{:knowledge:electronic:pasted:20190321-124951.png|Analyzer}} {{:knowledge:electronic:pasted:20190321-124951.png|Analyzer}}
  
-Another way to analyze the data is for the Arduino to send it over serial in textual form, let it run for some time, then copy it from the serial monitor and paste it in a spreadsheet. For example using a code that is similar to this: 
 分析数据的另一种方法是 Arduino 以文本形式通过串行发送数据,让它运行一段时间,然后从串行监视器复制数据并将其粘贴到电子表格中。例如,使用类似于以下的代码: 分析数据的另一种方法是 Arduino 以文本形式通过串行发送数据,让它运行一段时间,然后从串行监视器复制数据并将其粘贴到电子表格中。例如,使用类似于以下的代码:
 <code> <code>
行 268: 行 264:
 </code> </code>
  
-Then you can format the data in a spreadsheet, such as Excel, as a “3-D Surface” mesh graph. For example, see a graph of a Frequency Sweep from 1hz to 5000hz as captured and analyzed by the Arduino and FHT: +然后,您可以将电子表格(例如 Excel)中的数据格式化为“3-D 曲面”网格图。例如,查看 Arduino 和 FHT 捕获并分析从 1hz 到 5000hz 的频率扫描图:
-然后,您可以将电子表格(例如 Excel)中的数据格式化为“3-D 曲面”网格图。例如,查看 Arduino 和 FHT 捕获并分析从 1hz 到 5000hz 的频率扫描图:+
 {{:knowledge:electronic:pasted:20190321-125044.png|Mesh of FHT frequency sweep}} {{:knowledge:electronic:pasted:20190321-125044.png|Mesh of FHT frequency sweep}}
  
-===== Summary =====+===== 概括 =====
  
-My code for this project can be found at github for you to experiment with.+我的这个项目的代码可以在 github 上找到,供你尝试。
  
-The Arduino can be used for relative sound level measurement and for frequency analysis/visualization. One just needs a microphone to match the use case, an Arduino, some coding and optionally the FHT library. Have fun and let me know in the comments if you make something nice using such a setup.+Arduino 可用于相对声级测量和频率分析/可视化。只需要一个与用例匹配的麦克风、一个 Arduino、一些编码以及可选的 FHT 库。祝你玩得开心,如果你使用这样的设置做了一些不错的事情,请在评论中告诉我。
  
 https://blog.yavilevich.com/2016/08/arduino-sound-level-meter-and-spectrum-analyzer/ https://blog.yavilevich.com/2016/08/arduino-sound-level-meter-and-spectrum-analyzer/
  
  
knowledge/electronic/2019032101.1688703768.txt · 最后更改: 2023/07/07 04:22 由 ob