CANopen Win API. Version TK Engineering Oy

Similar documents
CANopen Library User Manual

NOVOtechnik. Content. TIM CANopen Gebrauchsanleitung TIM CANopen user manual SIEDLE GRUPPE

Contents. Additional Instructions P-3X CANopen

CANopen. Network configuration. Operating instructions Software. Integration of Bürkert devices in CANopen networks

Manual. CAN 300 PRO CANopen Slave. CAN Communication Modules for S7-300 as CANopen Slave. Edition 3 /

NOVOtechnik SIEDLE GRUPPE

CANopen Manager. Software Manual. CANopen Manager Manual Doc.-No.: C / Rev esd gmbh Page 1 of 44

CANopen Manager. Software Manual. CANopen Manager Software Manual Doc. No.: C / Rev. 2.2 Page 1 of 47

BMS CAN Manual. V2.0, September 3, 2018 Visit to download the latest revision of this manual Copyright 2018 Roboteq, Inc

Technical Documentation 0630

Operating Manual. Inferface. CANopen. English

Applied Motion Products CANopen Manual

CANopen IO X1 Fact sheet

CANopen Firmware. for PCAN-MicroMod. User Manual

PCAN-MicroMod CANopen CANopen Firmware for PCAN-MicroMod. User Manual V1.1.1

CANopen IO X2 Fact sheet

Pressure transmitter CANopen DST P92C

CANopen Commandline Tool

CANopen User manual Website: Technical Support: Skype: Phone: QQ: Technical forum:

User Manual Connection to CAN

hipecs-cio52 CANopen I/O module with 4 analog outputs

CANopen IO X4 Fact sheet

Dynamic Object Dictionary

hipecs-cio100 CANopen I/O module with 16/16 digital I/O

hipecs-cio56 CANopen I/O module with PT100/1000 inputs

PLC2 Board Communication Manual CANopen Slave

hipecs-cio55 CANopen I/O module with 4 analog inputs

TC.CANOPEN Manual. Option DO V02.62

AP-COBD Manual V /03

Motors Automation Energy Transmission & Distribution Coatings. Software WSCAN. User's Manual

Contents. Additional Instructions MHC-1 CANopen

celed LED Array Firmware Specification

Electrohydraulic Actuators PVE-CI, Series 6

Tritex II. CANopen - Option

Anybus CompactCom 30. CANopen NETWORK GUIDE HMSI EN 4.1 ENGLISH

Redes de Comunicação em Ambientes Industriais Aula 12

PISO-CAN200/400. Linux SocketCAN CANopen Manual

CANopen Application Note

Anybus -S CANopen. Fieldbus Appendix. ABS-COP-3 Rev HMS Industrial Networks AB. Germany Japan Sweden U.S.A UK

3 CH Analog Output module / CANopen

Additional instructions. Programming of D-20-9/D Pressure transmitter with CANopen Interface D with integrated Y-Piece

Embedded Motion Control Library

Type Guideline Name WCS-10 TCS-10 Configurator Getting Started Guide Department R&D WCS-10 TCS-10 Configurator Getting Started Guide.

Communications Manual MC 5010 MC 5005 MC 5004 MCS RS232 / WE CREATE MOTION

Quick Start Guide PN/CAN-Gateway. Version. 1 en. from FW

Software 1 General. 4 Manufacturer-Specific Parameters Overview Special Parameters Motor Parameters 19 5 Error Codes 33

User Reference Manual

Additional instructions. Programming of D-10-9/D Pressure transmitter with CANopen Interface D-11-9 D-10-9

hipecs-gw30 General Description Features Ordering Information RS232 / CAN - Gateway

MICROCANOPEN CLASSIC USER MANUAL

EtherCAT User Manual. For SS EtherCAT

User Manual of the Electronic Data Sheet for Pressure Transmitters with CANopen Interface HDA 4000 CANopen

STF-EtherCAT User Manual

CANopen Unit CANit-20

THE MICROCANOPEN PROTCOL STACK MICROCANOPEN USER MANUAL. Revision 331 for Version 3.30 of MicroCANopen Plus

CANopen Vehicle Gateway Software Specifications rev 2.01

CANopen Manual. Draw Wire Sensor Series SX Draw Wire Sensor Series MH Encoder Series WP

Positioning Controller

CANopen Slave. X-gateway Interface Addendum. Doc: HMSI , Rev: Connecting Devices TM

User Manual CANopen DeviceExplorer

CANopen MANUAL. TMCM axis stepper controller/driver board 2.8A RMS / 24V DC Encoder interface

FACTORY AUTOMATION. MANUAL R CANopen Protocol

EtherCAT User Manual. For STF EtherCAT

migra CAN Large Format Graphics Compatible LED Display with CANopen Interface

Supervisory Control Reference

1 SI CANopen CANopen Module for ET200S

migan CAN Large Format Numeric LED Display with CANopen Interface

CAN OPEN DP404 Digital Output

