![]() |
Qmix SDK
20200506
The software libraries for integration of all CETONI devices.
|
Before you can use the Qmix SDK you need to create a device configuration. A device configuration is a folder with a set of XML files which contain a complete description of the configuration of all devices in the current setup (see Device Configuration Files for a detailed description).
You can create a valid device configuration with the device configurator of the QmixElements software.
Do the following steps, to create a device configuration
The way how you include the library functions in your own development environment, depends on the compiler and on the programming language you use (see LabVIEW Integration for a detailed description of the Qmix SDK integration into LabVIEW). To access the labbCAN bus API, you have to include the library labbCAN_Bus_API.dll to your programming environment. You have to copy this file to the working directory of your system or to the application directory that contains your application EXE file. Use the calling convention LCB_CALL for this library. This convention is managing how the parameters are put on the stack and who is responsible to clean the stack after the function execution.
The interface of the library, constant definitions and declarations of the library functions, is defined in the header file interface/labbCAN_Bus_API.h
To use the DLLs and to access the devices you need to do a certain number of steps to initialize the common bus API and all of the device APIs properly.
The first thing you always need to do before you can use any device DLL is to initialize the common labbCAN Bus library by calling the function LCB_Open(). This function
The following code shows how to open the bus library:
If the function LCB_Open() returns successfully, the labbCAN environment is properly configured and all devices are in pre operational state. In this state the devices are ready for configuration but they do not send any process data.
Now you are ready to setup, configure, and initialize the single devices like single axis systems, analog I/O devices and channels or pumps. You can access each device by a certain "handle". A handle is simply a reference to the internal device object. Therefore the first step for device access is to obtain a device or channel handle. Each device DLL offers a number of functions to obtain a device handle. I.e. the labbCAN Axis System API offers two functions to obtain a valid device handle - LCA_GetAxisSystemHandle() and LCA_LookupAxisSystemByName(). While the first function allows an array like access to all detected positioning systems on the labbCAN bus the second function allows to lookup for a valid device handle by a unique device name.
The following code shows how to obtain an axis system handle by its name:
Normally all devices that are attached to the labbCAN bus are named devices. Each device has a unique device name. If there are a number of devices of the same type the name is suffixed with a number. You can find the names in the XML configuration files (see Device Configuration Files). Each tag <Device>
has an attribute Name
that defines the name of a certain device. The following example snippet from a neMAXYS device configuration file shows the configuration of an axis device with the name neMAXYS1_Y.
<DeviceList> <Device Name="neMAXYS1_Y"> <Type>Lcl::CEposAxis</Type> <Bus>CANopenBus1</Bus> <CANopenDevice NodeId="2">Usl::Epos::CEposDrive</CANopenDevice>
See the example labbCAN_CAPI_Init.cpp to learn how to initialize the labbCAN API properly.
If you have initialized all device APIs and if you finished configuration and setup of all devices then you should finally call the function LCB_Start(). This will start the communication on the bus and all connected devices will start sending their process data periodically or on change of state. After this call, all devices are in state Operational.
The following example code snippet shows a valid initialization procedure:
Just before an applications shuts down it needs to close all labbCAN specific libraries properly to free any claimed resources. To accomplish this an application needs to do the following steps.
The first step is to call the function LCB_Stop() to stop any further communication. This call will cause all devices to leave Operational state and to go into Pre Operational state.
If you would like to store any device parameters can do this now.
Call the function LCB_Close() to disconnect from device and to free any claimed resources.
The following example code snippet shows a valid shutdown procedure: