Development of CAN Network With Improved Parameters for Adaptive Car Front Lighting System

An analysis of implementation principles and algorithms of the adaptive car front-lighting system (AFS) and control methods is carried out. The AFS was adopted by the UNECE in 2007 as the rules for arranging front-lighting systems of vehicles when driving in the dark. Among the known algorithms of AFS operation, a preliminary inspection algorithm is chosen, based on the features of the driver's observation of the road in front of the vehicle, taking into account the characteristics of his vision. The requirements of the algorithm for the control system are analyzed. Control methods using Arduino controllers and computer network are considered. Given the capabilities of network technologies, the CAN network (Controller Area Network) is chosen to ensure the quality of control. It is recommended to use the CAN network option with a length of 40 or 100 m and a speed of 1,000, 500 kbit/s, respectively. Network performance parameters are calculated: speed, error probabilities, performance dependence on load, size of commands and duration of transmission, and compliance with AFS requirements. It is proposed to improve the network arbitration algorithm by increasing the probability of transmission of low-priority commands at high load. The AFS developed on the basis of the CAN network allows creating comfortable conditions for the driver in the dark, preventing accidents, and ensuring traffic safety.<br><br>An analysis of the AFS operation shows that it is directly related to the operation of most of the main components of the car, namely: engine, steering, gearbox, brakes, accelerometer, etc. It is operated under the driver’s control. Therefore, this system can have extended functions, serve as the basis for the safety system and vehicle control system as a whole.


Introduction
The problem of adaptive lighting arose with the advent of the automotive industry. During night driving, the driver of the vehicle must see the road. If the vehicle turns from the main road, the direction of the headlamps does not coincide with the direction of the side road and does not illuminate it. The driver has to drive in the dark. Obstacles or pedestrians may cause an accident. To ensure visibility, cars were equipped with swiveling headlamps, which can be turned, as a rule, manually. When driving fast on a winding road, the driver is unable to control the position of the headlamps and has to reduce speed, but this does not help much. There are still unlit areas of the road.
The other side is dazzling of road users moving in the opposite direction: drivers, bicyclists, pedestrians. To ensure visibility of the road, vehicles are equipped with headlamps with intense light sources. Instead of incandescent lamps, halogen, xenon, LED and even laser lamps are installed. Their brightness is much greater than in incandescent lamps and leads to dazzling of road users. To prevent this, low beam headlamps are installed on vehicles. In front of oncoming vehicles, the driver switches the high beam to the low beam. Switching the headlamps distracts him from the main job of driving the vehicle and reduces the visibility of the road.
There are different requirements for the system of vehicle lighting under different motorway conditions. For example, when driving around the city with speeds up to 50 km/h and heavy traffic, the light range is small, and the light beam is wide and provides lighting of the roadway and roadside, pedestrians passing on the sidewalk. In the case of high-speed driving on a motorway, on the contrary, headlamps should illuminate the road far ahead of the vehicle and their beam is narrow [1]. There are other requirements for lighting when driving on a country road.
In adverse weather conditions, other requirements apply to the lighting system. Fog and rain scatter the light of headlamps, especially the bright white-blue headlamps. Scattered light dazzles the driver and does not allow him to see objects on the road. To avoid this, fog lamps with a light spectrum shifted to the long-wave region, such as yellow headlamps, are used. Dazzling can also be prevented by placing headlamps below the main ones, their light spreads over the road and does not illuminate raindrops.
If the vehicle moves on a road that has slopes and descents, the car's headlamps rise on the descent, illuminate the next ascent and do not illuminate the near area of the road. On the ascent, the direction of the headlamps goes down and does not allow the driver to see the obstacles that come in front of the vehicle. Additional inconveniences occur when driving on a poor, uneven road. The vehicle oscillates about the longitudinal axis, the headlamps move up and down and flashing occurs in front of the driver's eyes. To improve visibility, vehicles are equipped with gyrostabilizers of headlamp position, which eliminate oscillations of headlamps relative to the road and flashing, take into account descents and ascents of the road, as well as vehicle loading. If vehicles are loaded unevenly, for example, the rear seat of the car accommodates passengers, the trunk is loaded, the longitudinal axis is deflected and the headlamps rise up.
The considered and other similar problems with vehicle headlamps were tried to be solved by various technical means, but there was no effective solution. The situation has changed since the 1990s. The development of electronics, microprocessor technology and computers made it possible to develop an adaptive lighting system. The adaptive lighting system is an electronic intelligent system that controls the operation of vehicle lighting devices. Lighting devices, namely headlamps, are made in the form of mechanotronic modules, usually with an electric drive and controllers. Traffic and road condition sensors and a computer are installed in vehicles. Controllers and computer control headlamps. In other words, an adaptive lighting system is installed on the vehicle, which has input devices, a control unit and actuators.
The urgency of research in this area is due to the high accident rate of vehicles in the dark. And with insufficient road lighting, the driver will not be able to make the right decision and prevent an emergency. The adopted AFS standard is aimed at providing high-quality road lighting. It allows for various methods of problem solving. The problem of lighting is related to the dynamics of the vehicle, the need to take into account the speed, turning radii of the road and traffic conditions, weather factors and the human factor. The problem of front-lighting automation and development of an adaptive lighting system is associated with creating comfortable conditions for the driver, ultimately, with the safety of all road users.

