The connection between the computer and peripheral devices has multiple interface methods: serial, USB, SCSI, and parallel. Each interface method has its advantages and disadvantages.
The connection between the computer and peripheral devices has multiple interface methods: serial, USB, SCSI, and parallel. Each interface method has its advantages and disadvantages, because the serial interface and USB interface have strong anti-interference ability and long transmission distance, the above two methods are used for data communication. However, in some applications, such as CCD and video data acquisition cards, the transmission distance is near. At this time, parallel interfaces are used, and such applications will increase with the increase of data processing speed.
In addition, when the computer is used for analog signal detection, the/D conversion interface circuit needs to be configured. The commercialized data acquisition card is expensive, developing a traditional data acquisition card requires a lot of knowledge, especially the development of low-layer drivers, which is difficult.
Define the foot position of a parallel interface
1. Physical Interface Description
The computer parallel adapter or data acquisition card basically adopts multi-mode control chip. The operating mode of the parallel adapter can be set in CMOS. The operating modes of parallel interfaces include standard parallel interfaces (SPP), simple bidirectional interfaces (PS/2), enhanced parallel interfaces (epp1.9), and extended functional interfaces (ECP.
The physical interface adopts the dsub25 needle internal-hole connector described in the ieee1284 standard. The pin signal varies with the working mode. The spp mode is used by default below (see table 1 ).
S corresponds to the Status Register and C corresponds to the control register. Their corresponding addresses are base address (378 h) + 1 and base address (378 h) + 2.
Table 1: Introduction to physical connections and output directions in parallel port spp Mode
2. Register description
Figure 1 shows the control register of the printer adapter, which uses only the lower five digits.
Figure 1: control register
Figure 2 shows the Status Register of the printer adapter, which uses only the 5-bit high.
Figure 2: Status Register
Table 1 shows the relationship between each user and the pin.
Circuit Principle
1. ad7820 pins and functions
Ad7820 is a high-speed 8-bit ADC chip compatible with the microprocessor. It uses a single + 5 V power supply without external clock and has a sampling and holding circuit, the conversion time reaches 1.36 μs. Pin 3:
Pin features:
Vin analog signal input;
Figure 3: ad7820 pin chart
DBO-DB7 three-state data output;
/Rdy write control/output ready;
Mode mode selection, internal pull through a 50μa Current Source Low, mode = 0 to activate the Read mode, mode = 1 to activate the write read mode;
Read control, low-power access to data at ordinary times;
InterruptedThe output control bit. When the power is low, the adswitch ends;
Gnd Power Supply location;
Vref (1) reference voltage negative end (1), zero-code input analog voltage, range: Gnd ≤ vref (1) ≤ vref (10 );
Vref (+) refers to the positive end of the voltage (10). The analog voltage is input at full scale. The range is vref (1) ≤ vref (10) ≤ VDD;
Segment selection and input, when reading or writing, must be low;
Overflow flag;
NC traffic control foot;
VDD Power Supply + 5 V.
2. Circuit Implementation
Figure 4: A/D conversion interface circuit
As shown in principle 4 of A/D conversion interface circuit, ad7820 starts data conversion when a negative pulse is generated in read-only mode. The required control signal is generated by the 14-pin C1-bit output line of the printer control port, and a negative pulse is output to the pin. the/D conversion starts and ends after 1.36 μs, the data lock exists in the three-state output data lock in the chip, and the pin outputs a low level. The pin is connected to the 11-pin socket corresponding to the S7-bit printer status port. You can check whether the switch is complete by querying the S7-bit status port.
In Figure 4, 74ls157 is a four-two-choose-1 data selector that sends the result to the S3 ~ of the printer status port twice ~ The S6 position, that is, the control signal connected to the printer pins 15, 13, 12, and 10, is controlled by the C2 position and 16 position of the printer control port. The computer obtains data from the printer status port twice.
Software Implementation
After the/D conversion interface circuit is configured on the PC, the analog electrical signal can be detected. The input range of the analog electrical signal is 0 ~ 4.98 v. Coupled with sensors, it can be used for non-electrical analog detection.
The following is a small program written in the VC ++ language. The input/output of the port in VC ++ can be achieved through the port I/O function in P and ou TP. The function is included in the conio. h library.
................. -Outp (0x37a, 3); // clear the port-outp (0x37a, 0); // start the/D conversion do {datainput =-Indium (0x379) & 0x80}; while (datainput! = 0x80); // wait until the conversion ends.Data=-Indium (0x379); // input low 4-Bit Data = Data & 0x78; data1 = data> 3;-outp (0x37a, 0x4); // The Control 16 foot is high data =-Indium (0x379); // The input four-digit DATA = Data & 0x78;-outp (0x37a, 3); // make a/D stop converting data = data <1; Data = data | data1 // 8-bit binary merge ............ // Further data processing
Conclusion
This system can be applied in some systems with low real-time requirements. It discards a large single-chip microcomputer system and does not occupy the expansion slot of the microcomputer. It is small in size and consumes less, in addition, it breaks through the fixed mode of traditional microcomputer data collection, making the interface between the data collection device and the microcomputer more flexible and convenient.