ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING New modes in the combined measuring instrument. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Measuring technology During the operation of the combined instrument [1], the program of its microcontroller was significantly improved. The new version 2.03 of this program provides the user, in addition to the already available modes for measuring the frequency of the input signal and single sweep in the logic analyzer. New functions are implemented in a purely software way, no changes had to be made to the hardware of the device. The single sweep mode was provided from the very beginning in the instrument's oscilloscope, but the author did not implement it in the logic analyzer, although it is no less useful in it. In the new version of the microcontroller program, this omission is corrected. Now we can say that the logic analyzer, like the instrument's oscilloscope, has two sweep modes: regular and single. They are almost identical with two exceptions. First, the logic analyzer does not measure the voltage of the input signal. This operation does not make sense here, since the signals of standard logic levels are examined. Secondly, the additional information displayed on the screen about the position of the information frame on the time axis in the logic analyzer mode is not superimposed on the area of the oscillograms and does not interfere with their observation. Therefore, its shutdown is not implemented as unnecessary. An example of the image on the indicator screen in the single sweep mode of the logic analyzer is shown in fig. 1.
From the regular sweep mode of the analyzer, this mode is entered by pressing the "5" key. It has the following control keys: "4" - move the frame to the left (to the beginning of the buffer); "5" - stop moving along the signal counts; "6" - move the frame to the right (to the end of the buffer); "0" - selection of the movement step (count or frame); "D" - exit from single sweep mode. A complete description of the single sweep mode is not given, since it is quite fully described in [2] in relation to an oscilloscope. As for the frequency measurement mode, the microcontroller of the ATxmega family allows you to implement several of its options. Along with the classical counting of the number of periods of the measured signal per unit of time, the timer-counters of this microcontroller are capable of directly measuring the repetition period of the input signal pulses, which makes it easy to calculate their repetition rate. The advantage of this method is the short measurement time, however, acceptable accuracy is maintained only up to a frequency not exceeding several tens of kilohertz. In this regard, the measurement of the signal frequency in the device is carried out by the classical method mentioned above. Its principle is simple. One timer-counter generates a measuring time interval, the second counts the input signal pulses during this interval. If the duration of the measuring interval is 1 s, then the number accumulated during this time in the second counter is the signal frequency in hertz. However, there are difficulties in implementing this method. Firstly, all timers-counters of the microcontroller of the ATxmega [3] family are 16-bit. This means that the maximum frequency correctly measured by such a counter is limited by the overflow of its counting register and is equal to 216 - 1 = 65535 Hz. This is clearly not enough, given that the elements of the microcontroller are operational up to a frequency of 32 MHz. The easiest way to increase the maximum measurable frequency is to decrease the measurement interval. For example, reducing it by a factor of four will result in a fourfold increase in the maximum value of the measured frequency. At the same time, the discreteness of its measurement will increase by the same factor, because each pulse will "weigh" four times more. Therefore, this path is inappropriate. It is possible to achieve an increase in the maximum measured frequency without increasing the measurement discreteness only by increasing the capacity of the input signal pulse counter. The architecture of the ATxmega microcontroller makes this possible by allowing several timers/counters to be connected in series. To get a 32-bit counter, it is enough to combine two 16-bit timer-counters. Overflow of a 32-bit counter per second can only occur at a frequency of 2 - 1 = 4294967295 Hz, so the upper limit of the measured frequency in this case is limited only by the frequency properties of the microcontroller elements and is equal to 32 MHz. Secondly, it is necessary to "bring" the input signal from the port line to the timer-counter and force the latter to count pulses in a wide interval of their repetition rate. Thirdly, it is necessary to ensure strictly synchronous operation of all microcontroller elements involved in the counting process, regardless of the operation of its other nodes, in order to avoid all sorts of unpredictable count failures. A wonderful tool available in the ATxmega family of microcontrollers - the event system [4] - will help to overcome these difficulties. With its help, you can generate all the signals necessary for operation and transport them from the source to the receiver with the lowest possible and, most importantly, stable delay. The functional diagram of the frequency meter implemented in the device under consideration is shown in fig. 2. The equipment of the input-output port allows you to analyze the state of each of its lines and generate events if they change. For example, to generate events for each rising or falling edge of the input signal. Timers-counters are able to count not only the internal clock pulses of the microcontroller, but also event signals. From this it becomes clear how the counting of the input signal pulses is organized.
The signal is applied to the PF3 line, which is configured as an input and generates events on the rising edges of the signal (one event for each period). Timer-counter TCC1 operates in the event counter mode delivered on channel 3 of the event router. It also generates and sends overflow events (OVF) of its 4-bit counting register to router channel 16. They are counted by the TCD1 timer-counter, which is configured to operate as a 16-bit counter of events delivered on channel 4. Once a second, at the end of the counting interval generated by the TCF0 timer-counter, configured to count the microcontroller synchronizer pulses, the program "glues" the results of the TCC1 and TCD1 counter timers into one 32-bit word and assigns its value to a variable. It then restarts all timers/counters, starting a new frequency measurement cycle. Key Features in Frequency Measurement Mode
The main sources of frequency measurement error should be considered: 1. Inaccurate setting of the clock frequency of the microcontroller, as a result of which the actual duration of the measuring interval differs from one second. This error has two components: systematic and random. The systematic component is the result of the inequality of the actual average value of the clock frequency to the nominal one. It is permanent and can be compensated for. How to do this will be discussed below. The random component of the error arises due to fluctuations in the frequency of the clock generator. There are quite a few factors that give rise to it. These are instability and ripple of the supply voltage, intrinsic noise of the generator elements, the influence of temperature, etc. In high-end devices, a whole range of measures is used to minimize the harmful effects of such factors, up to thermal stabilization and vibration protection of the clock generator. However, this type of error can only be reduced, it cannot be completely eliminated. In the author's copy of the device, it does not exceed ± 0,001%. This means that the frequency of 5 MHz is measured with an error of ±50 Hz. 2. Discretization error of the measurement result. It is familiar to anyone who has ever dealt with any digital measuring instrument. The origin of this error is explained by the graphs in Fig. 3. Depending on the relative position on the time axis of the boundaries of the measuring interval and the measured signal drops recorded by the counter, the counting result may differ by one. For example, in the case shown in the figure, 6 or 7 pulses can be counted at an actual repetition rate of about 6,6 Hz (with a counting interval of 1 s). This effect is preserved at any ratio of the measured frequency and the counting interval. When a measurement is repeated many times, the least significant digit of its result "jumps" by one from cycle to cycle. The relative value of this error grows inversely with the measured frequency. For example, a frequency around 100 Hz will be measured with an average relative error of ±0,5%. At a frequency of several megahertz and higher, the sampling error can be neglected. Here, the random component of the duration of the measurement interval prevails.
The program block that performs the frequency measurement was developed, like the entire program, in the BASCOM AVR programming system. When entering the frequency counter mode, the program appropriately sets up the elements of the microcontroller's internal structure involved in frequency measurement: - PF3 line, which receives the input signal, is configured as an input that generates events on rising signal drops, and channel 3 of the event router is configured to transmit signals about these events: Portf_pin3ctrl=1 Evsys_ch3mux=&B01111011 - configures the timer-counter TCF0 to generate a measuring interval with a duration of 1 s: config Tcf0=Normal,Prescale=7 Tcf0_per=31249 - configures the TCC1 timer-counter to count events coming through the router channel 3 from the PF3 line: config Tcc1=Normal Tcc1_ctrla=&B00001011 Tcc1_ctrld=&B00001011 and channel 4 of the router - to signal the overflow of the timer-counter TCC1: Evsys_ch4mux=&B11001000 - configures a timer-counter to count events coming from channel 4 of the router: config Tcd1=Normal Tcd1_ctrla=&w00001100 Tcd1_ctrld=&w00011100 As a result, the TCC1 and TCD1 timer-counters form a single 32-bit counter. The system is now ready to count the periods of the measured signal. Moreover, it is already underway, since each of the considered devices starts working immediately after initialization. But in order to get the correct result, it is necessary to start counting events from zero at the beginning of the measuring interval. Therefore, the measurement cycle should begin with the simultaneous zeroing of all three timers-counters participating in it. It is especially important to bind to the beginning of the measuring interval (the moment of restarting the TCF0 timer) the restart moment of the TCC1 timer-counter operating at the highest speed. The issue of strict binding of the moment of restarting the timer-counter TCD1 to the beginning of the measuring interval is not so acute. The first event that it will have to count will only occur when the TCC1 timer-counter overflows. Although the possibility of simultaneously restarting several timer-counters in the microcontroller is provided, it is implemented only through the event system. It cannot be used in the case under consideration, since the TCC1 timer-counter is configured to receive event signals from channel 3 and cannot receive event signals from other channels without reconfiguration. Therefore, only the processor can give the timer-counters a restart command, and only one by one. The frequency measurement cycle consists of two stages: the actual measurement and the formation of its result. The measurement phase is described by the following five lines of the program: Tcf0_ctrlfset=&B00001000 Tcc1_ctrlfset=&B00001000 Tcd1_ctrlfset=&B00001000 Bitwait Tcf0_intflags.0, Set Evsys_ch3mux=&B00000000 The first three lines of this fragment restart the timer-counters in the order TCF0, TCC1, TCD1. Therefore, the TCC1 timer-counter starts counting events not at the start of the measurement interval counted by the TCF0 timer-counter, but with a delay Δt1 relative to this moment (Fig. 4). It is equal to the duration of the processor reset operation of the timer-counter TCC1. Next, with the same delay, the processor restarts the TCD1 timer-counter, after which it starts waiting for the end of the measuring interval. When this moment arrives, the TCF0 timer-counter will set the overflow interrupt request flag in the zero bit of the TCF0_JNTFLAGS register.
Having detected this flag, the processor must prohibit the timer-counter TCC1 from further counting events (periods of the measured signal). This can be done in different ways. In our case, the last operation of the measurement step, the processor simply disables channel 3 of the event router. For this operation, he needs time Δt2 (Fig. 4), during which the counting of periods continues. If Δt2 ≠Δt1, the actual duration of event counting (frequency measurement) differs by Δt2 - Δt1 from the given duration of the measurement interval, this generates another component of the measurement error. To eliminate it, it is necessary to make these delays equal. However, in a high-level language program (including BASCOM AVR), it is difficult to determine the exact values of their duration, since the programmer does not know the algorithm for translating the used language constructs into machine commands. Therefore, in a real program, the fragments that restart the timer-counter TCC!, as well as fix the end of the measurement interval and stop TCC!, are written in assembly language, and measures are taken to ensure the same duration of execution of these fragments. This achieves the equality Δt2 = Δt1 and, consequently, the equality of the real duration of the measuring interval given. Next, consider the method implemented in the device to eliminate the systematic error associated with the inequality of the microcontroller clock frequency to the nominal value. As noted above, the consequence of such a discrepancy is the deviation of the duration of the measuring interval from the required value of 1 s and the deviation of the measured frequency value proportional to it from the actual one. First of all, this deviation must be measured. This will require an exemplary signal generator with a frequency of several megahertz or a set of any sufficiently stable generator and an exemplary frequency meter. The generator signal is fed to slots 8 and 3 (common) of connector X5 of the device. The codes from the file Osc-Volt-2_03.hex attached to the article are loaded into the program memory of the microcontroller of the device. After switching on, the device is switched to the frequency counter mode and the frequency of the exemplary generator is measured by it. The measurement must be repeated 10-20 times, and then calculate the average measured value of the frequency Famended. The correction factor is calculated by the formula K=Farr/Famended, where Farr - frequency of the exemplary generator. To enter the coefficient K into the program, in the Osc-Volt-2_03.bas file (the source code of the program) you need to find the commented line compensation: 'Temp2=Temp2*1.000004 It is labeled Compensation: to make it easier to find. It should be uncommented, and the multiplier 1.000004 (this value is valid for the author's copy of the device) should be replaced with the found value of the correction factor K. After that, it is necessary to compile the corrected program and load the codes from the resulting HEX file into the program memory of the microcontroller. As already mentioned, the signal whose frequency must be measured is fed to socket 8 of the X5 connector of the device, from where it enters the microcontroller input PF3. It is clear that the microcontroller is able to correctly perceive only such a signal, the levels of which correspond to those accepted in three- or five-volt logic. To measure the frequency of signals of a different form (for example, sinusoidal), an additional driver is required. Good results are obtained by using the comparator probe described in [5]. It can be connected to the X5 socket of the instrument. You only need to submit from the A fee! device to the free slot 2 of this connector voltage +5 or +3,3 V to power the probe (it is operational at any of the specified voltage values). Connect the probe according to the diagram shown in Fig. 5.
The screen view of the instrument indicator in the frequency counter mode is shown in fig. 6.
This mode is entered from the regular mode of the logic analyzer by pressing the "LA" key. Switch the device from the frequency counter mode to other modes by pressing the following keys: "OS" - to the oscilloscope mode; "LA" - to the logic analyzer mode; "GN" - in the signal generator mode. The microcontroller program can be downloaded from ftp://ftp.radio.ru/pub/2015/09/combi2-03.zip. Literature
Author: A. Savchenko See other articles Section Measuring technology. Read and write useful comments on this article. Latest news of science and technology, new electronics: The world's tallest astronomical observatory opened
04.05.2024 Controlling objects using air currents
04.05.2024 Purebred dogs get sick no more often than purebred dogs
03.05.2024
Other interesting news: ▪ Smart door for cats and dogs ▪ Gardening is one of the best antidepressants ▪ Chemical synthesis against superbugs ▪ Multi-color marker Colorpik Pen News feed of science and technology, new electronics
Interesting materials of the Free Technical Library: ▪ section of the site For a beginner radio amateur. Article selection ▪ Article In sound mind and solid memory. Popular expression ▪ article What code was set to launch American nuclear missiles in the 1960s and 70s? Detailed answer ▪ article Molokan compass. Legends, cultivation, methods of application ▪ article Microcasting at home. Encyclopedia of radio electronics and electrical engineering
Leave your comment on this article: All languages of this page Home page | Library | Articles | Website map | Site Reviews www.diagram.com.ua |