Literature review and problem statement
The AFS adaptive front-lighting system is designed to ensure vehicle safety when driving in the dark. The purpose of the AFS system is to provide high-quality road lighting under various traffic conditions. The system was adopted by the UN Economic Commission for Europe (EEC) in 2007 as the rules for the arrangement of the vehicle's front-lighting system, Regulation No. 123 [3]. Ukraine is one of the countries that adopted this regulation without comments. According to the regulation, the AFS operates according to the algorithm for controlling the rotation of the headlamps when driving on a winding road, according to the position of the steering wheel.
In [4], the results of studies of adaptive lighting systems of various types and functional purposes are given, but all of them are called "Adaptive Front-lighting System" (AFS). AFS systems were first installed on large cars, gradually being implemented in all vehicles. Experts from European insurance agencies note that cars with adaptive lighting sys-tems are 40 % less likely to have accidents at night than cars with traditional lighting.
Since the adoption of the rules, the system has evolved and improved. Now, based on various viewpoints of AFS implementation, four categories of algorithms are used [6]: -1 -regulation 123 algorithm, which takes into account the steering angle of the vehicle; -2 -safety algorithm, takes into account the vehicle's braking distance that must be illuminated; -3 -contrast algorithm, based on the illumination of the area, the travel time along which is 3 s; -4 -preliminary inspection algorithm, takes into account the characteristics of the driver's vision, based on determining the distance of focused vision.
The regulation 123 algorithm [3] is the simplest. It establishes an unambiguous relationship between the steering angle and the position of headlamps. Additionally, its implementation takes into account the road holding ability of the vehicle, which prevents changes in light direction in the case of rapid maneuvers during overtaking and changes in light direction on uneven roads.
The safety algorithm provides lighting of the road section sufficient for full braking during cornering, taking into account speed and other vehicle parameters [4].
According to the contrast algorithm, the front lighting system should provide clear lighting of the road turn section in front of the car, which is driven for 3 seconds [4]. This algorithm is considered the most proven and reliable. According to it, the maximum rotation angle of headlamps is 20°.
The preliminary inspection algorithm is a modern algorithm that is widely implemented. It is developed on the basis of the contrast algorithm and based on studying the functioning of the driver's eyes, namely determining the distance of focused view [5,6]. High-quality road lighting should be provided at a distance of focused vision.
The purpose of the AFS system is to provide high-quality road lighting under various traffic conditions, but the methods of information support of the system are not considered.
The AFS is implemented by a number of measures, the main of which is headlamp control. In [7], the use of a system of Arduino controllers and special headlamps with separate sections of 4 or more lamps was proposed to control the AFS. It does not have an electromechanical drive and computer. The system is based on switching lamps and pulse-width control (PWC) of light brightness. The controllers control headlamps and connection between the steering wheel and the right and left headlamps of the vehicle. Control is performed by switching lamps and adjusting their brightness at 16 levels. The control algorithm is programmed in the Arduino system. The authors [7] claim that the proposed system is more efficient than a system with a CAN network and a mechanical drive. The advantages are speed and lower power consumption. According to the authors, the system works more quickly and provides the necessary distribution of light flux and high-quality road lighting.
The authors of [5] note that the electromechanical drive has a delay of 40 ms, and the delay of signals in the CAN network, leading to the fact that the AFS at the road turns lags behind the turning angle of the vehicle. Strategies and methods that used an electric drive system to control the rotation of headlamps did not solve the problem, as the turning angle of headlamps in real time lags behind the driver's intentions. As a result, the system does not meet the requirements of active vehicle safety. The authors point out that accidents can be avoided if the driver is informed about the road curves and this is taken into account by the control system. A system is proposed that takes into account satellite orientation readings according to the electronic road map. It calculates the vehicle's turning radius, taking into account the vehicle's characteristics, road profile, speed and steering wheel position. A vehicle in a turn is considered to be a two-link system, the wheel pairs of which move along curves of different radii. This allows predicting the vehicle's movement on the turn and illuminating the necessary sections of the road. The authors believe that AFS implementation needs hightech equipment. The problem of AFS control is not solved by a pre-set algorithm [5].
The operation of computer networks in the control system is significantly different from the operation of the electrical network. In the electrical network, transmitted signals cause a clear change in the initial values. Computer networks are much more complex. They transmit data packets (frames in the CAN network), i. e. information. Data frames are distributed along the network, received by nodes, processed and, depending on the specific situation, certain actions are performed. The performance of this system is much lower, but its advantages are that it depends on the specific situation and therefore is more efficient.
Considering the characteristics of network technologies, it should be noted that there is no unambiguous relationship between network performance and data transfer rate. The frame transmission time is affected by the following factors: -frame size; -network load; -network conflicts; -time delays before transmission; -corruption and retransmission of files. An important network feature of performance. Network performance is the ratio of the actual transmission rate V(k) to the maximum possible V G [6].
Performance is determined by the method of network access. The classic, simplest ALOHA access method was used in the first computer networks [8]. The point is that data transfer can be started by any user as soon as he needs. Broadcast transmission is performed: all nodes sense the network, and those receive that need the frame to work. The maximum performance of the ALOHA network is 17 % at a load of k=0.5. Low performance is due to the fact that the network is not sensed and, in the case of simultaneous transmission, a conflict (collision) occurs, resulting in mutually damaged frames. Time is lost for retransmission, performance falls. An improvement of the access method is the "discrete ALOHA" method. Transmission can be started only at fixed points of time. The increase in performance is due to the transmission of the next frame after the set time interval [8]. Network sensing methods have even greater performance. The most popular are local Ethernet networks, which use the CSMA/CD access method (carrier sense multiple access with collision detection). In this network, collisions are resolved by destroying the frames that have started to be transmitted simultaneously and retransmitting them with a random delay.
The local network also includes the CAN network. It was created by BOSCH specifically for cars to replace the wiring system. Now CAN is used to control the operation of almost all car units [1] and in various fields of technology [9,10].
This network, along with Arduino, is used to control the AFS. However, as can be seen from [4,5], there are different opinions regarding the use of the CAN network for the AFS system. Therefore, it is necessary to make a detailed analysis of its work.
The CAN network is a numerical network of two conductors that form a twisted pair. According to the standard [3], the first conductor is black-brown CAN High, the second -orange-red, CAN Low. The CAN network protocol was developed by Robert Bosch GmbH based on physical and channel layer protocols of the standard Internet model. There are several types of buses that operate at different speeds and have different lengths. Consider the two fastest types of networks, namely: λ 1 : with a speed of v 1 =1 Mbit/s and a length of L 1 =40 m; and λ 2 : with a speed of v 2 =500 kbit/s, L 2 =100 m.
Vehicles have quite significant electromagnetic interference created by electrical equipment placed in a closed metal housing. To reduce the effect of interference in the CAN bus, a differential operation system is used. The signal is the difference between the potentials of two network wires. At the physical level, signals are generated as follows. At rest, the voltage of both CAN High and CAN Low wires is the same +2.5 V. This state is called "recessive", corresponding to the bit value of "1". The "dominant" state can be created by any node. The voltage on the High wire increases by 1 V, on the low wire -decreases. The voltage difference of 1.5-3.5 V is perceived as the value of the dominant bit, "0". The CAN bus is a reliable, noise-proof system that can operate even at an external voltage of up to 150 V [11]. The connection circuit of vehicle nodes and CAN bus is given in [6].
All devices connected to the network are considered as its nodes W1, W2,…, Wn. Each node includes: a transceiver, a CAN network controller and an actuator. The transceiver constantly senses the network and monitors every bit in the network. The controller analyzes the signals in the network, processes the received data and transmits a command to the actuator. The network uses packet data transmission. An information packet (frame) is transmitted to the network and received by the nodes that need it. The structure of the data frame is shown in Fig. 1.
The beginning of the frame contains 1 bit and the end of the frame -7 recessive bits in a row. There are two standard sizes of the arbitration field ( Fig. 1) -11 or 29 bits. The control field -18 bits, the data field -8 bytes (64 information bits), the cyclic redundancy check CRC field (15 bits), and the end of the frame -7 consecutive recessive bits [12].  Depending on architecture, the network can work with a master node that controls the data transmission, or when all nodes are equal.
The access method is similar to CSMA/CD with the difference that in the event of a collision, the transmitted frames are not destroyed, and one of them continues to be transmitted, which is a priority. Nodes do not have an address and broadcast transmission is performed. All nodes sense the network, and only those nodes receive information that need it. Any node can start transmission when the network is free. Fig. 2 shows the start of information transmission by two nodes n and m simultaneously. If the bits in the arbitration field of both nodes match, they transmit information. At the moment when the bits are different, the dominant bit "0" interrupts the weaker recessive "1". Because the nodes sense the network, the node that notices that the bit in the network is different from the one transmitted by it stops transmitting. Then only the node whose data bit was given priority continues transmission. In Fig. 2, the priority is node n. Node m stops transmitting information, in the case of Fig. 2, after the fifth bit. It can start again after the network is released. The content and importance of each information frame are encoded in the arbitration field. The information frame is considered more important, whose code in the arbitration field has a smaller numerical value. This ensures the transmission of more important information. Neither time nor information is lost. Arbitration imposes restrictions on the speed of the CAN network. It is limited by the requirement to receive and process each information bit by any node. During arbitration, a response to each bit of transmitted information must be obtained from the node that started the transmission simultaneously. This node is considered the most remote. The arbitration method (network access method) also imposes restrictions on the network length and performance requirements of the electronic devices used.
The literature review shows that the problem of AFS implementation is related to the safety of road users and is solved by various methods. High-quality lighting is provided by efficient light sources, automatic control of light flux distribution and other methods. The problem has two aspects. On the one hand, it is the choice of AFS operation algorithm and efficiency criteria. On the other hand, it is the choice of the AFS control method.
There are a number of AFS operation algorithms used by various car manufacturers. The main ones are discussed above. The task of the study is to choose the most effective.
The second part of the problem is to ensure AFS control in accordance with the algorithm, tasks and performance criteria. System adaptability is an important issue, i. e. the control system should be quite flexible and control the AFS under different traffic conditions, in different areas, depending on weather conditions, road parameters, traffic intensity, speed and turning radius in a rapidly changing dynamic environment.
To control the AFS operation, it is proposed to use two different systems, namely controllers like Arduino and local computer network. The advantage of the controller system is speed. In a few microseconds, such a system can perform almost any task according to a given algorithm. The computer network lags far behind in this regard. It transmits commands that contain many characters. Transmission of commands takes rather long time. The network usually has several nodes. Each node can transmit information (frames). These frames can coincide in time, collide and mutually destroy (collisions). This takes time and the system is rather slow.
Given the above, it is necessary to get answers to two questions: the feasibility of using a certain operation algorithm, as well as selecting a control system and appropriate equipment.

The aim and objectives of the study
The aim of the work is to study and improve control methods and increase the efficiency and reliability of the AFS system, taking into account the existing operating algorithms and ensure traffic safety in the dark.
To achieve the aim, the following objectives are set: -to evaluate the known AFS control algorithms and analyze the requirements they impose on the control system depending on: traffic conditions, speed and turning radii of the road, traffic intensity, road conditions, weather conditions, etc.; -to explore the capabilities of the control system based on Arduino and local computer network to perform control tasks in full, compare them, make a choice between a system of controllers or a network and its specific option; -in case of choosing the local CAN network as AFS control means, to analyze the transmission of commands, network reliability, probability of errors and method to eliminate them, to develop methods of improving network parameters and ensuring reliability; -to study the AFS operation with a specific option of the control system, joint operation of such system as an integral part of the vehicle traffic safety system, a component of the vehicle control system.

Analysis of requirements of AFS algorithms for the control system
As shown by the literature review, modern cars use various algorithms and corresponding criteria of AFS operation. The simplest and most common first 123 algorithm, the main element of which is to ensure that the headlamps turn in accordance with the steering wheel angle of the vehicle. One of the more complex is the preliminary inspection algorithm, which requires monitoring the vehicle speed, changing the light distribution curve of headlamps and changing the an- gle of their position when entering, moving along and coming off a turn. In addition, it is recommended [5] to use the forecast of the road curvature in front of the car, calculated according to the satellite navigation system and take into account different turning radii of the front and rear wheels of the car as for a two-link system. The complexity and cost of the AFS system determine the fact that different systems are installed on cars of different classes, which work according to different algorithms.
Since the aim of the study is to ensure reliable and error-free operation, it is necessary to focus on the known AFS algorithms and the possibility of their implementation in vehicles. From this point of view, control systems based on the CAN network are more promising. This network is now installed on almost every vehicle produced in Europe. The AFS can be implemented on its basis. To fully resolve the issue, it is necessary to determine specific requirements of the AFS to the control system in different traffic conditions. As a basis for the development of the AFS control system, the preliminary inspection algorithm was chosen as the most reasonable and one that provides all the capabilities of other algorithms considered.
The time of the preliminary inspection varies within t=3.5-1.2 s. In [6], the minimum time of preliminary inspection equal to t i =1.2 s was calculated and taken as a basis. During the specified period of time, the headlamps must make a smooth change of the lighting area in front of the vehicle. That is, the angle of the headlamps must be changed by steps that ensure visibility of the road during the turn. Studies on the use of the Arduino system [7] show that to ensure high-quality lighting, it is enough to change the light distribution by 16 steps. Based on this, we assume that the control system must change the angle of headlamps up to 20 times during the period of changing the point of focused view t i =1.2 s. So, during the vehicle movement, the minimum time interval of control commands is t 1 =60 ms. The use of electromechanical headlamp control modules in the AFS requires 40 ms. Therefore, the duration of preparing and transmitting a command should not exceed 20 ms. The command rate is V=17 per second.
According to Table 1, the distance of the preliminary inspection varies within 9.6-10.1 m. At the selected time interval, the angle of headlamps changes every 0.5 m of the path. The obtained data are taken as a basis for calculating the load of the CAN network and conditions of its use to control the AFS.
Thus, it is found that the control system should provide control commands to headlamps with an interval of not more than 20 ms. The command rate is 17 per second. These requirements are not strict and almost any electronic system can meet them. But to ensure the AFS operation, it is still necessary to take into account the operation of a number of network nodes that contain sensors that capture and process information about vehicle speed, current position of headlamps, road condition, etc., devices that process data and transmit control commands to the electromechanical drive of headlamps. In addition, the CAN network provides control over the operation of all components of the vehicle and it must have resources to control the AFS.

