Korenix JetBox 8152 Manuale utente

JetBox 8152 Linux CANBus
User Manual
www.korenix.com
StockCheck.com

Korenix | Table of Content
2
Copyright Notice
Copyri ht© 2012 Korenix Technolo y Co., Ltd.
All ri hts reserved.
Reproduction without permission is prohibited.
Information provided in this manual is intended to be accurate and reliable.
However, the ori inal manufacturer assumes no responsibility for its use, or for
any infrin ements upon the ri hts of third parties that may result from its use.
The material in this document is for product information only and is subject to
chan e without notice. While reasonable efforts have been made in the
preparation of this document to assure its accuracy, Korenix assumes no liabilities
resultin from errors or omissions in this document, or from the use of the
information contained herein.
Korenix reserves the ri ht to make chan es in the product desi n without notice
to its users.
Acknowledgments
Korenix is a re istered trademark of Korenix Technolo y Co., Ltd.
All other trademarks or re istered marks in the manual belon to their respective
manufacturers.
StockCheck.com

Korenix | Table of Content
3
Table of Content
Copyright Notice ............................................................................................2
Acknowledgments..........................................................................................2
Table of Content.............................................................................................................3
Chapter Introduction ...............................................................................................4
Chapter 2 Hardware Configuration.............................................................................6
2- Pin Assignment...........................................................................................6
2-2 Jumper Setting: JP6....................................................................................6
Chapter 3 Software Configuration ..............................................................................7
3- Installation..................................................................................................7
3-2 Example......................................................................................................8
Chapter 4 Korenix Library Reference ..........................................................................9
4- How to Use Library.....................................................................................9
4-2 Functions....................................................................................................9
4-3 Structure .................................................................................................. 5
Chapter 5 Appendix .................................................................................................. 7
5- Baud Rate Table........................................................................................ 7
5-2 Error Code Table....................................................................................... 8
5-3 Notes ........................................................................................................ 9
5-4 Revision history ........................................................................................20
5-5 Customer Service .....................................................................................20
StockCheck.com

Korenix | Introduction
4
Chapter 1 Introduction
The JetBox 8 52 has two ports for I/O communications, One RS-232/422/485 port and
one CANBUS port. The CAN (Controller Area Network) is a serial bus system
especially suited for networking "intelligent" I/O devices as well as sensors and
actuators within a machine or plant. Characterized by its multi-master protocol,
real-time capability, error correction, high noise immunity, and the existence of many
different silicon components, the CAN serial bus system, originally developed by
Bosch for use in automobiles, is increasingly being used in industrial automation.
CANbus
This section describes how to program and use the CANBUS. It provides a description
of the I/O memory map of the chip and discussion of the internal registers to aid you
in programming your CAN controller chip.
Defined Memory Mapping and Interrupt
The CANBUS occupies 2 bytes of memory space. You can set the base address and
access to the internal resources of the SJA 000 CAN controller chip. The SJA 000
chip access is multiplexed in such a way that the host must first write to 300h the
internal address of the CAN chip and after that perform a write to address 301h with
the actual data to be written into the desired memory location. Address 302h is a
hardware-reset function of the SJA 000. Performing a read or write to this address
StockCheck.com

Korenix | Introduction
5
will cause a hardware reset to the CAN controller. You may need to reset the chip in
case of an unrecoverable error in the CAN controller chip. And your can use interrupt
the main processor when a message is received or transmitted if interrupts are
enabled on the JetBox 8 52. By using interrupts you can write powerful code to CAN.
Example Programming
Write 300H to the CAN controller Control byte located in the on-chip address 0.
The Example is listed below:
Outportb (0x300, 0x00) : Write CAN Address 0 (Control Register )
Outportb (0x30 , 0x78) : Write Data of CAN Address 0 (Control Register )
And please see “SJA 000.pdf” for further information of the SJA 000 chip.
Description Factory Setting
Base Address 300H
Data Of Address 30 H
Hardware Reset Of SJA 000 Chips
302H
Interrupt Require Quest
StockCheck.com

Korenix | Hardware Configuration
6
Chapter 2 Hardware Configuration
2-1 in Assignment
The CANBUS is use DB9 standard connector. The following tables show the
CANBUS signal connections of this connector.
Note : The CANBUS DB9-pin out conforms to the ISO 898/2 standard
2-2 Jumper Setting: J 6
JP6: CANBUS Ter inal Resistor Selection
Note 2: The JP6 is the CANbus termination jumper. Only two termination
jumpers should be closed at the endpoints of the CANbus. Value Terminator Resistor
( 20 Ω). The ini u speed is 20k bps. The axi u speed is 1M bps. But when
CANBUS terminator is disabled, the maximize speed of CANBUS is 125k bps. If you
want to use high speed ( M bps), please enable terminator.
DB-9
CANBUS
CANBUS
Signal
CANBUS
Description
N.C -
6 N.C -
2 CAN-L Dominant Low
7 CAN-H Dominant High
3 CAN-Ground Isolated Ground
8 N.C -
4 N.C -
9 N.C -
5 Ground Digital Ground
Case Case Ground
Factory preset
StockCheck.com

