MOONS’ CANopen Library
User Manual
Rev. 1.1
Sep. 30th, 2017
©Copyright Shanghai AMP & MOONS’ Automation Co., Ltd. All Right Reserved.
MOONS’ CANopen Library User Manual
Contents
1 GETTING STARTED ......................................................................................... 5
1.1 INTRODUCTION .............................................................................................. 5
1.2 OPERATING SYSTEM ...................................................................................... 5
1.3 PREPARATIONS .............................................................................................. 5
2 HOW TO USE THE DLL ................................................................................... 6
2.1 CANOPENLIBHELPER CLASS ......................................................................... 6
2.2 INCLUDED FILES ............................................................................................ 6
2.3 USAGE FLOWCHART....................................................................................... 7
2.4 PROGRAMMING GUIDE ................................................................................... 8
2.4.1 C++ ...................................................................................................................... 8
2.4.2 C# ........................................................................................................................ 9
2.4.3 VB.NET ................................................................................................................ 9
2.5 ABOUT SAMPLE CODE SOLUTION .................................................................. 10
3 API DEFINITION ............................................................................................. 12
3.1 API LIST ..................................................................................................... 12
3.1.1 Events ................................................................................................................ 12
3.1.2 Basic APIs.......................................................................................................... 12
3.1.3 SDO APIs........................................................................................................... 13
3.1.4 Advanced APIs .................................................................................................. 17
3.2 API DESCRIPTIONS ...................................................................................... 18
3.2.1 Structure & Enumeration Definition ................................................................... 18
4 API REFERENCE ........................................................................................... 21
4.1 EVENTS ...................................................................................................... 21
4.2 BASIC APIS ................................................................................................. 22
4.3 SDO APIS .................................................................................................. 46
4.4 ADVANCED APIS .......................................................................................... 68
5 FAQ ................................................................................................................. 72
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 2 / 73
MOONS’ CANopen Library User Manual
5.1 HOW TO SOLVE "LOADERLOCK WAS DETECTED" WHEN ADAPTER IS ZLG? ......... 72
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 3 / 73
MOONS’ CANopen Library User Manual
Revision History
Rev. Author Participator Date Description
1.0 Austin 2017-02-23 First released.
1.1 Austin 2017-09-30 Added canlib32.dll to the included files.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 4 / 73
MOONS’ CANopen Library User Manual
1 Getting Started
1.1 Introduction
MOONS’ Motion Control Libraries provides powerful APIs to the users to write their Microsoft
Windows software when there are using MOONS’ field bus drives. It will help the users to develop
there motion control system rapidly and easily. MOONS’ Motion Control Libraries consist of the
following libraries:
Table 1.1 Motion Control Libraries List
Library DLL Description Communication
SCL SCLLib_x86.DLL Serial Port communication with RS232, RS485/422
SCL Library
SCLLib_x64.DLL
Ethernet SCL ESCLLib_x86.DLL Ethernet communication with SCL Ethernet
Library
ESCLLib_x64.DLL
CANopen CANopenLib_x86.DLL CANopen communication library CANopen
CANopenLib_x64.DLL
This User Manual gives basic instructions on how to use the CANopen Library to control your
MOONS’ drives via CANopen bus.
MOONS' provides VC++, VB.NET and C# sample codes to show you how to program with
MOONS’ CANopen Library. In the sample codes there is a helper file to encapsulate the
importation to the DLL. This will make it very convenient to use.
1.2 Operating System
Microsoft Windows XP(Service Pack 3), Vista, 7, 8 10 or later, 32-bit and 64-bit.
1.3 Preparations
Before you program your motion control application, you should do some configurations otherwise
it will lead the communication to muddle.
For MOONS' CANopen drives, you should configure all your drives in one CANopen fieldbus
network with same baud rate. Also the drives Node ID should be different entirely.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 5 / 73
MOONS’ CANopen Library User Manual
2 How to Use the DLL
2.1 CANopenLibHelper Class
When customer want to use our library, they can’t call the function directly becase our library
is a DLL. Fortunely, for VC++, C# and VB.NET, MOONS’ provides a helper file to simple the call to
the DLL APIs.You don’t need to write the complicated links to the DLL. You only need to write
several lines of code then you can make the motor moving.
MOONS’ provide 32-bit and 64-bit DLL for 32-bit and 64-bit operating system respectively.
32-bit 64-bit
Application Application
CANopenLibHelper CANopenLibHelper
class class
CANopenLib_x86.dll CANopenLib_x64.dll
Fig. 2.1 CANopen Library Helper
2.2 Included Files
Your own application should include some files. Open the installation folder, normally the
installation folder should be "C:\Program Files (x86)\MOONS'\CANopen Library\". Then enter the
sub-folder "Lib". If you are using 32-bit operating system, please enter the "x86" and copy all files
and folder to the running folder of your own software. See Fig. 2.2 and Fig. 2.3:
32-bit
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 6 / 73
MOONS’ CANopen Library User Manual
Fig. 2.2 32-bit included files
64-bit
Fig. 2.3 64-bit included files
2.3 Usage Flowchart
The usage flowchart of the DLL is as following:
1. Open
2. Motion or Monitor Commands
3. Close
Fig. 2.4 Usage flowchart of CANopen DLL
1. Open
Call this function to Open CANopen Adapter so that you can communication to the drive.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 7 / 73
MOONS’ CANopen Library User Manual
2. Motion or Monitor Commands
Here you can call the basic APIs or advanced APIs according to your application.
3. Close
Close CANopen communication and release resources.
2.4 Programming Guide
2.4.1 C++
// Define Adapter, 0=Kvaser, 1=PEAK, 2=ZLG
int nAdapter = 0;
// Initlize baud rate to 1Mbps
int nBaudRate = 0;
BYTE nChannel = 0;
// Set current node ID to 1
BYTE nNodeID = 1;
// Create an instance of helper
CANopenLibHelper *m_CANopenLibHelper = new CANopenLibHelper();
// For 32-bit operating system, using the following line:
// CANopenLibHelper *m_CANopenLibHelper = new CANopenLibHelper();
// Open CANopen Adapter
BOOL ret = m_CANopenLibHelper->Open(nAdapter, nBaudRate, nChannel);
// Enable the motor
ret = m_CANopenLibHelper->DriveEnable(nNodeID, TRUE);
// Rel Move: Distance = 20000 steps, Velocity = 10rps, Acceleration = 100 rps/s, Deceleration =
100rps/s
// Rel Move Velocity
double dVelocity = 10;
// Rel Move Acceleration
double dAccel = 100;
// Rel Move Deceleration
double dDecel = 100;
ret = m_CANopenLibHelper->RelMove(nNodeID, 20000, &dVelocity, &dAccel, &dDecel);
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 8 / 73
MOONS’ CANopen Library User Manual
2.4.2 C#
// Define Adapter, 0=Kvaser, 1=PEAK, 2=ZLG
int nAdapter = 0;
// Initlize baud rate to 1Mbps
int nBaudRate = 0;
byte nChannel = 0;
// Set current node ID to 1
byte nNodeID = 1;
// Create an instance of helper
CANopenLibHelper m_CANopenLibHelper = new CANopenLibHelper();
// For 32-bit operating system, using the following line:
// CANopenLibHelper m_CANopenLibHelper = new CANopenLibHelper();
// Open CANopen Adapter
bool ret = m_CANopenLibHelper.Open (nAdapter, nBaudRate, nChannel);
// Enable the motor
ret = m_CANopenLibHelper.DriveEnable(nNodeID, TRUE);
// Rel Move: Distance = 20000 steps, Velocity = 10rps, Acceleration = 100 rps/s, Deceleration =
100rps/s
// Rel Move Velocity
double dVelocity = 10;
// Rel Move Acceleration
double dAccel = 100;
// Rel Move Deceleration
double dDecel = 100;
ret = m_CANopenLibHelper.RelMove(nNodeID, 20000, dVelocity, dAccel, dDecel);
2.4.3 VB.NET
' Define Adapter, 0=Kvaser, 1=PEAK, 2=ZLG
Dim nAdapter As Integer = 0
' Initlize baud rate to 1Mbps
Dim nBaudRate As Integer = 0
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 9 / 73
MOONS’ CANopen Library User Manual
Dim nChannel As Byte = 0
' Set current node ID to 1
Dim nNodeID As Byte = 1
' Create an instance of helper
Dim m_CANopenLibHelper As New CANopenLibHelper()
' For 32-bit operating system, using the following line:
' CANopenLibHelper m_CANopenLibHelper = new CANopenLibHelper();
' Open CANopen Adapter
Dim ret As Boolean = m_CANopenLibHelper.Open(nAdapter, nBaudRate, nChannel)
' Enable the motor
ret = m_CANopenLibHelper.DriveEnable(nNodeID, True)
' Rel Move: Distance = 20000 steps, Velocity = 10rps, Acceleration = 100 rps/s, Deceleration =
100rps/s
' Rel Move Velocity
Dim dVelocity As Double = 10
' Rel Move Acceleration
Dim dAccel As Double = 100
' Rel Move Deceleration
Dim dDecel As Double = 100
ret = m_CANopenLibHelper.RelMove(nNodeID, 20000, dVelocity, dAccel, dDecel)
2.5 About Sample Code Solution
MOONS’ provides a Sample code with integrated VC++, C# and VB.NET in a Visual Studio
2010 solution. See below picture:
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 10 / 73
MOONS’ CANopen Library User Manual
Fig. 2.5 CANopenLibSample Properties
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 11 / 73
MOONS’ CANopen Library User Manual
3 API Definition
3.1 API List
3.1.1 Events
The DLL provides 4 type of events. OnHeartBeatReceive, OnDataSend, OnDataReceive and
OnTPDOReceived. You can handle your own process when the events are triggered.
Table 3.1 Events List
API Name Description
OnHeartBeatReceive Trigger when heart beat received
OnDataSend Trigger when send data to drive
OnDataReceive Trigger when received data from drive
OnTPDOReceived Trigger when TPDO received
3.1.2 Basic APIs
The basic APIs are about to the basic operation for communication such as the open CAN adapter
and close, etc..
Table 3.2 Basic API List
API Name Description
Open Open CANopen communication
Close Close CANopen communication
IsOpen Return a boolean value that indicate the port is open or closed.
SetExecuteTimeOut Set Execute Time Out
GetExecuteTimeOut Set Execute Time Out
SetExecuteRetryTimes Set Execute Retry Times
GetExecuteRetryTimes Set Execute Retry Times
ResetBuffer Reset buffer
GetLastErrorInfo Get the last command that received
GetLastHeartBeatMessage Get last heart beat message
GetLastSentMessage Get last sent message
GetLastReceivedMessage Get last received message
GetLastTPDOMessage Get last TPDO message
Write Write command to the drive
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 12 / 73
MOONS’ CANopen Library User Manual
ExecuteCommand Write command to the drive and read response from the drive
ReadSDOInt8 Read SDO data of char data
ReadSDOUInt8 Read SDO data of unsigned char data
ReadSDOInt16 Read SDO data of short data
ReadSDOUInt16 Read SDO data of unsigned short data
ReadSDOInt32 Read SDO data of int data
WriteSDOUInt32 Read SDO data of unsigned int data
SetToPreoperationalMode Set to preoperational mode
SetToOperationalMode Set to operational mode
SetRPDOMapping Set RPDO mapping settings
SetTPDOMapping Set TPDO mapping settings
RestorePDOMappingSettings Restore PDO mapping settings to factory default settings
WriteRPDO Write RPDO when drive is in operational mode
SaveParameters Save parameters to flash
3.1.3 SDO APIs
SDO APIs provide the operation for SDO. When you call these APIs, the drive must be in either
Pre-Operational or Operational mode.
Table 3.3 SDO API List
API Name Index Sub Description
ReadPositionGain 5000h 0 Read Position Gain
WritePositionGain 5000h 0 Write Position Gain
ReadPositionDeriGain 5001h 0 Read Position Deri Gain
WritePositionDeriGain 5001h 0 Write Position Deri Gain
ReadPositionDeriFilter 5002h 0 Read Position Deri Filter
WritePositionDeriFilter 5002h 0 Write Position Deri Filter
ReadVelocityGain 5003h 0 Read Velocity Gain
WriteVelocityGain 5003h 0 Write Velocity Gain
ReadVelocityIntegGain 5004h 0 Read Velocity Integ Gain
WriteVelocityIntegGain 5004h 0 Write Velocity Integ Gain
ReadAccFeedForward 5005h 0 Read Acc FeedForward
WriteAccFeedForward 5005h 0 Write Acc FeedForward
ReadPIDFilter 5006h 0 Read PID Filter
WritePIDFilter 5006h 0 Write PID Filter
ReadNotchFilter 5007h 0 Read Notch Filter
~500Eh
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 13 / 73
MOONS’ CANopen Library User Manual
WriteNotchFilter 5007h 0 Write Notch Filter
~500Eh
ReadPositionError 500Fh 0 Read Position Error
WritePositionError 500Fh 0 Write Position Error
ReadVelocityMax 5010h 0 Read Velocity Max
WriteVelocityMax 5010h 0 Write Velocity Max
ReadSmoothFilter 5011h 0 Read Smooth Filter
WriteSmoothFilter 5011h 0 Write Smooth Filter
ReadDriverTemp 5012h 0 Read Driver Temp
ReadErrorCode 603Fh 0 Read Error Code
ReadErrorCodeUpper 700Fh 0 Read Higher 16 Bit of ErrorCode
WriteControlWord 6040h 0 Write Control Word
ReadStatusWord 6041h 0 Read Status Word
ReadQuickStopOptionCode 605Ah 0 Read Quick Stop Option Code
WriteQuickStopOptionCode 605Ah 0 Write Quick Stop Option Code
WriteModesofOperation 6060h 0 Write Modes of Operation
ReadModesofOperation 6061h 0 Read Modes of Operation
ReadPositionTargetValueCalculated 6064h 0 Read Position Target Value Calculated
ReadFollowingErrorWindow 6065h 0 Read Following Error Window
WriteFollowingErrorWindow 6065h 0 Write Following Error Window
ReadVelocityTargetValueCalculated 606Ch 0 Read Velocity Target Value Calculated
ReadTargetTorque 6071h 0 Read Target Torque
WriteTargetTorque 6071h 0 Write Target Torque
ReadMaxRunningCurrent 6073h 0 Read Max Running Current
WriteMaxRunningCurrent 6073h 0 Write Max Running Current
ReadTorqueDemandValue 6074h 0 Read Torque Demand Value
ReadCurrentActualValue 6078h 0 Read Torque Actual Value
ReadTargetPosition 607Ah 0 Read Target Position
WriteTargetPosition 607Ah 0 Write Target Position
ReadHomingOffset 607Ch 0 Read Homing Offset
WriteHomingOffset 607Ch 0 Write Homing Offset
ReadPolarity 607Eh 0 Read Polarity
WritePolarity 607Eh 0 Write Polarity
ReadMaxProfileSpeed 607Fh 0 Read Max Profile Speed
WriteMaxProfileSpeed 607Fh 0 Write Max Profile Speed
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 14 / 73
MOONS’ CANopen Library User Manual
ReadProfileVelocity 6081h 0 Read Profile Velocity
WriteProfileVelocity 6081h 0 Write Profile Velocity
ReadProfileAcceleration 6083h 0 Read Profile Acceleration
WriteProfileAcceleration 6083h 0 Write Profile Acceleration
ReadProfileDeceleration 6084h 0 Read Profile Deceleration
WriteProfileDeceleration 6084h 0 Write Profile Deceleration
ReadQuickStopDeceleration 6085h 0 Read Quick Stop Deceleration
WriteQuickStopDeceleration 6085h 0 Write Quick Stop Deceleration
ReadTorqueSlop 6087h 0 Read Torque Slop
WriteTorqueSlop 6087h 0 Write Torque Slop
ReadHomingMethod 6098h 0 Read Homing Method
WriteHomingMethod 6098h 0 Write Homing Method
ReadHomingSpeedSearchSwitch 6099h 1 Read Homing Speed Search Switch
WriteHomingSpeedSearchSwitch 6099h 1 Write Homing Speed Search Switch
ReadHomingSpeedSearchIndex 6099h 2 Read Homing Speed Search Index
WriteHomingSpeedSearchIndex 6099h 2 Write Homing Speed Search Index
ReadHomingAcceleration 609Ah 0 Read Homing Acceleration
WriteHomingAcceleration 609Ah 0 Write Homing Acceleration
ReadDriveOutputs 60FEh 1 Read Drive Outputs
WriteDriveOutputs 60FEh 1 Write Drive Outputs
ReadTargetVelocity 60FFh 0 Read Target Velocity
WriteTargetVelocity 60FFh 0 Write Target Velocity
ReadSupportedDriveModes 6502h 0 Read Supported Drive Modes
ReadHomingSwitch 7001h 0 Read Homing Switch
WriteHomingSwitch 7001h 0 Write Homing Switch
ReadIdleCurrent 7002h 0 Read Idle Current
WriteIdleCurrent 7002h 0 Write Idle Current
ReadDisplayDriveInputs 7003h 0 Read Display Drive Inputs
ReadTorqueConstant 7005h 0 Read Torque Constant
WriteTorqueConstant 7005h 0 Write Torque Constant
WriteDSPClearAlarm 7006h 0 Write DSP Clear Alarm
ReadQSegment 7007h 0 Read Q Segment
WriteQSegment 7007h 0 Write Q Segment
ReadActualVelocity 7009h 0 Read Actual Velocity
ReadActualPosition 700Ah 0 Read Actual Position
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 15 / 73
MOONS’ CANopen Library User Manual
ReadDSPStatusCode 700Bh 0 Read DSP Status Code
WriteClearPosition 700Ch 0 Write Clear Position
ReadAccelerationCurrent 700Dh 0 Read Acceleration Current
WriteAccelerationCurrent 700Dh 0 Write Acceleration Current
ReadAnalogInput1 700Eh 0 Read Analog Input1
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 16 / 73
MOONS’ CANopen Library User Manual
3.1.4 Advanced APIs
Advanced APIs are the advanced operations to control the drive. Normally when using advanced
API, the DLL will send a series of commands to the drive.
Fig. 3.4 Advanced API List
API Name Description
WriteProfileParam Write Profile Param
SwitchControlWord Switch Control Word
DriveEnable Drive Enable
Stop Stop
AlarmReset Alarm Reset
RelMove Relative Move
AbsMove Absolute Move
MultipleAbsMoveWithStopping Multiple Absolute Move With Stopping
MultipleAbsMoveContinuous Multiple Absolute Move Continuous
ExecuteNormalQProgram Execute Normal Q Program
ExecuteSyncQProgram Execute Sync Q Program
Homing Homing
LaunchVelocityMode Launch Velocity Mode
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 17 / 73
MOONS’ CANopen Library User Manual
3.2 API Descriptions
3.2.1 Structure & Enumeration Definition
1. Error Message structure
Almost all the APIs will return Boolean value. If it return “TRUE”, it means the drive executes
correctly. Otherwise it means there is at least one problem when executing. In this case, you can
call GetLastErrorInfo immediately to get the error information. This function will return a structure
named ERROR_INFO. The definition of ERROR_INFO structure is as following:
typedef struct _ERROR_INFO
int ErrorCode;
char* Command;
char* ErrorMessage;
} ERROR_INFO, *PERROR_INFO;
Table 3.5 Error Message Structure
Field Description
ErrorCode Error code number
Command The command that leads to the error
ErrorMessage Detailed error message
2. CAN Message structure
When you read or write a CAN command, the command is definied in a structure named
CANMESSAGE. The definition of CANMESSAGE structure is as following:
typedef struct _CANMESSAGE{
long id;
UINT dlc;
BYTE msg[8];
UINT flag;
ULONG timeStamp;
} CANMESSAGE, *PCANMESSAGE;
Table 3.6 CAN Message Structure
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 18 / 73
MOONS’ CANopen Library User Manual
Field Description
id Cob ID
dlc Data length
msg Data array
flag flag
timeStamp Time Stamp
3. PDO Message structure
When received PDO message, you can use GetLastTPDOMessage to read the PDO information.
The PDO information is in a structure named PDOMESSAGE. The definition of PDOMESSAGE
structure is as following:
typedef struct _PDOMESSAGE{
public:
BYTE NodeID;
BYTE No;
BYTE Len;
BYTE msg[8];
} PDOMESSAGE, *PTDPMESSAGE;
Table 3.7 PDO Message Structure
Field Description
NodeID Drive Node ID
No PDO No
0:PDO 1
1:PDO 2
2:PDO 3
3:PDO 4
Len Length of PDO data
msg PDO data
4. PDO Mapping structure
You can use the SetRPDOMapping and SetTPDOMapping API to set the RPDO and TPDO
mapping. The mapping information is definied in a structure named PDOMAPPING. The definition
of PDO structure is as following:
PDOMAPPING Structure Definition:
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 19 / 73
MOONS’ CANopen Library User Manual
typedef struct _PDOMAPPING
{
int Index;
BYTE SubIndex;
BYTE BitCounts;
} PDOMAPPING, *PPDOMAPPING;
Table 3.8 PDO Mapping Structure
Field Description
Index OD index
SubIndex OD sub-index
BitCounts OD bit counts
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 20 / 73
MOONS’ CANopen Library User Manual
4 API Reference
4.1 Events
void OnHeartBeatReceived (void* pCallBack);
Description Trigger when received heart beat message
Arguments Definition Range/List
pCallBack Pointer of callback function
Return value None
This event is trigged when the DLL received heart beat message from the drive. You need call
GetLastHeartBeatMessage API to get detailed command data.
void OnDataSend(void* pCallBack);
Description Trigger when send data to drive
Arguments Definition Range/List
pCallBack Pointer of callback function
Return value None
This event is trigged when the DLL send message to the drive. You need to call
GetLastSentMessage API to get detailed command data.
void OnDataReceive(void* pCallBack);
Description Trigger when received data from drive
Arguments
pCallBack Pointer of callback function
Return value None
This event is trigged when the DLL received message from the drive. You need to call
GetLastReceivedMessage API to get detailed command data.
void OnTPDOReceive(void* pCallBack);
Description Trigger when received TPDO data from drive
Arguments
pCallBack Pointer of callback function
Return value None
This event is trigged when the DLL TPDO message from the drive. You need to call
GetLastTPDOMessage API to get detailed command data.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 21 / 73
MOONS’ CANopen Library User Manual
4.2 Basic APIs
BOOL Open(int nAdapter, int nBaudRate, BYTE nChannel);
Description Open CANopen communication
Arguments Definition Range/List
nAdapter Adapter 0~2:
0=Kvaser
1=PEAK
2=ZLG
nBaudRate Communication Baud Rate 0~7:
0=1Mbps
1=800kbps
2=500kbps
3=250kbps
4=125kbps
5=50kbps
6=20kbps
7=12.5kbps
nChannel Channel See Channel types
Return value return TRUE if open successfully, otherwise return FALSE.
The argument nChannel appoints the type of adapter. For example, if you use the PCI CAN of
Kvaser, the nChannel is 9(HWTYPE_PCICAN = 9). The following is the type list of Kvaser, PEAK
and ZLG adapter.
1. Kvaser
/// <summary>
/// PEAKDeviceType
/// </summary>
public enum KvaserDeviceType
{
/// <summary>
/// Unknown or undefined
/// </summary>
HWTYPE_NONE = 0,
/// <summary>
/// The virtual CAN bus
/// </summary>
HWTYPE_VIRTUAL = 1,
/// <summary>
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 22 / 73
MOONS’ CANopen Library User Manual
/// LAPcan Family
/// </summary>
HWTYPE_LAPCAN = 2,
/// <summary>
/// CANpari (obsolete).
/// </summary>
HWTYPE_CANPARI = 3,
/// <summary>
/// PCcan Family
/// </summary>
HWTYPE_PCCAN = 8,
/// <summary>
/// PCIcan Family
/// </summary>
HWTYPE_PCICAN = 9,
/// <summary>
/// USBcan (obsolete).
/// </summary>
HWTYPE_USBCAN = 11,
/// <summary>
/// PCIcan II family
/// </summary>
HWTYPE_PCICAN_II = 40,
/// <summary>
/// USBcan II, USBcan Rugged, Kvaser Memorator
/// </summary>
HWTYPE_USBCAN_II = 42,
/// <summary>
/// Simulated CAN bus for Kvaser Creator (obsolete).
/// </summary>
HWTYPE_SIMULATED = 44,
/// <summary>
/// Kvaser Acquisitor (obsolete).
/// </summary>
HWTYPE_ACQUISITOR = 46,
/// <summary>
/// Kvaser Leaf Family
/// </summary>
HWTYPE_LEAF = 48,
/// <summary>
/// Kvaser PC104+
/// </summary>
HWTYPE_PC104_PLUS = 50,
/// <summary>
/// Kvaser PCIcanx II
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 23 / 73
MOONS’ CANopen Library User Manual
/// </summary>
HWTYPE_PCICANX_II = 52,
/// <summary>
/// Kvaser Memorator Professional family
/// </summary>
HWTYPE_MEMORATOR_II = 54,
/// <summary>
/// Kvaser Memorator Professional family
/// </summary>
HWTYPE_MEMORATOR_PRO = 54,
/// <summary>
/// Kvaser USBcan Professional
/// </summary>
HWTYPE_USBCAN_PRO = 56,
/// <summary>
/// Obsolete name, use canHWTYPE_BLACKBIRD instead
/// </summary>
HWTYPE_IRIS = 58,
/// <summary>
/// Kvaser BlackBird
/// </summary>
HWTYPE_BLACKBIRD = 58,
/// <summary>
/// Kvaser Memorator Light
/// </summary>
HWTYPE_MEMORATOR_LIGHT = 60,
/// <summary>
/// Obsolete name, use canHWTYPE_EAGLE instead
/// </summary>
HWTYPE_MINIHYDRA = 62,
/// <summary>
/// Kvaser Eagle family
/// </summary>
HWTYPE_EAGLE = 62,
/// <summary>
/// Obsolete name, use canHWTYPE_BLACKBIRD_V2 instead
/// </summary>
HWTYPE_BAGEL = 64,
/// <summary>
/// Kvaser BlackBird v2
/// </summary>
HWTYPE_BLACKBIRD_V2 = 64,
/// <summary>
/// Kvaser Mini PCI Express
/// </summary>
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 24 / 73
MOONS’ CANopen Library User Manual
HWTYPE_MINIPCIE = 66,
/// <summary>
/// USBcan Pro HS/K-Line
/// </summary>
HWTYPE_USBCAN_KLINE = 68,
/// <summary>
/// Kvaser Ethercan
/// </summary>
HWTYPE_ETHERCAN = 70,
/// <summary>
/// Kvaser USBcan Light
/// </summary>
HWTYPE_USBCAN_LIGHT = 72,
/// <summary>
/// Kvaser USBcan Pro 5xHS and variants
/// </summary>
HWTYPE_USBCAN_PRO2 = 74,
/// <summary>
/// Kvaser PCIEcan 4xHS and variants
/// </summary>
HWTYPE_PCIE_V2 = 76,
/// <summary>
/// Kvaser Memorator Pro 5xHS and variants
/// </summary>
HWTYPE_MEMORATOR_PRO2 = 78,
/// <summary>
/// Kvaser Leaf Pro HS v2 and variants
/// </summary>
HWTYPE_LEAF2 = 80,
/// <summary>
/// Kvaser Memorator (2nd generation)
/// </summary>
HWTYPE_MEMORATOR_V2 = 82,
}
2. PEAK
/// <summary>
/// PEAKDeviceType
/// </summary>
public enum PEAKDeviceType
{
/// <summary>
/// Undefined/default value for a PCAN bus
/// </summary>
PCAN_NONEBUS = 0x00,
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 25 / 73
MOONS’ CANopen Library User Manual
/// <summary>
/// PCAN-ISA interface, channel 1
/// </summary>
PCAN_ISABUS1 = 0x21,
/// <summary>
/// PCAN-ISA interface, channel 2
/// </summary>
PCAN_ISABUS2 = 0x22,
/// <summary>
/// PCAN-ISA interface, channel 3
/// </summary>
PCAN_ISABUS3 = 0x23,
/// <summary>
/// PCAN-ISA interface, channel 4
/// </summary>
PCAN_ISABUS4 = 0x24,
/// <summary>
/// PCAN-ISA interface, channel 5
/// </summary>
PCAN_ISABUS5 = 0x25,
/// <summary>
/// PCAN-ISA interface, channel 6
/// </summary>
PCAN_ISABUS6 = 0x26,
/// <summary>
/// PCAN-ISA interface, channel 7
/// </summary>
PCAN_ISABUS7 = 0x27,
/// <summary>
/// PCAN-ISA interface, channel 8
/// </summary>
PCAN_ISABUS8 = 0x28,
/// <summary>
/// PPCAN-Dongle/LPT interface, channel 1
/// </summary>
PCAN_DNGBUS1 = 0x31,
/// <summary>
/// PCAN-PCI interface, channel 1
/// </summary>
PCAN_PCIBUS1 = 0x41,
/// <summary>
/// PCAN-PCI interface, channel 2
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 26 / 73
MOONS’ CANopen Library User Manual
/// </summary>
PCAN_PCIBUS2 = 0x42,
/// <summary>
/// PCAN-PCI interface, channel 3
/// </summary>
PCAN_PCIBUS3 = 0x43,
/// <summary>
/// PCAN-PCI interface, channel 4
/// </summary>
PCAN_PCIBUS4 = 0x44,
/// <summary>
/// PCAN-PCI interface, channel 5
/// </summary>
PCAN_PCIBUS5 = 0x45,
/// <summary>
/// PCAN-PCI interface, channel 6
/// </summary>
PCAN_PCIBUS6 = 0x46,
/// <summary>
/// PCAN-PCI interface, channel 7
/// </summary>
PCAN_PCIBUS7 = 0x47,
/// <summary>
/// PCAN-PCI interface, channel 8
/// </summary>
PCAN_PCIBUS8 = 0x48,
/// <summary>
/// PCAN-USB interface, channel 1
/// </summary>
PCAN_USBBUS1 = 0x51,
/// <summary>
/// PCAN-USB interface, channel 2
/// </summary>
PCAN_USBBUS2 = 0x52,
/// <summary>
/// PCAN-USB interface, channel 3
/// </summary>
PCAN_USBBUS3 = 0x53,
/// <summary>
/// PCAN-USB interface, channel 4
/// </summary>
PCAN_USBBUS4 = 0x54,
/// <summary>
/// PCAN-USB interface, channel 5
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 27 / 73
MOONS’ CANopen Library User Manual
/// </summary>
PCAN_USBBUS5 = 0x55,
/// <summary>
/// PCAN-USB interface, channel 6
/// </summary>
PCAN_USBBUS6 = 0x56,
/// <summary>
/// PCAN-USB interface, channel 7
/// </summary>
PCAN_USBBUS7 = 0x57,
/// <summary>
/// PCAN-USB interface, channel 8
/// </summary>
PCAN_USBBUS8 = 0x58,
/// <summary>
/// PCAN-PC Card interface, channel 1
/// </summary>
PCAN_PCCBUS1 = 0x61,
/// <summary>
/// PCAN-PC Card interface, channel 2
/// </summary>
PCAN_PCCBUS2 = 0x62,
}
3. ZLG
/// <summary>
/// ZLGDeviceType
/// </summary>
public enum ZLGDeviceType
{
PCI5121 = 1,
PCI9810 = 2,
USBCAN1 = 3,
USBCAN2 = 4,
USBCAN2A = 4,
PCI9820 = 5,
CAN232 = 6,
PCI5110 = 7,
CANLITE = 8,
ISA9620 = 9,
ISA5420 = 10,
PC104CAN = 11,
CANETUDP = 12,
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 28 / 73
MOONS’ CANopen Library User Manual
CANETE = 12,
DNP9810 = 13,
PCI9840 = 14,
PC104CAN2 = 15,
PCI9820I = 16,
CANETTCP = 17,
PEC9920 = 18,
PCIE_9220 = 18,
PCI5010U = 19,
USBCAN_E_U = 20,
USBCAN_2E_U = 21,
PCI5020U = 22,
EG20T_CAN = 23,
PCIE9221 = 24,
WIFICAN_TCP = 25,
WIFICAN_UDP = 26,
PCIe9120 = 27,
PCIe9110 = 28,
PCIe9140 = 29,
}
BOOL Close();
Description Close CANopen communication
Arguments Definition Range/List
None.
Return value return TRUE if close successfully, otherwise return FALSE.
BOOL IsOpen();
Description Get the communicatino is open or not
Arguments Definition Range/List
None.
Return value return TRUE if it is open, otherwise return FALSE.
void SetExecuteTimeOut(BYTE nTimeOut);
Description Set Execute Time Out in millisecond.
Arguments Definition Range/List
nTimeOut Execute time out in millisecond 5~255(Default 6)
Return value None.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 29 / 73
MOONS’ CANopen Library User Manual
BYTE GetExecuteTimeOut();
Description Get Execute Time Out in millisecond.
Arguments Definition Range/List
None.
Return value Execute time out in millisecond
void SetExecuteRetryTimes(BYTE nRetryTimes);
Description Set Execute Retry Times
Arguments Definition Range/List
nRetryTimes Execute retry times 1~10(Default 0)
Return value None.
BYTE GetExecuteRetryTimes();
Description Get Execute Time Out.
Arguments Definition Range/List
None.
Return value Execute retry times
BOOL ResetBuffer();
Description Reset the input buffer.
Arguments Definition Range/List
None.
Return value return TRUE if reset successfully, otherwise return FALSE.
void GetLastErrorInfo(ERROR_INFO* pErrorInfo);
Description Description
Arguments Arguments Range/List
pErrorInfo Pointer to Error Info Structure
Return value None.
void GetLastHeartBeatMessage(CANMESSAGE* CANMessage);
Description Get last heart beat message
Arguments Definition Range/List
pSendCanMessage Pointer to CAN message structure
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 30 / 73
MOONS’ CANopen Library User Manual
Return value None.
void GetLastSentMessage(CANMESSAGE* CANMessage);
Description Get last sent message
Arguments Definition Range/List
pSendCanMessage Pointer to CAN message structure
Return value None.
void GetLastReceivedMessage(CANMESSAGE* CANMessage);
Description Get last received message
Arguments Definition Range/List
pSendCanMessage Pointer to CAN message structure
Return value None.
void GetLastTPDOMessage(PDOMESSAGE* CANMessage);
Description Get last TPDO message
Arguments Definition Range/List
pSendCanMessage Pointer to PDO message structure
Return value None.
void GetLastTPDOMessageByNodeID(BYTE nNodeID, BYTE nPDONo, PDOMESSAGE* CANMessage);
Description Get last TPDO message
Arguments Definition Range/List
nNodeID Node ID 1~127
nPDONo PDO No 0~3
0: RPDO1
1: RPDO2
2: RPDO3
3: RPDO4
pSendCanMessage Pointer to PDO message structure
Return value None.
BOOL Write(CANMESSAGE pSendCanMessage);
Description Write one CAN message to drive
Arguments Definition Range/List
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 31 / 73
MOONS’ CANopen Library User Manual
pSendCanMessage CAN message structure
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ExecuteCommand(CANMESSAGE sSendCanMessage, CANMESSAGE* pReceivedCanMessage, int
nCanFunction, BOOL bMatchNodeID, BYTE nNodeID, BOOL bMatchIndex, int nIndex, BOOL bMatchFirstByte,
BYTE nFirstByte);
Description Send a CAN message to drive and read matched CAN message from the drive.
If there is no matched message, it will keep reading until execute time is out
Arguments Definition Range/List
sSendCanMessage CAN message to send to the drive
pReceivedCanMessage Pointer to response message structure
nCanFunction Matched CAN function
bMatchNodeID Match Node ID or not TRUE: Match Node ID
FALSE: Does not match Node ID
nNodeID Matched Node ID, it is ignored if bMatchNodeID is 1~127
FALSE
bMatchIndex Expected OD Index TRUE: Match OD Index
FALSE: Does not match OD
Index
nIndex Matched OD Index, it is ignored if bMatchIndex is
FALSE
bMatchFirstByte Point first byte of the CAN message or not TRUE: Match first byte of data
FALSE: Does not match first byte
of data
nFirstByte Matched First byte, it is ignored if bMatchFirstByte
is FALSE
Return value return TRUE if execute successfully, otherwise return FALSE.
BOOL ReadSDOInt8(BYTE nNodeID, int nIndex, BYTE nSubIndex, char* nData);
Description Read SDO data of 8-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if read successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 32 / 73
MOONS’ CANopen Library User Manual
BOOL ReadSDOUInt8(BYTE nNodeID, int nIndex, BYTE nSubIndex, BYTE* nData);
Description Read SDO data of unsigned 8-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadSDOInt16(BYTE nNodeID, int nIndex, BYTE nSubIndex, short* nData);
Description Read SDO data of 16-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadSDOUInt16(BYTE nNodeID, int nIndex, BYTE nSubIndex, USHORT* nData);
Description Read SDO data of unsigned 16-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadSDOInt32(BYTE nNodeID, int nIndex, BYTE nSubIndex, int* nData);
Description Read SDO data of 32-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 33 / 73
MOONS’ CANopen Library User Manual
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadSDOUInt32(BYTE nNodeID, int nIndex, BYTE nSubIndex, UINT* nData);
Description Read SDO data of unsigned 32-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteSDOInt8(BYTE nNodeID, int nIndex, BYTE nSubIndex, char* nData);
Description Write SDO data of 8-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL WriteSDOUInt8(BYTE nNodeID, int nIndex, BYTE nSubIndex, BYTE* nData);
Description Write SDO data of unsigned 8-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL WriteSDOInt16(BYTE nNodeID, int nIndex, BYTE nSubIndex, short* nData);
Description Write SDO data of 16-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 34 / 73
MOONS’ CANopen Library User Manual
nData Pointer to SDO Data
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL WriteSDOUInt16(BYTE nNodeID, int nIndex, BYTE nSubIndex, USHORT* nData);
Description Write SDO data of unsigned 16-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL WriteSDOInt32(BYTE nNodeID, int nIndex, BYTE nSubIndex, int* nData);
Description Write SDO data of 32-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL WriteSDOUInt32(BYTE nNodeID, int nIndex, BYTE nSubIndex, UINT* nData);
Description Write SDO data of unsigned 32-bit integer type
Arguments Definition Range/List
nNodeID Drive Node ID
nIndex OD Index
nSubIndex OD Sub-index
nData Pointer to SDO Data
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL SetToPreoperationalMode(BYTE nNodeID);
Description Set the drive to pre-operational mode
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Return value return TRUE if set successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 35 / 73
MOONS’ CANopen Library User Manual
BOOL SetToOperationalMode(BYTE nNodeID);
Description Set the drive to ooperational mode
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Return value return TRUE if set successfully, otherwise return FALSE.
BOOL SetRPDOMapping(BYTE nNodeID, BYTE nRPDONo, int nLen, PDOMAPPING* pPDOMapping);
Description Set RPDO Mapping
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nRPDONo RPDO number 0~3
0: RPDO1
1: RPDO2
2: RPDO3
3: RPDO4
nLen The length of PDOMAPPING array 1~8
pPDOMapping Pointer to the RPDO Mapping array
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL SetTPDOMapping(BYTE nNodeID, BYTE nRPDONo, int nLen, PDOMAPPING* pPDOMapping);
Description Set TPDO Mapping
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nRPDONo RPDO number 0~3
0: RPDO1
1: RPDO2
2: RPDO3
3: RPDO4
nLen The length of PDOMAPPING array 1~8
pPDOMapping Pointer to the TPDO Mapping array
Return value return TRUE if write successfully, otherwise return FALSE.
The following is the sample code that how to set PDO mapping:
C++
// This is a sample to show how to set PDO Mapping
BOOL SetPDOMappingSettingsSample()
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 36 / 73
MOONS’ CANopen Library User Manual
{
BOOL ret = TRUE;
byte nNodeID = 1;
byte nRPDONo; // (0~3) 1 means RPDO 2
byte nTPDONo; // (0~3) 1 means TPDO 2
int nLen = 2;
// RPDO 1
nLen = 1;
nRPDONo = 0;
PDOMAPPING RPdoMappingArr1[1];
RPdoMappingArr1[0].Index = 0x6040;
RPdoMappingArr1[0].SubIndex = 0;
RPdoMappingArr1[0].BitCounts = 0x10;
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, RPdoMappingArr1);
if (ret == FALSE)
{
printf("SetRPDOMapping failed\r\n");
return FALSE;
}
// RPDO 2
nLen = 2;
nRPDONo = 1;
PDOMAPPING RPdoMappingArr2[2];
RPdoMappingArr2[0].Index = 0x6040;
RPdoMappingArr2[0].SubIndex = 0;
RPdoMappingArr2[0].BitCounts = 0x10;
RPdoMappingArr2[1].Index = 0x607A;
RPdoMappingArr2[1].SubIndex = 0;
RPdoMappingArr2[1].BitCounts = 0x20;
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, RPdoMappingArr2);
if (ret == FALSE)
{
printf("SetRPDOMapping failed\r\n");
return FALSE;
}
// RPDO 3
nLen = 2;
nRPDONo = 2;
PDOMAPPING RPdoMappingArr3[2];
RPdoMappingArr3[0].Index = 0x6040;
RPdoMappingArr3[0].SubIndex = 0;
RPdoMappingArr3[0].BitCounts = 0x10;
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 37 / 73
MOONS’ CANopen Library User Manual
RPdoMappingArr3[1].Index = 0x60FF;
RPdoMappingArr3[1].SubIndex = 0;
RPdoMappingArr3[1].BitCounts = 0x20;
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, RPdoMappingArr3);
if (ret == FALSE)
{
printf("SetRPDOMapping failed\r\n");
return FALSE;
}
// RPDO 4
nLen = 1;
nRPDONo = 3;
PDOMAPPING RPdoMappingArr4[1];
RPdoMappingArr4[0].Index = 0x60FE;
RPdoMappingArr4[0].SubIndex = 0x01;
RPdoMappingArr4[0].BitCounts = 0x20;
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, RPdoMappingArr4);
if (ret == FALSE)
{
printf("SetRPDOMapping failed\r\n");
return FALSE;
}
// TPDO 1
nLen = 1;
nTPDONo = 0;
PDOMAPPING TPdoMappingArr1[1];
TPdoMappingArr1[0].Index = 0x6041;
TPdoMappingArr1[0].SubIndex = 0;
TPdoMappingArr1[0].BitCounts = 0x10;
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, TPdoMappingArr1);
if (ret == FALSE)
{
printf("SetTPDOMapping failed\r\n");
return FALSE;
}
// TPDO 2
nLen = 2;
nTPDONo = 1;
PDOMAPPING TPdoMappingArr2[2];
TPdoMappingArr2[0].Index = 0x6041;
TPdoMappingArr2[0].SubIndex = 0;
TPdoMappingArr2[0].BitCounts = 0x10;
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 38 / 73
MOONS’ CANopen Library User Manual
TPdoMappingArr2[1].Index = 0x700A;
TPdoMappingArr2[1].SubIndex = 0;
TPdoMappingArr2[1].BitCounts = 0x20;
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, TPdoMappingArr2);
if (ret == FALSE)
{
printf("SetTPDOMapping failed\r\n");
return FALSE;
}
// TPDO 3
nLen = 2;
nTPDONo = 2;
PDOMAPPING TPdoMappingArr3[2];
TPdoMappingArr3[0].Index = 0x6041;
TPdoMappingArr3[0].SubIndex = 0;
TPdoMappingArr3[0].BitCounts = 0x10;
TPdoMappingArr3[1].Index = 0x7009;
TPdoMappingArr3[1].SubIndex = 0;
TPdoMappingArr3[1].BitCounts = 0x10;
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, TPdoMappingArr3);
if (ret == FALSE)
{
printf("SetTPDOMapping failed\r\n");
return FALSE;
}
// TPDO 4
nLen = 1;
nTPDONo = 3;
PDOMAPPING TPdoMappingArr4[1];
TPdoMappingArr4[0].Index = 0x7003;
TPdoMappingArr4[0].SubIndex = 0;
TPdoMappingArr4[0].BitCounts = 0x10;
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, TPdoMappingArr4);
if (ret == FALSE)
{
printf("SetTPDOMapping failed\r\n");
return FALSE;
}
}
C#
/// <summary>
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 39 / 73
MOONS’ CANopen Library User Manual
/// This procedure shows how to set RPDO and TPDO mapping
/// </summary>
private void SetPDOMappingSettingsSample()
{
bool ret = true;
byte nNodeID = 1;
byte nRPDONo; // (0~3) 1 means RPDO 2
byte nTPDONo; // (0~3) 1 means TPDO 2
int nLen = 2;
PDOMapping[] PdoMappingArr;
// RPDO 1
nLen = 1;
nRPDONo = 0;
PdoMappingArr = new PDOMapping[nLen];
PdoMappingArr[0].Index = 0x6040;
PdoMappingArr[0].SubIndex = 0;
PdoMappingArr[0].BitCounts = 0x10;
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, PdoMappingArr);
if (ret == false)
{
txt_CommandHistory.AppendText(string.Format("SetRPDOMapping failed\r\n"));
}
// RPDO 2
nLen = 2;
nRPDONo = 1;
PdoMappingArr = new PDOMapping[nLen];
PdoMappingArr[0].Index = 0x6040;
PdoMappingArr[0].SubIndex = 0;
PdoMappingArr[0].BitCounts = 0x10;
PdoMappingArr[1].Index = 0x607A;
PdoMappingArr[1].SubIndex = 0;
PdoMappingArr[1].BitCounts = 0x20;
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, PdoMappingArr);
if (ret == false)
{
txt_CommandHistory.AppendText(string.Format("SetRPDOMapping failed\r\n"));
}
// RPDO 3
nLen = 2;
nRPDONo = 2;
PdoMappingArr = new PDOMapping[nLen];
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 40 / 73
MOONS’ CANopen Library User Manual
PdoMappingArr[0].Index = 0x6040;
PdoMappingArr[0].SubIndex = 0;
PdoMappingArr[0].BitCounts = 0x10;
PdoMappingArr[1].Index = 0x60FF;
PdoMappingArr[1].SubIndex = 0;
PdoMappingArr[1].BitCounts = 0x20;
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, PdoMappingArr);
if (ret == false)
{
txt_CommandHistory.AppendText(string.Format("SetRPDOMapping failed\r\n"));
}
// RPDO 4
nLen = 1;
nRPDONo = 3;
PdoMappingArr = new PDOMapping[nLen];
PdoMappingArr[0].Index = 0x60FE;
PdoMappingArr[0].SubIndex = 0x01;
PdoMappingArr[0].BitCounts = 0x20;
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, PdoMappingArr);
if (ret == false)
{
txt_CommandHistory.AppendText(string.Format("SetRPDOMapping failed\r\n"));
}
// TPDO 1
nLen = 1;
nTPDONo = 0;
PdoMappingArr = new PDOMapping[nLen];
PdoMappingArr[0].Index = 0x6041;
PdoMappingArr[0].SubIndex = 0;
PdoMappingArr[0].BitCounts = 0x10;
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, PdoMappingArr);
if (ret == false)
{
txt_CommandHistory.AppendText(string.Format("SetTPDOMapping failed\r\n"));
}
// TPDO 2
nLen = 2;
nTPDONo = 1;
PdoMappingArr = new PDOMapping[nLen];
PdoMappingArr[0].Index = 0x6041;
PdoMappingArr[0].SubIndex = 0;
PdoMappingArr[0].BitCounts = 0x10;
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 41 / 73
MOONS’ CANopen Library User Manual
PdoMappingArr[1].Index = 0x700A;
PdoMappingArr[1].SubIndex = 0;
PdoMappingArr[1].BitCounts = 0x20;
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, PdoMappingArr);
if (ret == false)
{
txt_CommandHistory.AppendText(string.Format("SetTPDOMapping failed\r\n"));
}
// TPDO 3
nLen = 2;
nTPDONo = 2;
PdoMappingArr = new PDOMapping[nLen];
PdoMappingArr[0].Index = 0x6041;
PdoMappingArr[0].SubIndex = 0;
PdoMappingArr[0].BitCounts = 0x10;
PdoMappingArr[1].Index = 0x7009;
PdoMappingArr[1].SubIndex = 0;
PdoMappingArr[1].BitCounts = 0x10;
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, PdoMappingArr);
if (ret == false)
{
txt_CommandHistory.AppendText(string.Format("SetTPDOMapping failed\r\n"));
}
// TPDO 4
nLen = 1;
nTPDONo = 3;
PdoMappingArr = new PDOMapping[nLen];
PdoMappingArr[0].Index = 0x7003;
PdoMappingArr[0].SubIndex = 0;
PdoMappingArr[0].BitCounts = 0x10;
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, PdoMappingArr);
if (ret == false)
{
txt_CommandHistory.AppendText(string.Format("SetTPDOMapping failed\r\n"));
}
}
VB.NET
''' <summary>
''' This procedure shows how to set RPDO and TPDO mapping
''' </summary>
Private Sub SetPDOMappingSettingsSample()
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 42 / 73
MOONS’ CANopen Library User Manual
Dim ret As Boolean = True
Dim nNodeID As Byte = 1
Dim nRPDONo As Byte ' (0~3) 1 means RPDO 2
Dim nTPDONo As Byte ' (0~3) 1 means TPDO 2
Dim nLen As Integer = 2
Dim PdoMappingArr() As PDOMapping
' RPDO 1
nLen = 1
nRPDONo = 0
PdoMappingArr = New PDOMapping(nLen - 1){}
PdoMappingArr(0).Index = &H6040
PdoMappingArr(0).SubIndex = 0
PdoMappingArr(0).BitCounts = &H10
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, PdoMappingArr)
If ret = False Then
txt_CommandHistory.AppendText(String.Format("SetRPDOMapping failed" & vbCrLf))
End If
' RPDO 2
nLen = 2
nRPDONo = 1
PdoMappingArr = New PDOMapping(nLen - 1){}
PdoMappingArr(0).Index = &H6040
PdoMappingArr(0).SubIndex = 0
PdoMappingArr(0).BitCounts = &H10
PdoMappingArr(1).Index = &H607A
PdoMappingArr(1).SubIndex = 0
PdoMappingArr(1).BitCounts = &H20
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, PdoMappingArr)
If ret = False Then
txt_CommandHistory.AppendText(String.Format("SetRPDOMapping failed" & vbCrLf))
End If
' RPDO 3
nLen = 2
nRPDONo = 2
PdoMappingArr = New PDOMapping(nLen - 1){}
PdoMappingArr(0).Index = &H6040
PdoMappingArr(0).SubIndex = 0
PdoMappingArr(0).BitCounts = &H10
PdoMappingArr(1).Index = &H60FF
PdoMappingArr(1).SubIndex = 0
PdoMappingArr(1).BitCounts = &H20
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 43 / 73
MOONS’ CANopen Library User Manual
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, PdoMappingArr)
If ret = False Then
txt_CommandHistory.AppendText(String.Format("SetRPDOMapping failed" & vbCrLf))
End If
' RPDO 4
nLen = 1
nRPDONo = 3
PdoMappingArr = New PDOMapping(nLen - 1){}
PdoMappingArr(0).Index = &H60FE
PdoMappingArr(0).SubIndex = &H1
PdoMappingArr(0).BitCounts = &H20
ret = m_CANopenLibHelper.SetRPDOMapping(nNodeID, nRPDONo, nLen, PdoMappingArr)
If ret = False Then
txt_CommandHistory.AppendText(String.Format("SetRPDOMapping failed" & vbCrLf))
End If
' TPDO 1
nLen = 1
nTPDONo = 0
PdoMappingArr = New PDOMapping(nLen - 1){}
PdoMappingArr(0).Index = &H6041
PdoMappingArr(0).SubIndex = 0
PdoMappingArr(0).BitCounts = &H10
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, PdoMappingArr)
If ret = False Then
txt_CommandHistory.AppendText(String.Format("SetTPDOMapping failed" & vbCrLf))
End If
' TPDO 2
nLen = 2
nTPDONo = 1
PdoMappingArr = New PDOMapping(nLen - 1){}
PdoMappingArr(0).Index = &H6041
PdoMappingArr(0).SubIndex = 0
PdoMappingArr(0).BitCounts = &H10
PdoMappingArr(1).Index = &H700A
PdoMappingArr(1).SubIndex = 0
PdoMappingArr(1).BitCounts = &H20
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, PdoMappingArr)
If ret = False Then
txt_CommandHistory.AppendText(String.Format("SetTPDOMapping failed" & vbCrLf))
End If
' TPDO 3
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 44 / 73
MOONS’ CANopen Library User Manual
nLen = 2
nTPDONo = 2
PdoMappingArr = New PDOMapping(nLen - 1){}
PdoMappingArr(0).Index = &H6041
PdoMappingArr(0).SubIndex = 0
PdoMappingArr(0).BitCounts = &H10
PdoMappingArr(1).Index = &H7009
PdoMappingArr(1).SubIndex = 0
PdoMappingArr(1).BitCounts = &H10
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, PdoMappingArr)
If ret = False Then
txt_CommandHistory.AppendText(String.Format("SetTPDOMapping failed" & vbCrLf))
End If
' TPDO 4
nLen = 1
nTPDONo = 3
PdoMappingArr = New PDOMapping(nLen - 1){}
PdoMappingArr(0).Index = &H7003
PdoMappingArr(0).SubIndex = 0
PdoMappingArr(0).BitCounts = &H10
ret = m_CANopenLibHelper.SetTPDOMapping(nNodeID, nTPDONo, nLen, PdoMappingArr)
If ret = False Then
txt_CommandHistory.AppendText(String.Format("SetTPDOMapping failed" & vbCrLf))
End If
End Sub
BOOL RestorePDOMappingSettings(BYTE nNodeID);
Description Restore RPDO & TPDO Mapping settings to factory default settings.
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Return value return TRUE if restore successfully, otherwise return FALSE.
BOOL WriteRPDO(BYTE nNodeID, BYTE nRPDONo, int nLen, BYTE* pData);
Description Write RPDO data to the drive
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nRPDONo RPDO number 0~3
0: RPDO1
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 45 / 73
MOONS’ CANopen Library User Manual
1: RPDO2
2: RPDO3
3: RPDO4
nLen The length of pData 1~8
pData Pointer to the RPDO data
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL SaveParameters(BYTE nNodeID);
Description Write an save command to the drive to save the parameters.
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Return value return TRUE if save successfully, otherwise return FALSE.
4.3 SDO APIs
BOOL ReadPositionGain(BYTE nNodeID, USHORT* nPositionGain);
Description Read Position Gain
Index, Sub-Index 5000h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nPositionGain Pointer to Position Gain value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WritePositionGain(BYTE nNodeID, USHORT nPositionGain);
Description Write Position Gain
Index, Sub-Index 5000h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nPositionGain Position Gain value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadPositionDeriGain(BYTE nNodeID, USHORT* nPositionDeriGain);
Description Read Position Derivative Gain
Index, Sub-Index 5001h, 0
Arguments Definition Range/List
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 46 / 73
MOONS’ CANopen Library User Manual
nNodeID Drive Node ID 1~127
nPositionDeriGain Pointer to Position Derivative Gain value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WritePositionDeriGain(BYTE nNodeID, USHORT nPositionDeriGain);
Description Write Position Derivative Gain
Index, Sub-Index 5001h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nPositionDeriGain Position Deri Derivative Gain value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadPositionDeriFilter(BYTE nNodeID, USHORT* nPositionDeriFilter);
Description Read Position Derivative Filter
Index, Sub-Index 5002h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nPositionDeriFilter Pointer to Position Derivative Filter value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WritePositionDeriFilter(BYTE nNodeID, USHORT nPositionDeriFilter);
Description Write Position Derivative Filter
Index, Sub-Index 5002h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nPositionDeriFilter Position Deri Derivative Filter value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadVelocityGain(BYTE nNodeID, USHORT* nVelocityGain);
Description Read velocity gain
Index, Sub-Index 5003h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nVelocityGain Pointer to velocity gain value
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 47 / 73
MOONS’ CANopen Library User Manual
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteVelocityGain(BYTE nNodeID, USHORT nVelocityGain);
Description Write velocity gain
Index, Sub-Index 5003h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nVelocityGain Velocity gain value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadVelocityIntegGain(BYTE nNodeID, USHORT* nVelocityIntegGain);
Description Read velocity integral gain
Index, Sub-Index 5004h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nVelocityIntegGain Pointer to velocity integral gain value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteVelocityIntegGain(BYTE nNodeID, USHORT nVelocityIntegGain);
Description Write Velocity Integral Gain
Index, Sub-Index 5004h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nVelocityIntegGain Velocity Integral Gain value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadAccFeedForward(BYTE nNodeID, USHORT* nAccFeedForward);
Description Read Acceleration/Deceleration feed forward
Index, Sub-Index 5005h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nAccFeedForward Pointer to Acceleration/Deceleration feed forward
Return value return TRUE if read successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 48 / 73
MOONS’ CANopen Library User Manual
BOOL WriteAccFeedForward(BYTE nNodeID, USHORT nVelocityGain);
Description Write Acceleration/Deceleration feed forward
Index, Sub-Index 5005h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nAccFeedForward Acceleration/Deceleration feed forward
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadPIDFilter(BYTE nNodeID, USHORT* nPIDFilter);
Description Read PID filter
Index, Sub-Index 5006h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nPIDFilter Pointer to PID Filter value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WritePIDFilter(BYTE nNodeID, USHORT nPIDFilter);
Description Write PID filter
Index, Sub-Index 5006h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nPIDFilter PID Filter value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadNotchFilter(BYTE nNodeID, int nIndex, short* nNotchFilter);
Description Read Notch filter
Index, Sub-Index 5007h~500Eh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nIndex Notch Filter Index 0~7
0: 5007h
1: 5008h
2: 5009h
3: 500Ah
4: 500Bh
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 49 / 73
MOONS’ CANopen Library User Manual
5: 500Ch
6: 500Dh
7: 500Eh
nNotchFilter Pointer to Notch Filter value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteNotchFilter(BYTE nNodeID, int nIndex, short nNotchFilter);
Description Write Notch Filter
Index, Sub-Index 5007h~500Eh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nIndex Notch Filter Index 0~7
0: 5007h
1: 5008h
2: 5009h
3: 500Ah
4: 500Bh
5: 500Ch
6: 500Dh
7: 500Eh
nNotchFilter Notch Filter value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadPositionError(BYTE nNodeID, USHORT* nPositionError);
Description Read Position Error
Index, Sub-Index 500Fh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nPositionError Pointer to Position Error value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WritePositionError(BYTE nNodeID, USHORT nPositionError);
Description Write Position Error
Index, Sub-Index 5010h, 0
Arguments Definition Range/List
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 50 / 73
MOONS’ CANopen Library User Manual
nNodeID Drive Node ID 1~127
nPositionError Position Error value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadVelocityMax(BYTE nNodeID, double* nVelocityMax);
Description Read maximum velocity in rev/sec
Index, Sub-Index 5010h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nVelocityMax Pointer to Velocity Max value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteVelocityMax(BYTE nNodeID, double nVelocityMax);
Description Write maximum velocity in rev/sec
Index, Sub-Index 5003h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nVelocityMax Velocity Max value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadSmoothFilter(BYTE nNodeID, USHORT* nSmoothFilter);
Description Read Smooth Filter
Index, Sub-Index 5011h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nSmoothFilter Pointer to Smooth Filter value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteSmoothFilter(BYTE nNodeID, USHORT nSmoothFilter);
Description Write Smooth Filter
Index, Sub-Index 5011h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nSmoothFilter Smooth Filter value
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 51 / 73
MOONS’ CANopen Library User Manual
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadDriverTemp(BYTE nNodeID, short* nDriverTemp);
Description Read drive temperature in 0.1 centigrade
Index, Sub-Index 5011h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nDriverTemp Pointer to driver’s temperature
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadErrorCode(BYTE nNodeID, USHORT* nErrorCode);
Description Read Error Code
Index, Sub-Index 603Fh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nErrorCode Pointer to Error Code
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadErrorCodeUpper(BYTE nNodeID, USHORT* nErrorCode);
Description Read higher 16 bit of error code for SS and M2 drive.
Index, Sub-Index 700Fh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nErrorCode Pointer to Error Code
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteControlWord(BYTE nNodeID, USHORT nControlWord);
Description Write Control Word
Index, Sub-Index 6040h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nControlWord Control Word
Return value return TRUE if write successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 52 / 73
MOONS’ CANopen Library User Manual
BOOL ReadStatusWord(BYTE nNodeID, USHORT* nStatusWord);
Description Read Status Word
Index, Sub-Index 6041h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nStatusWord Pointer to Status Word
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadQuickStopOptionCode(BYTE nNodeID, short* nQuickStopOptionCode);
Description Read Quick Stop Option Code
Index, Sub-Index 605Ah, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nQuickStopOptionCode Pointer to Quick Stop Option Code
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteQuickStopOptionCode(BYTE nNodeID, short nQuickStopOptionCode);
Description Write Quick Stop Option Code
Index, Sub-Index 605Ah, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nQuickStopOptionCode Quick Stop Option Code
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadModeofOperation(BYTE nNodeID, char* nModeofOperation);
Description Read Mode of Operation
Index, Sub-Index 6060h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nModeofOperation Pointer to Mode of Operation value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteModeofOperation(BYTE nNodeID, char nModeofOperation);
Description Write Mode of Operation
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 53 / 73
MOONS’ CANopen Library User Manual
Index, Sub-Index 6060h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nModeofOperation Mode of Operation value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadPositionTargetValueCalculated(BYTE nNodeID, int* pPositionTargetValueCalculated);
Description Read Position Target Value Calculated
Index, Sub-Index 6064h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
pPositionTargetValueCalculated Pointer to Position Target Value Calculated
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadFollowingErrorWindow(BYTE nNodeID, UINT* nFollowingErrorWindow);
Description Read Following Error Window
Index, Sub-Index 6065h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nFollowingErrorWindow Pointer to Following Error Window value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteFollowingErrorWindow(BYTE nNodeID, UINT nFollowingErrorWindow);
Description Write Following Error Window
Index, Sub-Index 6065h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nFollowingErrorWindow Following Error Window value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadVelocityTargetValueCalculated(BYTE nNodeID, double* dVelocityTargetValueCalculated);
Description Read calculated target velocity in rev/sec
Index, Sub-Index 606Ch, 0
Arguments Definition Range/List
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 54 / 73
MOONS’ CANopen Library User Manual
nNodeID Drive Node ID 1~127
dVelocityTargetValueCalculated Pointer to Velocity Target Value Calculated
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadTargetTorque(BYTE nNodeID, short* nTargetTorque);
Description Read Target Torque in mNm
Index, Sub-Index 6071h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nTargetTorque Pointer to Target Torque value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteTargetTorque(BYTE nNodeID, short nTargetTorque);
Description Write target torque in mNm
Index, Sub-Index 6071h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nTargetTorque Target torque value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadMaxRunningCurrent(BYTE nNodeID, double* nMaxRunningCurrent);
Description Read Max Running Current
Index, Sub-Index 6073h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nMaxRunningCurrent Pointer to Max Running Current value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteMaxRunningCurrent(BYTE nNodeID, double nMaxRunningCurrent);
Description Write Max Running Current
Index, Sub-Index 6073h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nMaxRunningCurrent Max Running Current value
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 55 / 73
MOONS’ CANopen Library User Manual
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadTorqueDemandValue(BYTE nNodeID, double* dTorqueDemandValue);
Description Read demand torque in Nm.
Index, Sub-Index 6074h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nTorqueDemandValue Pointer to demand torque
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadCurrentActualValue(BYTE nNodeID, double* dCurrentActualValue);
Description Read actual current in Amps
Index, Sub-Index 6078h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dCurrentActualValue Pointer to actual current
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadTargetPosition(BYTE nNodeID, int* nTargetPosition);
Description Read target position
Index, Sub-Index 607Ah, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nTargetPosition Pointer to target position value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteTargetPosition(BYTE nNodeID, int nTargetPosition);
Description Write target position
Index, Sub-Index 607Ah, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nTargetPosition Target position value
Return value return TRUE if write successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 56 / 73
MOONS’ CANopen Library User Manual
BOOL ReadHomingOffset(BYTE nNodeID, int* nHomingOffset);
Description Read homing offset
Index, Sub-Index 607Ch, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nHomingOffset Pointer to homing offset
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteHomingOffset(BYTE nNodeID, int nHomingOffset);
Description Write homing offset
Index, Sub-Index 607Ch, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nHomingOffset Homing offset
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadPolarity(BYTE nNodeID, BYTE* pPolarity);
Description Read polarity
Index, Sub-Index 607Eh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
pPolarity Pointer to polarity
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WritePolarity(BYTE nNodeID, BYTE pPolarity);
Description Write polarity
Index, Sub-Index 607Eh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
pPolarity Polarity
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadMaxProfileSpeed(BYTE nNodeID, double* dMaxProfileSpeed);
Description Read max profile speed
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 57 / 73
MOONS’ CANopen Library User Manual
Index, Sub-Index 607Fh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dMaxProfileSpeed Pointer to max profile speed 0.025~133.333, depends on
supported max velocity
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteMaxProfileSpeed(BYTE nNodeID, double dMaxProfileSpeed);
Description Write Smax profile speed
Index, Sub-Index 607Fh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dMaxProfileSpeed Max profile speed value 0.025~133.333, depends on
supported max velocity
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadProfileVelocity(BYTE nNodeID, double* dProfileVelocity);
Description Read profile velocity
Index, Sub-Index 6081h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dProfileVelocity Pointer to Profile velocity value 0.025~133.333, depends on
supported max velocity
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteProfileVelocity(BYTE nNodeID, double dProfileVelocity);
Description Write profile velocity
Index, Sub-Index 6081h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dProfileVelocity Profile velocity value 0.025~133.333, depends on
supported max velocity
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadProfileAcceleration(BYTE nNodeID, double* dProfileAcceleration);
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 58 / 73
MOONS’ CANopen Library User Manual
Description Read profile acceleration
Index, Sub-Index 6083h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dProfileAcceleration Point to profile acceleration 0.167~5461.167
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteProfileAcceleration(BYTE nNodeID, double dProfileAcceleration);
Description Write profile acceleration
Index, Sub-Index 6083h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dProfileAcceleration Profile Acceleration 0.167~5461.167
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadProfileDeceleration(BYTE nNodeID, double* dProfileDeceleration);
Description Read profile deceleration
Index, Sub-Index 6084h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dProfileDeceleration Point to profile deceleration 0.167~5461.167
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteProfileDeceleration(BYTE nNodeID, double dProfileDeceleration);
Description Write profile deceleration
Index, Sub-Index 6084h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dProfileDeceleration Profile Deceleration 0.167~5461.167
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadQuickStopDeceleration(BYTE nNodeID, double* dQuickStopDeceleration);
Description Read quick stop deceleration
Index, Sub-Index 6085h, 0
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 59 / 73
MOONS’ CANopen Library User Manual
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dQuickStopDeceleration Point to quick stop deceleration 0.167~5461.167
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteQuickStopDeceleration(BYTE nNodeID, double dQuickStopDeceleration);
Description Write quick stop deceleration
Index, Sub-Index 6085h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dQuickStopDeceleration Quick stop Deceleration 0.167~5461.167
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadTorqueSlop(BYTE nNodeID, UINT* nTorqueSlop);
Description Read torque slop
Index, Sub-Index 6087h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nTorqueSlop Pointer to torque slop
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteTorqueSlop(BYTE nNodeID, UINT nTorqueSlop);
Description Write torque slop
Index, Sub-Index 6087h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nTorqueSlop Torque slop
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadHomingMethod(BYTE nNodeID, BYTE* nHomingMethod);
Description Read homging method
Index, Sub-Index 6098h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 60 / 73
MOONS’ CANopen Library User Manual
nHomingMethod Point to homing method
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteHomingMethod(BYTE nNodeID, BYTE nHomingMethod);
Description Write homing method
Index, Sub-Index 6098h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nHomingMethod Homing method
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadHomingSpeedSearchSwitch(BYTE nNodeID, double* dSpeed);
Description Read homing speed when search switch
Index, Sub-Index 6099h, 1
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dSpeed Pointer to homing speed when search switch 0.025~133.333, depends on
supported max velocity
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteHomingSpeedSearchSwitch(BYTE nNodeID, double dSpeed);
Description Write homing speed when searching switch
Index, Sub-Index 6099h, 1
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dSpeed Homing speed when search switch 0.025~133.333, depends on
supported max velocity
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadHomingSpeedSearchIndex(BYTE nNodeID, double* dSpeed);
Description Read homing speed when search index
Index, Sub-Index 6099h, 2
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dSpeed Pointer to homing speed when search index 0.025~133.333, depends on
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 61 / 73
MOONS’ CANopen Library User Manual
supported max velocity
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteHomingSpeedSearchIndex(BYTE nNodeID, double dSpeed);
Description Write homing speed when search index
Index, Sub-Index 6099h, 2
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dSpeed Homing speed when search index 0.025~133.333, depends on
supported max velocity
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadHomingAcceleration(BYTE nNodeID, double* dHomingAcceleration);
Description Read homing acceleration
Index, Sub-Index 609Ah, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dHomingAcceleration Pointer to homing acceleration 0.167~5461.167
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteHomingAcceleration(BYTE nNodeID, double dHomingAcceleration);
Description Write homing acceleration
Index, Sub-Index 609Ah, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dHomingAcceleration Homing acceleration 0.167~5461.167
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadDriveOutputs(BYTE nNodeID, UINT* nDriveOutputs);
Description Read drive outputs
Index, Sub-Index 60FEh, 1
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nDriveOutputs Point to drive output
Return value return TRUE if read successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 62 / 73
MOONS’ CANopen Library User Manual
BOOL WriteDriveOutputs(BYTE nNodeID, UINT nDriveOutputs);
Description Write drive outputs
Index, Sub-Index 60FEh, 1
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nDriveOutputs Drive output
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadTargetVelocity(BYTE nNodeID, double* dTargetVelocity);
Description Read target velocity
Index, Sub-Index 60FFh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dTargetVelocity Pointer to target velocity
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteTargetVelocity(BYTE nNodeID, double dTargetVelocity);
Description Write target velocity
Index, Sub-Index 60FFh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dTargetVelocity Target velocity
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadSupportedDriveModes(BYTE nNodeID, UINT* nModes);
Description Read supported drive modes
Index, Sub-Index 6502h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nModes Pointer to supported modes
Return value return TRUE if read successfully, otherwise return FALSE.
Supported modes data structure:
Bit number Description
0 Profile Position Mode
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 63 / 73
MOONS’ CANopen Library User Manual
1 Velocity Mode
2 Profile Velocity Mode
3 Profile Torque Mode
4 reserved
5 Homing Mode
6 Interpolated Position Mode
7 reserved
8 reserved
9 reserved
10…15 reserved
16…31 Manufacturer sepcific
BOOL ReadHomingSwitch(BYTE nNodeID, BYTE* nHomingSwitch);
Description Read homing switch
Index, Sub-Index 7001h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nHomingSwitch Point to Homing switch
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteHomingSwitch(BYTE nNodeID, BYTE* nHomingSwitch);
Description Write homing switch
Index, Sub-Index 7001h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nHomingSwitch Homing switch
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadIdleCurrent(BYTE nNodeID, double* dIdleCurrent);
Description Read idle current in Amps
Index, Sub-Index 7002h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dIdleCurrent Point to Idle current in Amps
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteIdleCurrent(BYTE nNodeID, double* dIdleCurrent);
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 64 / 73
MOONS’ CANopen Library User Manual
Description Write idle current
Index, Sub-Index 7002h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dIdleCurrent Idle current
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadDisplayDriveInputs(BYTE nNodeID, USHORT* nDisplayDriveInputs);
Description Read information of driver’s digital inputs
Index, Sub-Index 7003h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nDisplayDriveInputs Information of driver’s digital inputs Bit0: input 1
Bit1: input 2
Bit2: input 3
Bit3: input 4
Bit4: input 5
Bit5: input 6
Bit6: input 7
Bit7: input 8
Bit8-15: reserved
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadTorqueConstant(BYTE nNodeID, USHORT* nTorqueConstant);
Description Read torque constant in mNm.
Index, Sub-Index 7005h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nTorqueConstant Pointer to torque constant value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteTorqueConstant(BYTE nNodeID, USHORT nTorqueConstant);
Description Write torque constant in mNm.
Index, Sub-Index 7005h, 0
Arguments Definition Range/List
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 65 / 73
MOONS’ CANopen Library User Manual
nNodeID Drive Node ID 1~127
nTorqueConstant Torque constant value
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL WriteDSPClearAlarm(BYTE nNodeID);
Description Write clear DSL alarm
Index, Sub-Index 7006h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadQSegment(BYTE nNodeID, BYTE* nQSegment);
Description Read Q segment
Index, Sub-Index 7007h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nQSegment Point to Q Segment 1~12 or 1~10 (for M Series)
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteQSegment(BYTE nNodeID, BYTE nQSegment);
Description Read Q segment
Index, Sub-Index 7007h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nQSegment Q Segment 1~12 or 1~10 (for M Series)
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadActualVelocity(BYTE nNodeID, double* dActualVelocity);
Description Read actual velocity
Index, Sub-Index 7009h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dActualVelocity Actual velocity
Return value return TRUE if read successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 66 / 73
MOONS’ CANopen Library User Manual
BOOL ReadActualPosition(BYTE nNodeID, int* nActualPosition);
Description Read actual velocity
Index, Sub-Index 700Ah, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nActualPosition Pointer to actual velocity
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL ReadDSPStatusCode(BYTE nNodeID, USHORT* nStatusCode);
Description Write PID Filter
Index, Sub-Index 700Bh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nStatusCode Status code
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteClearPosition(BYTE nNodeID);
Description Clear position
Index, Sub-Index 700Ch, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadAccelerationCurrent(BYTE nNodeID, double* dAccelerationCurrent);
Description Read acceleration current
Index, Sub-Index 700Dh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dAccelerationCurrent Acceleration Current
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteAccelerationCurrent(BYTE nNodeID, double dAccelerationCurrent);
Description Write acceleration current
Index, Sub-Index 700Dh, 0
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 67 / 73
MOONS’ CANopen Library User Manual
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dAccelerationCurrent Acceleration Current
Return value return TRUE if write successfully, otherwise return FALSE.
BOOL ReadAnalogInput1(BYTE nNodeID, USHORT* nAnalogInput1);
Description Write PID Filter
Index, Sub-Index 700Eh, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nAnalogInput1 Analog input value
Return value return TRUE if read successfully, otherwise return FALSE.
BOOL WriteProfileParam(BYTE nNodeID, int* nMode, int* nDistance, double* dVelocity, double* dAccel, double*
dDecel);
Description Write profile parameters
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nMode Mode, NULL to ignore this argument
nDistance Distance, NULL to ignore this argument
dVelocity Velocity, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
dAccel Acceleration, NULL to ignore this argument 0.167~5461.167
dDecel Deceleration, NULL to ignore this argument 0.167~5461.167
Return value return TRUE if write successfully, otherwise return FALSE.
4.4 Advanced APIs
BOOL SwitchControlWord(BYTE nNodeID, USHORT nControlWord1, USHORT nControlWord2);
Description Switch control word
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nControlWord1 Previous control word
nControlWord2 New control word
Return value return TRUE if switch successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 68 / 73
MOONS’ CANopen Library User Manual
BOOL DriveEnable(BYTE nNodeID, BOOL bEnable);
Description Enable drive or disable drive
Index, Sub-Index 5006h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
bEnable Enable option TRUE: Enable
FALSE: Disable
Return value return TRUE if execute successfully, otherwise return FALSE.
BOOL Stop(BYTE nNodeID);
Description Stop moving
Index, Sub-Index 5006h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Return value return TRUE if stop successfully, otherwise return FALSE.
BOOL AlarmReset(BYTE nNodeID);
Description Reset alarm
Index, Sub-Index 5006h, 0
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
Return value return TRUE if reset successfully, otherwise return FALSE.
BOOL RelMove(BYTE nNodeID, int nDistance, double* dVelocity, double* dAccel, double* dDecel);
Description Launch relative move
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nDistance Move Distance -2147483647~2147483647
dVelocity Velocity, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
dAccel Acceleration, NULL to ignore this argument 0.167~5461.167
dDecel Deceleration, NULL to ignore this argument 0.167~5461.167
Return value return TRUE if execute command successfully, otherwise return FALSE.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 69 / 73
MOONS’ CANopen Library User Manual
BOOL AbsMove(BYTE nNodeID, int nDistance, double* dVelocity, double* dAccel, double* dDecel);
Description Launch absolute move
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nDistance Move Distance -2147483647~2147483647
dVelocity Velocity, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
dAccel Acceleration, NULL to ignore this argument 0.167~5461.167
dDecel Deceleration, NULL to ignore this argument 0.167~5461.167
Return value return TRUE if execute successfully, otherwise return FALSE.
BOOL MultipleAbsMoveWithStopping(BYTE nNodeID, int nDistance1, int nDistance2, double* dVelocity1, double*
dVelocity2, double* dAccel, double* dDecel);
Description Launch Point to Point Move with stopping
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nDistance1 Move Distance 1 -2147483647~2147483647
nDistance2 Move Distance 2 -2147483647~2147483647
dVelocity1 Velocity 1, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
dVelocity2 Velocity 2, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
dAccel Acceleration, NULL to ignore this argument 0.167~5461.167
dDecel Deceleration, NULL to ignore this argument 0.167~5461.167
Return value return TRUE if execute command successfully, otherwise return FALSE.
BOOL MultipleAbsMoveContinuous(BYTE nNodeID, int nDistance1, int nDistance2, double* dVelocity1, double*
dVelocity2, double* dAccel, double* dDecel);
Description Launch Point to Point Move continuous
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nDistance1 Move Distance 1 -2147483647~2147483647
nDistance2 Move Distance 2 -2147483647~2147483647
dVelocity1 Velocity 1, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 70 / 73
MOONS’ CANopen Library User Manual
dVelocity2 Velocity 2, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
dAccel Acceleration, NULL to ignore this argument 0.167~5461.167
dDecel Deceleration, NULL to ignore this argument 0.167~5461.167
Return value return TRUE if execute command successfully, otherwise return FALSE.
BOOL ExecuteNormalQProgram(BYTE nNodeID, BYTE nSegment);
Description Execute Q program in normal mode
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nSegment Segment M Server Series:1~10
Other:1~12
Return value return TRUE if send command successfully, otherwise return FALSE.
BOOL ExecuteSyncQProgram(BYTE nNodeID, BYTE nSegment, UINT nSyncPulse);
Description Execute Q program in Sync mode
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nSegment Segment M Server Series:1~10
Other:1~12
nSyncPulse Sync Pulse
Return value return TRUE if execute command successfully, otherwise return FALSE.
BOOL Homing(BYTE nNodeID, int nHomingMethod, double* nHomingVelocity, double* dIndexVelocity, double*
nHomingAccel, int* nHomingOffset, int* nHomingSwitch);
Description Launch feed to double sensor move with mask distance
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
nHomingMethod Homing Method
nHomingVelocity Homing Velocity, NULL to ignore this argument
dIndexVelocity Index Velocity, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
nHomingAccel Homing Acceleration, NULL to ignore this argument 0.167~5461.167
nHomingOffset Homing Offset, NULL to ignore this argument -2147483647~2147483647
nHomingSwitch Homing Switch, NULL to ignore this argument 0.167~5461.167
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 71 / 73
MOONS’ CANopen Library User Manual
Return value return TRUE if execute command successfully, otherwise return FALSE.
BOOL LaunchVelocityMode(BYTE nNodeID, double* dVelocity, double* dAccel, double* dDecel);
Description Launch velocity mode
Arguments Definition Range/List
nNodeID Drive Node ID 1~127
dVelocity Velocity, NULL to ignore this argument 0.025~133.333, depends on
supported max velocity
dAccel Acceleration, NULL to ignore this argument 0.167~5461.167
dDecel Deceleration, NULL to ignore this argument 0.167~5461.167
Return value return TRUE if execute successfully, otherwise return FALSE.
5 FAQ
5.1 How to solve "LoaderLock was detected" when adapter is ZLG?
If the adapter is ZLG, when you run the sample code using Visual Studio 2010, an "LoadLock
was detected" dialog will be poped. See below picture:
Please open the menu: Debug -> Exceptions:
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 72 / 73
MOONS’ CANopen Library User Manual
Unchecked "Managed Debugging Assistants" -> "LoaderLock" and try again.
Shanghai AMP & MOONS’ Automation Equipment Co., Ltd., 2017 73 / 73