background image

PCI-1680U/1682U User Manual

92

CANopen

CANopen has the following functions:

Filter

Filter has CAN Filter setting

and CANopen Filter setting.

Name Function 

List Node 

List all CANopen nodes 

Change Node 

State Change CANopen node state 

Read Object 

Read CANopen node data 

Write Object 

Write CANopen node data 

Node Guard All 

Get all CANopen nodes 

Summary of Contents for PCI-1680U

Page 1: ...User Manual PCI 1680U 2 Port CAN Interface Universal PCI Communication Card w Isolation PCI 1682U 2 port CAN Interface Universal PCI Communication Card w CANopen ...

Page 2: ...llation Advantech assumes no liability under the terms of this warranty as a consequence of such events Because of Advantech s high quality control standards and rigorous testing most of our customers never need to use our repair service If an Advantech product is defec tive it will be repaired or replaced at no charge during the warranty period For out of warranty repairs you will be billed accor...

Page 3: ...cations Opera tion of this equipment in a residential area is likely to cause harmful interference in Technical Support and Assistance 1 Visit the Advantech web site at http support advantech com cn where you can find the latest information about the product 2 Contact your distributor sales representative or Advantech s customer service center for technical support if you need additional assistanc...

Page 4: ...om damage To avoid electrical shock always disconnect the power from your PC chassis before you work on it Don t touch any components on the CPU card or other cards while the PC is on Disconnect power before making any configuration changes The sudden rush of power as you connect a jumper or install a card may damage sensitive elec tronic components ...

Page 5: ...680U 1682U Terminator Resistor Reference 21 3 3 Card Installation 21 Chapter 4 Software Requirements 23 4 1 Introduction 24 4 1 1 Definitions Acronyms and Abbreviations 24 4 1 2 Reference 24 4 2 Overview of Advantech CAN Windows WDM CE Driver 24 Table 4 1 Hardware Support 26 4 3 Introduction to API 27 4 3 1 CreateFile 27 4 3 2 CloseHandle 29 4 3 3 DeviceIoControl 29 4 3 4 ReadFile 36 4 3 5 WriteFi...

Page 6: ...4 7 4 Guide for for VB NET development 69 4 7 5 Guide for C development 73 4 8 Examples 77 4 8 1 Interface 78 4 8 2 Flow Chart 83 4 9 Use Utility to test hardware 87 4 10 CANMonitor 88 4 10 1 Function Introduction 89 4 10 2 Introduction to Main Items in Menu Screen 90 4 11 COTI DLL for CANopen Conformance Test 94 Chapter 5 Pin Assignments and Wiring 95 5 1 Pin Assignments 96 Figure 5 1 PCI 1680U 1...

Page 7: ...Chapter 1 1 Introduction This chapter provides a general description of the PCI 1680U and PCI 1682U Sections include Description Features Specifications Ordering Information ...

Page 8: ... is increasingly being used in industrial automation Universal PCI PCI 1680U 1682U provides truly universal connectivity enabling a single product to be used to implement systems with dramatically different resource requirements This makes PCI 1680U 1682U the most robust most flexible and most economical choice for any application requiring isolation PCI 1680U 1682U uses a universal PCI connector ...

Page 9: ...transfer rate Isolation Protection 1 000 VDC Connector Dual DB9 male connectors Power Consumption 5 V 400 mA Typical Dimensions 185 x 100 mm Operating Temperature 0 65 C Storage Temperature 25 85 C Operating Humidity 5 95 Relative Humidity non condensing Storage Humidity 0 95 Relative Humidity non condensing 1 4 Ordering Information PCI 1680U 2 port CAN bus Universal PCI Communication Card with Is...

Page 10: ...PCI 1680U 1682U User Manual 4 ...

Page 11: ...Chapter 2 2 Install WDM driver This chapter shows how to install WDM driver Sections include PCI device setup ISA device setup Port setup Device setup ...

Page 12: ...ng applications with Advantech CAN Driver There are different installation procedures for PCI device driver and ISA device driver please respectively refer to PCI device installation procedures ISA device installation procedures Note Default installation path for Advantech CAN WDM Driver is C Program Files Advantech AdvCAN ...

Page 13: ...CI device setup The following installation procedures are for PCI devices Take PCI 1680 as example 1 First make sure hardware can be installed normally then turn on the computer and enter operating system You will see the following screen 2 Click Next as the following ...

Page 14: ... 2 ISA device setup The following installation procedures are for ISA devices Take PCM 3680 as an example 1 Follow the instructions in the manual to install the device then turn on the com puter to enter operating system 2 Enter Control Panel then select Add Hardware ...

