ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING Cable probe on PIC controllers. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Microcontrollers The described device consists of a transmitter and a receiver. On the side of the first, the ends of the wires are inserted into numbered clamps, and on the side of the second, they touch their other ends with a probe. The number of the terminal to which this or that wire is connected is displayed on the digital display of the receiver. To determine the numbers of cores, it is necessary to identify one of them and connect it to the common wire of the receiver and transmitter. The transmitter operates in the pulse distributor mode for ten pins of the microcontroller (MK). Each of them has its own constant, to which tens are added at the moment of changing their code. In order for all 80 pulse distribution cycles to be performed in the same time, each of them is completed in the time from one interruption to the next. Interrupts occur when the TMR0 timer overflows. It has a division ratio preset, chosen to fit 80 output pulses between interrupts. Consider the algorithm of the transmitter program (Fig. 1). After starting the program and initializing the registers, the tens register is reset. Its value is rewritten to port A for switching multiplexers. Next, interrupts are enabled, and the binary number of tens is used to find its decimal value, which is added to the first output constant. The output constant (K) is determined by its number: for the first it is equal to 1, for the second - 2, for the tenth -10. When the value of tens is zero, each output has a number of pulses equal to the output number. Next, the program checks register K for zero. If it is not present, one is subtracted from the register, which is accompanied by switching the output to a single state. Then a pause of 24 µs is maintained, and the output is set to zero, which lasts 30 µs (i.e., the period of oscillation is 54 µs). After that, the program checks the register for zero. If the register is empty, it goes into interrupt waiting mode, and if its value is not equal to zero, the entire pulse generation cycle at the output is repeated. Thus, the output is the number of pulses that was written to the K register. After the initialization of the registers, a prescaler with a division factor of 32 and a timer with a division factor of 137 (256 - 119) are turned on. With a 4 MHz crystal, the timer overflow interrupt should occur in about 4,38 ms (32-137 = 4384 µs), but the interrupt returns from the command without interrupt enable. To this time is added the cycle time until the interrupt is enabled and, in fact, the time for the interrupt itself to be executed (the total average duration of this time is 16 cycles). In addition, the prescaler is reset every time the timer is set, so the pause between interrupts is 4,4 ms. As it is not difficult to calculate, 80 oscillation periods will last 4,32 ms (54 μs x 80 \u4320d XNUMX μs), i.e. this time fits into the interval between interruptions. After the timer overflows, the usual procedure for saving the values of registers during an interrupt is performed and one is added (possibly subtracted) to the interrupt counter. The values of this counter are not used by the program, and the counter itself is required to execute the interrupt. But it is convenient to use when debugging a program. After restoring the values of the registers, an interrupt is enabled to generate pulses from the next output. After the pulses are generated at the tenth output, the tens register is increased by one and the whole cycle is repeated with the command to write the binary code of tens to port A. In the new cycle, the number of generated pulses at each output increases by ten. When the tens value reaches eight, the pulse shaping cycle will begin by resetting the tens register to zero. Thus, the maximum value of tens is seven, and the maximum number of pulses will be at the tenth output (10 + 70 = 80). All 80 interrupt cycles last 0,352 s (4,4 ms x 80). This time determines the guaranteed duration of the pause between the issuance of pulses at each output. For a single pulse at the first output, the pause duration will be increased by almost a time equal to the time between interruptions, and for 80 pulses at the tenth output, the pause between pulses will be 0,352 s. This should be noted in order to better understand the operation of the receiving part of the probe. The schematic diagram of the transmitter is shown in fig. 2. All bits of the port In MK DD1 are configured for output and have coefficients from one to eight. Bits RAO-RA2 are used to output the values of the tens register in binary code, RA3 and RA4 - as outputs with coefficients of 9 and 10, respectively. Since the RA4 output has an open drain, it is loaded with a resistor R1. The Y inputs (pin 3) of the DD2-DD11 multiplexers are connected to the bits of port B, the address inputs (A, B, C) are connected in parallel and connected to the outputs of dozens of MKs. Thus, with a zero value of the tens register, a zero address will be selected on all multiplexers, and a number of pulses will appear at their XO outputs (pin 13), equal to the output coefficient of the MK, which is connected to the Y input of the multiplexer. Only one pulse will be constantly present at the XO output of the DD2 microcircuit, and 11 pulses at the DD10 output of the same name. When the address of the multiplexer is increased by one, its next output (X1) will turn on, and the number of pulses on it will increase by ten. Thus, only its own number of pulses will appear sequentially at each output of the multiplexers. The lower (according to the diagram) output of the transmitter (Common) is connected, as noted, to one known wire, which will be common to the transmitter and receiver. The cable probe receiver works on the principle of a two-digit counter. The algorithm of his program is shown in Fig. 3, and the schematic diagram - in fig. 4. After start-up and initialization, the program proceeds to dynamic indication of two LED digital indicators with a common cathode. The time for the indication of one indicator is 5 ms, i.e., the entire indication cycle is repeated at a frequency of 100 Hz. The receiver uses two types of interrupts: on the overflow of the TMR0 timer and on a change in the signal at the RB0 input. When a pulse arrives at this input, the values of the current registers are saved. Next, the program checks the source of the interrupt. If it did not occur due to a timer overflow, then the pulse counter is incremented, the timer is reset (256 - 120 = 136) and the prescaler counter is reset. The program restores the values of the registers, and the display continues. Thus, when pulses are received from the RBO input, the timer is constantly reset, so the timer overflow interrupt is not possible as long as pulses are present at this input. If there are no pulses at the input for a long time, a timer overflow interrupt occurs. For the reliability of the receiver, the time between interruptions is slightly reduced compared to the transmitter and is equal to 4,38 ms. Timer overflow interrupts are counted by the interrupt counter. The pause between pulses at each output of the transmitter is 80 interrupts, so the interrupt counter in the receiver can count up to 80. If there were no input pulses during this time, the program rewrites the values of the pulse counter registers into the indication registers and the readings are updated. This happens every 0,35 s. Codes "firmware" MC transmitter and receiver are shown in Table. 1 and 2, respectively. Outputs RB1-RB7 MK DD1 switch elements (segments) of LED indicators HG1, HG2, outputs RA0, RA1 - their cathodes. The pulses from the probe are fed to the input RB0. Terminal X1 is connected to a known cable core, which serves as a common wire for the receiver and transmitter. If the transmitter multiplexer output is not selected by address, it will have an undefined level and when pulses appear on the receiver counter, there will be one false alarm (regardless of the set counter threshold: it can be either a zero-to-one or a one-to-zero threshold) . To avoid false pulses, the input is shunted by resistor R1. The receiver and transmitter are powered by batteries made up of three AA or AAA cells each. If you intend to work with the receiver for a long time, it is advisable to use a 3R12X battery. The receiver and transmitter used quartz resonators at a frequency of 4 MHz. Without any changes in the circuits and programs, you can use resonators with a lower frequency, down to 1 MHz. In this case, the refresh rate of the indicators readings will decrease accordingly, but it will remain at an acceptable value for the eyes - up to 25 Hz. The transmitter is mounted on two printed circuit boards, each of which is designed for 40 outputs (the second one differs from the first one in that it does not have a DD1 chip and there is a place for installing a resistor R1). The boards are placed one under the other, connected with screws and threaded posts, and a case for three battery cells is installed between the boards (in the area where the DD1 chip is located). The clamps for connecting wires on the transmitter board are self-made (Fig. 5). They consist of two identical brackets 2, bent in the form of the letter "L" from strips of sheet bronze or well-spring brass 0,4 ... 0,5 thick and 2,5 mm wide. One of the ends of the blanks is sawn to a width of about 1 mm (at a length of 1,5 ... 2 mm, depending on the thickness of the material of the boards 1), in the other, a hole with a diameter of 1,2 mm is drilled, after which the ends are bent. The sawn parts of the brackets are soldered into the boards, as shown in Fig. 5. To connect wire 3, the lower and upper (according to the figure) ends of the brackets are compressed until the holes match. After installation, the clamps are numbered in such a way that, by turning the transmitter (when the bottom becomes the top, and vice versa), their numbers can be seen. Author: N.Zaets, Veidenevka village, Belgorod region. See other articles Section Microcontrollers. Read and write useful comments on this article. Latest news of science and technology, new electronics: Machine for thinning flowers in gardens
02.05.2024 Advanced Infrared Microscope
02.05.2024 Air trap for insects
01.05.2024
Other interesting news: ▪ Anti-mosquito composition for clothing ▪ Hydrogen sailboat Nemesis Yacht ▪ High-speed remote radar-metal detector News feed of science and technology, new electronics
Interesting materials of the Free Technical Library: ▪ section of the site Calls and audio simulators. Article selection ▪ parachute article. History of invention and production
Leave your comment on this article: All languages of this page Home page | Library | Articles | Website map | Site Reviews www.diagram.com.ua |