CANOPEN-16DI-16DO-6AIx-4AOx-2E. CANopen IO Module User s Manual

Operating instructions RFID read/write head with CANopen interface

I-7565-CPM Intelligent USB/CANopen Master Module

SINAMICS S120. SINAMICS S120 CANopen interface. Commissioning Manual 10/2008 CANopen interface SINAMICS

Proportional Valves PVED-CC, Series 5 CANopen

CiA Draft Standard Proposal 410. CANopen. Device Profile for Inclinometer. This a draft standard proposal and not suitable to be implemented

CiA Draft Standard Proposal 419. CANopen. Device Profile for Battery Charger

Linear-Encoders CANopen Profile

Application Layer. Chapter 2.6. Layered model automation system. Application Process. Application. Data Link Physical.

Embedded Motion Control Library

ABSOPOS Series CANopen DS406 V3.1 Operating Manual Configuration and CAN-Bus Coupling

CANopen User Guide. Rev for ENGEL devices with CANopen support. ENGEL Elektroantriebe GmbH Am Klingenweg 10 D Walluf

Linear-Encoder Multi-Sensor CANopen Profile

CANopen CFW100. User s Manual. Phone: Fax: Web: -

DEIF A/S. White paper. XDi-net/CANopen reference manual A. DEIF A/S, Frisenborgvej 33 Tel.: , Fax:

CANopen communication protocol

LXM23A CANopen Fieldbus protocol for servo drive Fieldbus manual V2.00,

LVD Digital Servo Drive

CANopen CFW-11. Communication Manual. Phone: Fax: Web:

Temposonics. Magnetostrictive Linear Position Sensors. PROTOCOL MANUAL MH-Series CANopenSafety. The Measurable Difference

CiA Draft Standard Proposal 414. CANopen. Device Profiles for Weaving Machines. Part 1: General definitions

OPERATING INSTRUCTIONS. CANopen - Protocol with Device Profile in accordance with CiA DSP 408

CANopen Slave. Protocol API V Hilscher Gesellschaft für Systemautomation mbh

IO Module User Manual

LXM32A CANopen Fieldbus interface Fieldbus manual V1.05,

User Manual. R Series Encoders with CANopen Interface RNX HE 11 / 2005

CANopen Devices becoming intelligent with IEC Dipl.-Ing. (FH) Hansjürgen Eberle IXXAT Automation GmbH, Weingarten, Germany

SAFETY PRECAUTIONS CAUTION. WARNING Improper operation may result in serious personal injury or death.

I-8123W CANopen Master Module

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

CANopen Interface for SG5 and SG7

Doc ID: S94CAN01A S921. CANopen Communication Module S94CAN01A

Transcription:

Author SB/HL Checked Approved Type Guideline Name CANopen Win API Department R&D File Name CANopen Win API - API Documentation.odt Revision $Rev: $ Copyright TK Engineering Oy. All rights reserved. Reproduction, use or disclosure to third parties without express authority is strictly forbidden. Project/Product Project Code Date 2016-11-28 Printed Classification PUBLIC Page 1 (21) CANopen Win API Version 1.0.12 TK Engineering Oy

CANopen Win API - API Documentation 2 (21) Revision History Date Revision level Author Description 16.07.2014 1.0.0 SB/HL Initial draft 04.08.2014 1.0.1 HL Added COWA_AddLicense and example code 06.08.2014 1.0.2 HL Added callbacks and updated example code 12.08.2014 1.0.3 HL Updated the API according to latest code. Updated example code 18.08.2014 1.0.4 HL Added supported network variables area 29.08.2014 1.0.5 HL Restructured the document Added API constants and abbreviations 01.09.2014 1.0.6 HL Updated function prototype COWA_TransmitEmcy() 04.09.2014 1.0.7 HL Added COWA_INFO_CANOPENSTATUS 09.09.2014 1.0.8 HL Added COWA_SetNodeInfo() Updated example 10.12.2014 1.0.9 HL Updated contact information 17.12.2014 1.0.10 HL Added hyper-links and more file description 21.11.2016 1.0.11 HL Added COWA_GetRpdoStatus(). 21.11.2016 1.0.12 HL Added How to use network variables chapter Support Contact info@tke.fi for license Contact support@tke.fi for technical support Visit www.tke.fi for our products, service etc. Important Information About This Guide This document is Copyright 2014 TK Engineering Oy, Vaasa, Finland. We believe that the information in this document was accurate at the time of printing. TK Engineering Oy cannot, however, assume responsibility for any errors or omissions in this document. The information in

