Software-Based EDF Message Scheduling on CAN ... - IEEE Xplore

1 downloads 0 Views 985KB Size Report
Software-Based EDF Message Scheduling on CAN Networks. Santiago Fuster, Francisco Rodríguez, Alberto Bonastre. Dept. of Computer Engineering.
Software-Based EDF Message Scheduling on CAN Networks Santiago Fuster, Francisco Rodríguez, Alberto Bonastre Dept. of Computer Engineering Technical University of Valencia Camino de Vera s/n – 46022 Valencia, Spain [email protected], {prodrig, bonastre}@disca.upv.es

Abstract In this paper, a CAN-based communication system has been used to transmit data between different kinds of sensors and the drive control of an electrical vehicle. Software-based Earliest Deadline First (EDF) scheduling has been applied to order the data, making possible that more relevant measures meet with their delivery time and, discarding, if necessary, less relevant ones are discarded. The messages use their time-to-deadline as their priority level. With this mechanism, alongside with the discard of data that has lost its deadline, is it possible to deal with saturated that would require a bus utilization well above 100%

1. Introduction The automotive industry is one of the greatest of our time. The existing number of vehicles at the moment increases vertiginously, an even it is used as a reliable index of the development achieved by a society. Despite the society development, thousands of people die or get injured on traffic accidents annually. For this reason, one of the most profitable research lines, from the economic and social point of view, is the road safety, understanding it as the science that studies the avoidance and reduction of consequences of traffic accidents. Although the control systems have evolved remarkably, allowing an efficient and trustworthy control of vehicles, it is not possible to say the same about the sensorial systems which, in spite of its constant improvement, do not still allow guaranteeing the possibility of a full automatic control of the vehicle.

Within this line, our group, looking for the improvement of the security systems at the vehicles, is working on communication architectures that give support to sensorial systems. These systems generate a huge amount of information, partly redundant, that exceeds the capacity of the communication and processing systems. It is for that reason that some strategy becomes necessary, allowing the management of the communications to obtain a relevance based ordered data transmission. Classically the data is ordered in a static way but in the sensorial systems the relevance of the data depends on diverse factors and changes dynamically. For example, in a set of distance sensors, a natural arrangement of the data would be related to the measured distance or to the variation between consecutive measures (as an indication of the relative speed of an approaching obstacle). Within the dynamic scheduling algorithms EDF (Earliest Deadline First) [1] is one of the most used by its excellent benefits. This algorithm consists in a method of allocation of the dynamic priorities, so that, in run time, greater priority is assigned to the tasks whose deadline is closer to expire and the priority is updated as time goes by. In addition, this algorithm obtains an optimal scheduling when applied to a set of tasks competing for the use of a resource, generally the CPU. In this case, it will be applied to prioritize data to be transmitted through the bus transmission. The work presented here is structured as follows: First there is a description of a previous work with EDF on CAN. The whole system is described in section 3, with a special focus on the sensor and communications system. In the next section the proposed solution is explained. Finally the reader can find the conclusions and future work proposals.

Proceedings of the Second International Conference on Embedded Software and Systems (ICESS’05) 0-7695-2512-1/05 $20.00 © 2005

IEEE

2. Previous work EDF scheduling problem is solved in [2] using a specifically designed CAN controller with the following characteristics: • It provided more than a single transmission buffer. This allowed storing two or more messages ready to be sent into the controller memory, so the highest priority message was always ready for transmission. Even if it had to displace a lower priority message from the controller memory, there was no time interval with the transmission inhibited, which could produce a priority inversion problem [3]. • The controller assigned message priority from the set of messages ready for transmission using the CAN identifier, thus the same priority was used among messages competing for the use of the CAN bus and messages competing internally to be picked up for transmission. • It used two different time units to assign EDF scheduling times. A coarse time grain was used for those messages with a "far" deadline and a fine time grain for those with a "close" deadline. This duality allows the assignment of a wide range of deadline time values using fewer bits than a direct time encoding. It has also a higher quantization error however. • A special encoding of the time-laxity was provided into the CAN id field to allow the existence of background messages with no specified deadline. • The controller was improved with a circuitry devoted to periodically updating the time laxity of all messages stored into the transmission buffers using the dual time granularity. When a coarse-grain encoded deadline reaches a minimum threshold, it was automatically re-encoded to use the fine-grain encoding. 1 1111111

