CAN communication network, using the module msCAN with the microcontroller MC9S12XDT512.
Salvador Hernandez Gonzalez UTEQ, Querétaro, México
[email protected]
Jorge Luis Morales Montes UTEQ, Querétaro, México
[email protected]
Abstract This work use the CAN network, which consists of a pair of wires, to test the communication is a fact made use of a potentiometer with a unique identifier and use the standard CAN 2.0 B whose ID is 29 bits whose value was "V1" is passing through an analogdigital and got the value to the CAN network to view this data was used HyperTerminal. The test was performed initially with two MCU (microcontroller) and then increase to three. Results we studied in detail the bus, to monitor the behavior and see the consistency of schedule versus what is represented, at least in the initial part of the plot, coinciding bit by bit. The study deeper into a topic as relevant a particular area of opportunity to provide a programming methodology and to carry into practice the theoretical concepts, and have a development platform for future applications, and also serve as a physical model for interpret the regulations and reduce learning time and use of CAN technology. Keyword: CAN: Controller Area Network MCU: microcontroller
1. Introduction The CAN network is a serial, asynchronous, multimaster communications protocol designed to work with distributed control applications in real time and speed (bit rate) up to 1Mbit / s; for connecting electronic control unit,sensors and actuators in automotive and industrial application.[1] Originally developed by Robert Bosch Gmbh in early 1980 for the automotive sector, the advantages of the CAN protocol can also be moved to other application areas such as industry. The low cost of CAN networks plus high-performance microcontrollers used make them hard to beat an opponent at least the years. There are countless manufacturers of devices such as
Cuauhtemoc Carbajal Fernández ITESM; CEM. Atizapán, Edo de México
[email protected]
microcontrollers and CAN interfaces, one of the most trade has its msCAN programming module (Motorola Scalable Controller Area Network) protocol based on CAN. CAN used as a method of channel access protocol CSMA / CD + AMP, information is transmitted to the bus using frames, the main frameis known as data and there are three more remote, overload and error; are responsible for giving functionality to the bus. The data frame is responsible for transporting data, consists of a series of seven boxes called fields and are as follows: start, ID, control, data, CRC, ACK and EOF, the data field can contain up to 8 bytes.[2]
2. CAN numbers. In summary and for simplicity when studying the protocol was performed the following table with the most representative feature of the CAN protocol. Table 1; [2],[3]
Feature ISO Coding Access method channel Settings Versions
States
#
Description
1 ISO 11898 1 NRZ CDMA/CD+AMP 2 Basic 2 Full 2.0 A estándar d(id 11 bit) 2 2.0 B extended(id 29 bit) 0-dominant 2 1 recessive
Signals Node State
Frames
Model Layers Error
CAN H 2 CAN L Active 3 Passive Canceled Data frames, 4 Remote Overload, Error Physical, Transfer 4 Object ,Aplication. Bit, CRC, Form 5 Fill, ACK.
Data frame SOF, Identifier, fields 7 Control, Data CRC, ACK, EOF Data 8 8 bytes Table 1. CAN Summarized in numbers
3. Platform To build the platform (stage) card is used CSM12D (Axiom) Figure 1; containing the MC9S12XDT512 microcontroller (Freescale) and uses the transceiver PCA82C250 (Phillips) MCUs are connected via CAN port available on the card, it is important to note that of the three ports CAN0, CAN1 and CAN3 available on this MCU, only the CAN0 is wired the remaining two are available on the J1 port flags. [4], [5]
Figure 1. Connection Diagram of the CAN bus.
Since the controller is built into the micro, all you need to add is the transceiver and the connector includes the card and CSM12D. Regarding the former, the model used is the classic Philips PCA82C250. Supports connection to other nodes 110 to a maximum speed of 1Mbps. Tolerates short circuit between the bus lines and power supply through a current limiter, is thermally protected and has a high rejection to common mode noise peaks supporting important. An advantage of this card is that it already has a 120Ω resistor between terminals as terminator CAN H and CAN L and so only need to connect the three flags CAN port with an open connector one by one to to visualize the data sent and received we will use the serial port SCI also present on the card and connect to two computers respectively, to visualize the data, open a HyperTerminal session with standard parameters (9600-8-N-1) . [6], [7], [8] For the physical environment including CAN ports use 20 AWG twisted pair.
4. Programming To programming was used Codewarior 4.7, and was programmed in C language, being a high-level universal language available in this compiler. The MCU is used in "stand alone", to program and debug multilink interface was used. which allows you to program HC08 devices and HC12.y allows data exchange via the BDM port. without the need for developing an integrated card our card. The speed that was selected was 125 kbps, and is sent by a second data continuously, the fabric used was the 29-bit extended identifier. The first part in programming is to program the registers to initialize and enable the communication module msCAN see Figure 2, then continues with the records of time where prescalador assigned to 2 and SJW (Synchronization Jump With) = 3, also select SAMP = 0, = 3 and TSEG1 TSEG2 = 10 and you want to have 4 and 11 TQ (time quantum). The next part is to select the desired acceptance filter in our case we selected the 2 x 32-bit and proceed to the next part that is to program the ID acceptance mask and acceptance which we do for the characters "V1" and the last part is to enable the buffer for transmission. [7], [9], [10]
have an offset to 2.5 volts on channel a of oscilloscope is in the top and channel B is in the lower signs the socalled CAN High and CAN low respectively.
Figure 2 Programming Sequence The parameters for the register hexadecimal, [9]
must be given in
5.Results 5.1 Two MCU on the bus. Equipment was installed in accordance with the provisions of the initial part of this paper, see Figure 3. Switching two cards CSM12D, using twisted pair cable connection lime. Ending with 20 AWG threeway connector, which is connected in parallel with the CAN bus, CAN CAN H H (pin 1), ground to ground (pin 2), CAN L CAN L (pin 3) see Figure 6.6 . In the software module used the program msCAN shown in the previous section plus a routine to send the data obtained both serial port and the CAN bus and thus realize the successful communication.
Figure 4 Image showing signs oscilloscope CAN H and CAN L The received data is then visualize a data received of 3.9 Volts from MCU 1 and a 2.1 Volts transmitted data that comes from MCU 2, visualize this in hyperterminal screen, see Figure 5
Figure 5. Data sent and received
Figure 3. Two MCU on bus CAN The data we select is the voltage of 3.9 volts on the potentiometer MCU 1 and MCU 2 2.1Volts select a voltage, this voltage is easily manipulated as you take the card in the range of 0 to 5 V dc The oscilloscope was observed that by varying a single data (the voltage) the only observable change was in the CRC of the frame and the ACK as shown in Figure 4; which have different data and CRC, the voltage levels match the requirements stated about 1 volts and
5.2 Three MCU on the bus. Add a third card CSM12D see Figure 6, using twisted pair cable connection lime. Ending with 20 AWG three-way connector, which is connected in parallel with the CAN bus, CAN CAN H H (pin 1), ground to ground (pin 2), CAN L CAN L (pin 3). In the software we use the same program used previously set at the same speed and 125 kbps same identifier and mask for the buffer. Observe the operation
Initially programs were conducted separately for transmission and reception, but was simplified to one for transparency and scalability as the same program we can increase the number of nodes (MCU) and continue to function properly.
7. References [1]. R. Sebastián, M. Castro, E. Sancristobal, F. Yeves and J. Peire, Electrical and Computer Engineering Department,UNED,Madrid,SPAIN. J. Quesada Corporación Zigor S.A., Vitoria,SPAIN
Figure 6. Three MCU installed on bus CAN The received data is then visualize as two received 3.5 Volts and 5.0 Volts MCU MCU 1 and 2 respectively and a 1.9 Volts transmitted data that comes from MCU 3, Figure 7. Image showing HyperTerminal with one data sent and two data received.
[2]. Héctor Kaschel C.; Ing. Ernesto Pinto L., Análisis protocolar del bus de campo CAN, Fac. de Ingeniería, Depto. de Ingeniería Eléctrica. Universidad de Santiago de Chile [3]. M. Farsi, K. Ratcliff and Manuel Barbosa, An overview of Controller Area Network, computing & control engineering journal, june 1999 [4]. Olaf Pfeiffer,Andrew Ayre,Christian Keydel.Embedded networking with CAN and CANopen, Annabooks/Rtc Books (November 1, 2003) [5]. Application module student learning kit featuring freescale MC9S12XDT512. Freescale Semiconductor SLK0103UG, User Guide Rev. 0, 7/2006 [6]. Barret, “Embedded system design and applications with the 68HC12 on HCS12 Pearson,2005.
Figure 7 Image showing HyperTerminal data sent and received
[7]. Hang-Way Huang, The HCS12/9S12 an introduction to software and hardware interfacing,. Clifton Park, N.Y. Delmar, Thomson Learning.
6. Conclusion
[8]. CSM12D_SCH_C(SCHEMATIC), Axion manufacturing CSM12D AXM-0362
Among the difficulties encountered, this little documentation about the programming module msCAN, as to the microcontroller by the manufacturer is provided as needed. There are also some application notes for other manufacturers and models, but nothing directly MC9S12XDT family. On the use of the software found some factors that do not support transparency as a "release" compiler to the next, you have to add libraries. or to change the name of the record. The adjusted program can address entries, change speeds, handles frames. And to serve experimental model for possible developments with the CAN protocol.
[9]. MSCAN Block Guide V03.01, DOCUMENT NUMBER S12MSCANV3/D; Revised: 15 JUL 2004. Freescale Semiconductor. [10].Using MSCAN on the HCS12 Family, Application Note AN3034, Rev. 0, 09/2005, By Rebeca Delgado, Antonio Ramos, Luis Reynoso, RTAC Americas; Mexico 2005, Freescale Semiconductor.