ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING Lunokhod with microcontroller control. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Microcontrollers The described device was developed to demonstrate the capabilities of software and hardware systems for controlling moving objects. The object was a children's toy "moon rover" with a wire remote control, driven by two DC electric motors and allowing you to control each of them separately. When the power is turned on, the model starts to move forward. At the same time, the transmitter and receiver of pulsed IR radiation mounted in it are turned on. The movement continues until the intensity of the reflected IR signal exceeds the set threshold, which indicates the presence of an obstacle on the way. Once this happens, the model rolls around until the reflected signal falls below this threshold, after which it continues forward, and so on. A schematic diagram of the hardware-software complex for controlling the "Lunokhod" model is shown in the figure. It is based on the economical AT90S2313 (DD1) eight-bit CMOS microcontroller (MC) built using the advanced AVR RISC architecture. The clock frequency is set by the ZQ1 quartz resonator at a frequency of 5 MHz (it can be any other, up to 10 MHz). A circuit of resistor R13 and capacitor C12 serves to reset the MK at the moment the power is turned on. The connector X1 is introduced for quick connection and disconnection of the MK and the rest of the device, as well as for connecting the MK to a computer in order to update the program or diagnose work. In addition to the microcontroller, the device contains a pulse transmitter of infrared radiation (VT4, VD2), a receiver of radiation reflected by an obstacle, consisting of a photodiode VD1, a two-stage amplifier (VT1, VT2) and a synchronous detector (VT3), and four electronic switches (1VT1 - 1VT3, .. ., 4VT1 - 4VT3). The device is powered by a battery consisting of four Ni-Cd batteries of size C with a capacity of 1500 mAh, installed in the compartment provided in the model. The supply voltage of the microcontroller and the IR receiver is maintained by an unchanged microcircuit voltage regulator DA1. During operation, pulses with a repetition rate of about 0 Hz are received from the output of the PD4 port to the base of the transistor VT1220. As a result, it periodically opens, and the VD2 light-diode included in its collector circuit creates IR radiation pulsing with a specified frequency in the direction of movement of the model. Resistor R7 limits the current through the emitter junction of the transistor and protects the output of the MK port from damage during breakdown of this junction. The maximum current through the LED is limited by resistor R9. The IR radiation reflected by the obstacle is perceived by the VD1 photodiode, connected in parallel with the resistor R2, through which the direct current feedback is carried out, covering the two-stage amplifier on transistors VT1, VT2. Voltage pulses from the collector of transistor VT2 are fed to a synchronous detector made on a field-effect transistor VT3. Its use is due to the fact that during the operation of the locator, resistor R3 creates not only oscillations with a frequency of about 1220 Hz, but also ripples with a frequency of 100 Hz from incandescent lamps, as well as random interference in both the visible and IR ranges of the spectrum. The level of these interferences is often commensurate with the level of infrared radiation reflected by the obstacle, and if special measures are not taken, this can lead to the detection of a false obstacle. To prevent such errors, a synchronous detector was used. Its input (the gate of the transistor VT3) is connected to the same port (DO) as the input of the transmitter, therefore, synchronously with the flashes of the VD2 LED, the transistor VT3 opens, which connects the output of the amplifier on transistors VT1, VT2 to one of the inputs of the MK comparator (PB0 / AIN0 ). The exemplary voltage at its other input is set by a tuned resistor R12, thereby adjusting the sensitivity of the device to the reflected signal. The operation of the electric motors of the MK model is controlled by electronic keys S1 - S4. Consider the work of one of them, for example, the first one (the rest act similarly). When the input voltage is less than 0,6 V (log. 0), the transistors 1VT1 and 1VT3 are closed, and 1VT2 is open, so the voltage at the output and the output of the motor M1 connected to it is close to the voltage of the GB1 power battery. Submission to the input of the key level log. 1 causes transistor 1VT1 to open, due to which 1VT2 closes, and 1VT3 opens and the output voltage becomes close to 0. Resistor 1R1 limits the current consumed by the key from the MK output to a value of about 3 mA, which is much less than the allowable output current (20 mA at logic level 0 and 10 mA at logic level 1). The resistance of the resistor 1R2 is selected in such a way as to, on the one hand, provide a sufficient output current of the key when 1VT2 is open, and on the other hand, so that the current through the open transistor 1VT1 is not too large. Since the electric motors used in the model consume a very large current (about 600 mA) and create intense impulse noise, they had to be replaced by more economical and less interference motors DPB-902. It is possible to use other collector electric motors from tape recorders and radio tape recorders. To manage electronic keys, four high-order digits of port B are used: РВ7, РВ6, РВ5 and РВ4. The operation of the IR transmitter is controlled by the least significant bit of port D - PD0, the two least significant bits of port B (PB0 and PB1) are configured and used respectively as direct and inverse inputs of the analog comparator. As can be seen from the diagram, to turn on, for example, the electric motor M1, it is necessary to open one of the keys S1, S2 and close the other. If you open or close both keys, the voltages at their outputs will be the same, so the voltage on the electric motor will be 0. If you open the key S1 and close S2, the left (according to the diagram) output of the engine will be connected to the positive of the battery, and the right one - with its minus, and it will begin to rotate in one direction. If, on the contrary, open S2 and close S1, the motor connection polarity will be reversed and it will start to rotate in the opposite direction. Software inclusion is carried out by writing to port B of the constants indicated in Table. 1. Software control of the IR radiation transmitter is performed by writing a certain number to port D of the MK. If the least significant bit of this number is 0, the VD2 LED is off, and if it is 1, it is on. Sequential change of the values of this bit leads to the occurrence of a pulsating illumination level ahead of the model in the IR part of the spectrum. The level of reflected radiation is fixed by a photo sensor, and as it increases, an assumption is made about the presence of an obstacle ahead. The peculiarity of the program is that the control algorithm is placed in the MK timer handler. This is due to the fact that it is necessary to switch the emitting LED with a certain constant frequency, and to simplify the program, the control algorithm is placed there. After a reset signal is given at the moment the power is turned on, the MK starts executing the program from the Start mark. In this part of the program, the initial initialization of the stack, registers, I / O ports B and D, analog comparator, eight-bit timer is performed, the pulse repetition rate for the timer is set to CK / 8 (CK - clock frequency equal to 5 MHz), and the interrupt handler timer overflow. Since the timer overflows every time after 256 (28) pulses, the interrupt handler is called 2441 times per second. As a result, the emitting LED switches at a frequency of approximately 1221 Hz. The analysis of the received reflected signal is performed once in 20 timer cycles, i.e., with a frequency of 122 Hz. The control algorithm works as follows. Register r24 is used as a counter with a range of values from 0 to 240. At each check, if there is an obstacle and the counter value is less than 240, it is increased by 1, and if there is no obstacle, it is decreased by the same amount until it becomes 0. Further, at counter values from 0 to 16 command to move forward, from 17 to 31 - to stop, and from 32 to 240 - to turn around. Such an algorithm avoids false alarms and increases the probability of a complete bypass of the obstacle (the model turns around for some time even after it disappears). On register r27, a counter of turns is organized, according to which every second turn is made in the opposite direction to the previous one, and on register r18 - a counter of the motor control algorithm. It sequentially takes values from 0 to 3 with each interrupt call. At O, the right engine is turned off, and at 2, the left engine. Thus, the current consumed from the battery is reduced, thereby increasing the battery life of the model from one battery charge to the next. Program codes in the form of a hex-file are given in Table. 2. Full text of the program in assembly language Setting up the device is easy. First, turning off the microcontroller by disconnecting the parts of the X1 connector, install the battery in place and, by closing the contacts of the switch Q1, measure the voltage at the output of the DA1 stabilizer. Then, by connecting the oscilloscope to the drain of the transistor VT3 and illuminating the photodiode with some source of IR radiation (for example, a remote control for a TV or VCR), they make sure that the photodetector is working. The remaining nodes, when using serviceable parts and the absence of errors in installation, do not need to be adjusted. Finally, the MK is connected (with the power off) and the operability of the device as a whole is checked. The sensitivity of the photodetector, if necessary, adjust the tuning resistor R12. Author: P. Chechet, Vasilevichi, Gomel region, Belarus See other articles Section Microcontrollers. Read and write useful comments on this article. Latest news of science and technology, new electronics: Air trap for insects
01.05.2024 The threat of space debris to the Earth's magnetic field
01.05.2024 Solidification of bulk substances
30.04.2024
Other interesting news: ▪ MATSUSHITA Starts DVD-RAM Promotion ▪ Supercomputer successfully imitates communication with a teenager ▪ Fingerprint sensors in cameras and lenses News feed of science and technology, new electronics
Interesting materials of the Free Technical Library: ▪ website section Television. Article selection ▪ article There are only girls in jazz. Popular expression ▪ article What are nitrobacteria? Detailed answer ▪ article Fragrant parsley. Legends, cultivation, methods of application ▪ article Simple tachometer. 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 |