CCP agreement

1. Overview of the CCP Protocol

CCP (CAN Calibration Protocol) is a matching calibration protocol based on CAN bus. All ECUs need to go through the process of matching and calibration to determine their operating parameters and control parameters. Sometimes in order to achieve precise control of ECU and parameter matching and modification to meet predetermined requirements, it is necessary to accurately match and calibrate the ECU and optimize various control parameters. Based on this, the Association for Standardization of Automation and Measuring Systems (Association for Standardization of Automation and Measuring Systems) developed the CCP protocol. More vividly, the CCP protocol realizes the online monitoring of internal variables and the online modification of certain variables when necessary during the operation of the ECU. Monitoring the internal variables of the ECU can test the correctness of the operation of the ECU. If we find that the value of a variable is not what we expect, we can calibrate it and modify it to the expected value. For example, we want to monitor the speed of the engine in the ECU. If we find that the engine speed is wrong and not what we need, we can immediately modify it to the correct speed we need.

2. CCP communication

Above, we have a general impression of CCP, and we have an understanding of what CCP can do. The key thing below is how to realize it.

The ECU calibration based on the CCP protocol adopts the master-slave communication mode, and the master device is connected with multiple slave devices through the CAN bus. The master device is the measurement calibration system MCS (Measurement Calibration System), and the slave device is the ECU that needs to be calibrated. Here I introduce CANape for measurement and calibration system. CANape is an ECU calibration and testing tool. Combined with the CCP protocol, the calibration of the ECU can be completed, and the memory can be directly accessed and operated during the operation of the ECU. From the above introduction, now we should have at least such a block diagram (below) in our hearts. Through the CAN bus, CANape can read the variables in the ECU, and CANape can also write the variables in the ECU.

 

3. CCP protocol message frame format

CCP belongs to the application layer protocol of CAN bus. It occupies two ID identifiers of CAN messages, namely CRO (Command Receive Object) and DTO (Data Transmission Object), and uses 8 bytes of the data field in the data frame. CRO is used for the master device to send commands to the slave device, DTO is used for the slave device to send data to the master device, and the ID identifier can be agreed upon by itself. The first byte of the CRO data field is the command code CMD (Command Code). The CCP protocol stipulates a total of 28 commands. The slave device determines which command is requested by the master device through the CMD code. The second byte of the data field is the command counter CTR (Command Counter). The remaining 6 bytes are command parameters, and each command has its own corresponding command parameters. The CRO frame format is as follows:

 

Byte0

1

2

3

4

5

6

7

CMD

CTR

parameter

 

The first byte PID of the DTO data field defines the type of DTO to indicate the type of DTO; the second byte is the command return/error code ERR (Command Return-/Error Code), and the third byte CTR is the command Counter, the value of this bit corresponds to the CTR value of its corresponding CRO. The DTO format is as follows:

 

Byte0

1

2

3

4

5

6

7

PID

ERR

CTR                    

parameter

 

There are three types of DTO:
1) CRM (Command Return Message): sent by the slave device to feedback the message of the CRO command. PID=0xFF;

2) Event Message: When the slave device detects an internal error mechanism, it will be sent by the slave device to the master device to report its current running status and request the master device to suspend the current working process to deal with the error. PID=0xFE;
3) DAQ-DTO (Data Acquisition-DTO): used in DAQ mode, periodically sent by the slave device to the master device. PID (0x00~0xFD); the message format is as follows:

 

Byte0

1

2

3

4

5

6

7

PID

                                   uploaded data

 

根据CCP协议,主设备首先与从设备建立逻辑连接。建立逻辑连接后,主、从机之间所有的数据传递均由主机控制,从机执行主机命令后返回包含命令响应值或错误代码等信息的报文。任何一个从机都可以定时地根据由主机通过控制命令所设置的列表来传递内部的数据。所以说数据的传递是由主机初始化,由从机来执行,并且是由固定的循环采样频率或事件触发的。

4、CCP协议工作模式 
   CCP定义了两种工作模式:Polling(查询)模式及DAQ(Data Acquisition Command)模式。查询模式下,主设备与从设备间每一次通信都由主设备发送命令来起始,从设备收到主设备命令后,执行相应操作并反馈一帧报文。这种工作模式需要主机与从机之间进行“一问一答”信息交互,工作效率不高,但实现简单,占用ECU内存资源较小。 DAQ模式使从设备可以脱离主设备命令控制按一定周期自动向主设备上传数据。DAQ模式下,主设备首先发送一条请求DAQ命令,从设备收到后,按命令中参数自行配置并组织需要上传数据,然后按一定周期自主向主设备上传数据。这种模式不需要主机命令逐步控制,工作效率高,但实现较复杂,需要上传数据量很大,会占用大量ECU内存空间。