Research of control system operation and development of CAN network with improved parameters for adaptive car front-lighting system
First of all, the features of the Arduino system are considered. The use of Arduino controllers to control the system is limited by the fact that it transmits signals only to switch on and off certain lamps. Control commands are transmitted according to pre-set algorithms. However, the analysis shows that the operation of the AFS requires the coordinated operation of a number of vehicle mechanisms: steering wheel, engine, accelerator, turn signals, etc. Implementing these requirements with the Arduino system is quite difficult and sometimes impossible. It transmits only commands at the level of electrical signals, while the AFS operation requires consistent, intelligent control over the vehicle devices. The source [5] recommends to use the data of the satellite information system to improve AFS performance, and Arduino is not intended to work with such systems. The Arduino system is a system that works according to a set algorithm. As the AFS is an adaptive system that must work according to the specific situation during traffic, Arduino cannot be recommended as the main control system of the AFS.
It should be noted that the Arduino system is cheaper and easier to implement. Therefore, it can be used in some types of cars, for example in operation according to the 123 algorithm.
In view of the above, a local computer network of vehicles is needed, which can provide control at a higher level, when it is necessary to solve control problems not following a pre-set algorithm, but based on the specific situation at the moment.
When considering the use of a computer network, as noted above, it is important to consider the speed and time of transmitting control commands. Computer networks work at different levels: bits, data packets and commands, so to ensure efficiency, the network should work at these levels. Fig. 3 shows a diagram of information bit transmission in the CAN network. Networks with a length of 40 and 100 m with speeds of 1 Mbit/s and 500 kbit/s were selected for analysis. Network arbitration is performed as follows. Two nodes 1 and 2 started working simultaneously (calculation was made for the most remote nodes). The transmitted bit from node 1 moves to node 2 over time t c with the electromagnetic velocity c. The transceiver and the comparator of node 2 receive the signal, spending time t p on reception and t k on processing by the comparator and transmit the information bit to the network (or stop working, following the rules of arbitration). The bit transmitted over the network comes to node 1 at time t c . Node 1 processes it and only then transmits the next bit (following the rules of arbitration). Thus, the duration of transmission of the information bit is equal to twice the response time of the transceiver, comparator and the time of signal transmission over on the network. Accordingly, the network speed v satisfies the condition: where T b is the processing time of the information bit in the network; v is the network speed, bit/s. According to the calculations given in [5], a bit of information passes in the 40 m network for 0.133 microseconds in one direction, and taking into account the decrease in the electromagnetic velocity in the network wires t c ≈0.16 μs. At network speed v=1 Mbit/s, bit processing time T b =1 μs. According to condition (4), the electronic means -transceiver and comparator -must process a bit of information for a time of not more than 0.16 μs each. The network equipment has quite high requirements.
Modern electronic devices allow implementing the network. In the case of a 100 m network with a speed of 500 kbit/s, the requirements for electronic equipment are twice less. For slower networks, equipment requirements are much lower.
CAN network performance. The maximum frame rate V G depends on network speed and frame size. The structure of the frame is shown in Fig. 1. Since there are two options for networks: with an 11-bit and 29-bit arbitration field, the frame length is G=135 bits (Fig. 1). The maximum frame rate and transmission time T G are equal to: For a 40 m network: T G1 =0.135 ms, and for a 100 m network: T G2 =0.270 ms.
The method of access to the CAN network is close to CSMA/CD in the Ethernet network, but conflicts in the network are resolved differently. If the transmission is started simultaneously by several nodes, the transmission of one of the frames of a higher priority continues (Fig. 2). Time is not lost and network performance is theoretically about 100 % (taking into account the time interval between frames). If the network load is close to one (k≈1), low-priority frames will be delayed or not transmitted at all. To prevent this in the access method, it is recommended: a) to use underloaded networks; b) after frame transmission and beginning of the next, to set a delay for some time; c) to supplement the protocol with guaranteed transmission of a low-priority frame in case of a number of unsuccessful transmission attempts.
Option a. Implemented when the network load is about k≤0.8.
Option b. A delay is set, i. e. a certain inter-frame period during the transmission of several tens of bits. During this period, network access is random for any frame. Out of the frame period, the usual arbitration for the CAN network is resumed. If such a protocol is adopted, lower-priority frames are likely to pass, but network performance is somewhat reduced. If the waiting time has a normal distribution and the average waiting time of 0.1 frame duration and the variance of 0.1 frame length are taken, network performance can be calculated according to the formula: The results of the network performance calculation are shown in the graph (Fig. 4, c). Fig. 4, a, b shows the comparison of the performance of the network with collisions, characteristic of ALOHA, calculated according to the Poisson distribution for k=1: Fig. 4 shows the relative network load on the y-axis, and the network load on the x-axis, i. e. the number of attempts to access the network over the duration of one frame. Option c. Guaranteed transmission of a low-priority frame in the case of many unsuccessful attempts is provided as follows. After each unsuccessful attempt, a bit of information is entered into the node's memory, for example, according to the logarithmic law. 1 2, 4, 8, 16, 32. After the sixth bit, the node transmits 6 (or 7) dominant bits to the free network and immediately transmits its packet. Other nodes cannot interrupt such a packet and perceive it as the end of the frame. They can interrupt the transmission of the packet. This ensures the transmission of low-priority frames, in this case after 32 unsuccessful attempts.
In addition to the impact of conflicts and transmission delays, network performance is affected by frame corruption and retransmission. The physical level standard guarantees a minimum of external impact. The estimated probability of bit transmission error is p Δ1 =10 -4 . Note that the network Based on this, we estimate the probabilities of a correctly transmitted frame of size G bits. This probability is equal to the product of the probabilities of correctly transmitted G bits: For the frame size G=135 bits, we have: The transmitted frame is checked for error by the controller of the receiving node, according to the channel layer protocol of the CAN network. The check is performed by calculating the checksum in the field of the cyclic redundancy check field (CRC) of the frame (Fig. 1). Without going into the details of the method of checking the data transmission in the network according to the cyclic code, the probability of frame transmission error p ΔF is the product of the probabilities p bF during retransmission (more repetitions are theoretically possible) 10 1.82 10 .
In [12], the error probability of data frame transmission in CAN is given, which is equal to р=4.7•10 -11 . The obtained value, with simplifications, is close to the specified one.
Considering the influence of all factors, the frame rate according to the following formula: Accordingly, the number of frames transmitted per unit time can be defined as 1/V(k). When transmitting information and management commands in the network, you need to get confirmation of the results of the actions taken. This is another frame. The command rate calculated according to (4) at a load k=1 is: for 40 m and 100 m networks: V G1 =3,704, V G2 =1,852 command per second. The command exchange time: T K1 =1/3,290 3.04•10 -4 s≈0.3 ms; T K2 =1/1,654=6.05•10 -4 s≈0.6 ms.
The obtained data are the basis for calculating the operation of the CAN network in the AFS system.

1. Features of AFS control using CAN network
As a result of the analysis, it is shown that for efficient AFS control, it is necessary to provide generation and transmission of control commands over a time of 20 ms. If a 500 kbit/s CAN network is selected, it provides a transmission interval t i =1.2 ms, a command rate of 834 commands/s. This is enough for efficient control of the AFS. However, a number of other factors should be considered: -fluctuations in signal reception time; -delay in case of retransmission; -magnitude and impact of the information load of other nodes on the network.
During the operation of the CAN network, it cannot be guaranteed that the frame will be immediately received by the destination node. In [13], it was shown that there are variations in delivery time in the network. They are due to waiting for the start of transmission and possible repetitions of transmission due to interference. The expected delay time is 0.1 frame transmission duration, or 0.06 ms.
The retransmission delay is equal to 0.6 ms frame duration. The error probability of frame retransmission p Δ1 =1.3•10 -5 . So in two attempts, the command will be transmitted. Summing up, it is found that fluctuations in command delivery time will not exceed Δt=0.6+0.12=0.72 ms. The command duration t i =1.2 ms and the total delivery time in the 500 kbit/s network is 2 ms.
The next question is that network congestion is especially important when analyzing the AFS operation and choosing the type of network to ensure its operation. AFS systems are rapidly evolving and becoming more complex. The basic functions of adaptive lighting are: city lighting, county road lighting, highway lighting, low beam, high beam, cornering lighting, lighting in bad weather. These are different modes of operation with different distribution of the light flux of the main and additional headlamps, which should work in the speed range of 0-250 km/h [1]. Different companies use data of a whole system of sensors in their cars: wheel turning, speed, road stability, sensors of the current position of headlamps, position of brakes, accelerator, hydraulic pressure, etc. Modern AFS systems also use data obtained from the GPS satellite navigation system, which allows the driver to predict the next turn on the road, as well as video camera readings processed by a computer [2]. Sensors, actuators, computer are connected to the CAN network as nodes: W 1 , W 2 ,…W k [6]. Each node can transmit information to the network. Network load is characterized by the average time interval Т і with which it sends messages to the network. If we take into account that the network has n nodes, the network load is calculated according to the formula: Assume that the network has n=20 nodes. Each node transmits data with the frequency determined for the AFS operation, i. e. with a time interval Т і =60 ms. In this case, the network load according to (12) will be k=0.2. In this case, the network is not fully loaded. The probability of mutual interference is quite small and there is a reserve for its use.

2. Adaptive functions of the integrated AFS -CAN network system. Vehicle safety
In the research of the AFS control system using the CAN network, the main attention was focused on the implementation of algorithms of system functioning. Four considered algorithms of AFS operation [3][4][5][6][7] provide an automatic change of distribution of the light flux of headlamps for one of the considered algorithms: rotation of a steering wheel, maintenance of the set braking distance, algorithm of contrast with road lighting at a distance corresponding to driving time of 3 s and providing lighting of turns, taking into account the distance of the driver's focused vision. In fact, the control system is reduced to the implementation of these algorithms. If we limit ourselves to the analysis of only these issues, the AFS system can only be conditionally considered adaptive. However, the AFS operation is not limited to these algorithms. According to regulation 123, the AFS system must ensure the following functions: -urban low beam; -low and high beam of the highway; -low beam on a wet road; -static lighting of turns; -dynamic lighting of turns; -lighting in bad weather, rain, fog, snowfall; -stabilization of a light flux of headlamps when changing the load of the car, driving with acceleration and overtaking, driving on a rough road, etc.
To perform the considered functions, the AFS must be able to significantly change the distribution of the light flux of headlamps, taking into account adaptation to specific traffic conditions. While driving, the car moves from the highway to the urban environment, performs maneuvers, parking. Other vehicles move towards it, and it is necessary to switch on a low beam. Obstacles arise on the way that need to be quickly responded to. Weather conditions change while driving. Road signs also regulate traffic. Adaptation should be carried out in short periods of time and not distract the driver from driving.
Each AFS function is related to the safety of vehicles and other road users: oncoming vehicles, cyclists, motorcyclists, pedestrians, etc. To prevent accidents, the driver monitors the situation on the road and responds promptly to it. The AFS system should create comfortable conditions for the driver. A system that is able to take into account specific traffic circumstances and the situation on the road at a certain point in time can fully perform its functions. To implement the adaptive properties of the AFS, it is not enough just to follow these algorithms, it must be able to control the situation on the road and make decisions agreed with it.
The AFS functions are implemented by combining with the CAN network into a single system. This provides an expansion of the AFS functionality and creation of a vehicle safety system with adaptive functions. Such a system, depending on the class of the car, may include: video cameras, night vision cameras, radars, ultrasonic parking sensors, position sensors of the steering wheel, headlamps, wheels, rain sensors, controllers of engine, gearbox, brakes, accelerator, belts and airbags and other equipment. In a computer network, all nodes are active and perform actions depending on specific circumstances. The integrated safety system is operated from a single center, such as the vehicle's on-board computer. Given this, the AFS system is integrated and occupies a leading position in the vehicle safety system.
In [5], the option of adaptive operation of the AFS when the system works biasedly on the basis of data of the satellite navigation system and an electronic map is given. In more detail, the operation of such a system is as follows. The signals of the satellite navigation system, having a period f=1 ms, are transmitted to the CAN network. The network transmits these signals to the controller or control microprocessor, which matches them with a digital map of the area and determines the turning radius of the road in front of the vehicle. The driver and the AFS system are prepared to perform a turn and control the operation of the headlamps drive. The AFS functions in a particular situation are performed fully and conveniently for the driver.
The computer network is installed on almost all vehicles of automobile companies in Europe. The AFS system can work with almost all nodes that ensure traffic safety. It is integrated into a single system using the CAN network. If the load of one network is large, vehicles are equipped with several networks for different functional purposes.
The speed of electronic systems is an order of magnitude higher than the driver's response. For example, according to [14,15], the time of fixation of individual objects and events on the road by the driver's eyes, with the possibility of their clear recognition, is approximately 0.1 s. The mechanical reaction of the driver is manifested in 0.2-0.3 s. The total response time of the driver is about 0.3-0.5 s. The vehicle, at a speed of 100 km/h, will travel 15 m during this time. The response of the electronics system and the command rate in the CAN network are about 1 ms. Given the above operating time of electromechanical actuators of 40 ms, it was found that the combined use of the AFS and CAN network significantly improves vehicle safety.
If we consider the AFS as an integral part of the vehicle safety system, it should be taken into account that the time interval of 20 ms is taken as the basis for its operation and submission of control commands. At this time, the position of the vehicle moving at speeds of 30, 60, 120, 240 km/h is tracked every 1 m, 2 m, 4 m, 8 m of the path, respectively. Such a detailed analysis of vehicle traffic on the road is sufficient to ensure traffic safety. The analysis shows that the AFS system contains most of the elements that ensure vehicle safety, it can serve as a basis for building an automatic vehicle safety system. The system itself can warn the driver of an emergency, or take actions to respond to them.

Discussion of the results of AFS operation with CAN network
The main task of the AFS system is to ensure vehicle safety in the dark. According to the recommendations [3], adaptive front-lighting systems (AFS) are installed in vehicles. To control their operation, local computer networks and Arduino-type controller systems are used [7]. The advantage of the Arduino controller system is speed. Computer networks cannot provide such speed due to lengthy communication processes. However, the advantage of computer networks is the ability to respond flexibly to a specific situation. Therefore, there is a problem with which control to choose.
The paper considers the known algorithms of operation of AFS systems and analyzes the requirements they pose to the control system. According to the results of the research of modern algorithms of AFS operation, namely the preliminary inspection algorithm, the control system should provide time to change the position of headlamps when entering the turn of 1.2 s with 20 steps. To do this, in the case of using an electromechanical drive of headlamps, it must generate and transmit commands over the network to the actuator within 20 ms.
The study of the processes of generating control commands and transmitting them using the CAN network is performed on three levels: bits, frames and the commands themselves. The research was performed for networks of different length and speed, in different operation modes and load. The transmission time of the signal through the 40 m CAN network is 0.16 μs, which determines the requirements of the response time of the transceiver and the comparator of the node for 0.18 μs. The command rate of the 100 m and 40 m networks is 1,852/s and 3,704/s. The exchange of commands is carried out for 0.3 ms and 0.6 ms, which allows the AFS to work at a load of k=0.2 and k=0.1. The estimated reliability of the networks provides an error probability of not more than p=1.8•10 -10 , which fully meets the requirements of the AFS system. Networks with speeds of 1,000 and 500 kbit/s, lengths of 100 and 40 m, respectively, meet the AFS requirements, and they load the network by 20 % and 10 %, respectively.
Some disadvantage of the CAN network is the low probability and the ability to completely block the transmission of low-priority commands and in case of a load about more than 90 %. Two methods to solve this problem are proposed. One sets time delays and random network access during the initial period of competition. Another is guaranteed network access after a certain number of unsuccessful attempts. The first method requires changing the exchange protocol and slightly reduces network performance (Fig. 4). The second is implemented by the node controller, by counting the number of access attempts and generating a corresponding packet with dominant bits. Using the proposed methods increases the probability of transmission of low-priority commands.
The paper considers the possibilities of expanding the AFS functions and creating a car safety system based on it. The AFS system works together with the control system of the vehicle in which the CAN network is installed. This provides adaptive properties of the AFS and the change of characteristics according to the traffic conditions at a particular time. The implementation of the integrated safety system is carried out by installing additional high-tech equipment and can be carried out on cars of different classes: from B to F (from subcompact to large).

