scanning the data. The period of the digitised waveform is then the difference between the time at point ‘A’ and ‘C’.
Note that the identifier Case (initially set to 1) is used to control the different phases of scanning the data. When the value of Case is 1, the ADC data array is first searched for an element pointed to by DataPtr that is less than the threshold. Once such an element has been found, the variable Case is set to 2 to commence the next phase of scanning. The identifier Quit is used in a logical sense. It is initially set to 0, meaning ‘do not quit’. The value of Quit is tested at the end of each iteration of the loop and if set, the loop will be terminated by executing the break statement. Once the last point (C) has been found, there is no need to proceed with scanning, so Quit is set to 1. The time difference representing the period of the signal is then calculated and printed on-screen.
13.9 Summary
In this chapter we learned how the built-in timer of the PC operates and how it can be used. The object class PCTimer has been developed with the capability to measure very long time periods. It has member functions to mark a time reference, accurately read the elapsed time, and also generate specific delays.
The PCTimer class operates without disabling the PC’s interrupts. As such, the interrupt service routines will generate short interruptions that can contribute to minor inaccuracies when measuring time. This was demonstrated when one of our example programs made repeated measurements of a ‘fixed-time’ event with interrupts enabled, and later with interrupts disabled. Other programs were presented in this chapter that measured a person’s reflex reaction time, generated a waveform plot using an accurate time-base, and used regular and accurate timing to digitise the electrical waveform produced by the interface board’s Charge/Discharge circuit.
13.10 Bibliography
Van Gilluwe, F., The Undocumented PC, Addison Wesley, 1994.
IBM, Technical Reference – Personal Computer AT, IBM Corporation, 1985.
Auslander D.M. and Tham, C. H., Real-Time Software for Control, Prentice Hall, 1990.
Intel, M8254 Programmable Interval Timer – Data Sheet, Intel Corporation, 1986.