In this paper, an IEEE1588 based clock synchronization technique for CAN (Controller Area Network) is presented. Clock synchronization plays a key role to the success of a networked embedded system. Recently, the IEEE1588 algorithm making use of dedicated chipsets has been widely adopted for the synchronization of various industrial applications using Ethernet. However, there is no chipset available for CAN. This paper presents the implementation of IEEE1588 for CAN, which is implemented using only software and CAN packets without any dedicated chipset. The proposed approach is verified by the comparison between the estimated synchronization precision with a simple model and the measured precision with experimental setup. ※ 본 연구는 미래창조과학부 및 정보통신산업진흥원의 IT융합 고급인력과정 지원사업의 연구결과로 수행되었음 (NIPA-2013-H0401-13-1005) First Author : 경북대학교 전자공학부 고신뢰성 임베디드 제어 시스템 연구실, itisuptous@nate.com, 학생회원 ° Corresponding Author : 경북대학교 전자공학부 고신뢰성 임베디드 제어 시스템 연구실, dilee@ee.knu.ac.kr, 정회원 * 경상공업고등학교 지능형로봇과, solitarykim@hanmail.net 논문번호:KICS2014-02-035, 접수일자:2014년 2월 4일, 심사일자:2014년 2월 17일, 최종논문접수일자:2014년 2월 21일 I. 서 론 1980년대 이후 마이크로프로세스 기술과 이를 이 용한 산업용 네트워크 기술의 발전에 힘입어 다양한 분야에서 네트워크 기반 임베디드 시스템의 적용이 이루어지고 있다. 필드버스(fieldbus) 또는 데이터버스 (databus)로 불리는 산업용 네트워크는 단순히 복잡한 배선 문제를 개선하는 것 뿐 아니라, 모듈화 설계, 유 지보수 효율성, 시스템 설치 및 수정보완 편리성 등의 장점을 제공하므로, 최근에는 고도의 안전성과 신뢰도 가 요구되는 경성실시간(hard real-time) 시스템에서 도 많이 이용되고 있다. 1980년대 중반 독일의 Bosch 사에 의해 차량내 통신 용도로 개발된 CAN (Controller Area Network) 은 짧고 주기적인 메시지 한국통신학회논문지(J-KICS) '14-02 Vol.39B No.02 124 그림 1. Round-robin 스케줄을 적용한 시간기반 시스템 Fig. 1. Round-robin scheduling of time-triggered system. 의 전송에 적합한 대표적인 필드버스이다. CAN은 차 량에 성공적으로 적용되어 안정성이 검증되었을 뿐 아니라, 사용이 간편하고, 전용 칩과 개발장비를 비롯 해 다양한 지원 제품들이 개발됨에 따라 최근에는 자 동차 산업 외에도 제트엔진, 풍력발전, 잠수함 등에 이르기까지 CAN의 적용분야가 꾸준히 확대되는 추 세이다 . 하지만 최대 1Mbps의 데이터 전송률, 우 선순위가 낮게 지정된 메시지의 과도한 전송지연, 메 시지 충돌 발생시 전송지연이 랜덤하게 변하는 특성 등으로 인해 CAN을 제동장치나 조향장치 등 경성실 시간 시스템에 직접 적용하기에는 어려움이 있다. 이 러한 문제점을 극복하기 위한 대안으로써 시스템을 시간기반(time-triggered)으로 설계 및 구현하는 방안 이 자주 이용된다 . 즉 네트워크에 연결된 노드들이 수행하는 태스크에 대해 그림 1과 같은 round-robin 방 식의 스케줄을 적용함으로서 네트워크의 대역폭 사용효 율을 높이고, 메시지 충돌이 발생하지 않도록 하여 우선 순위와 무관하게 일정한 전송 특성을 얻을 수 있다. 그러나 시간기반 시스템 구현을 위해서는 높은 신뢰 도와 정밀도를 가지는 시간동기(clock synchronization) 의 확보가 반드시 필요하며 , CAN 기반 시스템의 시 간동기에 대한 연구도 다수 발표된 바 있다 . 하지 만 기존 연구에서 제시한 방법들은 ‘in-house’ 구현, 즉 해당 시스템을 위해 자체 개발한 소프트웨어에 의 존하므로 여러 가지 문제점이 따른다. 무엇보다 동기 알고리즘의 신뢰성을 검증하기 어렵고, 소프트웨어 엔 지니어의 역량에 따라 시간동기 성능의 편차가 발생 할 수 있으며, 새로운 시스템 또는 네트워크 적용시 시간동기 소프트웨어를 재작성할 필요가 있다. 이러한 문제점은 표준화된 시간동기 기법을 적용하여 극복 가능하다. 대표적인 임베디드 네트워크용 시간동기 표 준으로 IEEE1588 을 들 수 있다. PTP(Precision Time Protocol)로 불리우는 IEEE1588은 마스터-슬레 이브 방식의 시간동기 기법이며, 마스터가 전송하는 Sync 메시지와 FollowUp 메시지를 이용하여 전송지연 에 의한 동기오차를 보상한다. 멀티캐스트(multicast) 방식의 네트워크에 모두 적용가능 하지만, 아직까지는 EtherCAT, TTEthernet 등 산업용 Ethernet에만 이용 되고 있다. 일반적으로 IEEE1588의 적용을 위해서 전 용 칩을 사용하는데 현재까지 상용화된 칩은 모두 Ethernet 용도로 개발되었기 때문이다. 최근에는 IEEE1588의 동기성능 개선 또는 마스터 고장 상황 인지 및 복구 기법 등에 관한 연구결과가 제시되고 있 으나 이들 역시 Ethernet에 적용한 연구들이 대부분이 다 . 본 논문에서는 CAN 기반 시스템의 시간동기를 위 해 IEEE1588을 소프트웨어로 구현하고, 실험용 네트 워크를 구성하여 동기정밀도를 정량적으로 분석한다. 아울러 시간동기 정밀도 추정을 위한 모델을 도출하 여, 실험을 통해 얻은 정밀도와 모델의 결과를 비교한 다. 일반적으로 IEEE1588 전용 칩을 이용하여 Ethernet에 적용시 수 us 수준의 동기정밀도를 얻을 수 있으나, 본 논문에서는 소프트웨어 방식의 구현과 저사양 클럭 및 CAN의 낮은 전송속도를 고려하여 수 백 us 수준의 동기정밀도를 얻는 것을 목표로 한다.