5、两种模式对应的处理过程

   定义两种处理器只是为了更好的理解接收CRO报文后的处理过程,DAQ模式首先也还得经过命令处理器对命令进行解读,若为DAQ命令则转给DAQ处理器处理。

   1)、针对Polling模式的命令处理器

       命令处理器主要是获取并解读主设备的CCP命令,并执行该命令;命令执行完后,向主设备发送应答;若执行出错,应答中应包含向主设备报错的信息;若主设备命令要求对DAQ进行操作,则该操作传送给DAQ处理器处理,由DAQ处理器完成DAQ操作。

   2)、DAQ处理器实现DAQ模式

   DAQ处理器的任务是根据主设备的需要,定时向CAN总线上发送DAQ数据。DAQ模式,简单的说就是由ECU组织,定期的向CANape发送数据。DAQ传送的数据由一系列的表来组织,这些表称为ODT,每个ODT表包含7个元素。这些ODT描述的参数需要ECU用DAQ-DTO帧周期发送给CANape用来监测。当ECU的DAQ机制启动后,ECU按CANape里设定的周期,将每个ODT表描述的参数当前的值顺次放入相应的DAQ-DTO帧中,然后发送给CANape。

      标定的实现过程:CANape发送GET_DAQ_SIZE命令(参数为指定的list号),得到指定的list的ODT数量,并且得到该list中DTO的第一个PID号,然后发送SET_DAQ_PTR命令(参数为list号,ODT号,ODT中的元素号),指定需要初始化的元素。最后,根据命令SET_DAQ_PTR设置的具体元素,发送WRITE_DAQ命令(参数为元素的byte大小,元素的地址),通过反复地执行SET_DAQ_PTR和WRITE_DAQ这两条命令,初始化一个具体的ODT表,然后初始化完一个具体的List表,最后初始化完所有的list表。这样,CANape就完成了ODT的初始化工作。之后开始和停止DAQ数据的传输。CANape发送START_STOP命令(可以准备DAQ数据的上传),发送START_STOP_ALL来上传所有准备好的DAQ数据。ECU采集指定的数据后以DTO的形式上传给CANape,实现DAQ模式。

6、测量标定系统的总体框图介绍

   测量标定系统的简单框图如下图所示。主设备发送CRO报文到总线,经过ECU CAN Driver的接收,由CAN Driver与CCP Dirver的接口函数把接收的报文转给命令处理器,由命令处理器解析命令,若是查询模式的命令,则根据命令返回相应的CRM报文;若是DAQ模式的命令,则转给DAQ处理器进行处理,之后按命令给定的周期,自己组织采集需要的数据,通过DAQ-DTO报文的形式返回给主设备。

 

CANape里已经集成了CCP和CAN的驱动,CANape发送命令的形式是通过测量窗口的配置。举例来说,如要测量发动机的转速,首先根据ECU里的map文件确定转速在ECU中的地址,配置成A2L格式的数据库文件,在测量配置窗口配置转速这一变量,设置成polling模式,新建一个显示窗口添加该变量,运行CANape即可实现转速的在线监测。

7、标定数据库(A2L)

   CANape与ECU之间的通信需要一个描述文件支持,这个文件称为ASAP2描述文件。CANape对ECU参数标定和数据测量都是基于这个文件,该文件记录了ECU中各参数详细信息,如标定参数和测量变量ECU中存储地址、存储结构、数据类型和转换公式等。CANape中,每个标定参数和测量数据都会有一个变量名,如发动机温度、冷却水温度。当CANape需要访问某个变量时,找到ASAP2描述文件中变量名,找到该变量在ECU中的存储地址、数据长度等信息。为了对ASAP2文件进行维护和修改,CANape集成了一个ASAP2 Editor的数据库编辑器,生成和修改ASAP2控制器描述文件。所有信息都能对话框形式进行设置和修改。该数据库编辑器还能工作在独立模式下,以生成一个A2L格式的控制器描述文件。 当ECU底层程序修改后,一些标定参数和测量数据内存址可能发生变动,CANape支持linker map文件自动更新ASAP2文件里的信息。Map文件是ECU底层程序编译时由编译器生成一种映射文件,Map文件可以自动更新ASAP2文件,保证了测量与标定变量时地址的一致性。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325909022&siteId=291194637