i... ii

Background message, no deadline

1 ccccccc

i... ii

Large deadline, coarse-grain encoded time laxity

0 fffffff

i... ii

Tight deadline, fine-grain encoded time laxity M bits are used to code the message's identifier K bits are used to code the message's laxity time.

Figure 1. Time laxity encoding into the CAN id field The main advantage of this hardware solution was the automatic update of the time laxity of all messages ready for transmission, thus eliminating the CPU overhead. Recognized as the best dynamic priority scheduling, some authors reject the use of EDF in practical situation due to this overhead [4].

As a side benefit, the use of specialized hardware to update the time laxity allows the system designer to select an update frequency much higher than the best update frequency of a software approach. This high frequency update reduces the quantization error produced when discrete time units are used to compute the time laxity. Each transmission buffer 2K Freq. divider Base clock

Freq. divider

IEEE

M U X

Update laxity clock MSB of CAN id

Reset each time the laxity field is written by the CPU

Figure 2. EDF CAN controller automatic update circuitry Despite the fact the EDF CAN controller is an efficient solution to the scheduling problem, it is not, however, a solution for every scenario. When designing a low cost, low power network of sensors, the use of such a solution (at the present day) produces insurmountable drawbacks. As there exists no EDF CAN controller in mass-production, the only viable alternative is the implementation of the controller design using programmable devices (e.g. FieldProgrammable Gate Array or FPGA) with a noticeable increase in price, power requirement and circuit size of the network nodes.

3. System description 3.1. Sensor system To achieve the proposed safety conditions, two sets of sensor devices are proposed. 1. Two laser rangers – such as LMS200 from SICK [5]- installed at the front and rear parts of the vehicle. These sensors activate three digital outputs when an intrusion on three predefined fields occurs. Laser sensors also provide range information of a 180º scan with 0.5º and 1 cm precision via RS422. 2. A ring of 16 ultrasound (US) and 12 infrared (IR) sensors used as medium and short distance protection mechanisms, respectively. US sensors from Polaroid 600-Series [6] are used to detect object presence up to 8m with an opening angular range of 30º. The IR sensors, Sharp GP2D02 [7], transmit distance information up to 70cm. Due to the variety of devices an industrial network has been proposed as a communication link. The CAN bus has been selected because of its unbeatable features, such as non-destructive contention, prioritybased data transmission protocol and robustness.

Proceedings of the Second International Conference on Embedded Software and Systems (ICESS’05) 0-7695-2512-1/05 $20.00 © 2005

Fine-grain clock

Coarse-grain clock

Digital Outputs

A/D Break Node

Steering Wheel D/A Node

RS 422

A/D Accelerator Node

Absolute Encoder Node

x2

Protection mechanism

Monitoring

Torque Node

Steering wheel control loop

16xUS Nodes

12xIR Nodes

Hall Effect Node

Laser Alarm Node

Laser Processor Node

D/A Accelerator Node

Laser Scanner

GPS

RS 232

CAN Field Bus

Speed control loop

Computer

Figure 3. Hardware architecture This vehicle has been automated with an on-board embedded computer connected to sensors and actuators, distributed around the vehicle, through the CAN bus. The hardware architecture is described in Figure 3. An industrial PC computer running RT-Linux OS carries out the control tasks. A low-level software architecture layer receives and transmits data through the CAN bus storing it in specific blackboards [8] The new sensorial system has been applied for sensor fusion, map building, kinematic control, object tracking, obstacle avoidance, etc. In a first stage, all the implemented algorithms are based on well-known techniques. In particular, sensor fusion and map building are based on wavelet and Hough transforms. Vehicle localization and obstacle tracking are based on Kalman filter, were multi-rate techniques have been applied.

is the selected processor for each laser node. The rest of the hardware is specifically designed depending on the type of sensor connected to it. All the CAN nodes use the same CAN transceiver from Philips, the 82c250, to connect the communication controller with the physical media, communicating at 500Kbauds. In Table 1 the workload of the system is described. It can be seen, for every frame type in the system, how many nodes can transmit these kinds of frames, and its maximum total amount in the system per second, being classified by its data bytes. The total number of bytes per second can be obtained from this table, but CAN overload (header, stuffing, etc) must be considered.

3.2. Communications system The hardware architecture is based on CAN field bus as shown in Figure 3, due to the distributed location of sensors and actuators around the vehicle. In particular, CAN nodes have been designed to be connected to different sensors and actuators. An embedded computer is located on the vehicle for navigation and map building tasks. CAN nodes use different processors depending on the complexity of the node task. In particular, the simpler IR and US sensor nodes have been designed around the C8051F041 [9], a Silicon Lab's 8-bit microcontroller from the MCS-51 family. This microcontroller incorporates a CAN 2.0B communication controller from Bosch [10] internally and is capable of executing at 25 MIPS. A 32-bit, 40MHz MPC565 [11], one of the MPC500 RISC family member from Motorola with 3 internal CAN 2.0B controllers (called TouCAN units),

Figure 4. Sensorized electric vehicle With the frame load shown in Table 1, the total required bandwidth would require a minimum bit rate of 2.86 Mbps to be schedulable, which surpasses the standard maximum transmission speed of 1 Mbps.

Proceedings of the Second International Conference on Embedded Software and Systems (ICESS’05) 0-7695-2512-1/05 $20.00 © 2005

IEEE

Table 1. Maximum frame load per second F R A M E CLASS T Y P E SYNC 00 Laser Alarm SUBTOTAL Hall Effect Accelerator D/A Steering Wheel D/A 01 Absolute Encoder Torque SUBTOTAL US IR 10 Laser Processor SUBTOTAL Break A/D 11 Accelerator A/D SUBTOTAL TOTAL

CAN nodes

0

1

Data bytes 2

4 2

200

1 1 1 1 1

100 100 100 100 100

16 12 2

48

1 1

10 10

39

4. Solution

4

200 11 i

568 ...

iii

10 t ... ttt i ... iii

The problem presented above can be partially solved with existing hardware from the laser scanners manufacturer, but we want to go further using the EDF scheduling in the data transmission, and that feature is not implemented in the existing solutions. Our proposal uses the inherent CAN priority scheme to prioritize measured data in order to guarantee high-relevance data delivery in the shortest possible time. Relevance of the information is evaluated by means of a relative-velocity criterion. In this way, the most relative velocity detected (evaluated by means of the difference between two consecutive measures), the highest the priority. First, a START frame is transmitted; this message contains the deadline for the distance measurement data frames. The control frames are transmitted every 10 ms. After a few milliseconds the measurement nodes have the data ready and start sending frames whenever they can. When the deadline expires the rest of the distance data is discarded and the monitoring frames can be transmitted.

4.1. Can identifiers The extended CAN identifier has been chosen to implement the EDF, so, according with the CAN 2.0B specifications, 29 bits are available for message identification field.

IEEE

Background and monitoring message, no deadline Low priority sensorial measurements, variable deadline

01 i

...

iii

High priority control signals

00 i

...

iii

Alarms, no deadline M or 27 bits are used to code the message's identifier K or 0 bits are used to code the message's laxity time.

Figure 5. Time laxity encoding into the CAN id field As shown in Figure 5, we have defined four different types of CAN frames. The highest priority is reserved for alarm messages followed by control signals. The laser alarm nodes will send their frames without delays. Control signals include the steering wheel control loop and the speed control loop subsystems. The distance measurements use the third class of frames. Last priority frame category is use for background and monitoring messages. Figure 6 shows a bus utilization example. Notice that there are four types of frames, 00 to 11, ordered by priority, the lower type the higher priority. In the example, when the second burst of control frames are sent a Laser Alarm node gets the bus by it highest priority and sends an alarm between the control frames. Notice also that there is more distance measurement data stored into the nodes when the deadline expires, but the data is discarded and their associated messages are not transmitted.

Proceedings of the Second International Conference on Embedded Software and Systems (ICESS’05) 0-7695-2512-1/05 $20.00 © 2005

Required Bandwidth (bps) 320 18,000 18,320 10,000 10,000 10,000 10,000 10,000 50,000 64 6,400 4,800 27769 2,776,900 2,788,100 1,000 1,000 2,000 27833 2,858,420 4

AR ST

R SE LA ARM AL

T

T AR ST

00 01 10 11 Total

DEADLINE

Unsent messages discarded

FRAME CLASSES 00 Alarm

01 Control

10 Measurement

11 Monitoring

Figure 6. CAN bus utilization by frame types The CAN identifiers are software-updated, messages queued at the transmission buffers and awaiting transmission being updated first. The US and IR nodes will have at most one message stored corresponding to the last measure, but the laser nodes CPU will have to update a large pool of messages; their higher load of work requires a more powerful processor. The time period to update message deadlines is fixed to 100 microseconds. At 500 Kbps this means that the encoded time laxity of every stored message waiting for transmission is updated 2 or 3 times while a single message is being transmitted over the bus, depending on its data length. In our implementation a 16-bit field is reserved for the K value and 11-bits are used to store the M value. With this encoding there is no need to change our previously selected CAN node identifiers and the CAN uniqueness is guaranteed. The larger time laxity that can be encoded is approximately 6.5 seconds, large enough for this application.

4.2. Functioning modes The distance measurement nodes and specially the laser processor nodes can be programmed in several operating modes. We are going to focus our attention in the laser nodes as they have the more versatile use. The distance measured from the laser scanners can be processed with the following goals: a) Map mode. Main objective of this mode is the creation of a map of the environment, so every distance must be transmitted as collected, without processing. This is a slow motion mode, and has no advantages from conventional laser use. No deadlines are needed because vehicle speed and the data collection process are adjusted to accommodate the large processing time. b) Object detection mode. This mode is for faster car or object speeds. The laser scanners work at their maximum throughput and only the most relevant data can be delivered on time to the control computer. In this mode we need to send the angle and the scanner

number. This information is coded in the 11 bits of the identifier. The data to be sent is composed of four bytes, two with the actual laser measurement, and two with the difference between the present measurement and the last one. When working in object detection mode, the control computer sends a start frame at the beginning of the measurement period, establishing the maximum allowed deadline. The distance measurement nodes using EDF-scheduling (third frame category), will not send any message that would miss it deadline. Although there is a single start frame, it is important to remark that the US and IR sensors are activated in different rounds, so the measured data could be available only some time after receiving this frame. These rounds are required to avoid the crosstalk effect from adjacent sensors. The US response time will be highly affected by the distance to its closest obstacle because of the variable measurement time. The laser nodes use another strategy. Their higher measurement frequency allows them to always have data ready to be transmitted, so it is not necessary to wait for the start of a new scan and it is possible to send data just after receiving each start frame. These nodes have two buffers that can collect a full scan each one of them. One of the buffers contain the currently being transmitted data, while the other one is being filled with newer scan data. When a new start frame arrives, the laser CPU switches the use of the buffers transmitting the newer measures and overwriting the already transmitted data.

4.3. Model of the system The system workload has been modeled in System C [12], an open source C++ class library and a methodology that can be used to create a cycleaccurate model of software algorithms, hardware architectures, and interfaces of system-on-a-chip and system-level designs. After the model was completed and verified, the modified simulator used in [13] was applied to test the communication system. Simulation of the model has proved that the most relevant messages, such as alarm messages, were sent on time. Measurement messages are ordered by relevance, promoting more important ones delivery, and only less important data for the obstacle avoidance in our trajectory were discarded. As the deadline time provided by the controller decreases, the relevance of the messages discarded became lower. Low priority messages, such as monitoring ones, must wait until no higher priority messages use the bus. Due to this message discarding feature, is it possible to guarantee that the CAN bus has enough free

Proceedings of the Second International Conference on Embedded Software and Systems (ICESS’05) 0-7695-2512-1/05 $20.00 © 2005

IEEE

