Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Can you control the direction of the hull model with a single chip microcomputer?
Can you control the direction of the hull model with a single chip microcomputer?
Of course.

Since the electric car model can be used, there is no reason why the boat can't.

Demonstration of automatic control scheme of electric model car based on single chip microcomputer

According to the basic requirements of the topic, the design task is mainly to complete the speed control of the electric vehicle in the prescribed driving route, and use variable speed driving according to different driving sections to process and display the relevant data in the trip. In order to keep the car in contact with the fixed point, this system is equipped with infrared digital sensor device to realize the positioning of the car during driving. The implementation scheme of the system is as follows.

1. Generally, the following schemes can be adopted for data acquisition: (1) The combination of light emitting diode and phototransistor is adopted; (2) adopting the combination of infrared light emitting diode and receiving tube; (3) use laser.

In contrast, in this design, because it is close-range detection, we use the second scheme to complete data acquisition. Because the wavelength of infrared light is longer than that of visible light, it is less affected by visible light. At the same time, the infrared system also has the advantages of small size, light weight, effective prevention of visible light wave interference, minimum requirements for auxiliary equipment and no harm to human eyes. Of course, infrared light also has some disadvantages, such as attenuation when propagating in humid atmosphere, fog and clouds, so it is only suitable for indoor communication. The reflective photodetector we choose has the characteristics of small size, high sensitivity, good linearity, simple peripheral circuit and circuit design, convenient installation, low power requirement, stable and reliable performance, etc. It is an ideal choice as a short-range sensor.

2. Selection of display equipment For vehicle display, we use a digital tube to select the display content by pressing the time and distance keys.

3. The communication mode can be selected by radio or infrared ray. Radio mode communication distance is far, but the circuit is more complicated; Infrared light mode is suitable for short-distance communication and the circuit is simple. At present, only one-way transmission is considered, so we choose infrared light as the carrier of information transmission.

4. The selection of power supply and on-board weight should consider the horsepower, on-board weight and friction resistance of electric vehicles, and the circuit devices should be selected from three aspects: low power consumption, small size and light weight, so the power supply is composed of six 5th batteries, and 9 volts DC is used for power supply.

System block diagram and working principle

The diagram above shows the block diagram of the system. Data acquisition completes the detection of different signs through photoelectric sensors, and sends them to in and Tl ports of single chip microcomputer in the form of electrical signal pulses. Single-chip microcomputer analyzes, calculates and processes the sent signals, outputs signals from Pl. 1 port, and controls the speed of motor, thus adjusting the running speed of electric vehicle. After the electric car returns to the starting point, it immediately outputs data from the serial port of the single chip microcomputer, showing the distance traveled and the time spent. In addition, the data output by single chip microcomputer from port Pl.7 is sent to the hand-held receiving system at the designated position by infrared, and the hand-held receiving system is also processed by single chip microcomputer, so that we can know the driving time and position of electric vehicles at any time. The keyboard is convenient for setting parameters during debugging, which makes the speed and position of the car more accurate.

Hardware principle analysis and design

Because the runway is white, there are black lines in some designated areas. According to the absorption and reflection characteristics of color to light, the conduction state of light receiving tubes in black and white areas is different. When the car runs on the designated runway, the reflective photoelectric detector attached to the bottom of the car will have different reactions. A photoelectric sensor is attached to the front end of the trolley to collect the data in the line area and convert the changed optical signal into an electrical signal. The signal is shaped by Schmidt trigger circuit and sent to the interrupt terminal (INTO) of single chip microcomputer. A piece of white paper is attached to the rear wheel of the car, and a photoelectric sensor is attached to the wheel frame to collect the revolutions of the wheel and send them to the counter port (Tl). After being processed by a single chip microcomputer, the steering and pulse width of the motor are controlled by P 1.0 and P 1. 1 respectively, and the vehicle display shows the number of signs passing through the ground during operation. After the car stops, the time and mileage of the whole journey are displayed. The display part is provided with two buttons, one is used to restart the single chip microcomputer, and the other is used to turn pages to check various parameters in the running process of the car. In the hand-held display part, the integrated infrared receiver sends serial data to the single chip microcomputer, and the mileage and running time of the designated position are displayed by analog serial communication in the software.

