Automatic positioning system of headlight based on C8051

Publisher:数字小巨人Latest update time:2010-10-21 Source: 电子设计应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The headlight meter is a special testing device used to test headlights. It is mainly composed of two parts: the automatic positioning system and the testing system. After receiving the testing command, it can automatically enter the lighting area of ​​the tested headlight to track the optical axis, and then automatically detect the luminous intensity, height, and the irradiation direction of the high and low beams of the tested headlight. It can also automatically measure the headlights of the four-lamp system or the two-lamp system. After the test is completed, it automatically returns to the initial position and the test results are automatically sent out.

The design idea of ​​this system is to amplify the light intensity signal sensed by the headlight meter at different positions during the movement through the light sensing device, obtain the corresponding control signal through the appropriate control algorithm, and then output this control signal to the motor, so that the headlight meter is positioned at the appropriate detection position through the motor, thereby completing the automatic positioning of the headlight meter. The hardware structure block diagram of the headlight meter is shown in Figure 1.


Figure 1 Headlight instrument hardware structure diagram


Figure 2 Ambient light compensation circuit


Figure 3 Photodiode amplifier circuit

Hardware Design

The hardware part of the entire automatic positioning system mainly includes the column photosensitive part, PSD photosensitive part, DC brushless motor drive part, sensor part, communication part, LED display part and logic circuit part. The coordination and data transmission of each part are completed by the main microcontroller C8051F020. The main microcontroller is the core of the system. On the one hand, it is responsible for completing the data collection and processing during the movement of the headlight instrument, and on the other hand, it must pass the processing results to the corresponding control motor for corresponding position adjustment. Therefore, there are high requirements for the operating speed and interface functions of the processor.

Column photosensitive part

The column of the headlight instrument has 8 photodiodes evenly distributed in the direction perpendicular to the ground. After the headlight instrument starts and enters the lighting area, the photodiode converts the sensed light into an electrical signal, and then sends these 8 electrical signals to the ADC of C8051F020 for sampling after amplification. C8051F020 integrates two multi-channel ADC subsystems. Since this part does not require high data accuracy, an 8-bit ADC1 system is selected to convert 8 electrical signals using a single-ended input method.

Figure 2 is an ambient light voltage compensation circuit. This circuit uses a photodiode placed under ambient light to generate different reference voltages Verf according to the intensity of the external ambient light, and serves as the reverse voltage reference compensation of the photodiode amplifier circuit on the column. Figure 3 is an amplifier circuit diagram of a pair of photodiodes. The actual magnification can be adjusted by adjusting the resistance values ​​of R3 (R7) and R2 (R6) according to the performance of the photodiode used.

PSD photosensitive part

The PSD sensor is used to accurately locate the center of the headlight. This sensor is a photoelectric position sensitive element based on the lateral photoelectric effect. When the incident light point falls on different positions on the photosensitive surface of the device, the PSD will output different electrical signals accordingly. By processing the output signal, the position of the incident light point on the PSD device can be determined. The intensity and size of the incident light point are independent of the position output signal of the PSD. At the same time, since the PSD is a non-divided element, there is no strict requirement for the shape of the light spot, so the position of the light spot can be continuously measured to obtain a continuous coordinate signal.

The headlamp light passes through the Fresnel lens of the headlight head and is projected onto the condenser at the rear of the light box. There is a small hole at the appropriate position of the condenser. The light passes through the small hole and is focused into a light spot. This light spot shines on the PSD surface and outputs electrical signals of different strengths. The operational amplifier TLC2272 is used to amplify these 4 electrical signals in two stages in phase and then send them to the 12-bit ADC0 for conversion. It should be noted that the amplified voltage value should not exceed the reference voltage of C8051F020 to avoid voltage saturation.

DC brushless motor drive part

Controlling the left and right and up and down movement of the headlight is achieved by driving two DC brushless motors (one vertical and one horizontal). The system periodically samples the feedback signal voltage, and the sampled value is processed by digital signal as the parameter of the controller. Finally, the control quantity is obtained by the appropriate control algorithm, and converted into the control voltage of the DC brushless motor by DAC to adjust the motor speed.

Sensor part

The headlight instrument uses an incremental photoelectric encoder as a feedback element for the motor rotation direction and speed. It is a sensor that converts the mechanical geometric displacement on the output shaft into pulses or digital quantities through photoelectric conversion. Depending on the rotation of the component, the photoelectric encoder generates an electrical pulse signal and sends it to the single-chip microcomputer for processing. The incremental photoelectric encoder has three-phase pulse signal outputs A, B, and Z. When rotating forward, the A-phase pulse leads the B-phase pulse by 90° (or 1/4 cycle); when reversing, the B-phase pulse leads the A-phase pulse by 90°. In this design, the A-phase pulse is used to trigger an external interrupt, and then the rotation direction of the motor is determined according to the level of the B-phase pulse, and the number of encoder pulses is recorded at the same time.

The communication part

C8051F020 has two enhanced UART serial ports, of which UART0 is connected to the RS-232 serial port of the PC to receive detection commands and send detection results; UART1 is connected to the communication serial port of the headlight instrument detection device, and the corresponding detection items are started according to the received PC detection command, and then the results are returned to the main microcontroller.

I2C bus LED display part

SAA1064 is a 4-bit LED driver from Philips. It is a bipolar circuit with an I2C interface and is designed to drive a 4-bit seven-segment LED display with a decimal point. The device has an I2C bus slave transmitter and receiver inside, which can be programmed to 4 different slave device addresses through the input level of the address pin ADR. Two SAA1064 drivers are used in this system.

Logic circuit part