bandwidth to transmit these low priority messages, although the system has distance measurements to collapse the CAN bus and raise the utilization well above 100% in object detection mode. This is because the incorporation of the EDF scheduling and the way the nodes discard their data when the assigned deadline is missed reduce the bus utilization to a reasonable value.

5. Conclusions and future work In this paper has been presented the message scheduling for a CAN bus transmission. We have chosen a mixed priority assignation. As the data to be transmitted in the proposed system exceeds the available bandwidth of the communication network, no all messages can be scheduled onto the bus. Fortunately, no all distance measurement data is indispensable for the system function, even if their priority is higher than monitoring messages. Guaranteeing delivery of most relevant measurement data is the goal of the proposed solution, being achieved by means of controlled data loses. This is the key concept behind our scheduling scheme, based on mixed priorities. With the deadline included at the start frame, the control node has the possibility of determining the amount of data to be lost. In the Map mode all the distance measurement frames are received at the control computer, this is because in this mode the deadline is high enough to allow it. In the Object Detection mode, the high laser scanning frequency and the shorter deadline only allows the transmission of a 15% of the measurements for the worst case of bit stuffing and laser alarms. Messages have been ordered according to their temporal requirements into several classes. The system is schedulable because distance measurement messages that can not meet the assigned deadline are discarded. Whenever bus transmission errors reduce the bus bandwidth, the number of discarded messages will be increased, but these messages will always be the lowest priority distance measurement frames. As discussed at section 4, the EDF approach to the scheduling of CAN bus communication has proved itself as a great advance to deal with huge amounts of data. The use of dynamic priorities based on time-tolive grants the shortest deadline data to be delivered as soon as possible and distributed dynamic priority schemes have proven possible. Although the sensorial node have enough distance measurements to collapse the CAN bus bandwidth several times, the deadline attached in the start frame

makes it possible to guarantee enough free bandwidth at the CAN bus to transmit lowest priority messages. It is important to remark that the software update overhead at US and IR nodes is very low, because they will have only one message pending at most. At the laser nodes the overhead is higher but affordable. As future work, it is intended to test the real system in real conditions, once the operating modes and control algorithms have been enhanced. We are working in a fault tolerant model. The incorporation of a degraded performance model is been studied. It will only be activated with high rates of bus transmission errors. In such conditions, to keep the safety conditions, it is necessary to increase the deadline to work with enough distance measurements and to decrease the vehicle speed.

References [1] A. Burns, A.J. Wellings. Real time systems and their programming languages, 3rd edition, Addison Wesley 2001. [2] F. Rodríguez, J.C. Campelo. EDF message scheduling on a CAN network, 5th International CAN Conference, 1998 [3] K. Tindell, A. Burns, A.J. Wellings. Calculating controller area network (CAN) message response times, Control Engineering Practice, vol. 3, no. 8, pp. 11631169, 1995 [4] K.M. Zuberi, K.G. Shin. Scheduling Messages on Controller Area Network for Real-Time CIM Applications, IEEE Transactions on Robotics and Automation, pp. 310-314, April, 1997 [5] http://www.sick.com [6] http://mansky.co.uk/polaroid.html [7] http://www.sharp.com [8] S. Fuster, L. Armesto, R. Pizá, J. Tornero. Sensorization of an electric vehicle based on Can bus, World Automotive Congress, Barcelona, Spain, May 2004 [9] Silicon Laboratories. C8051F04x Mixed Signal ISP Flash MCU Family rev. 1.4, http://www.silabs.com [10] Robert Bosch GmbH., C_CAN User's Manual rev 1.2, http://www.semiconductors.bosch.de [11] Motorola. MPC565/MPC566 User's Manual rev 2, http://www.freescale.com [12] System C Version 2.0 User’s manual. 2002 [13] L. Armesto, S. Fuster, F. Jiménez, J. Tornero. Real-time application for car-like vehicles based on Can bus, Industrial Simulation Conference, Valencia, Spain, 2003

Proceedings of the Second International Conference on Embedded Software and Systems (ICESS’05) 0-7695-2512-1/05 $20.00 © 2005

IEEE