CANopen Win API - API Documentation 3 (21) this document is subject to change without notice and should not be taken as a commitment by TK Engineering Oy. Table of Contents 1 Introduction... 4 2 Abbreviation... 4 3 API Features... 4 4 API Functions... 5 4.1 COWA_GetDllVersion()...5 4.2 COWA_InitLibrary()...5 4.3 COWA_AddLicense()...5 4.4 COWA_CreateNode()...6 4.5 COWA_SetBitrate()...6 4.6 COWA_GetBitrate()...6 4.7 COWA_SetNodeId()...6 4.8 COWA_GetNodeId()...6 4.9 COWA_SetNodeInfo()...6 4.10 COWA_EnableNode()...7 4.11 COWA_SetLocalNmtState()...7 4.12 COWA_SendNmtCommand()...7 4.13 COWA_GetNmtState()...7 4.14 COWA_GetNodeInfo()...7 4.15 COWA_GetRpdoStatus()...8 4.16 COWA_ReadSdo()...8 4.17 COWA_WriteSdo()...9 4.18 COWA_TransmitEmcy()...9 4.19 COWA_CloseNode()...9 4.20 COWA_CloseLibrary()...10 5 API Constants...10 5.1 Definition of cowaresult...10 5.2 Definition of bus speed...10 5.3 Definition of cowanmtcommand...11 5.4 Definition of cowanmtstate...11 5.5 Definition of cowaemcyerrorcode...11 5.6 Definition of SDO Abort Code...12 5.7 Definition of Flags used in COWA_GetNodeInfo()...13 5.8 Definition used in COWA_SetNodeInfo()...13 5.9 Definition used in COWA_GetRpdoStatus()...13 6 How to use Network Variables...13 7 Example...14 8 References... 20

CANopen Win API - API Documentation 4 (21) 1 Introduction This document describes how to use CANopen Win API (COWA) DLL in your application. The available files are: File CANopenWinAPI.h CANopenWinAPI32.dll CANopenWinAPI64.dll CANopenWinAPI32.lib CANopenWinAPI64.lib Description The header file you need to include in your project The 32-bit DLL The 64-bit DLL for 64 bit application The 32-bit static library The 64-bit static library for 64 bit application 2 Abbreviation Abbreviation TKE CiA CAN COWA API OD SDO Node id PDO TPDO RPDO EMCY NMT Definition TK Engineering Oy CAN in Automation Controller Area Network CANopen Win API Application Programming Interface Object Dictionary Service Data Object Node identifier Process Data Object Transmit PDO Receive PDO Emergency Object Network Management 3 API Features CiA 301 compliant OD and NMT-master functionality CiA 302-4 compliant network variables CiA 302-5 compliant SDO manager(default SDO channels) Supports Kvaser hardware by default 10 TPDOs (object 0x1800-0x1809) and 10 RPDOs (object 0x1400-0x1409) are supported by default Supports RPDO timeout monitoring

CANopen Win API - API Documentation 5 (21) Supports 127 default client SDOs. The 128 th client SDO is free to use One default SDO server is configured. 127 SDO server objects are free to use Supports network variable objects (range between object 0xA000 and 0xA8FF) with data type of INTEGER8, UNSIGNED8, INTEGER16, UNSIGNED16, INTEGER32 and UNSIGNED32. Each supported object has maximum 254 sub indexes One node is supported currently Supports both string based license and hardware license Contact us for customized features 4 API Functions 4.1 COWA_GetDllVersion() unsigned long COWA_GetDllVersion(); Returns the version number of the CANopenWinAPI DLL. The bytes from left to right are: 1- Reserved 2- Major version 3- Minor version 4- Minor minor version For example, If the version of the DLL is 1.2.3, the return value will be 0x00010203. If the minor minor version is an odd number, then DLL is a developed version. If it is an even number, the DLL is a released version. 4.2 COWA_InitLibrary() void COWA_InitLibrary(); Initializes internal data structures. MUST be called before any other functions in the API can be called. Return nothing. 4.3 COWA_AddLicense() cowaresult COWA_AddLicense(char * mylicense); This function is only for string based license. If you have a license that is written to Kvaser hardware, this function can be ignored. If you have a string based license, then this function MUST be the second call after calling COWA_InitLibrary(). Otherwise, no other functions will work. You can add only one license per calling. Call this function several times if you have more than one license. Return COWA_OK as success. However, it doesn't mean the license is valid. The validation of the license will be reported in the following calls.

CANopen Win API - API Documentation 6 (21) Return COWA_ERR_XXX on failure. Contact us if you would like to purchase a license. Contact support team to get a 30-days demo license. 4.4 COWA_CreateNode() cowanodehandle COWA_CreateNode(); Create a new node assigned to the first available CAN channel. Returns the handle to the node. Return -1 means invalid handle. 4.5 COWA_SetBitrate() cowaresult COWA_SetBitrate( cowanodehandle handle, cowabitrate bitrate); Set the bitrate to the local node. Return COWA_OK on success, return COWA_ERR_XXX on failure. The call to this function will fail if the node was already running(i.e. after COWA_EnableNode() was called). 4.6 COWA_GetBitrate() cowaresult COWA_GetBitrate( cowanodehandle handle, cowabitrate *bitrate); Get the birate of the local node. Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.7 COWA_SetNodeId() cowaresult COWA_SetNodeId( cowanodehandle handle, uint8_t nodeid); Set the node id of the local node. The valid node id is between 1 and 127. The call to this function will fail if the node was already running(i.e. after COWA_EnableNode() was called). Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.8 COWA_GetNodeId() cowaresult COWA_GetNodeId( cowanodehandle handle, uint8_t *nodeid); Get the node id of the local node. Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.9 COWA_SetNodeInfo() cowaresult COWA_SetNodeInfo( cowanodehandle handle, uint8_t type, uint8_t *data, int32_t size); This function is used to configure the basic information for the local node. e.g. Identity Object and Manufacture Device Name, Hareware Version and Software Version. You MUST use this function to configure the node before calling COWA_EnableNode(). Arguments: handle The current handle of the node

