Subscribe to Test & Measurement World
RSS
Reprints/License
Print
Email
Average Rating:
  • (0)
    Rate this:
  • 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 2:00:00 AM

    pdf button


    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.

    Average Rating:
  • (0)
    Rate this:
  • RSS
    Reprints/License
    Print
    Email
    Similar Content from T&MW

    No related content found.

    • 0 rated items found.

    Datasheets.com Electronic Parts & Inventory Search

    185 million searchable parts
    • Part Number
    • Description
    • Inventory
    • Products
    • Manufacturers
    Canon Resource Center

    Featured Company


    Most Recent Resources

    Featured Job On
    Scroll for More Jobs
    Advertisement
    More Content
    • Blogs
    • Webcasts

    Sorry, no blogs are active for this topic.

    » VIEW ALL BLOGS RSS
    • All


    Advertisement
    Advertisement
    About Us   |   Advertising Info   |   Site Map   |   Contact Us   |   FREE Subscription
    © 2011 UBM Electronics . All rights reserved.
    Use of this Web site is subject to its Terms of Use | Privacy Policy

    Feedback Form
    Feedback Analytics