Conclusions
1. Requirements for the AFS control systems in accordance with the preliminary inspection algorithm are set. According to the driving modes, the distribution of the light flux of headlamps, when entering the turn, should be changed for a time t i =1.2 s. When using electromechanical headlamp control systems, the time intervals and duration of preparation and submission of AFS commands should not exceed 20 ms.
2. For efficient operation of AFS, it is necessary to use computer networks with a speed not lower than 500 kbit/s and a bandwidth of up to 800 commands per second. Using controller systems such as Arduino and others is admissible only in systems operating under the simplified algorithms.
3. The analysis of the features of the CAN network at the physical and channel levels is performed, which allowed determining the time characteristics of transmission of signals and commands by the network. The time of signal transmission through the 40 m CAN network reaches 0.16 μs, which determines the requirements of the response time of the transceiver and comparator of the node of 0.18 μs. The command rate in the 100 m and 40 m networks is 1,852/s and 3,704/s. The exchange of commands is carried out for 0.3 ms and 0.6 ms, which allows the AFS to operate at a load of k=0.2 and k=0.1. Network reliability is sufficient for the AFS, and the probability of errors does not exceed p=1.8•10 -10 . Two methods are proposed to prevent the blocking of transmission of low-priority commands: the method of random access to the network and the method of guaranteed access. The first is to set a short interval of probabilistic access, the second is forced access after a certain number of unsuccessful attempts. This prevents complete blocking of low-priority commands when the network is loaded.
4. Studies of AFS operation with the CAN network are performed. This system provides efficient operation and loads the 500 kbit/s network by 20 % (k=0.2) (respectively for a 1 Mbit/s network: k=0.1). This is completely sufficient for the guaranteed operation of the AFS and makes it possible to expand the functions and create a car safety system based on the AFS, or to include the AFS in the vehicle control system.