필터 지우기
필터 지우기

10-Bit ADC

조회 수: 5 (최근 30일)
Steve
Steve 2012년 1월 28일
I have searched for this but everything that I find pertains to images...
I am using a 10-bit ADC from a pic18F microcontroller and have to communicate data to MatLab via RS-232. Can this be done? What commands would need to be used?
Any help is appreciated. Thank you!

답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 29일
Although in theory RS232 can transfer 10 bit bytes, in practice it is seldom done. Instead the practice is to break anything more than 8 bits up in to 8 bit chunks, padding with bits of 0. As you are programing both ends (I guess), you could choose to transfer 10 bit bytes over RS-232, but other people wanting to interface to your design will not expect 10 bit bytes (and might not know how to program their own software to handle them.)
There are different practices about where the byte breaks are done, and about where the 0's go. When you are making your decision, I recommend you take in to account the ease of extending to greater precision -- if, for example, the 10-bit ADC was replaced with a 12-bit, it would be nice of nothing in the byte protocol changed.
Beyond the above, the commands you need to know are fopen(), fclose(), fread(), fwrite(), set(), and get(), and possibly fprintf() and fscanf(). Of these, chances are that the only one that will "surprise" you is fprintf(), in that one common form of it has a different behavior than when it is used for files. Though I suppose I should say that many people have been surprised by serial port timeouts when using fread() and fscanf(), which is more a matter of using proper set() parameters rather than a real difference in the commands.

카테고리

Help CenterFile Exchange에서 Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by