Korenix | Software Configuration
7
Chapter 3 Software Configuration
3-1 Installation
Prerequisites
To make CANBus work correctly. We have to install three components first.
Make sure your network is connected.
. GCC : call “yu install gcc”
2. OpenSSL : call “yu install openssl”
3. OpenSSL-devel : call “yu install openssl-devel.i386”
After install these components, the CANBUS library and follow example code
will work successfully.
Do the following steps to setup the driver
. Login in as root. ( username : root, password : korenix )
2. Default CanBus code are built-in jetbox linux environment. Go to the path
/CanBus and you will see the follow directory.
3. In the “library” directory. You will see the two files below.
libmycanbus.so. .0.0 :
It contains all CanBus functions that user can use it to program.
mycanbus.h :
It defines CanBus structure, message type and baud rates settings.
All details will be shown in Chapter 4.
4. In the “example” directory. You will see the files below.
StockCheck.com

Korenix | Software Configuration
8
Call “ ake” to compile files and “ ake install” to install library to /usr/lib.
All details will be shown in next session.
3-2 Example
CANBus example for Linux is a simple CAN monitor for viewing and transmitting CAN
messages. When you call “make” and “make install” to compile/install all need files.
It will generate two sample files, “cantest” and “canrcv”.
cantest
There will be four command as below :
cantest -i : Initial CanBus Chip and set baud rate to 25K.
cantest -r : Reset CanBus Chip
cantest -s : Get CanBus status
cantest -w : Write CAN message. We use standard message type in this example.
canrcv
This example show you how to receive CAN message from other CANBus. Before
to receive CAN messages, you have to reset CAN chip first and initial it.
StockCheck.com

Korenix | Korenix Library Reference
9
Chapter 4 Korenix Library Reference
This section shows how to use Korenix CANbus Library to develop your program.
When you call “make install” in the example directory, the library will be installed to
the /usr/lib path.
4-1 How to Use Library
We use dlopen to load CANBus library. You will see it in the example. Like this
handle = dlopen ("/usr/lib/lib ycanbus.so.1", RTLD_NOW);
Use dlsy to take a "handle" of a dynamic library returned by dlopen and the null
terminated symbol name, returning the address where that symbol is loaded.
Init_CanBus = dlsy (handle, "Init_Can");
Call “ an dlopen” to detail infor ation of dlopen, dlsy .
All functions (sy bol) are listed in next session.
4-2 Functions
The CanPort library provides the following functions
Init_Can
void Init_Can(BYTE BTR0, BYTE BTR )
Para eters
BTR0
BUS TIMING REGISTER 0
BTR
BUS TIMING REGISTER
This function sets configuration parameters to initialize the CAN controller.
Configuration parameters include baud rate. Valid Baud rate codes can be taken from
the Baud Rate Table.
StockCheck.com

Korenix | Korenix Library Reference
0
This function will also set up the Interrupt Enable Register, Acceptance Code Register,
Acceptance Mask Register and Output Control Register.
Can_Chip_Reset
void Can_Chip_Reset(void)
This function resets the CAN controller to default state.
The transmitting and receiving of messages will be canceled, and messages
in the driver buffer will be cleared as well.
Can_Send_Message
void Can_Send_Message(CANMsg *MsgToSend)
Para eters
MsgToSend
Message to transmit. Please refer to Structure for details.
Can_Receive_Message
void Can_Receive_Message(CANMsg *MsgToRead)
Para eters
MsgToRead
Returns a CAN message from the receive queue.
Can_Status_Report
BYTE Can_Status_Report(void)
Return
Status of CAN controller
Get the current status of the CAN controller.
StockCheck.com
Indice
Altri manuali Korenix Hardware di rete
Manuali Hardware di rete popolari di altre marche

Matrix Switch Corporation
Matrix Switch Corporation MSC-HD161DEL Manuale utente

B&B Electronics
B&B Electronics ZXT9-IO-222R2 Manuale utente

Yudor
Yudor YDS-16 Manuale utente

D-Link
D-Link ShareCenter DNS-320L Manuale utente

Samsung
Samsung ES1642dc Istruzioni per l’uso

Honeywell Home
Honeywell Home LTEM-PV Istruzioni per il montaggio