CANopen Win API - API Documentation 7 (21) type One of COWA_INFO_XXX used for this function data Pointer to the buffer size The size of the buffer where data points to Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.10 COWA_EnableNode() cowaresult COWA_EnableNode( cowanodehandle handle); Enable a node on the first available channel. The node will go on bus with the configuted node id and bitrate. Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.11 COWA_SetLocalNmtState() cowaresult COWA_SetLocalNmtState( cowanodehandle handle, cowanmtcommand command); Send the NMT command to the local node to enter specified NMT state. Return COWA_OK as success, return COWA_ERR_XXX on failure. 4.12 COWA_SendNmtCommand() cowaresult COWA_SendNmtCommand( cowanodehandle handle, uint8_t nodeid, cowanmtcommand command); Send the NMT command to the specified remote node on the network to enter specified NMT state. Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.13 COWA_GetNmtState() cowaresult COWA_GetNmtState( cowanodehandle handle, int nodeid, cowanmtstate *state); Get the NMT state of the specified node. If the nodeid is 0 or equal to the node id of the local node, the NMT state of the local node will be returned to *state. (see CiA314 version 0.0.3.5, section 6.5.2 Inquiring NMT state) Otherwise, the status (operational state) of a node that is being monitored through the nodeguarding or heartbeat consumer protocols will be return. Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.14 COWA_GetNodeInfo() COWA_GetNodeInfo( cowanodehandle handle, uint8_t type, int32_t *data); Get runtime information about the node, e.g. CAN bus status. Arguments: handle The current handle to the node type One of COWA_INFO_XXX that describes the information field we want to get.

CANopen Win API - API Documentation 8 (21) data Pointer to unsigned 32 bit variable that will get the data For COWA_INFO_CANSTATUS, data will be the flag COWA_CANSTAT_XXX or the combination of them. For COWA_INFO_CANOPENSTATUS, data will be the flag COWA_CANOPENSTAT_XXX or the combination of them. Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.15 COWA_GetRpdoStatus() cowaresult COWA_GetRpdoStatus( cowanodehandle handle, uint16_t rpdonumber, uint32_t *rpdostatus); Get the status of the monitored RPDO. e.g. if it s timeout or not. Arguments: handle The current handle of the node rpdonumber The number index of the RPDO. It should start from 1. *rpdostatus Pointer of the buffer to store the RPDO status flag. Check COWA_RPDO_XXX Return COWA_OK on success, return COWA_ERR_XXX on failure. 4.16 COWA_ReadSdo() cowaresult COWA_ReadSdo( cowanodehandle handle, uint8_t sdonumber, uint16_t index, uint8_t subindex, uint8_t * data, int32_t * size, uint32_t *sdoabortcode); The default SDO COB-ID is used in CANopenWinAPI. If sdonumber is 0, read the Object Dictionary of the local node. The value will be stored in data. sdoabortcode is assigned to an error code in case of error. If sdonumber is not 0, this function will send SDO read request of the Object Dictionary of the remote node. Arguments: handle The current handle of the node sdonumber 0 if access to local OD, other value if access remote OD index The index of the OD entry subindex The sub index of the OD entry data Pointer to the buffer where the data will be stored size Size is both input and output. When calling the function size should contain the size (in bytes) of the memory pointed to by data. When the function returns successfully it will set size to the actual number of bytes stored in data. sdoabortcode One of COWA_SDO_XXX. 0 if no error Note: You need to check both sdoabortcode and function return value. If the SDO abort message was received from the SDO server, then sdoabortcode contains the abort code while function returns COWA_OK. Return COWA_OK on success, return COWA_ERR_XXX on failure.

