NuCOM© PCI-7841/cPCI-7841/PM-7841 Dual-Port Isolated CAN Interface Card User’s Manual Manual Rev. 3.00 Revision Date: June 28, 2006 Part No: 50-11109-1010 Advance Technologies; Automate the World.
Copyright 2006 ADLINK TECHNOLOGY INC. All Rights Reserved. The information in this document is subject to change without prior notice in order to improve reliability, design, and function and does not represent a commitment on the part of the manufacturer. In no event will the manufacturer be liable for direct, indirect, special, incidental, or consequential damages arising out of the use or inability to use the product or documentation, even if advised of the possibility of such damages.
Getting Service from ADLINK Customer Satisfaction is top priority for ADLINK Technology Inc. Please contact us should you require any service or assistance. ADLINK TECHNOLOGY INC. Web Site: http://www.adlinktech.com Sales & Service: Service@adlinktech.com TEL: +886-2-82265877 FAX: +886-2-82265717 Address: 9F, No. 166, Jian Yi Road, Chungho City, Taipei, 235 Taiwan Please email or FAX this completed service form for prompt and satisfactory service.
Table of Contents Table of Contents..................................................................... i List of Tables.......................................................................... iii List of Figures ........................................................................ iv 1 Introduction ........................................................................ 1 1.1 1.2 1.3 PCI/cPCI/PM-7841 Features ............................................... 1 Applications ............................
CanEnableReceive() ..................................................... 24 CanDisableReceive() .................................................... 25 CanSendMsg() .............................................................. 25 CanRcvMsg() ................................................................ 26 CAN-layer Status Functions ......................................... 27 CanClearOverrun() ....................................................... 27 CanClearRxBuffer() .................................
List of Tables Table 1-1: PCI-7841 Specifications ........................................... 4 Table 1-2: cPCI-7841 Specifications ......................................... 4 Table 1-3: PM-7841 Specifications ............................................
List of Figures Figure 2-1: Default Base Address Configuration........................ 13 Figure 2-2: IRQ Settings ............................................................
1 Introduction The PCI/cPCI/PM-7841 is a Controller Area Network (CAN) interface card used for industrial PC with PCI, Compact-PCI, and PC104 bus. It supports dual ports CAN’s interface that can run independently or bridged at the same time. The built-in CAN controller provides bus arbitration and error detection with auto correction and re-transmission function. The PCI cards are plug and play therefore it is not necessary to set any jumper for matching the PC environment.
The cPCI-7841 is a Dual-Port Isolated CAN Interface Card with the following features: X Two independent CAN network operation X Bridge function supports X Compatible with CAN specification 2.
1.
1.3 Specifications PCI-7841 Specification Table Ports 2 CAN channels (V2.
Size 132(L)mm x 98(H)mm Table 1-2: cPCI-7841 Specifications PM-7841 Specification Table Ports 2 CAN channels (V2.
6 Introduction
2 Installation This chapter describes how to install the PCI/cPCI/PM-7841. At first, the contents in the package and unpacking information that you should be careful are described. 2.1 Before Installing the PCI/cPCI/PM-7841 Your PCI/cPCI/PM-7841 card contains sensitive electronic components that can be easily damaged by static electricity. The card should be done on a grounded anti-static mat. The operator should be wearing an anti-static wristband, grounded at the same point as the anti-static mat.
PCI-7841 Layout: Terminator Configuration A 120 Ohm terminal resistor is installed for each port, while JP1 enables the terminal resistor for port0 and JP2 enables the terminal resistor for port 1 Connector Pin Definition P3 and P4 are CAN connectors; pin definition is as follows: 8 Installation
2.3 Installing cPCI-7841 What you have In addition to this User's Manual, the package includes the following items: X cPCI-7841 Dual Port Compact-PCI Isolated CAN Interface Card X ADLINK CD-ROM If any of these items is missing or damaged, contact the dealer from whom you purchased the product. Save the shipping materials and carton in case you want to ship or store the product in the future.
Connector Pin Definition J1 and J2 are CAN connectors; pin definition is as follows: 2.4 Installing PM-7841 What you have In addition to this User's Manual, the package includes the following items: X PM-7841 Dual Port PC-104 Isolated CAN Interface Card X ADLINK CD-ROM If any of these items is missing or damaged, contact the dealer from whom you purchased the product. Save the shipping materials and carton in case you want to ship or store the product in the future.
PM-7841 Layout Terminator Configuration A 120 Ohm terminal resistor is installed for each port, while JP1 enables the. terminal resistor for port0 and JP2 enables the terminal resistor for port 1.
Connector Pin Define J1 and J2 are CAN connectors; pin definition is as follows: 2.5 Jumper and DIP Switch Description You can configure the output of each channel and base address by setting jumpers and DIP switches on the PM-7841. The card's jumpers and switches are preset at the factory. Under normal circumstances, you should not need to change the jumper settings. A jumper switch is closed (sometimes referred to as "shorted") with the plastic cap inserted over two pins of the jumper.
SW1 : Base Address = 0x200 ON 1 2 3 4 5 A(8 7 6 5 4) Figure 2-1: Default Base Address Configuration (*): default setting ON X: don't care OFF Note: Installation : 0 : 1 A4,…, A9 correspond to PC-104(ISA) bus address lines.
2.7 IRQ Level Setting A hardware interrupt can be triggered by the external Interrupt signal which is from JP3 ad JP4. The jumper setting is specified as below: Note: Be aware that there is no other add-on cards sharing the same interrupt level in the system.
3 Function Reference The cPCI/PCI-7841 functions are organize into the following sections: X CAN layer functions X Card Initialization and configuration functions X CAN layer I/O functions X CAN layer status functions X CAN layer Error and Event Handling functions X DeviceNet layer functions X Send and Receive packet functions X Connection establish and release functions X DeviceNet object class functions The particular functions associated with each function are presented in next page.
CanClearOverrun() CanClearRxBuffer() CanClearTxBuffer() CanGetErrorCode() CanGetErrorWarningLimit() CanSetErrorWarningLimit() CanGetRxErrorCount() CanGetTxErrorCount() CanSetTxErrorCount() CanGetPortStatus() CanGetLedStatus()1 CanSetLedStatus()1 Error and Event handling functions Operation System DOS Windows 95/98/NT Note: Function Name CanInstallCallBack() CanRemoveCallBack() CanInstallEvent() only for compact PCI and PC-104 version.
Members mode: 0 means using 11-bit in CAN-ID field 1 means using 29-bit in CAN-ID field. accCode:Acceptance Code for CAN controller. accMask:Acceptance Mask for CAN controller. baudrate:Baud rate setting for the CAN controller. Value Baudrate 0 125 Kbps 1 250 Kbps 2 500 Kbps 3 1M bps CanPortConfig(), CanGetPortStatus(), and PORT_STATUS structure PORT_STATUS structure define The PORT_STATUS structure defines the status register and PORT_STRUCT of CAN port.
unsigned unsigned unsigned unsigned short short short short TxEnd: 1; RxStatus: 1; TxStatus: 1; ErrorStatus: 1; unsigned short BusStatus: 1; unsigned short reserved: 8; }; See Also CanGetPortStatus(), and PORT_STATUS structure CAN_PACKET structure define The CAN_PACKET structure defines the packet format of CAN packet. It is used by the CanSendMsg(), and CanRcvMsg() functions.
DEVICENET_PACKET structure define The DEVICENET_PACKET structure defines the packet format of DeviceNet packet. It is widely used by the DeviceNet layer functions. typedef struct _tagDEVICENET_PACKET { BYTE Group; BYTE MAC_ID; BYTE HostMAC_ID; BYTE MESSAGE_ID; BYTE len; BYTE data[8]; DWORD time; BYTE reserved; }DEVICENET_PACKET; Members Group: Group of DeviceNet packet. MAC_ID: Address of destination. HostMAC_ID:Address of source. MESSAGE_ID:Message ID of DeviceNet packet. len: Length of data field.
3.2 CAN LAYER Functions CAN-layer Card Initialization Functions PM7841_Install(base, irq_chn, 0xd000) Purpose Get the version of driver Prototype C/C++ int PM7841_Install(int baseAddr, int irq_chn, int memorySpace) Parameters baseAddr:Base Address of PM-7841(DIP Switch) Irq_chn: IRQ channel (Jumpper) MemorySpace: Memory Mapping Range Return Value A signed integer 0 : Successful -1: Failed Remarks PM7841 is PC104(ISA) CAN interface card. It will need 32-bytes I/O space and 1K memory space.
Remarks See Also Usage Call this function to retrieve the version of current using driver. This function is for your program to get the version of library and dynamic-linked library. none C/C++ #include “pci7841.h” WORD version = GetDriverVersion(); majorVersion = version >> 8; minorVersion = version & 0x00FF; CanOpenDriver() Purpose Prototype Parameters port: Return Value Remarks See Also Usage Open a specific port, and initialize driver.
Parameters Return Value Remarks See Also Usage handle : handle retrieve from CanOpenDriver() Port : index of port Return 0 if successful -1 if error occurs Call this function to close a port. CanOpenDriver() See usage of CanOpenDriver().
CanCloseDriver(handle); CanDetectBaudrate() Purpose Prototype Parameters Return Value Others is the baudrate Perform auto-detect baud rate algorithm. C/C++ int CanDetectBaudrate(int handle, int miliSecs) handle: handle retrieve from CanOpenDriver() MiliSecs: timeout time(ms) Return –1 if error occurs Value Baudrate Remarks See Also Usage 0 125 Kbps 1 250 Kbps 2 500 Kbps 3 1 Mbps Call this function to detect the baud rate of a port. The function performs an algorithm to detect your baud rate.
CanConfigPort(handle, &port_struct); CanCloseDriver(handle); Visual Basic(Windows 95/98/NT) CanRead() Purpose Prototype Parameters Return Value Remarks See Also Usage Direct read the register of PCI-7841. C/C++ BYTE CanRead(int handle, int offset) handle : handle retrieve from CanOpenDriver() offset : offset of register Return data read from port. Direct read the register of PCI-7841.
Parameters Return Value Remarks See Also Usage void CanEnableReceive(int handle); handle : handle retrieve from CanOpenDriver() none Call this function to enable receive. Any packet on the network that can induce a interrupt on your computer. If that packet can pass your acceptance code and acceptance mask setting. So if your program doesn’t want to be disturbed. You can call CanDisableReceive() to disable receive and CanEnableReceive() to enable receives.
Remarks See Also Usage -1 if error occurs Send a message to an opened CAN port. Actually, this function copies the data to the sending queue. Error occurs when the port has not been opened yet or the packet is a NULL pointer. You can use the Error and Event handling functions to handle the exceptions. CanRcvMsg() C/C++ #include “pci7841.
See Also Usage card to memory. It starts after your port configuration is done. This function copies the buffer to your application. So if your program has the critical section to process the data on the network. We suggest that you can call the CanClearBuffer() to clear the buffer first. Error would be happened most under the following conditions: 1. You want to access a port that has not be opened. 2. Your packet is a NULL pointer. 3. The receive buffer is empty.
…. CanClearOverrun(handle); CanCloseDriver(handle); CanClearRxBuffer() Purpose Prototype Parameters Return Value Remarks See Also Usage Clear data in the receive buffer C/C++ void CanClearRxBuffer(int handle) handle : handle retrieve from CanOpenDriver() none Clear the data in the receive buffer There are 2-type of buffer defined in the driver. First one is the FIFO in the card, the second one is the memory space inside the driver. Both of them would be cleared after using this function.
un-send message would be stored in the memory of the driver. The sequence of outgoing message is the FIRST-IN-FIRSTOUT. According this algorithm, if your program need to send an emergency data, you can clear the transmit buffer and send it again. CanRcvMsg() C/C++ See Also Usage #include “pci7841.h int handle = CanOpenDriver(0, 0);//open the port 0 of card 0 ….
Bit interpretation of ERRC1 and ERRC2 Bit ERRC1 Bit ERRC2 Function 0 0 bit error 0 1 form error 1 0 stuff error 1 1 other type of error Bit interpretation of SEG4 to SEG 0 SEG4 SEG3 SEG2 SEG1 SEG0 30 Function 0 0 0 1 1 start of frame 0 0 0 1 0 ID.28 to ID.21 0 0 1 1 0 ID.20 to ID.18 0 0 1 0 0 bit SRTR 0 0 1 0 1 bit IDE 0 0 1 1 1 ID.17 to ID.13 0 1 1 1 1 ID.12 to ID.5 0 1 1 1 0 ID.4 to ID.
Remarks See Also Usage Get the information about the type and location of errors on the bus. When a bus error occurs, if your program installed the call-back function or error-handling event. The error-bit position would be captured into the card. The value would be fixed in the card until your program read it back. CanGetErrorWarningLimit(), CanSetErrorWarningLimit() C/C++ #include “pci7841.h int handle = CanOpenDriver(0, 0);//open the port 0 of card 0 ….
CanSetErrorWarning(handle, 96); CanCloseDriver(handle); CanGetErrorWarningLimit() Purpose Prototype Parameters Return Value Remarks See Also Usage Get the Error Warning Limit C/C++ BYTE CanGetErrorWarningLimit(int handle) Visual Basic(Windows 95/98/NT) handle : handle retrieve from CanOpenDriver() 0-255 (Error warning limit value) Get the error warning limit CanSetErrorWarningLimit() C/C++ #include “pci7841.h int handle = CanOpenDriver(0, 0);//open the port 0 of card 0 ….
#include “pci7841.h int handle = CanOpenDriver(0, 0);//open the port 0 of card 0 …. BYTE error_count = CanGetRxErrorCount(); CanCloseDriver(handle); CanGetTxErrorCount() Purpose Prototype Parameters Return Value Remarks See Also Usage Get the current value of the transmit error counter C/C++ BYTE CanGetTxErrorCount(int handle) handle : handle retrieve from CanOpenDriver() value This function reflects the current of the transmit error counter. After hardware reset happened, the value would set to 127.
Parameters Return Value Remarks See Also Usage handle : handle retrieve from CanOpenDriver() value : a byte value None This function set the current of the transmit error counter. Please see the remark of CanGetTxErrorCount(). CanRcvMsg() C/C++ #include “pci7841.h int handle = CanOpenDriver(0, 0);//open the port 0 of card 0 ….
CanCloseDriver(handle); CanGetLedStatus() Purpose Prototype Parameters Return Value Get the LED status of cPCI-7841 and PM7841 C/C++ BYTE CanGetLedStatus (int card, int index); card : card number Index : index of LED status of Led Value Function Remarks See Also Usage 0 Led Off 1 Led On Get the status of Led This function supports the cPCI-7841 and PM-7841. CanSetLEDStatus() C/C++ #include “pci7841.h int handle = CanOpenDriver(0, 0);//open the port 0 of card 0 ….
Return Value Remarks See Also Usage 0 Led Off 1 Led On none Set Led status of cPCI-7841 and PM-7841 This function supports the cPCI-7841 and PM-7841 CanRcvMsg() C/C++ #include “pci7841.h int handle = CanOpenDriver(0, 0);//open the port 0 of card 0 ….
Error and Event Handling Functions When the exception occurs, your program may need to take some algorithm to recover the problem. The following functions are operation-system depended functions. You should care about the restriction in the operation-system.
See Also Usage occurs when the event happened. It will not be disabled until using CanRemoveCallBack() or a hardware reset. Actually, the call-back function is a part of ISR. You need to care about the DOS reentrance problem, and returns as soon as possible to preventing the lost of data. CanRemoveCallBack() C/C++(DOS) #include “pci7841.h void (far ErrorWarning)(); int handle = CanOpenDriver(0, 0); // open the port 0 of card 0 … // Installs the ErrorWarning handling event and stores the previous one.
7 Return Value Remarks See Also Usage Bus Error void (far *proc)() : Previous call-back function Return 0 is successful -1 if error occurs Install the call-back function for event handling In normal state, all hardware interrupt of cPCI/PCI-7841 wouldn’t be set except receive and transmit interrupt. After calling the CanInstallCallBack(), the corresponding interrupt would be activated. The interrupt occurs when the event happened.
CanCloseDriver(handle); Windows 95/98 Environment CanGetReceiveEvent() Purpose Prototype Parameters Return Value Remarks See Also Usage Install the event under Windows 95/98/NT system C/C++ (Windows 95/98/NT) void CanGetReceiveEvent(int handle, HANDLE *hevent); handle : handle retrieve from CanOpenDriver() Heven : HANDLE point for receive event none Retrieve receive notify event Under Windows 95/98/NT environment, your program can wait the input message by waiting an event.
// You need not to call ResetEvent()…..
See Also Usage system). You can’t release the event object you created, because it was attached to the VxD. The VxD would release the event object when you installed another event. One way to disable the event handling is that you install another event which handle is NULL (ex: CanInstallEvent(handle, index, NULL)). And you can create a thread to handle the error event. CanRemoveCallBack(),CanInstallCallBack() C/C++ (Windows 95/98/NT) #include “pci7841.
Warranty Policy Thank you for choosing ADLINK. To understand your rights and enjoy all the after-sales services we offer, please read the following carefully. 1. Before using ADLINK’s products please read the user manual and follow the instructions exactly. When sending in damaged products for repair, please attach an RMA application form which can be downloaded from: http:// rma.adlinktech.com/policy/. 2.
3. Our repair service is not covered by ADLINK's guarantee in the following situations: X Damage caused by not following instructions in the User's Manual. X Damage caused by carelessness on the user's part during product transportation. X Damage caused by fire, earthquakes, floods, lightening, pollution, other acts of God, and/or incorrect usage of voltage transformers. X Damage caused by unsuitable storage environments (i.e. high temperatures, high humidity, or volatile chemicals).