Page 15: ...9 PCI 1680U 1682U User Manual Chapter 2 Install WDM driver 3 Click Next as the following 4 Click Next as the following ...

Page 16: ...PCI 1680U 1682U User Manual 10 5 Click Next as the following 6 Click Next as the following ...

Page 17: ...11 PCI 1680U 1682U User Manual Chapter 2 Install WDM driver 7 Click Have Disk 8 Suppose inf file is installed under C Program Files Advantech AdvCAN inf click Next as the following ...

Page 18: ... Click Next as the following 10 When the installation is complete click View or change resources for this hard ware Advanced to configure resources of the device Users can also directly click Finish and configure it in Device Manager ...

Page 19: ...13 PCI 1680U 1682U User Manual Chapter 2 Install WDM driver 11 Select Set Configuration Manually 12 Configure according to your hardware 13 Restart the computer to finish the installation ...

Page 20: ...en bus driver is installed users can install port driver AdvCanPort sys according to the instructions The installation file is AdvCanPort inf When the installation is finished users can find the device in Device Manager and set ports in properties page ...

Page 21: ...et Advantech CAN device Windows Device Manager can be opened in the following two ways Control Panel Administrative Tools Computer Management then select Device Manager Right click icon of My Computer and click Manage then select Device Manager 2 Click the eAutomation CAN port that you want to configure and select Proper ties to open properties page of the port Users can set the device in PORT_INF...

Page 22: ...PCI 1680U 1682U User Manual 16 ...

Page 23: ...Chapter 3 3 Hardware Installation This chapter covers inspection and installation of hardware and drivers Sections include Initial inspection Jumper locations setting Card installation ...

Page 24: ...etain the shipping carton and packing material for inspection by the carrier After inspection we will make arrangements to repair or replace the unit When you handle the PCI 1680U 1682U remove it from its protective packaging by grasping the rear metal panel Keep the anti vibration packing Whenever you remove the card from the PC store it in this package for protection Warning Discharge your body ...

Page 25: ...19 PCI 1680U 1682U User Manual Chapter 3 Hardware Installation 3 2 Jumper Locations Setting Figure 3 1 PCI 1680U Silk Screen ...

Page 26: ...PCI 1680U 1682U User Manual 20 Figure 3 2 PCI 1682U Silk Screen ...

Page 27: ... Locate the expansion slots or passive back plane at the rear of the PC and choose any unused slot 7 Remove the screw that secures the expansion slot cover to the PC save the screw to secure the interface card retaining bracket 8 Remove the anti vibration card clamp if supplied 9 Carefully grasp the upper edge of the PCI communication card 10 Align the hole in the retaining bracket with the hole o...

Page 28: ...eplace the screw in the expansion slot s retaining bracket 14 Replace anti vibration cardholder 15 Replace the PC s cover Connect the cables you removed in step 3 16 Turn the computer power on 17 The board is now installed in the computer See Chapter 5 for information on cabling ...

Page 29: ...Chapter 4 4 Software Requirements This chapter has information on the software of PCI 1680U 1682U ...

Page 30: ...rs which run in PeliCAN mode are used to drive SJA1000 chip on Advantech CAN device Bus drivers and ports drivers are compliant with PCI and ISA bus and provide the users with coherent operation interfaces Users can directly write applications with windows API Examples of VC VB VB NET C NET VC NET eVC are supplied in the package providing a refer ence for users to develop applications When develop...

Page 31: ...rom that of CE in the following aspects Driver Installation WDM The user should refer to Install WDM Driver to install the driver CE The driver has been pre built in Platform image so the user doesn t need to install the driver Development Kit Installtion WDM none CE Advantech platform SDK Function WDM Support all the functions listed in the manual CE Not support self reception function Interface ...

Page 32: ...No Yes TPC 120H 1 port Isolated ISA CAN bus Device on TPC 120H No Yes TPC 32T 1 port Isolated ISA CAN bus Device on TPC 32T No Yes AMAX 2050 1 port Isolated PCI CAN bus Device on AMAX 2050 No Yes ADAM 5095 2 port Isolated PCI CAN bus Card No Yes ADVANTECH GENERAL CAN PORT 1 PORT 1 port Isolated PCI CAN bus Card Yes Yes ADVANTECH GENERAL CAN PORT 2 PORT 2 port Isolated PCI CAN bus Card Yes Yes ADVA...