CANopen Win API - API Documentation 9 (21) 4.17 COWA_WriteSdo() cowaresult COWA_WriteSdo( cowanodehandle handle, uint8_t sdonumber, uint16_t index, uint8_t subindex, uint8_t * data, int32_t size, uint32_t * sdoabortcode); If the sdonumber is 0, write to the Object Dictionary of the local node. sdoabortcode is assigned to an error code in case of error. Otherwise, send the write access request of the Object Dictionary to the remote node. Arguments: handle The current handle of the node sdonumber 0 if access to local OD, other value if access remote OD index The index of the OD entry subindex The sub index of the OD entry data Pointer to the buffer where the data will be written size The size( in bytes) of the buffer that data points to. sdoabortcode One of COWA_SDO_XXX. 0 if no error or unspecified Return COWA_OK on success, return COWA_ERR_XXX on failure. Remember to check the abort code when return value is not COWA_OK. 4.18 COWA_TransmitEmcy() cowaresult COWA_TransmitEmcy( cowanodehandle handle, cowaemcyerrorcode emcyerrorcode, uint16_t additionalinfo, uint8_t mb1, uint8_t mb2, uint8_t mb3, uint8_t mb4, uint8_t mb5); Transmit an EMCY message to the CAN bus. Arguments: handle The current handle of the node emcyerrorcode One of COWA_EMCY_XXX additionalinfo The additional information of the error history field in object 0x1003. See CiA-301 for more info mb1 - mb5 The 5 bytes of manufacture specific error code. See CiA-301 v 4.2.0 section 7.2.7.3 Emergency object protocol for more info Return COWA_OK as function was called successfully, return COWA_ERR_XXX on failure. Note: There is no guarantee that the EMCY message will be successfully transferred to the CAN bus even though it returns COWA_OK 4.19 COWA_CloseNode() cowaresult COWA_CloseNode( cowanodehandle handle); Goes off bus, closes CAN channel, frees handle. The handle will become invalid. Return COWA_OK on success, return COWA_ERR_XXX on failure.

CANopen Win API - API Documentation 10 (21) 4.20 COWA_CloseLibrary() void COWA_CloseLibrary(); Releases memories and frees all resources. Must be the last function to be called. Need to call COWA_InitLibrary() again to use the library. 5 API Constants 5.1 Definition of cowaresult typedef int cowaresult; // Result code for function calls #define COWA_OK 0 // OK, no errors #define COWA_ERR_PARAM_RANGE -1 // Parameter out of range #define COWA_ERR_INVHANDLE -2 // Handle is invalid #define COWA_ERR_INTERNAL -3 // Internal error #define COWA_ERR_LIB_NOT_INITIALIZED -4 // Library is not initialized #define COWA_ERR_PARAM -5 // Bad parameter passed to the function #define COWA_ERR_NODE_IS_RUNNING -6 // The node is already started #define COWA_ERR_NODE_NOT_ENABLED -7 // The node is not started #define COWA_ERR_NODE_NOT_CREATED -8 // The node is not created yet #define COWA_ERR_OTHER -9 // Other error #define COWA_ERR_NO_CAN_HW -10 // No CAN hardware channel #define COWA_ERR_SW_BUFF_FULL -11 // Internal software buffer is overflow #define COWA_ERR_LICENSE -12 // No valid license #define COWA_ERR_UNDEFINED_SDO_NO -13 // The SDO number is undefined #define COWA_ERR_BUSY -14 // The resource is in use, try again // later #define COWA_ERR_TIMEOUT -15 // A timeout occurred #define COWA_ERR_NOTSUPPORTED -16 // Not supported #define COWA_ERR_PDO_NOTFOUND -17 // The PDO is not found /* CAN error code */ #define COWA_ERR_CAN #define COWA_ERR_CAN_NOMSG #define COWA_ERR_CAN_OVERFLOW #define COWA_ERR_CAN_HARDWARE #define COWA_ERR_CAN_TIMEOUT -17 // General CAN error -18 // No CAN message to read -19 // Receive message buffer is overflow -20 // CAN hardware error -21 // CAN timeout 5.2 Definition of bus speed typedef enum { COWA_BITRATE_1M = 0, COWA_BITRATE_800K = 1, COWA_BITRATE_500K = 2, COWA_BITRATE_250K = 3, COWA_BITRATE_125K = 4, COWA_BITRATE_100K = 5, COWA_BITRATE_50K = 6, COWA_BITRATE_25K = 7 cowabitrate;

