Global TMW:
Login  |  Register          Free Newsletter Subscription
Subscribe
Email
Print
Reprint
Learn RSS

Test Ideas: Serial port controls ADC

Using a PC's serial port, C# code, and an ADC, you can digitize an analog signal.

By Yury Magda, Consultant, Cherkassy, Ukraine -- Test & Measurement World, 10/1/2008

Have a test idea you'd like to share? Publish it here and receive $150. Send us your ideas.

Read other Test Ideas.
Read Design Ideas published by EDN.

Engineers often need simple measurement circuits that connect to a PC. When you don't have the resources to buy a digitizer for low-speed signals, you can build one yourself with just two ICs connected to a PC's serial port. The throughput rate of the digitizer depends mainly on the performance of the PC's operating system, processor speed, and memory. I was able to achieve 250 samples/s with a 2.4-GHz Pentium-based PC with 512 Mbytes RAM running Windows XP. Faster processors will produce higher sample rates. You can calculate your throughput rate by counting the number of conversions for 1 s.

The circuit in Figure 1 shows that you can use an MCP3201 12-bit successive-approximation ADC (analog-to-digital converter) with a MAX232 RS-232 interface IC. Using an application written in C#, you can get data into a PC that runs Windows XP or Vista. (Click to download the source code.)



Figure 1. A MAX232 IC interfaces an MCP3201 ADC to a PC’s serial port.

The MCP3201 uses RTS (ready-to-send), CTS (clear-to-send), and DTR (data-terminal ready) serial-port lines to communicate with a PC. Its standard SPI (serial peripheral interface) port communicates to the MAX232. The analog signal connects to the MCP3201's IN+ pin, and the MAX232 converts RS-232 signal levels to TTL-compatible levels.

The digital output stream from the DOUT pin goes through the MAX232 to the serial point on the IC's CTS line. The RTS line provides clock pulses to the ADC's CLK (clock) pin. Each separate bit appears at the DOUT pin on the falling edge of the CLK signal. Thus, a software application must latch the bit on the rising edge of the clock pulse. Finally, the DTR line produces the CS (chip select) signal that frames the conversion process. The CS bit must be low while the conversion is in progress. Figure 2 shows a timing diagram of the process.



Figure 2. Software latches 15 bits, discarding the first three after reading the data.

In Figure 2, the valid data bits (most-significant bit first) appear on the DOUT line after the third CLK pulse goes low. Thus, you must use software to discard the first three bits after reading the data.

The software application is written in free MicrosoftVisual C# 2008 Express Edition. The built-in SerialPort component in C# provides full control over the port. The software is implemented as a simple console application. You don't need a device driver to use a serial port with this code.

You can easily repeat or modify the source code to fit your application. For example, you can send the data from the ADC to another location over the Internet or pass data to Excel or another application for analysis.

You can also improve on the hardware design in Figure 1. For example, placing a low-pass filter in front of the ADC will reduce noise and thus reduce errors caused by aliasing. Always use a bypass capacitor on the MAX232's VCC pin. Place the 1-μF capacitor (recommended value) as close as possible to the device pin.

You can replace the MCP3201 with a similar successive-approximation ADC that also has an SPI-compatible interface. For instance, you may use a Linear Technology LTC1286 or LTC1297. If you plan to use a different ADC, you will need to make some hardware modifications, so check the manufacturer's data sheet for details. Instead of a MAX232 line driver, you can use similar parts such as MAX225 or MAX233. These parts don't require any external components, thus simplifying the design.

If you use other hardware, you may need to modify the application source code, too. As an example, you may need to change the for (int i = 0; i < 15; i++) loop statement in the source code according to the timing diagram of the part you select.

Email
Print
Reprint
Learn RSS

Talkback

We would love your feedback!

Post a comment

» VIEW ALL TALKBACK THREADS

Related Content

Related Content

 

By This Author

There are no other articles written by this author.

Sponsored Links


TMW Resource Center


 
Advertisement
SPONSORED LINKS

More Content

  • Blogs
  • Podcasts

Blogs

  • Martin Rowe
    Rowe's and Columns

    November 5, 2008
    Technical articles retain value
    I'm always amazed, and pleased, when I hear from readers who still find value in old T&MW articl...
    More
  • Martin Rowe
    Rowe's and Columns

    October 31, 2008
    Measurement proverbs
    The other day, I received some measurement proverbs that I'd like to share. The proverbs come from K...
    More
  • » VIEW ALL BLOGS RSS

Podcasts

Advertisements





NEWSLETTERS
Click on a title below to learn more.

Test Industry News (3 Times Per Month)
Machine-Vision & Inspection (Monthly)
Communications Test (Monthly)
Design, Test & Yield (Monthly)
Automotive, Aerospace & Defense (Monthly)
Instrumentation (Monthly)
Resource Center E-Alert (Monthly)
©2008 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy
Please visit these other Reed Business sites