JP2015210667A - Communication unit and can(control area network) communication control program - Google Patents

Communication unit and can(control area network) communication control program Download PDF

Info

Publication number
JP2015210667A
JP2015210667A JP2014091833A JP2014091833A JP2015210667A JP 2015210667 A JP2015210667 A JP 2015210667A JP 2014091833 A JP2014091833 A JP 2014091833A JP 2014091833 A JP2014091833 A JP 2014091833A JP 2015210667 A JP2015210667 A JP 2015210667A
Authority
JP
Japan
Prior art keywords
communication
frame
microcomputer
serial port
message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2014091833A
Other languages
Japanese (ja)
Inventor
一裕 樋渡
Kazuhiro Hiwatari
一裕 樋渡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
FDK Lithium Ion Capacitor Co Ltd
Original Assignee
FDK Lithium Ion Capacitor Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by FDK Lithium Ion Capacitor Co Ltd filed Critical FDK Lithium Ion Capacitor Co Ltd
Priority to JP2014091833A priority Critical patent/JP2015210667A/en
Publication of JP2015210667A publication Critical patent/JP2015210667A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Bus Control (AREA)
  • Small-Scale Networks (AREA)

Abstract

PROBLEM TO BE SOLVED: To allow communication modules connected to CAN(Control Area Network) buses having different communication speeds to communicate with each other without increasing a communication load.SOLUTION: A communication unit is characterized to control CAN communication between modules connected to a plurality of CAN buses having different communication speeds by a CPU disposed in a microcomputer by connecting a plurality of different CAN controllers connected to the CAN buses having different communication speeds to a plurality of serial ports disposed in the microcontroller, and processing CAN messages input from the CAN buses via the CAN controllers and the serial ports on the basis of input serial port IDs and CAN message IDs.

Description

本発明は、通信ユニットおよびCAN通信制御プログラムに関する。   The present invention relates to a communication unit and a CAN communication control program.

CAN(Control Area Network)は、シンプルなネットワーク構成のため、低コストで構築できるネットワークである。さらには、CAN通信は、故障検出機能が優れており、信頼性が高い通信方式として知られている。   CAN (Control Area Network) is a network that can be constructed at low cost because of its simple network configuration. Furthermore, CAN communication is known as a highly reliable communication method that has an excellent failure detection function.

CANは、CANバスごとにCANコントローラが1つ設置される。CANコントローラは、CANを流通する信号が、CAN通信のプロトコルに従って各モジュールに正常に伝達されるように制御する。   In the CAN, one CAN controller is installed for each CAN bus. The CAN controller controls so that a signal flowing through the CAN is normally transmitted to each module in accordance with a CAN communication protocol.

特開2005−196568号公報JP 2005-196568 A

しかしながら、CANが異なる通信速度のCANバスを含む場合には、異なるCANバス上のモジュール同士は直接通信出来ない。そのため、従来は、ゲートウェイを介して異なるCANバス上のモジュール同士が通信するが、ゲートウェイ設置などにより、ネットワークの構築コストが高くなるととともに、通信負荷が増大するという問題がある。   However, when CAN includes CAN buses having different communication speeds, modules on different CAN buses cannot directly communicate with each other. Therefore, conventionally, modules on different CAN buses communicate with each other via a gateway. However, there is a problem that a network construction cost is increased due to installation of a gateway and the communication load is increased.

本発明は、通信速度が異なるCANバスに接続された通信モジュール同士が、通信負荷を増大させずに通信可能にすることを目的とする。   An object of the present invention is to enable communication between communication modules connected to CAN buses having different communication speeds without increasing a communication load.

一態様の通信ユニットは、複数の異なる通信速度のCANバスにそれぞれ接続された複数のCANコントローラと、前記CANコントローラとそれぞれ接続された複数のシリアルポートを介して、前記異なる通信速度のCANバスにそれぞれ接続された装置間のCAN通信を制御するCPU(Central Processing Unit)を有したマイコンと、を有することを特徴とする。   The communication unit according to an aspect includes a plurality of CAN controllers respectively connected to a plurality of CAN buses having different communication speeds, and a plurality of serial ports connected to the CAN controllers to the CAN buses having different communication speeds. And a microcomputer having a CPU (Central Processing Unit) for controlling CAN communication between the devices connected to each other.

通信速度が異なるCANバスに接続された通信モジュール同士が、通信負荷を増大させずに通信できる。   Communication modules connected to CAN buses having different communication speeds can communicate without increasing the communication load.

図1は、実施例1に係るCANの構成の一例を示すブロック図である。FIG. 1 is a block diagram illustrating an example of a configuration of a CAN according to the first embodiment. 図2は、CANコントローラの内部構成の一例を示すブロック図である。FIG. 2 is a block diagram illustrating an example of the internal configuration of the CAN controller. 図3は、マイコンの内部構成の一例を示すブロック図である。FIG. 3 is a block diagram showing an example of the internal configuration of the microcomputer. 図4は、処理内容を示すテーブルの一例を示す図である。FIG. 4 is a diagram illustrating an example of a table indicating processing contents. 図5は、CANコントローラが入力した受信フレームを処理する手順を示すフローチャートである。FIG. 5 is a flowchart showing a procedure for processing a received frame input by the CAN controller. 図6は、CANコントローラからフレームを受信したマイコンが受信したフレームを処理する手順を示すフローチャートである。FIG. 6 is a flowchart illustrating a procedure of processing a frame received by the microcomputer that has received the frame from the CAN controller. 図7は、マイコンからCANコントローラへフレーム送信を指令する手順を示すフローチャートである。FIG. 7 is a flowchart showing a procedure for instructing frame transmission from the microcomputer to the CAN controller. 図8は、マイコンからの指示に基づいて、フレーム送信指令が出されたCANコントローラが送信フレームを生成してCANバスに送出する手順を示すフローチャートである。FIG. 8 is a flowchart showing a procedure in which a CAN controller to which a frame transmission command is issued generates a transmission frame and sends it to the CAN bus based on an instruction from the microcomputer. 図9は、実施例2に係る、マイコン150が、テーブルを外部メモリに格納して読み込む構成を示す一例を示すブロック図である。FIG. 9 is a block diagram illustrating an example of a configuration in which the microcomputer 150 stores and reads a table in an external memory according to the second embodiment. 図10は、実施例3に係る出力キューの例を示す図である。FIG. 10 is a diagram illustrating an example of an output queue according to the third embodiment. 図11は、実施例3に係るキューに所定の待ち時間を超えた送信データが生じた場合の制御を示す図である。FIG. 11 is a diagram illustrating control when transmission data that exceeds a predetermined waiting time occurs in the queue according to the third embodiment.

