Electronic Design

Use A PC Serial Port For Pulse-Encoded Communications

The simple method described here evaluates a one-wire device that uses pulse-width-encoded communications from a PC serial port. Communications errors such as parity and acknowledge are monitored. The hardware interface to the PC is a MAX232 driver/receiver, and the slave in this example case is a Texas Instruments TMP141 temperature sensor. The circuit can be expanded to four sensors on the same bus by using the TMP141's four programmable addresses derived from A0 and A1 (Fig. 1).

The main scheme for this method is to use the built-in timing of the RS-232 baud-rate control. Three "bit codes" are required for most communications: (Start bit), data (bit 0), and data (bit 1) (see the table and Fig. 2). Using mscomm in Visual Basic, the PC COM port is configured to output 8 data bits, parity None, 1 Stop bit, and flow control none. The setting of COM port data bits along with the baud rate determines the bit-code widths. Baud rate is changed between bits to create the different pulse-width codes.

Reprogramming the PC COM port baud rate can create a delay of 20 to 30 ms between bits, but this is okay because there's no time-out event in the slave. Yet the delays can make it a challenge to read the output on a logic analyzer. The Visual Basic program controls two-way communication to the TMP141 sensor. The program allows internal registers to be read and programmed. Details of communication execution are in the Visual Basic program, which can be downloaded at ED Online 12237 at www.electronicdesign.com.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.