CANopen Win API - API Documentation 11 (21) 5.3 Definition of cowanmtcommand typedef enum { COWA_NMT_CMD_START = 1, // PreOperational -> Operational COWA_NMT_CMD_STOP = 2, // -> Stopped COWA_NMT_CMD_ENTER_PREOP = 128, // -> PreOperational State COWA_NMT_CMD_RESET_NODE = 129, // -> Reset Node COWA_NMT_CMD_RESET_COMM = 130 // -> Reset Communication cowanmtcommand; 5.4 Definition of cowanmtstate typedef enum { COWA_NMT_STATE_BOOTUP = 0, // Initialisation COWA_NMT_STATE_STOPPED = 4, // Stopped COWA_NMT_STATE_OPERATIONAL = 5, // Operational COWA_NMT_STATE_PREOP = 127 // Pre-operational COWA_NMT_STATE_UNKNOWN = 255 // Sate unknown is only used internally cowanmtstate; 5.5 Definition of cowaemcyerrorcode typedef enum{ COWA_EMCY_NO_ERRORS = 0x0000, COWA_EMCY_ERROR_RESET = 0x0000, COWA_EMCY_GENERIC_ERRORS = 0x1000, COWA_EMCY_CURRENT_ERRORS = 0x2000, COWA_EMCY_CURRENT_DEVICE_INPUT_ERRORS = 0x2100, COWA_EMCY_CURRENT_INSIDE_DEVICE_ERRORS = 0x2200, COWA_EMCY_CURRENT_DEVICE_OUTPUT_ERRORS = 0x2300, COWA_EMCY_VOLTAGE_ERRORS = 0x3000, COWA_EMCY_VOLTAGE_MAINS_ERRORS = 0x3100, COWA_EMCY_VOLTAGE_INSIDE_DEVICE_ERRORS = 0x3200, COWA_EMCY_VOLTAGE_OUTPUT_ERRORS = 0x3300, COWA_EMCY_TEMPERATURE_ERRORS = 0x4000, COWA_EMCY_TEMPERATURE_AMBIENT_ERRORS = 0x4100, COWA_EMCY_TEMPERATURE_DEVICE_ERRORS = 0x4200, COWA_EMCY_HARDWARE_ERRORS = 0x5000, COWA_EMCY_SOFTWARE_ERRORS = 0x6000, COWA_EMCY_SOFTWARE_INTERNAL_ERRORS = 0x6100, COWA_EMCY_SOFTWARE_USER_ERRORS = 0x6200, COWA_EMCY_SOFTWARE_DATA_SET_ERRORS = 0x6300, COWA_EMCY_ADDITIONAL_MODULES_ERRORS = 0x7000, COWA_EMCY_MONITORING_ERRORS = 0x8000, COWA_EMCY_MONITORING_COMMUNICATION_ERRORS = 0x8100, COWA_EMCY_MONITORING_COM_CAN_OVERRUN_ERROR = 0x8110, COWA_EMCY_MONITORING_COM_CAN_PASSIVE_ERROR = 0x8120, COWA_EMCY_MONITORING_COM_LIFE_GUARD_HB_ERROR = 0x8130, COWA_EMCY_MONITORING_COM_BUS_RECOVERY_ERROR = 0x8140, COWA_EMCY_MONITORING_COM_COBID_COLLISION_ERROR = 0x8150, COWA_EMCY_MONITORING_PROTOCOL_ERRORS = 0x8200, COWA_EMCY_MONITORING_PROTOCOL_LENGTH_ERROR = 0x8210, COWA_EMCY_MONITORING_PROTOCOL_LENGTH_EXCEEDED_ERROR = 0x8220, COWA_EMCY_EXTERNAL_ERRORS = 0x9000, COWA_EMCY_ADDITIONAL_FUNCTION_ERRORS = 0xF000, COWA_EMCY_DEVICE_SPECIFIC_ERRORS = 0xFF00 cowaemcyerrorcode;

CANopen Win API - API Documentation 12 (21) 5.6 Definition of SDO Abort Code #define COWA_SDO_TOGGLE_BIT_NOT_ALTERED /* Toggle bit not altered */ #define COWA_SDO_PROTOCOL_TIMED_OUT /* SDO protocol timed out */ 0x05030000 0x05040000 #define COWA_SDO_UNKNOWN_CMD 0x05040001 /* Client/server command specifier not valid or unknown */ #define COWA_SDO_UNSUPPORTED_ACCESS_TO_OBJECT /* Unsupported access to an object */ #define COWA_SDO_OBJECT_READ_ONLY /* Attempt to write a read-only object */ #define COWA_SDO_OBJECT_WRITE_ONLY /* Attempt to read a write-only object */ #define COWA_SDO_OBJECT_DOES_NOT_EXISTS /* Object does not exists in the Object Dictionary */ 0x06010000 0x06010002 0x06010001 0x06020000 #define COWA_SDO_OBJECT_LENGTH 0x06070010 /* Data type does not match, length of service parameter does not match */ #define COWA_SDO_SERVICE_PARAM_TOO_HIGH 0x06070012 /* Data type does not match, length of service parameter too high */ #define COWA_SDO_SERVICE_PARAM_TOO_LOW 0x06070013 /* Data type does not match, length of service parameter too low */ #define COWA_SDO_INVALID_SUBINDEX /* Sub-index does not exist */ 0x06090011 #define COWA_SDO_OBJDICT_DYN_GEN_FAILED 0x08000023 /* Object dictionary dynamic generation fails or no object dictionary is present */ #define COWA_SDO_GENERAL /* General error */ #define COWA_SDO_GENERAL_PARAMETER_INCOMPATIBILITY /* General paramter internal incompabilitity */ 0x08000000 0x06040043 #define COWA_SDO_GENERAL_INTERNAL_INCOMPABILITY 0x06040047 /* General internal incompatibility in the device */ #define COWA_SDO_NOT_MAPABLE /* Try to map un-mapable object to PDO. */ #define COWA_SDO_DATA_CAN_NOT_BE_STORED /* the requested data can not be stored */ #define COWA_SDO_OUT_OF_MEMORY /* Node is out of memory. */ #define COWA_SDO_PDO_LENGHT /* Leght of PDO is exceeded */ #define COWA_SDO_VAL_RANGE_FOR_PARAM_EXCEEDED /* Param out of range. */ 0x06040041 0x08000020 0x05040005 0x06040042 0x06090030

CANopen Win API - API Documentation 13 (21) #define COWA_SDO_VALUE_TOO_HIGH 0x06090031 /* Value of parameter written too high (download only). */ #define COWA_SDO_VALUE_TOO_LOW 0x06090032 /* Value of parameter written too low (download only). */ #define COWA_SDO_ABORT_SDO_TRANSFER /* Abort SDO transfer */ 0x06060000 5.7 Definition of Flags used in COWA_GetNodeInfo() // Data types for COWA_GetNodeInfo #define COWA_INFO_CANSTATUS 1 #define COWA_INFO_CANOPENSTATUS 2 // Flags for CAN status for function COWA_GetNodeInfo with type COWA_INFO_CANSTATUS #define COWA_CANSTAT_ERROR_PASSIVE 1 #define COWA_CANSTAT_BUS_OFF 2 #define COWA_CANSTAT_ERROR_WARNING 4 #define COWA_CANSTAT_ERROR_ACTIVE 8 /** Flags for CANopen status for function COWA_GetNodeInfo with type COWA_INFO_CANOPENSTATUS. */ #define COWA_CANOPENSTAT_SDOABORT 1 // There was an SDO abort since the last time we read the CANopen status. This flag is reset on every read 5.8 Definition used in COWA_SetNodeInfo() /** Data types used in COWA_SetNodeInfo(). */ #define COWA_INFO_MFG_DEVICENAME 3 #define COWA_INFO_MFG_HW_VERSION 4 #define COWA_INFO_MFG_SW_VERSION 5 #define COWA_INFO_VENDORID 6 #define COWA_INFO_PRODUCTCODE 7 #define COWA_INFO_REVNUM 8 #define COWA_INFO_SERIALNUM 9 5.9 Definition used in COWA_GetRpdoStatus() #define COWA_RPDO_TIMEOUT 1 // The monitored RPDO is timeout 6 How to use Network Variables The network variable objects (range between object 0xA000 and 0xA8FF) with data type of INTEGER8, UNSIGNED8, INTEGER16, UNSIGNED16, INTEGER32 and

CANopen Win API - API Documentation 14 (21) UNSIGNED32 can be accessed by the application through API function COWA_ReadSdo() and COWA_WriteSdo() with sdonumber set to 0. 7 Example Below is a simple example that shows you the basic sequence to use the CANopen Win API. //... #include "CANopenWinAPI.h" //... int ExampleCode(){ cowaresult res; cowanodehandle myhandle; cowabitrate mybitrate = COWA_BITRATE_250K; uint8_t mynodeid = 2; uint8_t NodeA_Id = 4; COWA_InitLibrary(); printf("\n Init library done!\n"); /* Add License for string based license, if you have Kvaser hardware licnese, this function can be ignored */ char *mylicense = "E24393C 3DCDB71C B8CE377E 709C0602 2912006A 0 10078"; res = COWA_AddLicense( mylicense); printf("\n COWA_AddLicense failed. res = %d!\n", res); return -1; printf("\n Add License success!\n"); myhandle = COWA_CreateNode(); if( myhandle < 0 ){ printf("\n COWA_CreateNode failed. res = %d!\n", myhandle); return -3;

CANopen Win API - API Documentation 15 (21) printf("\n Create Node success!\n"); res = COWA_SetBitrate( myhandle, mybitrate); printf("\n COWA_SetBitrate failed. res = %d!\n", res); return -4; printf("\n Set Bitrate success!\n"); res = COWA_SetNodeId( myhandle, mynodeid); printf("\n COWA_SetNodeId failed. res = %d!\n", res); return -5; printf("\n Set Node ID success!\n"); char devicename[] = "CANopen DLL"; int32_t len = (int32_t)strlen(devicename); res = COWA_SetNodeInfo( myhandle, COWA_INFO_MFG_DEVICENAME, (uint8_t *)&devicename, len); printf("\n COWA_SetNodeInfo failed. res = %d!\n", res); return -6; printf("\n Set Device Name success!\n"); res = COWA_EnableNode( myhandle); printf("\n COWA_EnableNode failed. res = %d!\n", res); return -7; printf("\n Enable Node success, node goes on CAN-bus!\n"); int32_t canstatus;

CANopen Win API - API Documentation 16 (21) res = COWA_GetNodeInfo( myhandle, COWA_INFO_CANSTATUS, &canstatus); printf("\n COWA_GetNodeInfo failed. res = %d!\n", res); return -8; printf("\n Get CAN status success! CAN status = %d\n", canstatus); /* Set/Get Local NMT State Example */ cowanmtstate state; res = COWA_GetNmtState( myhandle, mynodeid, &state); printf("\n COWA_GetNmtState failed. res = %d\n", res); return -9; printf("\n Get Local NMT state success!\n"); printf("\n Local NMT state is = %d\n", state); res = COWA_SetLocalNmtState( myhandle, COWA_NMT_CMD_START); printf("\n COWA_SetLocalNmtState failed. res = %d\n", res); return -10; printf("\n Set Local NMT state success!\n"); int32_t size; uint32_t err; uint8_t data_8 = 0; uint16_t data_16 = 0; uint32_t data_32 = 0; /* SDO read access to the local OD, the SDO number should be 0 */ data_32 = 0;

CANopen Win API - API Documentation 17 (21) size = sizeof(data_32); res = COWA_ReadSdo( myhandle, 0, 0x1280, 0x02, (uint8_t *)&data_32, &size, &err); printf("\n COWA_ReadSdo to local OD 0x1280 subidx 0x02 failed. res = %d, err = %d\n", res, err); return -11; printf("\n SDO read-access to local OD 0x1280 subidx 0x02 success.\n"); /* SDO Write-access to local OD Example */ // Configure local OD 0x1016 consumer heartbeat time size = 4; data_32 = 0x403E8; // consumer heartbeat 1000 ms from node 4 res = COWA_WriteSdo( myhandle, 0, 0x1016, 0x01, (uint8_t *)&data_32, size, &err); printf("\n COWA_WriteSdo to local OD 0x1016 subidx 0x01 failed. res = %d, err = %d\n", res, err); return -12; printf("\n SDO write-access to local OD 0x1016 subidx 0x01 success.\n"); // SDO write-access to remote OD : Configure Node A producer heartbeat time 1000 ms // Note : we are using Default client SDOs, therefore, sdonumber and the node id are the same data_16 = 0x3E8; res = COWA_WriteSdo( myhandle, 4, 0x1017, 0x00, (uint8_t *)&data_16, 2, &err); printf("\n COWA_WriteSdo to remote OD 0x1017 subidx 0x00 failed. res = %d, err = %d\n", res, err); return -13;

CANopen Win API - API Documentation 18 (21) /* SDO Read-access to remote OD Example */ // SDO read-access to remote OD 0x1017 sub index 0x00 to see if 0x3E8 was written to. data_16 = 0; size = sizeof(data_16); res = COWA_ReadSdo( myhandle, 4, 0x1017, 0x00, (uint8_t *)&data_16, &size, &err); printf("\n COWA_ReadSdo to remote OD 0x1017 subidx 0x00 failed. res = %d, err = %d\n", res, err); return -14; if( data_16!= 0x3E8){ printf("\n Value in remote OD 0x1017 subidx 0x00 is invalid. value(should be 1000) = %d\n", data_16); return -15; Sleep(1000); // Get the NMT state of the Node A(been monitored) res = COWA_GetNmtState( myhandle, 4, &state); printf("\n COWA_GetNmtState failed. res = %d\n", res); return -16; printf("\n COWA_GetNmtState Node A's state = %d\n", state); // Set the NMT state (operational) to the remote node over CAN network res = COWA_SendNmtCommand( myhandle, NodeA_Id, COWA_NMT_CMD_START); printf("\n COWA_SendNmtCommand to node A failed. res = %d\n", res);

CANopen Win API - API Documentation 19 (21) return -17; // Now we set Node A's producer heartbeat time to 0. (disable heartbeat) data_16 = 0; size = 2; res = COWA_WriteSdo( myhandle, 4, 0x1017, 0x00, (uint8_t *)&data_16, size, &err); printf("\n COWA_WriteSdo to node A 0x1017, sub index 0x00 failed. res = %d\n", res); return -18; /* Transmit EMCY Example */ // You can call this function to send a EMCY message res = COWA_TransmitEmcy( myhandle, COWA_EMCY_SOFTWARE_ERRORS, 0, 0, 0,0,0,0); printf("\n COWA_TransmitEmcy failed. res = %d\n", res); return -19; // Now we close the node, the node will go off CAN-bus. And then close the library, free all the resources res = COWA_CloseNode( myhandle); printf("\n COWA_CloseNode failed. res = %d\n", res); return -20; printf("\n Close local Node success.\n"); COWA_CloseLibrary(); printf("\n Close Library done\n"); return 0;

CANopen Win API - API Documentation 20 (21) 8 References CiA 301 CANopen application layer and communication, version 4.2.0 CiA 302 CANopen additional application layer functions Part 4: Network variables and process image, version 4.1.0 CiA 314 Accessing CANopen services in devices programmable in IEC 61131-3 languages, version 0.0.3.5

CANopen Win API - API Documentation 21 (21)