Latest News
|NewsletterAbel Raynus, Armatron International, Malden, MA; Edited by Martin Rowe and Fran Granville -- EDN, 7/24/2008
A microcontroller detects output pulses in a device under test.
While recently designing an automatic test station employing a microcontroller, I faced a nonstandard task: Detect the presence or the absence of output pulses in the DUT (device under test). You might think this task is easy to accomplish by connecting an LED to the DUT output. The blinking LED provides evidence of the pulse’s presence.
That approach would work if that test were the only one you needed to perform. In this station, however, the pulse test is just one of more than a dozen tests and measurements. The test station should display the final result - pass or fail - only after completing all the tests. So, it should represent the result of each test in binary format - that is, yes for pass or no for fail. This Design Idea describes a simple way of solving this problem.
The pulses for detection enter the IRQ (interrupt-request) pin of the Freescale MC68HRC908JK1 microcontroller (Figure 1). Each pulse period is 500 msec, causing an external interrupt. At least three interrupts should occur within 2 seconds. The program waits for 2 seconds, and, if no external interrupts occur during that time, it declares that the pulse test has failed. The red LED on the PB1 pin then switches on, and the test stops.
Otherwise, after three interrupts, the program starts the next test. To evaluate the pulse test separately from the rest of the tests, this demo program ends in an indefinite loop instead of starting the next test. When the green LED on the PB0 pin lights up, it indicates that the pulse test has successfully completed. The LEDs work with built-in current-limiting resistors, such as W934GD5V and W934ID5V devices from Kingbright.
This design uses the low-end, 8-bit MC68HRC908JK1 microcontroller because of its low cost and ability to have 10 8-bit ADC channels. Listing 1 is the firmware-assembly code for the device. You calculate the time delay for the oscillation frequency at approximately 4 MHz, which a 20-kΩ resistor and a 10-pF capacitor determine. This approach is applicable to any type of microcontroller because it uses standard assembly instructions. You need to recalculate the time delay only in case of different oscillation frequencies.