Pulse-Width Measurement Made By Microcontroller With MFT

Feb. 9, 1998
The Multifunction Timer (MFT) used in low-end Motorola microcontrollers (68HC7O5J1A, 68HC705K1, etc.) is much more simplified when compared to its predecessors. It doesn’t perform the three traditional main timer functions: Timer Overflow (TOF), Input...

The Multifunction Timer (MFT) used in low-end Motorola microcontrollers (68HC7O5J1A, 68HC705K1, etc.) is much more simplified when compared to its predecessors. It doesn’t perform the three traditional main timer functions: Timer Overflow (TOF), Input Capture (ICF), and Output Compare (OCF). Instead, the MFT provides only the Timer Overflow feature. The absence of the Input Capture (ICF) capability, with its easily manipulated change of the positive and negative edges of the captured signal, makes accurate pulse-width measurement non-obvious.

The idea described here demonstrates a way to overcome this deficiency of low-end MFT using a simple software solution. The Pulse Width Detector measures the width of an input pulse (W), compares it with the given value (WO), and indicates the result by illuminating one of corresponding LEDs: “More”, “Equal”, or “Less” (see the figure). The assembler program for the Pulse Width Detector is given (see the listing).

The Pulse Width Detector takes advantage of the fact (unfortunately, not mentioned in all Motorola manuals) that, when Port A pins are employed as edge-sensitive external interrupt inputs, these pins can be used simultaneously as regular level-sensitive input pins.

Using this method, the measurement procedure becomes straightforward. The rising edge of a measured pulse on pin A0 causes an interrupt. The interrupt service routine activates the counter W, which counts until a high level exists on pin A0. The falling edge of the measured pulse stops the counting, and counter W contains the pulse-width information.

This kind of detector was used in Armatron’s wireless data-transmission system to recognize pulse-width variations from W*TR to (W+1)*TR, where W (the contents of the counter W) = 0,1,2,....255. TR (time resolution) is determined by period of the timer W increment, which depends on the counter loop duration (9 µs) and the constant N (end of the loop condition). The time resolution should be chosen according to design objectives. In our detector, N = 55, which yields TR = (9 µs × 55) + 0.5 µs = 0.5 ms. The maximum time measured is limited only by the number of counter W stages used.

Because this idea requires only one external interrupt pin, the techniques are usable with most microcontrollers. Other possible applications are multiwidth pulse detection, pulse-width decoding, width-to-digit conversion, and so on.

Sponsored Recommendations

Understanding Thermal Challenges in EV Charging Applications

March 28, 2024
As EVs emerge as the dominant mode of transportation, factors such as battery range and quicker charging rates will play pivotal roles in the global economy.

Board-Mount DC/DC Converters in Medical Applications

March 27, 2024
AC/DC or board-mount DC/DC converters provide power for medical devices. This article explains why isolation might be needed and which safety standards apply.

Use Rugged Multiband Antennas to Solve the Mobile Connectivity Challenge

March 27, 2024
Selecting and using antennas for mobile applications requires attention to electrical, mechanical, and environmental characteristics: TE modules can help.

Out-of-the-box Cellular and Wi-Fi connectivity with AWS IoT ExpressLink

March 27, 2024
This demo shows how to enroll LTE-M and Wi-Fi evaluation boards with AWS IoT Core, set up a Connected Health Solution as well as AWS AT commands and AWS IoT ExpressLink security...

Comments

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