Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?

[Ideas For Design]
DOWNLOAD THE CODE:
1777.zip


Use The PC's Parallel Port For Fast Data Acquisition And Control



Eli Flaxer  |   ED Online ID #1777  |   December 9, 2002

Article Rating:

Many designers require that their PCs act as complete control systems without any internal hardware. For this function, users need at least one channel of analog data acquisition to monitor the controlled signal. They also require one digital output channel to handle the external element's on/off function.

For precise control, users must replace the on/off control with proportional, integral, derivative (PID) control, which means replacing the Digital Out signal with Analog Out or pulse-width modulation (PWM). Some applications will need more than one channel.

When implemented, the control circuit includes eight channels of 12-bit analog-to-digital (a-d) conversion, two bits of Digital Out (DO), two bits of PWM, and two bits of Digital In (DI). They're all connected to the PC through the parallel port in Enhance Parallel Port (EPP) mode (see the figure). In EPP mode, the port is an 8-bit bidirectional bus with four control bits. A complete I/O cycle takes around 1 µs, so the maximum transfer rate is about 1 Mbyte/s. Because the a-d conversion takes several I/O cycles, the analog transfer rate is about 100 kHz. Moreover, the switching between input and output mode is very fast—1 µs—so the system has quick response times.

Modern digital designs are increasingly based on CPLDs. Flexible and inexpensive, the CPLDs replace many "old-fashioned" logic parts with a single high-density device. Designs can be very compact, small in size, and ultra fast. There are several methods to design, synthesize, and simulate the contents of the CPLD: hardware description languages such as Verilog, VHDL, and schematic editors. WARP 6.0 VHDL from Cypress Semiconductor was used to synthesize and simulate the CPLD in the figure.

The most significant device in this circuit is U1, the Cypress Semiconductor CY37064P44 CPLD with 64 macro cells and 44 pins. It implements all of the circuit's logic in a chip set. Because the parallel port doesn't include an address bus, the system must read or write any data with two cycles: first writing the address, then reading or writing the relevant data. Using this architecture, each register in the chip set has its own address:

0-ADCL: Read low byte of ADC.
1-ADCH: Read high byte of ADC.
2-ADCS: Write start conversion/Read end of conversion.
3-Digital: Write 2 DO bits/Read 2 DI bits.
4-PWM: Write 8 bits duty cycle for PWM.
5-PWMen: Write 2 bits to Enable/Disable PWM output.

The circuit's second device, U2, is Maxim's MAX1973 multirange, 12-bit data-acquisition system. It requires only a single +5-V supply. The circuit provides eight analog input channels that are independently software programmable for a variety of ranges: ±10 V, ±5 V, 0 to +10 V, or 0 to +5 V. This setup gives users the flexibility to interface with industrial sensors (4-20 mA, ±12 V, and ±15 V). In addition, the converter has an overvoltage protection of up to ±16.5 V and can work at a rate of 100 ksamples/s.

U2 is configured to use an internal clock and an internal reference by connecting C8, C9, and C10 to the analog ground. Conversions are initiated with a writing of a control byte to ADCS. The format of a control byte is: "0-1-0-R-B-A2-A1-A0," where R is a range (0 = 5 V, 1 = 10 V), B is a polarity (0 = unipolar, 1 = bipolar), and A2-A1-A0 is the channel index in binary code.

For example, to operate channel 3 with a range of 10 V, the user must write "01011011" to ADCS. As noted before, the user needs only to send a byte to the parallel port. All other signals (DB, CS, WR, RD, and so on) are controlled by the CPLD. After the conversion is complete, U2 is signaled by the INT pin, which can be read through bit 0 of ADCS. Then, the user can read the low byte (ADCL) and the high byte (ADCH) of the result.

To write or read the digital bits, the user must write or read the relevant data to or from the two LSBs of digital (address 3). To set the duty cycle of the PWM output between 0° and 360°, users should write an 8-bit binary number to the PWM register (address 4). Enabling or disabling the PWM output is accomplished by setting or clearing the two LSBs of the PWMen register (address 5).

U3 is 10-MHz clock. The five components—C1, C2, C3, L1, and L2—are filters for the power pins of the analog part. R1 and C6 are power-on reset. All LEDS are low current (2 mA). U4 is a low-drop +5-V regulator.

From the programmer's point of view, there's a need for three low-level functions: writeAddress, writeData, and readData. Those functions can be written in assembly, C, or any other high-level language (see Listing 1).

Designers may program the CPLD with any industrial parallel CPLD programmer, but the best method is to use the in-system reprogramming (ISR) feature. J1 is a JTAG port designed for this purpose. Users simply connect the UltraISR or C3ISR programming cable between J1 and the PC, load the JEDEC file, and program the device (see Listing 2). Readers can use the JEDEC file to program the CPLD or synthesize the VHDL source file. Moreover, readers can modify the VHDL source file for their own applications (see Listing 3).

To download the listings, click Download the Code at the top of the page.




Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


  • C Tools Accelerate HDV Development On Xilinx FPGAs
  • A New Design Inflection Point
  • Forecasting Industry Growth For 2009 And Beyond
  • EDA Retools To Exploit Multicore Architectures
  • Design And Verification Move Up In Abstraction
  • EDA Retools To Exploit Multicore Architectures
  • A New Design Inflection Point
  • Design And Verification Move Up In Abstraction
    1) Transportation Guidelines For Lithium Batteries Get Updated
    (1232 views today)
    2) Build A Smart Battery Charger Using A Single-Transistor Circuit
    (282 views today)
    3) WHITE PAPER: Liquid-Level Monitoring Using a Pressure Sensor
    (206 views today)
    4) 1-A Switching Regulators Operate With 96% Efficiency To Replace Linear Regulators
    (137 views today)
    5) The Field Of Energy Harvesting Begins To Ripen
    (107 views today)
    ALL TOP 20







    Reader Comments

    i want to know how to interface 8051(f005) microcontroller through parallel port. resolution of the adc belongs to this microcontroller is of 12 bits.can u give me the code in c.

    saikat -January 17, 2007

    i need read 2 rotarey encoder whit parallel port please help me thank ypu

    ahmad talebi -August 18, 2006

    i want to know about computer interfacing through microcontroller by serial or parallel port can u gv me the code in c or c++ to read the values from serial or parallel port send by the microcontroller i m using 89c51 ic plz guide me through

    neelesh -May 27, 2006
    Read more comments...

    POST YOUR COMMENTS HERE

    Name:

    Email:
    Rate this article:

     less useful more useful 
    1
    2
    3
    4
    5
    Your Comments:

    Enter the text from the image below




    Please refresh the page if you have trouble reading this text.
     
     

    PartFinder

    Find real-time pricing, stock status, same-day/next-day shipping options and more. Brought to you by Digi-Key. Go to PartFinder.    
    GlobalSpec

    PART SEARCH :
    Powered by: GlobalSpec - The Engineering Search Engine
    Sponsored Links

    Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
    Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources