我如何使用c中的微控制器对模数转换进行编程
我正在做一个 DSP 项目,我想获取一个模拟文件,并使用连接到 DSP 板上 ADC 的微控制器将其转换为数字输出。我该如何用c语言编写这个程序?
至少我认为就这么简单。
这就是我需要的。
输入---------输出
Angolog -->数字
数字 -->模拟
Im doing a dsp project and i want to take an anolog file and convert it to a digital output using a microconroller attached to a ADC on a dsp board. How would i program this in c?
Pretty much its as simple as that, atleast i think.
This is what i need.
Input --------- Output
Angolog --> Digital
Digital --> Anolog
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你确实需要澄清你的问题。就像模拟文件是什么意思?从编程的角度来看,文件系统是二进制的,当然介质是磁性的或其他技术,并且涉及模拟。 ADC 从模拟变为数字,因此它是模拟输入而不是数字输出。
ADC 模数转换器,将模拟输入输入设备并将其转换为数字,以便您可以在芯片内部使用它们、编程、保存到文件等。DAC
数模转换器,获取数字值并将其转换为模拟输出。
在这两种情况下,您都需要查看芯片和电路板的具体细节。从编程的角度来看,如果没有其他事情,您需要研究 ADC 和/或 DAC 的详细信息。具有 ADC 的微控制器并不罕见,但您需要了解如何让微控制器上的 ADC 启动采样、如何知道采样何时完成以及采样后如何读取数字数据。 DAC 通常是外部的,有时是串行的,因此您可能必须对 spi 或 i2c 进行位操作,或者研究微控制器可能具有哪些硬件来进行 spi 或 i2c 通信,或者微控制器中是否有 DAC,如何使用它(哪些寄存器用于写等)。
如果您有一个特定的公开可用的微控制器板,例如评估板,那么这里或其他地方的人们可以更容易地向您展示在哪里寻找原理图、数据表等。否则,即使确切地知道哪个微控制器和使用什么 I/O 引脚,在提出这样的问题时会很有帮助。可能有很多可以借鉴的示例程序。它可以简单到现有库的几行 C 语言,也可以复杂到带有中断服务例程的多行 C 语言,可能还需要一些汇编程序。
You really need to clarify your question. Like what do you mean by analog file? File systems are binary from a programming perspective, sure the media is magnetic or other technologies and there is analog involved. An ADC goes from Analog to Digital, so it is an an analog input not a digital output.
ADC analog to digital converter, takes analog inputs to the device and converts them to digital so you can use them inside the chip, program, save to files, etc.
DAC digital to analog converter, takes digital values and converts them to analog outputs.
In both cases you need to look at the specific details for the chips and the board. From a programming perspective if nothing else you need to look into the details for the ADC and or DAC. Microcontrollers having an ADC is not uncommon, but you need to read up on how to get the ADC on that microcontroller to initiate a sample, how to know when the sample has completed and how to read the digital data once the sample has been taken. DACs are often external, sometimes serial, so you may have to bit bang spi or i2c or look into what hardware the microcontroller might have for speaking spi or i2c or if there is a dac in the microcontroller, how to use it (what registers to write, etc).
If you have a specific publicly available microcontroller board, for example an eval board, then that makes it much easier for folks here or elsewhere to show you where to look for the schematics, data sheets, etc. Otherwise, even knowing exactly which microcontroller and what I/O pins are used, would be helpful when asking such a question. There are probably lots of example programs out there that could be borrowed from. And it could be as simple as a few lines of C to an existing library, or as complicated as many lines of C with interrupt service routines, and possibly some assembler.
这很大程度上取决于您的硬件,并且问题中没有任何信息可以提供真正的答案。
一般来说,您应该查看系统的文档,尤其是 AD/DA 部分。应该有好的例子。如果存在特定问题,请发布更具体的问题。
This is extremely dependent on your hardware and there's no information in the question that would enable a real answer.
In general, you should see the documentation for your system, especially the AD/DA parts. There should be good examples. If there's a particular problem, post a more specific question.