Page 33: ...PCTSTR lpFileName DWORD dwDesiredAccess DWORD dwShareMode LPSECURITY_ATTRIBUTES lpSecurityAttributes DWORD dwCreationDisposition DWORD dwFlagsAndAttributes HANDLE hTemplateFile CreateFile Open specified Can port CloseHandle Close specified Can port DeviceIoControl Send commands to drivers including configuration management and getting status etc ReadFile Read data WriteFile Send data GetOverLapped...

Page 34: ...N_EXISTING FILE_ATTRIBUTE_NORMAL FILE_FLAG_OVERLAPPED NULL Name Direction Description lpFileName Input Name of device which was opened such as CAN1 Note In WINDOWS CE use CAN1 ldwDesiredAccess Input Ways of opening the port which is usually GENERIC_READ GENERIC_WRITE dwShareMode Input Does not support share open It must be set to 0 lpSecurityAttributes Input NULL dwCreationDisposition Input OPEN_E...

Page 35: ...lose BOOL bRet CloseHandle hDevice See Also CreateFile 4 3 3 DeviceIoControl Users can use this interface to send commands configure ports like stop device start device configure Baud Rate etc See Command_par CanStatusPar_t for detailed configuration Syntax BOOL DeviceIoControl HANDLE hDevice DWORD dwIoControlCode LPVOID lpInBuffer DWORD nInBufferSize LPVOID lpOutBuffer DWORD nOutBufferSize LPDWOR...

Page 36: ...ned NULL if bSuccess error config target CONF_TIMING config val1 1000 set 1000K Name Direction Description hDevice Input Handle of the device which was opened dwIoControlCode Input Control code shows the specific operation mode lpInBuffer Input Start address sent to data area of driver nInBufferSize Input Byte length sent to data area of driver lpOutBuffer Output Address of data area which receive...

Page 37: ...LL if bSuccess error cmd cmd CMD_START bSuccess DeviceIoControl hDevice CAN_IOCTL_COMMAND cmd sizeof Command_par NULL 0 dwReturned NULL if bSuccess error Set acceptance filter DWORD dwReturned Command_par_t cmd Config_par_t config cmd cmd CMD_STOP BOOL bSuccess DeviceIoControl hDevice CAN_IOCTL_COMMAND cmd sizeof Command_par NULL 0 dwReturned NULL if bSuccess ...

Page 38: ...CONFIG config sizeof Command_par NULL 0 dwReturned NULL if bSuccess error config target CONF_ACC config val1 0xffffffff config val2 0xffffffff bSuccess DeviceIoControl hDevice CAN_IOCTL_CONFIG config sizeof Command_par NULL 0 dwReturned NULL if bSuccess error cmd cmd CMD_START bSuccess DeviceIoControl hDevice CAN_IOCTL_COMMAND cmd sizeof Command_par NULL 0 dwReturned NULL ...

Page 39: ...OP BOOL bSuccess DeviceIoControl hDevice CAN_IOCTL_COMMAND cmd sizeof Command_par NULL 0 dwReturned NULL if bSuccess error config target CONF_LISTEN_ONLY_MODE config val1 1 1 ON 0 OFF bSuccess DeviceIoControl hDevice CAN_IOCTL_CONFIG config sizeof Command_par NULL 0 dwReturned NULL if bSuccess error cmd cmd CMD_START bSuccess DeviceIoControl hDevice CAN_IOCTL_COMMAND cmd ...

Page 40: ...WORD dwReturned Command_par_t cmd cmd cmd CMD_RESET BOOL bSuccess DeviceIoControl hDevice CAN_IOCTL_COMMAND cmd sizeof Command_par NULL 0 dwReturned NULL if bSuccess error cmd cmd CMD_START bSuccess DeviceIoControl hDevice CAN_IOCTL_COMMAND cmd sizeof Command_par NULL 0 dwReturned NULL if bSuccess error ...

Page 41: ...LEARBUFFERS BOOL bSuccess DeviceIoControl hDevice CAN_IOCTL_COMMAND cmd sizeof Command_par NULL 0 dwReturned NULL if bSuccess error Get status of device DWORD dwReturned CanStatusPar_t status BOOL bSuccess DeviceIoControl hDevice CAN_IOCTL_STATUS NULL 0 status sizeof CanStatusPar_t dwReturned NULL See Also Command_par CanStatusPar_t ...

Page 42: ... frames in Advantech CAN Win dows WDM CE Driver Name Direction Description hDevice Input Handle of the device which was opened lpBuffer Output Start address of receive buffer nNmberOf FramesToRead Input Number of frames to be received from drivers The defini tion here is different from that in MSDN lpNumberOf FramesRead Output Real number of frames received from driver The definition here is diffe...

Page 43: ...TED If busoff of device is discovered before drivers read any frames GetLastError will be called to return ERROR_GEN_FAILURE If drivers cannot allocate resources according to the number defined by the third parameter frame GetLastError will be called to return ERROR_INVALID_PARAMETER In asynchronous mode operation will be pending if drivers cannot complete user s read request and GetLastError will...

Page 44: ...G_OVR CAN controller Msg overflow error if ReadBuffer flags MSG_PASSIVE CAN controller in error passive else Timeout else DWORD dwError GetLastError if dwError ERROR_IO_PENDING pengding else if dwError ERROR_INVALID_PARAMETER parameter error else if dwError ERROR_OPERATION_ABORTED cancelled else if dwError ERROR_GEN_FAILURE bus off ...

Page 45: ...OR_OPERATION_ABORTED If busoff of device is discovered before drivers send any frames GetLastError will be called to return ERROR_GEN_FAILURE If drivers cannot allocate resources according to the number defined by the third parameter frame GetLastError will be called to return ERROR_INVALID_PARAMETER Note The third and fourth parameters of WriteFile are defined as byte length in MSDN but stand for...

Page 46: ...f canmsg_t WriteBuffer flags 0 Standard frame WriteBuffer flags MSG_EXT Extended frame WriteBuffer flags MSG_RTR Remote frame WriteBuffer id 0 WriteBuffer length DATALENGTH for int i 0 i DATALENGTH i WriteBuffer data i i BOOL bSuccess WriteFile hDevice WriteBuffer 1 dwWrite 0 if bSuccess if dwWrite 1 SUCCESS else Timeout else DWORD dwError GetLastError if dwError ERROR_IO_PENDING pengding else if ...

Page 47: ...mEvent is called the call will be returned and the event type returned will be zero Syntax BOOL SetCommMask HANDLE hDevice DWORD dwEvtMask Parameters Return Value Successful return non zero values Unsuccessful return zero value Please call Get LastError function Example BOOL bSuccess SetCommMask hDevice EV_ERR EV_RXCHAR See Also WaitCommEvent GetCommMask Note Events supported at present are only T...

Page 48: ...mMask to set event users should also call WaitCommEvent function to wait event Syntax BOOL WaitCommEvent HANDLE hDevice LPDWORD lpEvtMask LPOVERLAPPED lpOverlapped Parameters Name Direction Description hDevice Input Handle of the device which was opened lpEvtMask Output Store event type which return from drivers Name Direction Description hDevice Input Handle of the device which was opened lpEvtMa...

Page 49: ...asynchronous mode operation will be pending if drivers cannot complete user s request and GetLastError will be called to return ERROR_IO_PENDING See MSDN for more information Example Wait event in synchronous mode BOOL bSuccess SetCommMask hDevice EV_ERR EV_RXCHAR if bSuccess error DWORD dwMask 0 bSuccess WaitCommEvent hDevice dwMask NULL if bSuccess if dwMask EV_ERR to do DWORD dwError ClearCommE...

Page 50: ...r function Note Definitions of error codes supported are as below Name Description CE_RXOVER Receive Queue overflow CE_OVERRUN Receive Overrun Error CE_FRAME Passive error CE_BREAK Busoff Note The third parameter is unused please set it to NULL Name Direction Description hDevice Input Handle of the device which was opened lpErrors Output Store error codes which return from drivers lpStat Output Em...

Page 51: ...nt hDevice dwMask NULL if bSuccess if dwMask EV_ERR to do DWORD dwError bSuccess ClearCommError hDevice dwError NULL if bSuccess to do if dwError CE_FRAME dwError CE_BREAK CanStatusPar_t status DWORD dwReturned DeviceIoControl hDevice CAN_IOCTL_STATUS NULL 0 status sizeof CanStatusPar_t dwReturned NULL See Also WaitCommEvent DeviceIoControl ...

Page 52: ...ov BOOL bSuccess DWORD dwEvtMask DWORD dwLength hDevice CreateFile CAN1 GENERIC_READ GENERIC_WRITE 0 exclusive access NULL default security attributes OPEN_EXISTING FILE_FLAG_OVERLAPPED NULL Name Direction Description hDevice Input Handle of the device which was opened lpOverlapped Input Events need to be waited are included Refer to MSDN for more information lpNumberOf FramesTransferred Output Re...

Page 53: ...ess Handle the error printf SetCommMask failed with error d n GetLas tError return Create an event object for use by WaitCommEvent ov hEvent CreateEvent NULL default security attributes FALSE auto reset event FALSE not signaled NULL no name Intialize the rest of the OVERLAPPED structure to zero ov Internal 0 ov InternalHigh 0 ov Offset 0 ov OffsetHigh 0 if WaitCommEvent hDevice dwEvtMask ov if dwE...

Page 54: ...ngth TRUE To do else To do else printf Wait failed with error d n GetLastEr ror See Also ReadFile WriteFile WaitCommEvent 4 4 Structure List The table below is a list of structures needed by Advantech CAN WDM Driver Methods canmsg_t Received Sent message structure CanStatusPar_t Port status structure Command_par Command Configure operation structure ...

Page 55: ...ID does not equal 0xFFFFFFFF flags may be Remote frame Extended frame Standard frame Self Reception or software overrun Name Description flags Types of messages cob Reserved id ID of message length of messages 0 8 data Data transferred Made up of 0 8 Byte data Bit Declaration Meaning Description 0 MSG_RTR RTR 1 means Remote frame 0 means data frame 1 MSG_OVR Hardware OVER RUN 1 means receive buffe...

Page 56: ...usPar_t Member Description Name Description baud Actual bit rate status T he status register SR CAN address 2 error_warning_limit The error warning limit register EWLR CAN address 13 rx_errors The RX error counter register RXERR CAN address 14 tx_errors The TX error counter register TXERR CAN address 15 error_code The error code capture register ECC CAN address 12 rx_buffer_size Size of rx buffer ...

Page 57: ...n the Baud Rate will be 10k Custom mode If user need the baud rate is not in above table user can use the custom mode to set the custom baud rate The CAN port s baud rate is determine by CAN clock BTR0 and BTR1 The Advantech CAN devices use 8MHZ clock and oscillator frequency is 16M The internal clock is divided by two from the oscillator frequency BTR0 and BTR1 Timing Registers are used for defin...

Page 58: ...dle of device Btr0 BTR0 register value Btr1 BTR1 register value Returns 0 SUCCESS or 0 failure int acSetBaudRegister HANDLE hDevice unsigned char Btr0 unsigned char Btr1 unsigned int BaudRateValue Btr0 256 BaudRateValue Btr1 return acSetBaud hDevice BaudRateValue can_receive cpp Line 105 nRet acSetBaudRegister hDevice byBtr0 byBtr1 Set baud rate if nRet 0 SetDlgItemText hwnd IDC_SHOW_RESULT Failed...

Page 59: ...nds are supported Target value BTR0 BTR1 Setting value 5K 0xBF 0xFF 0xFFBF 40K 0x87 0xFF 0xFF87 80K 0x83 0xFF 0xFF83 200K 0x81 0xFA 0xFA81 400K 0x80 0xFA 0xFA80 Name Description cmd Send start or stop command to drivers target Send configure command to drivers val1 Parameter 1 val2 Parameter 2 error Reserved retval Reserved Optional commands Corresponding value of cmd Description val1 val2 CMD_STA...

Page 60: ...ffer id 0 WriteBuffer length 8 for int i 0 i 8 i WriteBuffer data i i WriteFile hDevice WriteBuffer 1 dwWrite 0 Optional configures Corresponding value of target Description val1 val2 CONF_ACC 0 Acceptance code regis ter and acceptance mask register Need to enter reset mode Acceptance mask register default set ting 0xFFFFFFFF Acceptance code register default set ting 0xFFFFFFFF CONF_ACCM 1 Accepta...

Page 61: ... dwWrite 0 canmsg_t WriteBuffer ZeroMemory WriteBuffer sizeof canmsg_t WriteBuffer flags 0 Standard frame WriteBuffer flags MSG_EXT Extended frame WriteBuffer flags MSG_RTR Remote frame WriteBuffer id 0 WriteBuffer length 0 WriteFile hDevice WriteBuffer 1 dwWrite 0 4 5 4How to dispose received messages DWORD dwRead canmsg_t ReadBuffer ZeroMemory ReadBuffer sizeof canmsg_t BOOL bSuccess ReadFile hD...

Page 62: ... MSG_OVR CAN controller Msg overflow error if ReadBuffer flags MSG_PASSIVE CAN controller in error passive else Timeout else DWORD dwError GetLastError if dwError ERROR_IO_PENDING pengding else if dwError ERROR_INVALID_PARAMETER parameter error else if dwError ERROR_OPERATION_ABORTED cancelled else if dwError ERROR_GEN_FAILURE bus off See Also canmsg_t WriteFile ReadFile ...

Page 63: ...also included for fil tering Data1 corresponds to ACR2 AMR2 Data2 corresponds to ACR3 AMR3 If the received Standard frame is a Remote frame and the RTR bit is 1 then only the identifier will be used for filtering If the received Standard frame is a data frame and the data field is less than 2 bytes then the missed data will not be used for filtering For Extended frame 29 identifiers and the RTR bi...

Page 64: ...of 29 bits used for the filtering Filter2 is composed of ACR2 ACR3 AMR2 and AMR3 The higher 16 bits out of 29 bits are used for the filtering Example of Standard frame Filter1 In this example Data1 and RTR are not considered and the accepted ID 0x1 Filter2 In this example RTR are not considered and the accepted ID 0x1 Example of Extended frame Filter1 In this example the accepted IDs include 0x200...

Page 65: ...te a new VC project Related header files must be used before using Advantech CAN Windows WDM CE Driver interface function Make sure the driver had been installed correctly Please refer to relevant books and documentations regarding detailed information about VC development Please follow the following procedures to create a new VC project 1 Select File New from the main menu to create a new applica...

Page 66: ...d Include header files AdvCan h in Advantech CAN Windows WDM CE Driver In VC work area right click Header Files then select Add Files to Folder to add header files to the project 4 7 1 3 Write code 1 Select Add to Project New from Project then select C Source File ...

Page 67: ...LL OPEN_EXISTING 0 NULL if hDevice INVALID_HANDLE_VALUE printf Open Can Port Error return Get Can port status flag DeviceIoControl hDevice CAN_IOCTL_STATUS NULL 0 CanStatus sizeof CanStatusPar_t dwReturned 0 if flag printf GetStatus Error return printf Acceptance code 0x x n CanStatus acceptancecode printf Acceptance mask 0x x n CanStatus acceptancemask printf Baud u n CanStatus baud printf Self r...

Page 68: ...in Visual Basic environment 4 7 2 1 Create a new VB project Related header files must be used before using Advantech CAN Windows WDM CE Driver interface function Make sure the driver had been installed correctly Please refer to relevant books and documentations regarding detailed information about VB development Please follow the following procedures to create a new VB project 1 Select File New Pr...

Page 69: ...ts 4 7 2 2 Add files and design graphical interfaces 1 Add Include header files AdvCan bas in AdvCAN Windows WDM CE Driver Right click the project and select Add Module Item then select Existing Item to add AdvCan bas Installation path AdvCan Include AdvCan bas ...

Page 70: ...ong Dim ov As OVERLAPPED Open Can Port CAN1 You can also change CAN1 to a port s name which you have installed hDevice CreateFile can1 GENERIC_READ GENERIC_WRITE 0 0 OPEN_EXISTING FILE_ATTRIBUTE_NORMAL FILE_FLAG_OVERLAPPED 0 Open the CAN port in synchronous mode If hDevice HFFFFFFFF Then MsgBox Open Error Exit Sub End If Get Can port status result DeviceIoControl hDevice CAN_IOCTL_STATUS Noth ing ...

Page 71: ...e Hex Status acceptance mask TextBox4 Text Self recevie CStr Status selfrecep tion TextBox5 Text Read TimeOut CStr Status ReadTime Out TextBox6 Text Write TimeOut CStr Sta tus WriteTimeOut result CloseHandle hDevice Close the CAN port If Not result Then MsgBox Failed to close the CAN port End If End Sub 4 7 2 4 Test application Run the application the following result will be displayed ...

Page 72: ...ding detailed information about VC NET development Please follow the following procedures to create a new VC NET project 1 Select File New Project from the main menu to create a new application project and source file Define the type of the new project as Windows Forms Application and select a path for files of the project 2 Click OK according to the instructions on the screen A new VC NET project...

Page 73: ...67 PCI 1680U 1682U User Manual Chapter 4 Software Requirements 2 Design graphical interfaces Add one Button and six Text controls to Form1 ...

Page 74: ...ATTRIBUTES lpSecurityAt tributes OPEN_EXISTING FILE_ATTRIBUTE_NORMAL FILE_FLAG_OVERLAPPED NULL if unsigned int hDevice 0xffffffff MessageBox Show Open CAN port Error return Get Can port status result DeviceIoControl hDe vice ULONG CAN_IOCTL_STATUS cmd 0 CanSta tus sizeof CanStatusPar_t LPDWORD dwOutLen ov if result MessageBox Show GetStauts Error return this textBox1 Text Baud rate CanSta tus baud...

Page 75: ...ning a CAN port and reading its current status so as to simply explain how to write base applications in VB NET environment 4 7 4 1 Create a new VB NET project Related header files must be used before using Advantech CAN Windows WDM CE Driver interface function Make sure the driver had been installed correctly Please refer to relevant books and documentations regarding detailed information about V...

Page 76: ...For Project Types select Visual Basic Projects Templates is Windows Application A new VB NET project is created 4 7 4 2 Add files and design graphical interfaces 1 Add Include header files AdvCan vb in AdvCAN Windows WDM CE Driver Right click the project then select Add Add Existing Item to add AdvCan vb Installation path AdvCan Include AdvCan vb ...

Page 77: ...r_t Dim result As Boolean Dim dwOutLen As Integer Dim ov As New OVERLAPPED Open Can Port CAN1 You can also change CAN1 to a port s name which you have installed hDevice CreateFile can1 GENERIC_READ GENERIC_WRITE 0 Nothing OPEN_EXISTING FILE_ATTRIBUTE_NORMAL FILE_FLAG_OVERLAPPED 0 If hDevice ToInt32 HFFFFFFFF Then MsgBox Open Error Exit Sub End If Get Can port status result DeviceIoControl hDevice ...

Page 78: ...xtBox4 Text Self recevie status selfreception TextBox5 Text Read TimeOut status readtimeout TextBox6 Text Write TimeOut status writetimeout result CloseHandle hDevice Close the CAN port If Not result Then MsgBox Failed to close the CAN port End If End Sub 4 7 4 4 Test application Run the application the following result will be displayed ...

Page 79: ...g Advantech CAN Windows WDM CE Driver interface function Make sure the driver had been installed correctly Please refer to relevant books and documentations regarding detailed information about C development Please follow the following procedures to create a new C project 1 Select File New Project from the main menu For Project Types select Visual C Projects Templates is Windows Application 2 Type...

Page 80: ... 2 Add files and design graphical interfaces 1 Add Include header files AdvCan cs in Advantech CAN Windows WDM CE Driver Right click the project then select Add Add Existing Item to add AdvCan cs Installation path AdvCan Include AdvCan cs ...

Page 81: ...75 PCI 1680U 1682U User Manual Chapter 4 Software Requirements 2 Design graphical interfaces Add one Button and six TextBox controls to Form1 ...

Page 82: ...an FILE_ATTRIBUTE_NORMAL Adv Can FILE_FLAG_OVERLAPPED 0 if hDevice 0xffffffff MessageBox Show Open CAN port Error return Get Can port status result AdvCan DeviceIoControl hDevice Adv Can CAN_IOCTL_STATUS ref cmd 0 ref CanStatus Marshal SizeOf Can Status ref dwOutLen ref ov if result MessageBox Show GetStauts Error return textBox1 Text Baud rate CanStatus baud ToString textBox2 Text Accept code Can...

Page 83: ... to develop appli cations WDM Example Name Description VC VB VB NET C NET VC NET Can Configure This example shows how to configure each item of CAN port Yes Yes Yes Yes Yes Can Send This example shows how to send data to CAN port Yes Yes Yes Yes Yes Can Receive This example shows how to receive data from CAN port Yes Yes Yes Yes Yes Can Event This example shows how to receive send data from to CAN...

Page 84: ... box can realize self reception function On WDM platform the user can select either synchronous mode or asynchronous mode While on CE platform only synchronous mode is supported After configuring the above items users can click Start button to send data After clicking Start button the name of the button will change into Stop At the same time results of sent frames will be shown in the textbox on t...

Page 85: ...79 PCI 1680U 1682U User Manual Chapter 4 Software Requirements WDM CE ...

Page 86: ...uld write values of BTR0 and BTR1 manually in the textbox The default values of both are 125k Type value of timeout in Timeout filed The default value is 3000 ms On WDM platform the user can select either synchronous mode or asynchro nous mode While on CE platform only synchronous mode is supported After config uring the above items users can click Start button to receive data After clicking Start...

Page 87: ...mask for receiving data in the fields of Accep tance Mask and Acceptance Code The default value is 0xFFFFFFFF Type values of timeout in Write Timeout and Read Timeout fields The default value is 3000 ms After configuring the above items users can click Configure button to change the current setting of the port After clicking Configure button successful message and the new configuration information...

Page 88: ...an0 can1 etc Value of Baud Rate is fixed at 125 k and Value of timeout is fixed at 3000 ms The user can select RTR check box can realize RTR function After configuring the above items users can click Start button to send receive data After clicking Start button the name of the button will change into Stop At the same time results of sent received results will be shown in both textboxes The two por...

Page 89: ...83 PCI 1680U 1682U User Manual Chapter 4 Software Requirements CE 4 8 2 Flow Chart 4 8 2 1 Send flow chart ...

Page 90: ...PCI 1680U 1682U User Manual 84 4 8 2 2 Receive flow chart ...

Page 91: ...85 PCI 1680U 1682U User Manual Chapter 4 Software Requirements 4 8 2 3 Configure flow chart ...

Page 92: ...PCI 1680U 1682U User Manual 86 4 8 2 4 Event flow chart Either flow chart of the two sub threads is as below ...

Page 93: ...rease if you want the data increase automatically When setting is finished users can choose to Open Close the port Start Tx Stop Tx and Start Rx Stop Rx In Part 2 detail information of received data will be shown when communication is built In Part 3 the following items will be shown Numbers of sent frames timeout sent frames received frames and timeout received frames Times of entering PASSIVE er...

Page 94: ...sages in CAN network and to show the messages according to different message types CANMonitor can show messages in the formats of CAN and CANopen System Requirements Windows 2000 32 bit Windows XP 32 bit Windows Vista 32 bit Windows 7 64 bit Windows XP 64 bit Windows Vista 64 bit Windows 7 ...

Page 95: ...s messages Clear Data Clears all data Auto Scroll Supports auto scroll function Goto Goes to the specified message line Listen only mode Supports Listen Only mode CAN Message Filter Configures CAN message filter modes CAN Message View Shows CAN format message List Node Lists CANopen nodes detected and the node state Change Node State Changes the specified CANopen node state Read Data from Node Rea...

Page 96: ...ew has the following functions Name Function New Open device Close Close device Load Load data from File Save Save data to File Exit Exit the program Name Function Toolbar Whether to show the toolbar Status Bar Whether to show the status bar Auto Scroll Whether to scroll automatically Clear Clear all the messages Goto Go to the specified line ...

Page 97: ...ludes ID and Data will be displayed as Hex format Dec The monitor data which includes ID and Data will be displayed as Dec format Ascii The monitor Data will be displayed as Dec format but ID will be displayed as Hex format Name Function Run Start communication Stop Stop communication Show Show the message Hide Hide the message Listen Only Whether to open Listen Only mode Name Function Send CAN Me...

Page 98: ...ctions Filter Filter has CAN Filter setting and CANopen Filter setting Name Function List Node List all CANopen nodes Change Node State Change CANopen node state Read Object Read CANopen node data Write Object Write CANopen node data Node Guard All Get all CANopen nodes ...

Page 99: ...ide the message Auto Scroll Whether to scroll automatically Clear Clear all the messages Name Function S1 Show the load the two formats Kbit s and bit s will be selected automatically S2 Show the current status of the device Normal Passive Bus off S3 Show the number of the messages sent S4 Show the number of the messages received S5 Show the number of Overrun S6 Show the number of lines of the dat...

Page 100: ...vantech CAN WDM Driver This file has to be copied into the directory of the CANopen Conformance Test More detailed presentation about CAN open Conformance Test Tool please refer to http www can cia org index php id 141 The default installation path for COTI DLL is C Program Files Advantech Adv CAN COTI System Requirements Windows 2000 32 bit Windows XP 32 bit Windows Vista ...

Page 101: ...Chapter 5 5 Pin Assignments and Wiring This chapter covers the pin assignment for the CAN connec tor and the wiring of the two transmission wires Sections include Pin Assignments Wiring ...

Page 102: ...e 5 1 PCI 1680U 1682U DB 9 pin assignment 5 2 Wiring The CAN standard supports half duplex communication This means that just two wires are used to transmit and receive data Table 5 1 PCI 1680U 1682U Pin Wiring and Description PCI 1680U 1682U DTE male DB 9 Terminal DTE Pin Signal Signal 2 CAN_L CAN_L 3 GND GND 7 CAN_H CAN_H ...

Page 103: ...97 PCI 1680U 1682U User Manual Chapter 5 Pin Assignments and Wiring ...

Page 104: ...cations are subject to change without notice No part of this publication may be reproduced in any form or by any means electronic photocopying recording or otherwise without prior written permis sion of the publisher All brand and product names are trademarks or registered trademarks of their respective companies Advantech Co Ltd 2010 ...

Reviews: