Subscribe to EDN
RSS
Reprints/License
Print
Email

Single printer-port pin acts as an encoder output

Haobin Dong, Huazhong University of Science and Technology, China -- EDN, June 7, 2001

Encoders and decoders are common elements in alarm, remote-control, and measurement systems. However, most of these devices require many I/O lines when under microprocessor or PC control. For example, the HT-12E encoder has eight address pins, four data pins, and one transmit-enable-control pin. As an alternative, you can simulate the HT-12E using a single pin of a PC's printer port as the encoder output. Software determines the functions of the encoder.

The HT-12E is a CMOS IC. This encoder serially transmits data as defined by the state of the A0 to A7 and D0 to D3 input pints. On power-up, the DOUT pin is low. The HT-12E begins a 4-word transmission cycle on receipt of a transmission enable, or TE, signal, which is active low. The cycle repeats as long as the TE signal is low. When TE goes high, the encoder completes its final 4-word transmission cycle and then stops (Figure 1).

You can preset the status of each address or data pin independently to logic high or low. If the TE signal is low, the encoder scans and sequentially transmits the status of the 12 bits of address and data in the order of A0 to A8 and D0 to D3 (Figure 2).

The IC encodes each logic high or low into pulses (Figure 3). The encoder represents a logic low as a long pulse (011) and a logic high as a short pulse (001). Every logic bit takes three OSC periods. The information sequentially transmits via the DOUT pin.

Figure 4 shows the test circuit for a virtual encoder that includes an optocoupler and the decoder, IC1. The encoder output comes from printer Port Pin 2 of the DB25 connector. The data port is at address 0x378h of the PC's LPT. R1 limits drive current from the PC's printer port. IC2's Schmitt trigger shapes the optocoupler's output. The D0 pin of IC1 connects to R2 and an LED.

According to Figure 2 and Figure 3, one complete transmission period consists of 73 OSC periods. The pilot period, which is 12 bits, is all logic low (0, 36 OSC periods) followed by a one-third-bit sync period (one OSC). After those periods follows 8 bits of address and 4 bits of data, all of which need 36 OSC periods. Every bit of address or data is either a "001" encoded pulse for a logic high or a "011" for all other cases. A time interval exists between two pulses, and a software loop controls the interval. Also, the interval must be in accordance with the OSC periods of the decoder.

Software listings consist of implementation routines in Turbo C, the main code for determining the delay time, and a test-program site. The delay time, T_delay, is a global variable in the codes. The variables T_min, T_max, and T_step are properly predefined based on the PC. After you compile and execute the delay-time program, the T_delay value is read when the LED starts to flash. The value for the current design and the PC is 1000. Compile and run the test program, and you will observe that the LED continues to flash until you hit any key to stop the code.


RSS
Reprints/License
Print
Email
Talkback
Canon Resource Center

Featured Company


Most Recent Resources

Advertisement
Related Content

No related content found.

  • 0 rated items found.
Advertisement

KNOWLEDGE CENTER

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
Engineering Careers
Jobs sponsored by
Advertisement
About EDN   |   Site Map   |   Contact Us   |   Subscription   |   RSS
© 2012 UBM Electronics. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other UBM Canon sites

UBM Canon | Design News | Test & Measurement World | Packaging Digest | EDN | Qmed | Pharmalive | Appliance Magazine | Plastics Today | Powder Bulk Solids | Canon Trade Shows