Logic circuits are indispensable in the design of single-chip microcomputer systems. General logic circuits use general logic ICs (such as the 74 series) to build circuits. The more complex the system, the more complex the corresponding logic circuits, and the more logic ICs are required. However, if a programmable logic device is used to implement it, as long as the logic expression is described according to the specified syntax, after simulation, compilation and other processes, and finally downloaded to the programmable logic device, the designed logic function can be completed, thereby greatly improving the freedom of logic design.

In this system, Xilinx's CPLD programmable logic device XC9572 is used. The device contains 36 macro units and has 1600 logic gates. The development environment uses Xilinx's software toolkit FOUNDATION ISE7.1i. The design process is as follows: First, describe the circuit's functions, interfaces, and overall structure from an abstract perspective. Next, use behavioral level description to analyze the circuit's functions, performance, standard compatibility, and other issues. The behavioral level description is written in VHDL language, and the logic circuit design of the motor control module, encoder count control module, and travel limit switch control module are implemented respectively. Finally, through CPLD decoding, the command control I/O is mapped to the corresponding independent address. Taking the motor control module as an example, the six control quantities of the two motors, namely, enable, brake, and turn, only need to operate on the corresponding bits of their mapped addresses.

Software Design

The uC/OS-II operating system is used in the software design of this system. The latest KEIL7.50 integrated development environment is selected to develop the program. By embedding uC/OS-II in the system, the entire program can be divided into many tasks, each of which is relatively independent. Even if a task has a problem, it will not affect the operation of other tasks. This not only improves the reliability of the system, but also makes it easier to debug the program. Task

Creation

According to the goals to be achieved at different stages in the headlight positioning process, the software design is divided into main tasks, automatic test tasks, position control tasks, column light finding tasks, PSD light finding tasks, PC communication tasks, detection communication tasks, motor braking tasks and I2C display tasks.

Each task has its own name, memory space and priority. The priority setting varies according to different systems. In this design, the motor braking task plays a role in protecting the equipment in the system. If the motor cannot be braked in time in the event of control failure, it may cause damage to the headlight instrument, so its priority is set to the highest; PSD light finding task and column light finding task are relatively frequent, and the quality of task execution is directly related to the accuracy of the detection results. The priority is set to the second and third levels respectively; the remaining tasks are all in the normal operation state, just to achieve human-computer interaction, display status and parameters, and have no direct impact on the detection performance. There is no strict high and low priority setting, and it can be set at will.

Analysis of system operation process

The first link of system operation is initialization, which includes two parts: the first part is the initialization of the system and hardware parts, creating the main task; the second part is to create semaphores and establish functional tasks, and assign priorities to them. After

the system is initialized, it starts running from the main task first, and all functional tasks are in a ready state at this time. After power-on, the test personnel send the detection command on the PC. At this time, the first functional task to respond is the PC communication task. The system uses interrupts to receive instructions from the PC and sends a mark to start automatic detection according to the content of the instruction. The main task wakes up the automatic detection task after receiving the automatic detection mark, and sends a display signal to wake up the I2C display task. After entering the automatic detection task, the system calls different functional tasks at different detection stages according to the detection process. After the detection project is completed, the headlight instrument automatically returns to the starting position and waits for the next detection command.

Conclusion

The headlight automatic positioning system in this paper makes full use of the superior performance of the C8051F020 single-chip microcomputer, so that the control system is well integrated and the design cost is reduced. At the same time, practice shows that the use of the C/OS-II real-time operating system in motion control systems with complex systems, strict requirements on real-time performance and accuracy, and requiring more parallel processing tasks will speed up the development of embedded control systems, reduce the complexity of software writing, improve product development efficiency, and make maintenance and function expansion very convenient. The actual operation of the system for half a month at a certain automobile inspection station in Shandong has proved that the system has accurate light positioning, fast response speed, and good operation.

Reference address:Automatic positioning system of headlight based on C8051

Previous article:Application of Virtual SPI in Communication between XF-S4240 and MCS51
Next article:Research on the Sun Automatic Tracking System Based on Single Chip Microcomputer

Recommended ReadingLatest update time:2024-11-16 20:51

Multi-task watchdog design for uC/OS-II system
In embedded systems, a common method to improve the reliability and security of microcomputer systems is to use a "watchdog". Watchdogs are divided into hardware watchdogs and software watchdogs. Hardware watchdogs use a "watchdog" circuit to constrain the running time of microcomputer tasks, i.e., "feeding the dog", t
[Microcontroller]
Design of a signal acquisition system using ARM7+UC/OS-II
In some industrial sites, equipment is prone to failure after long-term operation. In order to monitor these devices, data acquisition devices are usually used to collect data from them during operation and send them to the PC. The data is analyzed by specific software running on the PC to determine the status of th
[Microcontroller]
Design of a signal acquisition system using ARM7+UC/OS-II
Transplantation and Implementation of uC/OS-II on ARM System
0 Preface When developing embedded systems, embedded development platforms based on ARM and uC/OS-II are generally chosen because ARM microprocessors have the advantages of fast processing speed, ultra-low power consumption, low price, and wide application prospects . After porting uC/OS-II to the ARM system, the ad
[Microcontroller]
Transplantation and Implementation of uC/OS-II on ARM System
Design of network electric energy meter based on GPRS communication and uC/OS-ii
  With the development of technology, the meter reading method has also changed from on-site manual meter reading to remote automatic meter reading. At present, there are many technologies used for meter reading, such as RS 485 bus, infrared and power line carrier, etc. These meter reading technologies are relatively
[Microcontroller]
Design of network electric energy meter based on GPRS communication and uC/OS-ii
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号