1. The data acquisition part can use the sensitivity of infrared reflective detector to black or white to complete data acquisition. The diagram above is the schematic diagram of the data acquisition circuit. In the figure, the +0 and 2 terminals of 65438 are light emitting terminals, and the 3 and 4 terminals are light receiving terminals. When the photoelectric reflector moves on the black-and-white surface, varying pulse voltages are obtained at four terminals. After comprehensively comparing different dielectric materials, we choose the data of photoelectric reflector 0.5cm from the ground as the benchmark, and this voltage is shaped by Schmidt circuit to get a TTL level, which is sent to the single chip microcomputer.

We use NE555 timer to form Schmidt circuit, and the hysteresis characteristics of input and output are shown in the above figure. When the voltage changes from low to high: 0 < vi < l/3vcc, Vo = "1": l/3vcc < vi < 2/3vcc, Vo remains unchanged; Vi > 2/3vcc, Vo goes to "0". When the voltage changes from high to low: 2/3vcc < VI < VCC, Vo = "0L/3vcc < VI < 2/3vcc, VO remains unchanged; Vi < 1/3vcc, Vo flipped to "l". When the input low level ViH is 0.49V, the high level VIH is 4. 19V, and the pressure difference is 3.70V If Vcc=5V, there are l/3Vcc= 1.67V and 2/3Vcc=3.33V, which can meet the requirements. However, in order to adapt to the actual situation, different return voltages (1/3VCC) can be obtained by changing the voltage of the fifth pin of NE555 with a variable reference voltage. The larger the voltage, the stronger the anti-interference ability of the circuit, but the lower the trigger sensitivity. Considering comprehensively, let's assume that the voltage at pin ⑤ is 3.60V, then l/3Vcc= 1.2V, and 2/3Vcc = 2.4v. Referring to Figure 2, when the photoelectric sensor detects the black line, the fourth terminal voltage is at a high level of 4. 19V, the second pin of NE555 is also at a high level, and the third pin outputs ". On the other hand, when it is on white paper, pin ③ of NE555 outputs a high level of "1". The falling edge can trigger the interrupt "0" of AT89C5 1. Similarly, a piece of white paper is attached to the black wheel, and there are high and low levels of changes when it rotates. Trigger the timer T 1 of AT89C5 1 to count, and count the revolutions of the wheels, so as to get the driving speed and distance of the car.

2. Motor speed control The running speed of a car is measured by adding a reflector on the rear wheel. When the wheel rotates, the photoelectric reflector will detect the pulse, calculate the number of revolutions of the wheel with one counter of the single chip microcomputer, and measure the time with another counter. Combined with the values of two counters, the speed of the car is calculated by single chip microcomputer, and the mileage is calculated by the circumference and revolution of the wheel.

In the control part of automobile motor, the system uses the combination of different transistors such as 8050 and 8550 to build a "bridge", which realizes the easy control of driving motor. The motor drive circuit is as follows, and its control process is as follows: Pl.0 is the forward and reverse control terminal, and Pl. 1 is the start-stop control terminal.

(1) When PL.1is at high level: When Pl.0 is at low level, the backward terminal is at low level, and the inverter composed of Q5 1 makes the forward terminal at high level. Then, Q52, Q53 and Q54 are turned on, and Q55, Q56 and Q57 are turned off. Where Q52 is the excitation stage, and Q53 and Q54 are the power amplifier stages. The current flows from +9V to the "+"terminal of the motor through Q53, then to the "-"terminal, and finally through the human body ground terminal of Q54, and the motor rotates forward. When Pl.0 is at high level, otherwise, Q55, Q56 and Q57 are turned on, Q52, Q53 and Q54 are turned off, and the motor is reversed.

(2) When PL. 1 is low level, both "forward" and "reverse" terminals are low level, and the motor stops running.

The advantages of this "bridge" are simple principle, easy control and strong load capacity. With the cooperation of single chip microcomputer, it is easy to adjust the speed of the driving motor by adjusting the pulse width, and the car can adapt to various power sources by modifying the specific parameters of the keyboard. It is precisely because of this technology that the process of completing the basic requirements becomes simple and easy.

