PWM-To-RS-232 Translator Boasts Over 11-Bit Accuracy

June 22, 2006
WILLIAM GRILL, Honeywell Aerospace-Olathe, Olathe, Kansas [email protected] Over the years, many sensor monitor designs would have benefited by being able to have their encoded pulse-width modulation (PWM) data forwarded to and post-proc

WILLIAM GRILL, Honeywell Aerospace-Olathe, Olathe, Kansas
[email protected]

Over the years, many sensor monitor designs would have benefited by being able to have their encoded pulse-width modulation (PWM) data forwarded to and post-processed by a PC-based host. However you encode the PWM information, the PWM-to-RS-232 translator described here has a small footprint and a total cost under a few dollars.

Several relatively small and inexpensive controllers are available (in addition to several techniques) to perform this function. This application uses the Microchip 10F20x-series, four-I/O controller. It was selected because of its predictable execution time and small (SOT23) package. Portable into multiple compatible controller footprints, this translator should give new life to dozens of old ideas and serve as a bridge circuit for new designs. The circuit includes the controller (U1), transistor translators (Q1 and Q2), and the 78L05 regulator (U2) (Fig. 1).

Assembly-language-based processes in the controller equalize the branch paths to constant-length loops. Both high and low input states are evaluated by totalizing the number of these 8- s loops in each state, using 16-bit "totalized-count" registers. An 8-bit " loopindex" register allows up to 255 periods to be accumulated. When all periods are processed, the totalized-count registers are copied and zeroed, the loop-index register is reloaded, and the request line is qualified.

The request input is asserted as a high to low transition on U1's P2 (pin 4). When the request is asserted, the saved results are scheduled to an RS-232 serial link. As a result, the period between serial updates depends on the number of selected totalized index loops and the PWM's input period.

The update frequency is approximately:

Update frequency (Hz) ≤ 1/\[(no. of totalized loops * PWM period) + RS-232 transmission time\]

If no request is detected, the entire process is repeated.

The included Windows-based monitor and control schedules the requests or receives updates continuously over the RS-232 bus. Using a Visual-Basic-based interface migrates the calculation and display processing to the more powerful host. It also provides a platform to extend and adapt this simple and inexpensive implementation to your own particular application.

Five bytes are sequenced into Q1 and onto the serial bus at a fixed, 9600-baud rate, transmitted in the order shown below:

  • Number of loop-index counts selected
  • Low-state totalized-count most significant byte (MSB)
  • Low-state totalized-count least significant byte (LSB)
  • High-state totalized-count MSB
  • High-state totalized-count LSB

With the factory-set calibration of the on-chip's 4-MHz clock, the link timing is adequate over most of the common temperature range. Evaluating both states yields consistent accuracy by eliminating this reference clock's error.

Designs are usually flexible enough to pick the PWM period. Allowing for a range of PWM's period, there's some margin required to ensure that with the selected number of loop-index counts, the totalized count doesn't exceed the 16-bit counter-register space. In general, this limitation is:

216 1 > no. of totalized loops * \[(1/Input frequency)/8 μs\]

The controller is coded to supply fixed 16, 1, or 8 totalized period counts for the Mode control U1 (P3, pin 6) strapped low, pulled high, or floating, respectively. The loop-index count used in the coded processes, passed in the link, and displayedin the monitor window can also be adjusted by selecting an appropriate capacitor (C1) and resistor (R1) on U1, pin 6, Mode pin.

Upon power-up, the controller qualifies the Mode pin for a high or floating state. Then it discharges the pin and threestates—monitoring its status while indexing a local counter register every 9 μs— until it either detects a logical high or declares it strapped to zero by counting through its maximum count. Because the pin is momentarily driven high and low, this input should always be terminated with at least 220 Ω.

The monitor window created in this application shows the totalized register's raw data, the number of loop counts, and the resulting ratios of totalized high and low counts (Fig. 2).

While 8 bits of accuracy is enough for many applications that need low sample update rates or low information bandwidths, accuracies of 11 bits or more, at the monitor window, are easily available. Trading update time for higher loop counts and increasing the PWM period will reduce the error. The ability to accumulate multiple periods lets the calculated accuracy be improved by filtering input jitter and the process' uncertainty in the input's edge detection.

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!