以下に添付図面を参照して本願に係る通信ユニットおよびCAN通信制御プログラムについて説明する。なお、この実施例は開示の技術を限定するものではない。そして、各実施例は、処理内容を矛盾させない範囲で適宜組み合わせることが可能である。   Hereinafter, a communication unit and a CAN communication control program according to the present application will be described with reference to the accompanying drawings. Note that this embodiment does not limit the disclosed technology. Each embodiment can be appropriately combined within a range in which processing contents are not contradictory.

[実施例1に係るCANの構成]
図1は、実施例1に係るCANの構成の一例であるCAN1を示すブロック図である。図1に示すように、CAN1は、通信ユニット100と、バス10、20と、モジュール11、12、21、22とを有する。通信ユニット100は、CANバス10に接続するCANコントローラ110と、CANバス20に接続するCANコントローラ120と、CANバス10とCANバス20との通信を制御するマイクロコントローラ(以下、マイコン150とを有する。
[Configuration of CAN according to Embodiment 1]
FIG. 1 is a block diagram illustrating a CAN 1 that is an example of a configuration of a CAN according to the first embodiment. As illustrated in FIG. 1, the CAN 1 includes a communication unit 100, buses 10 and 20, and modules 11, 12, 21, and 22. The communication unit 100 includes a CAN controller 110 connected to the CAN bus 10, a CAN controller 120 connected to the CAN bus 20, and a microcontroller (hereinafter referred to as a microcomputer 150) that controls communication between the CAN bus 10 and the CAN bus 20. .

CANバス10とCANバス20とは通信速度が異なるバスであり、例えば、図1の例では、CANバス10の通信速度が500kbpsであり、CANバス20の通信速度が125kbpsである。CANバス10に接続されるモジュール11および12は、例えば、ABS(Antilock Brake System)やECM(Engine Control Module)など、モジュール21、22よりも高速通信を行うモジュールである。一方、CANバス20に接続されるモジュール21、22は、例えば、DIM(Driver Information Module)やCCM(Climate Control Module)など、モジュール11、12よりも低速通信を行うモジュールである。   The CAN bus 10 and the CAN bus 20 are buses having different communication speeds. For example, in the example of FIG. 1, the communication speed of the CAN bus 10 is 500 kbps, and the communication speed of the CAN bus 20 is 125 kbps. The modules 11 and 12 connected to the CAN bus 10 are modules that perform higher-speed communication than the modules 21 and 22, such as ABS (Antilock Brake System) and ECM (Engine Control Module). On the other hand, the modules 21 and 22 connected to the CAN bus 20 are modules that perform lower-speed communication than the modules 11 and 12, such as a DIM (Driver Information Module) and a CCM (Climate Control Module).

CANコントローラ110およびCANコントローラ120は、それぞれCANバス10およびCANバス20の通信速度に適応して、モジュール11、12、21、22とフレーム通信をおこなう。CANコントローラ110およびCANコントローラ120は、フレームの種類を識別し、フレームから情報を選択して所定規格のシリアルデータへ変換する。そして、CANコントローラ110およびCANコントローラ120は、マイコン150のシリアルポート151およびシリアルポート152を介してマイコン150へシリアルデータを送信する。   The CAN controller 110 and the CAN controller 120 perform frame communication with the modules 11, 12, 21, and 22 in accordance with the communication speeds of the CAN bus 10 and the CAN bus 20, respectively. The CAN controller 110 and the CAN controller 120 identify the type of frame, select information from the frame, and convert it into serial data of a predetermined standard. Then, CAN controller 110 and CAN controller 120 transmit serial data to microcomputer 150 via serial port 151 and serial port 152 of microcomputer 150.

ここで、CANで流通するフレームには、(1)データフレーム、(2)リモートフレーム、(3)オーバーロードフレーム、(4)エラーフレーム、の4種類がある。フレームは、種類ごとにデータフォーマットが異なる。これらフレームのうちオーバーロードフレーム、エラーフレームは、それぞれオーバーロード、エラーの異常が発生したときに、モジュール11、12、21、22とマイコン150との間でやりとりされるフレームである。他のモジュールにデータを送るデータフレーム、他のモジュールにデータフレームをリクエストするリモートフレームが、通常時にモジュール11、12、21、22とマイコン150との間でやりとりされるフレームである。なお、データフレームおよびリモートフレームは、指令する処理内容に対応するメッセージIDを含んでいる。   Here, there are four types of frames distributed in CAN: (1) data frame, (2) remote frame, (3) overload frame, and (4) error frame. The frame has a different data format for each type. Of these frames, an overload frame and an error frame are frames exchanged between the modules 11, 12, 21, and 22 and the microcomputer 150 when an overload or error abnormality occurs, respectively. A data frame for sending data to another module and a remote frame for requesting a data frame from another module are frames exchanged between the modules 11, 12, 21, 22 and the microcomputer 150 at normal times. Note that the data frame and the remote frame include a message ID corresponding to the processing content to be commanded.

[実施例1に係るCANコントローラの構成]
図2は、実施例1に係るCANコントローラの内部構成の一例を示すブロック図である。実施例1に係るCANコントローラ110は、CANI/F(InterFace、以下同様)112、メッセージフィルタ114、シリアルI/F116、送信エンジン118を有する。CANI/F112は、モジュール11、12からCANバス10を介して受信したフレームの種類を判別し、フレームの種類に応じたフォーマットでフレームから所定情報を抽出して、メッセージフィルタ114へ出力する。また、CANI/F112は、送信エンジン118から受け付けたメッセージをフレームへ変換し、CANバス10を介してモジュール11、12へ送信する。
[Configuration of CAN Controller according to Embodiment 1]
FIG. 2 is a block diagram illustrating an example of the internal configuration of the CAN controller according to the first embodiment. The CAN controller 110 according to the first embodiment includes a CAN I / F (InterFace, hereinafter the same) 112, a message filter 114, a serial I / F 116, and a transmission engine 118. The CAN I / F 112 determines the type of frame received from the modules 11 and 12 via the CAN bus 10, extracts predetermined information from the frame in a format corresponding to the type of frame, and outputs it to the message filter 114. The CAN I / F 112 converts the message received from the transmission engine 118 into a frame and transmits the frame to the modules 11 and 12 via the CAN bus 10.

メッセージフィルタ114は、CANI/F112から受信した所定情報を種別に基づきフィルタリングして、シリアルI/F116へ出力する。シリアルI/F116は、メッセージフィルタ114から受信したメッセージをシリアル変換し、シリアルポート151を介してマイコン150へ出力する。   The message filter 114 filters the predetermined information received from the CAN I / F 112 based on the type, and outputs it to the serial I / F 116. The serial I / F 116 serially converts the message received from the message filter 114 and outputs it to the microcomputer 150 via the serial port 151.

また、シリアルI/F116は、シリアルポート151からしたメッセージを含むシリアルデータをCANコントローラ110の内部形式のデータへ変換し、送信エンジン118へ出力する。送信エンジン118は、シリアルI/F116から受信したメッセージを含むデータから所定情報を抽出し、所定情報に基づく種類のフォーマットでメッセージを含むデータを生成し、CANI/F112へ出力する。CANI/F112は、送信エンジン118からメッセージを含むデータを受信すると、フレームに変換してCANバス10を介してモジュール11、12へ送信する。   Further, the serial I / F 116 converts serial data including a message from the serial port 151 into data in an internal format of the CAN controller 110 and outputs the data to the transmission engine 118. The transmission engine 118 extracts predetermined information from data including a message received from the serial I / F 116, generates data including a message in a format of a type based on the predetermined information, and outputs the data to the CAN I / F 112. When receiving data including a message from the transmission engine 118, the CAN I / F 112 converts the data into a frame and transmits the frame to the modules 11 and 12 via the CAN bus 10.

図3は、マイコン150の内部構成の一例を示すブロック図である。図3では、シリアルポート151、152から入力されたシリアル信号のうち、SDAはデータ信号を伝送するデータ線であり、それぞれマイコン150を制御するCPU155に接続される。SCKはクロック線であり、シリアルポート151、152に対して共通の内部クロック信号が入力される。CPU155は、テーブル160を参照してシリアルポート151、152が受信したフレームに含まれる情報の内容を特定する。また、CPU150からシリアルポート151、152を経由してCANコントローラ110、120にフレームの作成と送信を指示する情報を送出する。   FIG. 3 is a block diagram showing an example of the internal configuration of the microcomputer 150. In FIG. 3, among the serial signals input from the serial ports 151 and 152, SDA is a data line for transmitting a data signal, and is connected to a CPU 155 that controls the microcomputer 150. SCK is a clock line, and a common internal clock signal is input to the serial ports 151 and 152. The CPU 155 refers to the table 160 and specifies the content of information included in the frame received by the serial ports 151 and 152. Further, the CPU 150 sends information instructing frame creation and transmission to the CAN controllers 110 and 120 via the serial ports 151 and 152.

図3に示しているシリアル通信は2線式であり、プロトコルとしては、例えば、I2C(Inter-Integrated Circuit、登録商標)バスを用いることができる。なお、図示していないが、3線のシリアル通信プロトコルを採用してもよく、その場合SPI(Serial Peripheral Interface、登録商標)などを用いることができる。   The serial communication shown in FIG. 3 is a two-wire system, and for example, an I2C (Inter-Integrated Circuit, registered trademark) bus can be used as a protocol. Although not shown, a three-wire serial communication protocol may be adopted, and in that case, SPI (Serial Peripheral Interface, registered trademark) or the like can be used.

図4は、テーブル160の例で、CPUに入力された信号に対応する処理を示すものである。ここで、シリアルポート番号161は、信号がシリアルポート151、152のいずれからの信号であるかを示すものである。メッセージID162は、信号が由来するフレームに含まれているIDであり、フレームの意図する処理を表すものである。テーブル160に示すように、シリアルポート番号161、メッセージID162の組み合わせに対応する処理内容163がテーブル160に登録されている。   FIG. 4 is an example of the table 160 and shows processing corresponding to a signal input to the CPU. Here, the serial port number 161 indicates from which of the serial ports 151 and 152 the signal is. The message ID 162 is an ID included in the frame from which the signal is derived, and represents the process intended by the frame. As shown in the table 160, the processing content 163 corresponding to the combination of the serial port number 161 and the message ID 162 is registered in the table 160.

例えば、(シリアルポート1、メッセージID:#1)に対応する処理として、温度モジュールがこのフレーム(リモートフレーム)を受信した場合にデータを送信することを指示している。また、(シリアルポート1、メッセージID:#2)に対応する処理として、表示モジュールがこのフレーム(データフレーム)を受信した場合にデータを読み取って表示することを指示している。マイコン150は、温度モジュールでも、表示モジュールでもないので、これらメッセージを受信しても廃棄される。   For example, as a process corresponding to (serial port 1, message ID: # 1), the temperature module instructs to transmit data when this frame (remote frame) is received. Further, as processing corresponding to (serial port 1, message ID: # 2), the display module instructs to read and display data when receiving this frame (data frame). Since the microcomputer 150 is neither a temperature module nor a display module, it is discarded even if these messages are received.

一方、(シリアルポート2、メッセージID:#1)に対応する処理は、エンジンモジュールがそのデータフレームを受信した場合にフレームに含まれるデータを読み取るように指示するものである。また、(シリアルポート2、メッセージID:#2)に対応する処理は、マイコンがこのフレーム(データフレーム)を受信した場合にデータを読み取って、所定の演算を行ってパラメータを求め、結果をエンジンモジュールへ送信することを指示している。後者のメッセージを受信した場合にはCPU155は所定の演算を行い、さらにその結果を含むデータフレームをエンジンモジュールへ送信する。   On the other hand, the process corresponding to (serial port 2, message ID: # 1) is an instruction to read data included in the frame when the engine module receives the data frame. Also, the processing corresponding to (serial port 2, message ID: # 2) is a process in which when the microcomputer receives this frame (data frame), it reads the data, performs a predetermined calculation to obtain a parameter, and obtains the result from the engine. Instructed to send to the module. When the latter message is received, the CPU 155 performs a predetermined calculation, and further transmits a data frame including the result to the engine module.

図5は、CANコントローラ110が入力した受信フレームを処理する例を示すフローチャートである。CANI/F112は、入力した受信フレームから所定の情報を抽出し(S101)、メッセージフィルタ114に解析された情報を送信する(S102)。次にメッセージフィルタ114は、受信フレームの内容をマイコン150に送信する必要があるかどうかを判定し、送信が必要と判定された場合は(S103、Yes)、シリアルI/F116に解析された情報を送信し(S104)、送信先のシリアルポート151へ送信する(S105)。一方、受信フレームの内容をマイコン150に送信する必要がないと判定した場合は(S103、No)は、受信フレームを廃棄する(S106)。   FIG. 5 is a flowchart illustrating an example of processing a received frame input by the CAN controller 110. The CAN I / F 112 extracts predetermined information from the input received frame (S101), and transmits the analyzed information to the message filter 114 (S102). Next, the message filter 114 determines whether it is necessary to transmit the contents of the received frame to the microcomputer 150. If it is determined that transmission is necessary (S103, Yes), the information analyzed by the serial I / F 116 is determined. Is transmitted (S104), and is transmitted to the destination serial port 151 (S105). On the other hand, when it is determined that the content of the received frame does not need to be transmitted to the microcomputer 150 (S103, No), the received frame is discarded (S106).

例えば、CANコントローラ110が、(3)のオーバーロードフレームを受信した場合には、CANコントローラ110は、CANプロトコルに従い、CANコントローラ110はオーバーロードフラグを返信するが、オーバーロードフレーム自体はマイコン150に送信する必要はないと判定する。   For example, when the CAN controller 110 receives the overload frame (3), the CAN controller 110 returns an overload flag in accordance with the CAN protocol, but the overload frame itself is sent to the microcomputer 150. It is determined that there is no need to transmit.

また、CANコントローラ110は、(4)のエラーフレームを受信した場合には、エラーの状態に応じて、図示しないエラーカウンターの値を増加させるが、エラーフレーム自体はマイコン150に送信する必要はないと判定する。   In addition, when receiving the error frame (4), the CAN controller 110 increases the value of an error counter (not shown) according to the error state, but the error frame itself does not need to be transmitted to the microcomputer 150. Is determined.

一方、(1)のデータフレーム、(2)のリモートフレームを受信した場合には、フレームからRTR(Remote Transmission Request)、メッセージIDなどが抽出される。ここでRTRはフレームがデータフレームであるかリモートフレームであるかを、メッセージIDは、データ内容や送信ノードを示す情報である。   On the other hand, when the data frame (1) and the remote frame (2) are received, an RTR (Remote Transmission Request), a message ID, and the like are extracted from the frame. Here, the RTR is information indicating whether the frame is a data frame or a remote frame, and the message ID is information indicating data contents or a transmission node.

なお、上記に示したCANコントローラの動作は、基本的な機能をいくつか示しただけだが、CANコントローラ110はCANプロトコルに規定される通信調停やエラー検出などの基本機能に関する処理も実行する。   The operation of the CAN controller described above shows only some basic functions, but the CAN controller 110 also executes processing related to basic functions such as communication arbitration and error detection defined in the CAN protocol.

また、CANコントローラは、メッセージフィルタ114は多種多様な選別機能を有し、マイコンの負荷を軽くするような、高機能なものであっても良い。   In addition, the CAN controller may have a high function such that the message filter 114 has a wide variety of sorting functions and reduces the load on the microcomputer.

図6は、CANコントローラ110からフレームを受信したマイコン150が受信したフレームを処理する例を示すフローチャートである。   FIG. 6 is a flowchart illustrating an example of processing a frame received by the microcomputer 150 that has received a frame from the CAN controller 110.

マイコン150は、シリアルポートをN個有し、CANバスの通信速度が高速な順で、番号の若いポートに接続されているものとする。まず、i=1にセットし(S201)、i番目のシリアルポート(以後、「シリアルポートi」などと呼ぶ)への受信の有無を調べ、受信がない場合は(S202 No)、i=i+1に増分して(S206)、i>Nでなければ(S207 No)S202へ戻り、i>Nなら(S207 Yes)S201へ戻る。   It is assumed that the microcomputer 150 has N serial ports and is connected to a port with a smaller number in order of increasing CAN bus communication speed. First, i = 1 is set (S201), and the presence or absence of reception to the i-th serial port (hereinafter referred to as "serial port i" or the like) is checked. If there is no reception (No in S202), i = i + 1 If i> N (S207 No), the process returns to S202. If i> N (S207 Yes), the process returns to S201.

マイコン150は、S202で受信があった場合には(S202 Yes)、受信されたのがリモートフレームか否かを判定する(S203)。リモートフレームと判定した場合には(S203 Yes)、マイコン150は、メッセージIDを参照して、マイコン150自身が該リモートフレームに対しデータフレームを送信するかどうかを判定する(S204)。送信しないと判定した場合には(S204 No)、マイコン150は、フレームを受信したシリアルポートi以外のシリアルポートから受信したリモートフレームと同様のリモートフレームを送信するように指示し(S205)、処理を終了する。ここで、受信フレームがリモートフレームかどうかは、フレームに含まれる上述のRTRで判定することができる。   If there is a reception in S202 (S202 Yes), the microcomputer 150 determines whether the received frame is a remote frame (S203). If it is determined that the frame is a remote frame (S203 Yes), the microcomputer 150 refers to the message ID and determines whether the microcomputer 150 itself transmits a data frame to the remote frame (S204). If it is determined not to transmit (No in S204), the microcomputer 150 instructs to transmit a remote frame similar to a remote frame received from a serial port other than the serial port i that received the frame (S205). Exit. Here, whether or not the received frame is a remote frame can be determined by the above-described RTR included in the frame.

一方、マイコン150自身がデータフレームを送信すると判定した場合には(S204 Yes)、マイコン150は、CANコントローラ110からデータフレームを送信するようにシリアルポートiから指示を出力し(S209)、処理を終了する。   On the other hand, if the microcomputer 150 determines that the data frame is to be transmitted (S204 Yes), the microcomputer 150 outputs an instruction from the serial port i so as to transmit the data frame from the CAN controller 110 (S209), and performs the process. finish.

また、受信されたのがリモートフレームでなかった場合は(S203 No)、上述のように、オーバーロードフレームとエラーフレームとは、CANコントローラ110で遮断されているため、受信したのはデータフレームなので、メッセージIDとデータを読み取って必要に応じて対応し(S208)、処理を終了する。   If the received frame is not a remote frame (No in S203), the overload frame and the error frame are blocked by the CAN controller 110 as described above, so the received frame is a data frame. Then, the message ID and the data are read and dealt with if necessary (S208), and the process is terminated.

以上、マイコン150がCANコントローラ、シリアルI/Fを介してCANバスからフレームを受信する手順の一例を示した。   Heretofore, an example of the procedure in which the microcomputer 150 receives a frame from the CAN bus via the CAN controller and serial I / F has been shown.

マイコン150は、データフレームの送信を要求するリモートフレームを受信した場合や、受信したデータが所定の条件を満たしていることを他のCANモジュールに通知する場合などには、CANコントローラにフレーム送信を指示する。図4の(シリアルポート2、メッセージID:#2)に対応する処理は、データが所定の条件を満たしていることを通知する例である。マイコン150からCANコントローラへのフレーム送信の指令処理を示すフローチャートの例を図7に示す。   When the microcomputer 150 receives a remote frame requesting transmission of a data frame or notifies other CAN modules that the received data satisfies a predetermined condition, the microcomputer 150 transmits the frame to the CAN controller. Instruct. The process corresponding to (serial port 2, message ID: # 2) in FIG. 4 is an example of notifying that the data satisfies a predetermined condition. FIG. 7 shows an example of a flowchart showing a frame transmission command process from the microcomputer 150 to the CAN controller.

まず、CPUは送信内容と、送信対象とするCANバスに対応するシリアルポートを決定する(S301)。ここで送信は同一のCANバスに複数送出しても良いし、複数種類のCANバスの送出するものでも良い。次に送信フレームがデータフレームを含むかを判定し(S302)、データフレームを含まない場合は(S302 No)S304へ進み、データフレームを含む場合は(S302 Yes)送信データを決定して(S303)からS304に進む。ここで、マイコン150は図6と同様のものとする。S304で、i=1にセットされたのち、上記送信対象にシリアルポートiへの送信が含まれているかを調べ、送信が含まれていない場合は(S305 No)、i=i+1に増分して(S307)、i>Nでなければ(S308 No)S305へ戻る。上記送信対象にシリアルポートiへの送信が含まれている場合は(S305 Yes)、シリアルポートiに送信指令と決定した送信内容とを出力してから(S306)S307に進む。S308でi>Nなら(S308 Yes)処理を終了する。   First, the CPU determines the transmission contents and the serial port corresponding to the CAN bus to be transmitted (S301). Here, a plurality of transmissions may be transmitted to the same CAN bus, or a plurality of types of CAN buses may be transmitted. Next, it is determined whether the transmission frame includes a data frame (S302). If the data frame is not included (S302 No), the process proceeds to S304. If the data frame includes a data frame (S302 Yes), the transmission data is determined (S303). ) To S304. Here, the microcomputer 150 is the same as that shown in FIG. In S304, after i = 1 is set, it is checked whether transmission to the serial port i is included in the transmission target. If transmission is not included (S305 No), i = i + 1 is incremented. (S307) If i> N is not satisfied (No in S308), the process returns to S305. When the transmission target includes transmission to the serial port i (Yes in S305), the transmission command and the determined transmission content are output to the serial port i (S306), and the process proceeds to S307. If i> N in S308 (S308 Yes), the process is terminated.

図8は、前述の図7に示した、マイコン150からの指示に基づいて、フレーム送信指令が出されたシリアルI/Fに繋がれたCANコントローラ110が送信フレームを生成してCANバス10に送出する処理の例を示すフローチャートである。   In FIG. 8, based on the instruction from the microcomputer 150 shown in FIG. 7, the CAN controller 110 connected to the serial I / F to which a frame transmission command is issued generates a transmission frame and sends it to the CAN bus 10. It is a flowchart which shows the example of the process to send out.

マイコン150から入力された送信指令は、シリアルI/F116を介し送信エンジン118に転送され(S401)、送信エンジン118は送られた送信指令から所定の情報を抽出してフレームを生成する(S402)。生成したフレームの送信が許可されれば(S403、Yes)、CANI/F112に生成したフレームを送信し(S404)、CANバス10に対応したCAN信号に変換して送信する(S405)。一方、フレーム送信が許可されなかった場合(S403、No)、所定時間待機後に(S406)、再度フレーム送信の許可を問い合わせる(S403)。   The transmission command input from the microcomputer 150 is transferred to the transmission engine 118 via the serial I / F 116 (S401), and the transmission engine 118 extracts predetermined information from the transmitted transmission command and generates a frame (S402). . If transmission of the generated frame is permitted (S403, Yes), the generated frame is transmitted to the CAN I / F 112 (S404), converted into a CAN signal corresponding to the CAN bus 10, and transmitted (S405). On the other hand, when frame transmission is not permitted (S403, No), after waiting for a predetermined time (S406), the frame transmission permission is inquired again (S403).

ここで、フレーム送信が許可されないような場合には、例えば、CANコントローラ110自身のエラーカウンターが所定値を超えている場合がある。他に、CANバス10に繋がれた他のCANコントローラからエラーカウンターが所定値を超えていることを通知するエラーフレームを受信しているなどCANバス10上での通信がCANプロトコルで禁止される場合にもフレーム送信は許可されない。さらには、CANコントローラ110が送信フレーム用のバッファを有し、該バッファ上に生成したフレームより先に送信すべき未送信フレームが残っているような場合などCANコントローラ110自身の構成の問題でフレーム送信が許可されない場合もある。   Here, when frame transmission is not permitted, for example, the error counter of the CAN controller 110 itself may exceed a predetermined value. In addition, communication on the CAN bus 10 is prohibited by the CAN protocol, such as receiving an error frame notifying that the error counter exceeds a predetermined value from another CAN controller connected to the CAN bus 10. Even in this case, frame transmission is not permitted. Furthermore, if the CAN controller 110 has a transmission frame buffer, and there is an untransmitted frame to be transmitted before the frame generated on the buffer, the CAN controller 110 itself has a configuration problem. In some cases, transmission is not permitted.

[実施例1の効果]
上述してきたように、本実施例に係る通信ユニットを用いることで、異なる通信速度のCANバス上のモジュール間の通信を、ゲートウェイなどを設けることなく、マイコンを介して実現できる。
[Effect of Example 1]
As described above, by using the communication unit according to the present embodiment, communication between modules on the CAN bus having different communication speeds can be realized via a microcomputer without providing a gateway or the like.

また、マイコンを介して異なる通信速度のCANバスにリモートフレームを選択的に送信することができるので、送信フレームの優先度に応じて適切な通信速度のCANバスを選択して送信する制御が実現する。   In addition, remote frames can be selectively transmitted to CAN buses with different communication speeds via a microcomputer, so that control for selecting and transmitting CAN buses with appropriate communication speeds according to the priority of transmission frames is realized. To do.

さらに、シリアルポート番号161とメッセージID162のペアに対し処理を割り当てるテーブルに基づいて処理を決定するので、同一のメッセージIDに対しシリアルポート毎に異なる処理を割り当てることができるので、処理の自由度が高くなる。   Furthermore, since the process is determined based on the table for assigning the process to the pair of the serial port number 161 and the message ID 162, different processes can be assigned to the same message ID for each serial port. Get higher.

さて、これまで開示の装置に関する実施例について説明したが、本発明は上述した実施例以外にも、種々の異なる形態にて実施されてよいものである。そこで、以下では、本発明に含まれる他の実施例を説明する。   Although the embodiments related to the disclosed apparatus have been described above, the present invention may be implemented in various different forms other than the above-described embodiments. Therefore, another embodiment included in the present invention will be described below.

上記実施例1では、図3のように、マイコン150の内部にテーブル160を備えた構成をとっていた。しかし、テーブル160を予めマイコン内部に所持せずに、外部から読み込ませる構成も考えられる。   In the first embodiment, as shown in FIG. 3, the microcomputer 150 is provided with a table 160. However, a configuration in which the table 160 is read from the outside without being held in the microcomputer in advance is also conceivable.

図9に示すマイコン150は、テーブル160を、USB(Universal Serial Bus)メモリやIC(Integrated Circuit)カードなどの外部メモリに格納してマイコンは該外部メモリからテーブル160を読み込む構成を示すものである。このように、着脱自在な外部メモリにマイコンの設定を格納すれば、その設定に基づきマイコンを動作させることができるので、マイコンの設定を別のマイコンに適用する処理が容易になる。   The microcomputer 150 shown in FIG. 9 shows a configuration in which the table 160 is stored in an external memory such as a USB (Universal Serial Bus) memory or an IC (Integrated Circuit) card, and the microcomputer reads the table 160 from the external memory. . Thus, if the setting of the microcomputer is stored in the removable external memory, the microcomputer can be operated based on the setting, so that the process of applying the setting of the microcomputer to another microcomputer becomes easy.

[実施例2の効果]
上述してきたように、本実施例ではCANメッセージに対する処理内容を示すテーブルを外部メモリに記憶させているので、メッセージに対する処理内容の変更が容易である。また、外部メモリの内容は、バックアップが容易であるし、その内容を他の大容量記憶に保存することで、複数の設定を容易に管理できる。
[Effect of Example 2]
As described above, in this embodiment, since the table indicating the processing contents for the CAN message is stored in the external memory, it is easy to change the processing contents for the message. The contents of the external memory can be easily backed up, and a plurality of settings can be easily managed by storing the contents in another large-capacity storage.

実施例1では、マイコン150は、図7のフローチャートに示すように、CANコントローラへフレーム送信を指令する場合、シリアルポート、送信内容を決定した上で、決定されたシリアルポートを介しCANコントローラへ送信指令、送信内容を出力している(S306)。   In the first embodiment, as illustrated in the flowchart of FIG. 7, when the microcomputer 150 instructs the CAN controller to transmit a frame, the microcomputer 150 determines the serial port and transmission contents, and then transmits to the CAN controller via the determined serial port. The command and transmission contents are output (S306).

しかし、上記のようにフレーム送信するシリアルポートを1つに固定せずに、別のシリアルポートに変更したり、あるいは複数のシリアルポートから送信させたりするようにする制御が考えられる。   However, as described above, it is conceivable that the serial port for transmitting a frame is not fixed to one, but is changed to another serial port or transmitted from a plurality of serial ports.

具体的には、マイコンからCANコントローラへ送信指令を出す際に、CANコントローラにCANバスへの送信の可否を問い合わせるようにする。そして、送信が不可能な場合は問い合わせたCANコントローラからの送信を止め、代わりに、別のCANコントローラからの送信が可能になるのを待つようにS306でキューを制御してもよい。   Specifically, when a transmission command is issued from the microcomputer to the CAN controller, the CAN controller is inquired of whether or not transmission to the CAN bus is possible. If transmission is impossible, the queue may be controlled in step S306 so as to stop transmission from the inquired CAN controller and wait for transmission from another CAN controller instead.

上記のような制御を実現するための、出力キューとキューへの送信データ追加の例を、図10に示す。出力キュー170は、送信するシリアルポート番号171、メッセージID172、送信するデータ173、および待ち時間174を含んでいる。シリアルポート番号171はシリアルポート1が最も高速のCANバスに繋がれており、上にあるフレームほど送信の優先度が高くなっている。いま、S306で決定した送信データは、図10(a)では、送信データ177、178は、それぞれ矢印で示す出力するシリアルポートの待ちの最後部に挿入される。挿入後のキューは図10(b)のようになる。そして、図10(b)キューの上から順に出力可能な送信データが出力されていくことになる。上記のうち待ち時間174は、最初は送信データ177、178のように0だが、キューから送信データが出力される毎に、1ずつ加算されるようになっており、送信データがキューに登録されてから経過した時間を表している。   An example of the output queue and transmission data addition to the queue for realizing the above control is shown in FIG. The output queue 170 includes a serial port number 171 to be transmitted, a message ID 172, data 173 to be transmitted, and a waiting time 174. In the serial port number 171, the serial port 1 is connected to the fastest CAN bus, and the priority of transmission is higher in the upper frame. Now, in FIG. 10A, the transmission data determined in S306 is inserted at the last part of the waiting serial port to be output indicated by the arrows in FIG. The queue after insertion is as shown in FIG. Then, transmission data that can be output in order from the top of the queue shown in FIG. 10B is output. Among the above, the waiting time 174 is initially 0 like transmission data 177 and 178, but is incremented by 1 every time transmission data is output from the queue, and the transmission data is registered in the queue. It represents the time that has elapsed since then.

いま、図10のように、高速なCANバスで通信されるデータは緊急性が高いので、そこに繋がれたシリアルポートの送信データが優先されるのは理にかなっている。しかし、通信速度の速い送信データが多い場合は通信速度の速い送信データのみが処理され、通信速度の遅いCANバスに対応するシリアルポートへの送信データは送信が大幅に遅延する恐れがある。そのような大幅な遅延を避けるために、待ち時間が所定の閾値を超えた送信データは、優先度の高いシリアルポートから送信されるように制御すればよい。   Now, as shown in FIG. 10, data communicated via a high-speed CAN bus is highly urgent, and it makes sense that priority is given to transmission data of a serial port connected thereto. However, when there is a lot of transmission data with a high communication speed, only the transmission data with a high communication speed is processed, and transmission of the transmission data to the serial port corresponding to the CAN bus with a low communication speed may be delayed significantly. In order to avoid such a large delay, transmission data whose waiting time exceeds a predetermined threshold may be controlled so as to be transmitted from a serial port having a high priority.

図11を用いて、所定の閾値を超えた送信データが生じた場合の制御を説明する。まず、送信データをキューから選び出す前に、登録されている送信データ中で、待ち時間が所定の閾値を超えたものがあるかどうかを調べる。図11(a)では、閾値が4と設定されており、矢印で示す最下行の送信データ179が待ち時間=5で、その条件に該当している。図11(b)で、当該送信データ179を抽出し、図11(c)で、抽出した送信データ179のシリアルポート番号を優先して処理されるようにシリアルポート番号1に変更し、同時に待ち時間を0に変更する。そして、変更した送信データ180を図11(d)でシリアルポート1の最後部に挿入する。このように処理することで、前記待ち時間が所定の閾値を超えた送信データの送信の順位が上がるので、キュー上の優先度の低いシリアルポートから送信される送信データの送信が大幅に遅延することが回避できる。   Control when transmission data exceeding a predetermined threshold occurs will be described with reference to FIG. First, before selecting transmission data from the queue, it is checked whether there is any registered transmission data whose waiting time exceeds a predetermined threshold. In FIG. 11A, the threshold value is set to 4, and the transmission data 179 in the bottom row indicated by the arrow corresponds to the condition with waiting time = 5. In FIG. 11 (b), the transmission data 179 is extracted, and in FIG. 11 (c), the serial port number of the extracted transmission data 179 is changed to serial port number 1 so as to be processed preferentially, and waiting at the same time. Change the time to zero. Then, the changed transmission data 180 is inserted into the last part of the serial port 1 in FIG. By processing in this way, the order of transmission of transmission data whose waiting time exceeds a predetermined threshold is increased, so transmission of transmission data transmitted from a serial port with low priority on the queue is greatly delayed. Can be avoided.

なお、図11(c)では、抽出したシリアルポート3の送信データ179に対応する送信データ179を消去している。しかし、消去すると当該送信データは、当初送信先に設定されていたCANバスには送信されなくなるので、消去せずにそのまま残してもよい。   In FIG. 11C, the transmission data 179 corresponding to the extracted transmission data 179 of the serial port 3 is deleted. However, if the data is deleted, the transmission data is not transmitted to the CAN bus that was initially set as the transmission destination. Therefore, the transmission data may be left without being deleted.

[実施例3の効果]
上述してきたように、本実施例では 送信フレームの待ち時間が所定の時間を超えた場合に、より通信速度の高いCANバスから送信されるように制御するので、送信データの送信が大幅に遅延することを回避できる。
[Effect of Example 3]
As described above, in this embodiment, when the waiting time of a transmission frame exceeds a predetermined time, control is performed so that transmission is performed from a CAN bus having a higher communication speed, so transmission of transmission data is greatly delayed. Can be avoided.

10,20 CANバス
11,12,21,22 モジュール
100 通信ユニット
110,120 CANコントローラ
112 CANI/F
114 メッセージフィルタで
116 シリアルI/F
118 送信エンジン
150 マイコン
151,152 シリアルポート
155 CPU
160,170 テーブル
161,171 シリアルポート番号
162,172 メッセージID
163,173 処理内容
174 待ち時間
177,178,179,180 送信データ
10, 20 CAN bus 11, 12, 21, 22 Module 100 Communication unit 110, 120 CAN controller 112 CAN I / F
114 With message filter 116 Serial I / F
118 Transmission engine 150 Microcomputer 151,152 Serial port 155 CPU
160, 170 Table 161, 171 Serial port number 162, 172 Message ID
163, 173 Processing content 174 Wait time 177, 178, 179, 180 Transmission data

Claims (6)

異なる通信速度のCANバスにそれぞれ接続された複数のCANコントローラと、
前記CANコントローラとそれぞれ接続された複数のシリアルポートを介して、前記異なる通信速度のCANバスにそれぞれ接続された装置間のCAN通信を制御するマイコンと
を有することを特徴とする通信ユニット。
A plurality of CAN controllers respectively connected to CAN buses having different communication speeds;
A communication unit, comprising: a microcomputer for controlling CAN communication between devices connected to the CAN buses having different communication speeds via a plurality of serial ports respectively connected to the CAN controller.
前記マイコンは、接続されたCANバスの通信速度が高い順に前記シリアルポートにアクセスしてCAN信号を受信することを特徴とする請求項1に記載の通信ユニット。   2. The communication unit according to claim 1, wherein the microcomputer receives the CAN signal by accessing the serial port in descending order of communication speed of the connected CAN bus. 前記マイコンは、前記シリアルポートの識別情報とCANメッセージの識別情報との組み合わせに対応する処理内容を定義する定義情報を記憶する記憶部を参照して、前記CAN通信を制御する
ことを特徴とする請求項1または2に記載の通信ユニット。
The microcomputer controls the CAN communication with reference to a storage unit that stores definition information defining processing contents corresponding to a combination of the identification information of the serial port and the identification information of the CAN message. The communication unit according to claim 1 or 2.
前記マイコンは、接続されたCANバスの通信速度が高い順に前記シリアルポートにアクセスしてCAN信号を送信する
ことを特徴とする請求項1〜3のいずれか一つに記載の通信ユニット。
The communication unit according to claim 1, wherein the microcomputer accesses the serial port in descending order of communication speed of a connected CAN bus and transmits a CAN signal.
前記マイコンは、送信の待機時間が所定値を超えたCANメッセージに対して、現在送信元に設定されているシリアルポートより通信速度が高いCANバスに対応したシリアルポートに送信元を変更する
ことを特徴とする請求項1〜4のいずれか一つに記載の通信ユニット。
In response to a CAN message whose transmission standby time exceeds a predetermined value, the microcomputer changes the transmission source to a serial port corresponding to a CAN bus whose communication speed is higher than the serial port currently set as the transmission source. The communication unit according to any one of claims 1 to 4, characterized in that:
コンピュータに、
異なる通信速度のCANバス上のCANメッセージを選別し、
選別されたCANメッセージをシリアル信号に変換し、
前記CANメッセージを、当該CANメッセージが入力されたシリアルポートのIDと当該CANメッセージのIDとに基づいて制御する、
処理を実行させることを特徴とするCAN通信制御プログラム。
On the computer,
Select CAN messages on CAN bus with different communication speeds,
Convert the selected CAN message into a serial signal,
Controlling the CAN message based on the ID of the serial port to which the CAN message is input and the ID of the CAN message;
A CAN communication control program for executing a process.
JP2014091833A 2014-04-25 2014-04-25 Communication unit and can(control area network) communication control program Pending JP2015210667A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2014091833A JP2015210667A (en) 2014-04-25 2014-04-25 Communication unit and can(control area network) communication control program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2014091833A JP2015210667A (en) 2014-04-25 2014-04-25 Communication unit and can(control area network) communication control program

Publications (1)

Publication Number Publication Date
JP2015210667A true JP2015210667A (en) 2015-11-24

Family

ID=54612801

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2014091833A Pending JP2015210667A (en) 2014-04-25 2014-04-25 Communication unit and can(control area network) communication control program

Country Status (1)

Country Link
JP (1) JP2015210667A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2571302A (en) * 2018-02-23 2019-08-28 Grey Orange Pte Ltd Hybrid can bus system

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2571302A (en) * 2018-02-23 2019-08-28 Grey Orange Pte Ltd Hybrid can bus system

Similar Documents

Publication Publication Date Title
US9170569B2 (en) Method for electing an active master device from two redundant master devices
JP2016032274A (en) Gateway unit
US11467566B2 (en) Communication device, communication terminal, communication device and method for operating a communication system for transmitting time-critical data
JP2014045421A (en) Network system
US10176128B2 (en) Communication system for inter-chip communication
JP2006191337A (en) Gateway device for transferring message between buses and network system using the device
CN110268348B (en) Control device, control method, and computer-readable recording medium
CN104426793A (en) Apparatus For Controlling Network Traffic
US20190268300A1 (en) Communication device and method of controlling communication device
US9882737B2 (en) Network system
JP2015210667A (en) Communication unit and can(control area network) communication control program
WO2014007067A1 (en) Communication system, relay apparatus and communication apparatus
JP2021166335A (en) On-vehicle relay device, information processing method, and program
JP5458968B2 (en) Safety control system
JP5728043B2 (en) Gateway device
CN108243244B (en) Vehicle-mounted communication system and control method thereof
JP4361540B2 (en) Gateway device, data transfer method, and program
JP4873220B2 (en) Field communication system
US20220137604A1 (en) Coordination Device and Method for Providing Control Applications via a Communication Network for Transmitting Time-Critical Data
US11226611B2 (en) Control device, control method, and control program
JP6276738B2 (en) CAN communication unit and CAN communication program
JP2018055318A (en) Electronic apparatus and program
JP7277206B2 (en) Communication control device and method
JP6183281B2 (en) Communication system and electronic control device
JP2012114724A (en) Electronic control device

Legal Events

Date Code Title Description
A711 Notification of change in applicant

Free format text: JAPANESE INTERMEDIATE CODE: A712

Effective date: 20151104

RD02 Notification of acceptance of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7422

Effective date: 20151221