In the aspect of speed control, it is generally realized by changing the voltage across the motor, which can be continuous (adding DC voltage) or intermittent (adding pulse voltage). For simplicity and practicality, we adopt pulse width control, and the change of pulse width can be realized by hardware or software. The hardware implementation is to adjust the charging and discharging time by changing the RC parameters in the oscillating circuit; The software method is realized by setting the holding time of high level and low level. Comparatively speaking, the quantitative index of software adjustment is higher and the adjustment is more reliable, convenient and accurate. Therefore, the keyboard has become an indispensable device for human-computer communication.

The pulse frequency will also affect the motor speed. High pulse frequency has good continuity, but poor load capacity, and low frequency is the opposite. Experiments show that the pulse frequency is 15 ~ 20 Hz, and the effect is the best.

Pulse width modulation is essentially to adjust the average power applied to both ends of the motor. Through calculation, it can be found that the speed of the car is directly proportional to the pulse width.

The consideration of software programming is to set the variable of pulse width, and generate a 20Hz square wave with adjustable pulse width at the start-stop control terminal of P 1. 1.

3. The display and keyboard display part adopt unique and innovative software technology, and only three lines are used, namely data line, clock line and input/output control line. By programming the serial port of single chip microcomputer, the serial interface technology between keyboard display and single chip microcomputer is creatively realized. There are only two pieces of 74LS 164 and one piece of 74LS 166 for external hardware. Through this interface, we use eight LED tubes, which can be extended or interfaced with the keyboard. The schematic diagram is shown below.

At the same time, we have another scheme, that is, when the serial port of single chip microcomputer is occupied by other hardware, we can also use only one I/O port to realize the function of analog serial port, which makes the application of hardware more flexible and convenient. This system adopts analog serial port technology to realize data transmission between vehicle-mounted system and handheld display system. This is in line with the principle of "using software to realize hardware as much as possible" pursued in today's era, which greatly reduces the cost of peripheral hardware.

Three-wire serial display/keyboard principle: Three wires are DAT (P3. O)- serial input/output data line, CLK(p 3. 1)- shift clock line and RD(p 3.7)- input/output control line.

When RD is low, it is in display mode, and the data line (DAT) outputs bit code and segment code, one *** 16 bit. After the data is sent, the bit code is stored in U2(74LS 164) and the segment code is stored in Ul(74LS 164), so that a number can be displayed in the specified bit. Using the persistence effect of human vision, a data can be displayed dynamically; When RD is high, it is in keyboard mode. The inverter composed of 90 14 shields the clock signals of UI and U2, but the bit code and segment code are still stored in Ul and U2, so they can still be displayed normally, while the clock pair U3(74LS 166) is still valid. Because the reserved bit code is still in U2, it can be used as the row code of the row and column keyboard. When a key is pressed, the column code is sent to the data line (DAT) through U3. In this way, the single chip microcomputer can determine the keys through the row and column codes.

During normal operation, each number displayed reads one or less codes. Because both the monitor and the keyboard are dynamically scanned, they look continuous. Through RD, keyboard and display can be coordinated, and keys can be read at the same time, making full use of serial port resources.

4. In the infrared data transmission part, a simple modulation scheme is adopted, and the carrier generation is completed by using CD4069 and 38kHz crystal oscillator. At the same time, the transistor 8050 modulates the data signal of the carrier wave, and the modulated signal directly drives the infrared light emitting tube in a keying manner. At the receiving end, the signal passes through the pre-amplifier, limiting amplification, band-pass filtering, detection, integration, Schmidt comparison and other unit circuits in the integrated receiving head, and then the standard TTL level signal is output at the output end, which is directly sent to the Pl.7 port of the single chip microcomputer. The received data is demodulated in the form of software analog serial port and sent to the display part for display. Indoor infrared communication uses line of sight light or reflected light to complete communication. In indoor environment, the attenuation caused by atmospheric and meteorological conditions can be ignored, and the channel attenuation is mainly determined by the geometric structure of the system and the gain of the condenser of the receiver.

The system uses line-of-sight light to complete communication indoors. The experimental results show that the infrared emission power is 63μW, and the optical power of the receiver when receiving data normally is -27dBm, which basically meets the requirements of short-distance data transmission.